|
@@ -2,19 +2,20 @@ package com.rongwei.bscommon.sys.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.rongwei.bscommon.sys.feign.SysNotifyFeginService;
|
|
|
import com.rongwei.bscommon.sys.service.*;
|
|
|
import com.rongwei.bscommon.sys.utils.ZhcxCommon;
|
|
|
import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpDo;
|
|
|
import com.rongwei.bscommon.sys.dao.ZhcxOutsideInspectionItpDao;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpSupervisionDispatchDo;
|
|
|
-import com.rongwei.bsentity.domain.ZhcxSupervisionCustomUserManageDo;
|
|
|
+import com.rongwei.bsentity.dto.NotifyDto;
|
|
|
import com.rongwei.bsentity.vo.OperOutsideInspectionVo;
|
|
|
import com.rongwei.bsentity.vo.SupervisionVo;
|
|
|
import com.rongwei.commonservice.serial.service.SysSerialNumberService;
|
|
|
-import com.rongwei.rwadmincommon.system.domain.SysRoleDo;
|
|
|
import com.rongwei.rwadmincommon.system.service.SysGeneralCRUDService;
|
|
|
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
import com.rongwei.rwcommon.base.R;
|
|
@@ -55,9 +56,6 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
|
|
|
@Autowired
|
|
|
private ZhcxOutsideInspectionItpSupervisionDispatchService dispatchService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private ZhcxSubcontractorUserService userService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private ZhcxCommon zhcxCommon;
|
|
|
|
|
@@ -68,7 +66,7 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
|
|
|
private SysGeneralCRUDService sysGeneralCRUDService;
|
|
|
|
|
|
@Autowired
|
|
|
- private ZhcxSupervisionCustomUserManageService zhcxSupervisionCustomUserManageService;
|
|
|
+ private SysNotifyFeginService notifyFeginService;
|
|
|
|
|
|
/**
|
|
|
* 拆单
|
|
@@ -80,35 +78,47 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
|
|
|
ZhcxOutsideInspectionItpDo itpDo = this.getById(id); //报验单
|
|
|
|
|
|
//构件
|
|
|
+ String[] structureNames;
|
|
|
if(ObjectUtil.isEmpty(itpDo.getStructurename())) {
|
|
|
- return ;
|
|
|
+ structureNames = new String[0];
|
|
|
+ } else {
|
|
|
+ structureNames = itpDo.getStructurename().split(","); //构件
|
|
|
}
|
|
|
|
|
|
//报验点
|
|
|
if(ObjectUtil.isEmpty(itpDo.getInspectioncontent())) {
|
|
|
return ;
|
|
|
}
|
|
|
-
|
|
|
- String[] structurNames = itpDo.getStructurename().split(","); //构件
|
|
|
String[] inspectionContents = itpDo.getInspectioncontent().split(","); //报验点
|
|
|
|
|
|
- if(structurNames.length * inspectionContents.length <= 1) {
|
|
|
+// if(structureNames.length * inspectionContents.length < 1) {
|
|
|
+// return ;
|
|
|
+// }
|
|
|
+ //只有一个构件和报验点时
|
|
|
+ //不需要拆单
|
|
|
+ if(structureNames.length * inspectionContents.length <= 1) {
|
|
|
+ //存在报验单号,则不再生成
|
|
|
+ if(ObjectUtil.isNotEmpty(itpDo.getInspectioncode())) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ ZhcxOutsideInspectionItpDo updateEntity = new ZhcxOutsideInspectionItpDo();
|
|
|
+ updateEntity.setId(id);
|
|
|
+ updateEntity.setInspectioncode(genCode());
|
|
|
+ updateById(updateEntity);
|
|
|
return ;
|
|
|
}
|
|
|
|
|
|
-// String[] structureIds = itpDo.getStructureid().split(",");
|
|
|
-
|
|
|
List<ZhcxOutsideInspectionItpDo> insertList = new ArrayList<>();
|
|
|
List<ZhcxOutsideInspectionItpDo> updateList = new ArrayList<>();
|
|
|
List<String> newItpIdList = new ArrayList<>();
|
|
|
|
|
|
int count = -1;
|
|
|
- for(int m = 0, n = structurNames.length; m < n; m++) {
|
|
|
+ for(int m = 0, n = structureNames.length; m < n; m++) {
|
|
|
for(String inspectionContent : inspectionContents) {
|
|
|
count++;
|
|
|
|
|
|
if(count == 0) { //第一个做修改
|
|
|
- itpDo.setStructurename(structurNames[m]);
|
|
|
+ itpDo.setStructurename(structureNames[m]);
|
|
|
itpDo.setInspectioncontent(inspectionContent);
|
|
|
itpDo.setInspectioncode(genCode());
|
|
|
// itpDo.setStructureid(structureIds[m]);
|
|
@@ -118,7 +128,7 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
|
|
|
|
|
|
ZhcxOutsideInspectionItpDo entity = new ZhcxOutsideInspectionItpDo();
|
|
|
BeanUtil.copyProperties(itpDo, entity);
|
|
|
- entity.setStructurename(structurNames[m]);
|
|
|
+ entity.setStructurename(structureNames[m]);
|
|
|
entity.setInspectioncontent(inspectionContent);
|
|
|
entity.setId(SecurityUtil.getUUID());
|
|
|
entity.setInspectioncode(genCode());
|
|
@@ -151,6 +161,9 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
|
|
|
List<ZhcxOutsideInspectionItpSupervisionDispatchDo> saveDispatchDos = new ArrayList<>();
|
|
|
List<ZhcxOutsideInspectionItpSupervisionDispatchDo> updateDispatchDos = new ArrayList<>();
|
|
|
List<ZhcxOutsideInspectionItpDo> inspectionItpDos = new ArrayList<>();
|
|
|
+
|
|
|
+ List<NotifyDto> notifyDtoList = new ArrayList<>();
|
|
|
+
|
|
|
SysUserVo user = zhcxCommon.getCurrentUser();
|
|
|
log.info("当前登录用户ID"+user.getId());
|
|
|
// List<SysRoleDo> roleDos = user.getRoleDos();
|
|
@@ -230,6 +243,13 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
|
|
|
dispatchDo.setRefusereason(vo.get(i).getReason());
|
|
|
dispatchDo.setDispatchstatus("30");
|
|
|
inspectionItpDo.setInspectionstatus("40");
|
|
|
+
|
|
|
+ //获取邮件发送信息
|
|
|
+ NotifyDto mailInfo4Cancel = getMailInfo4Cancel(vo.get(i), inspectionItpDo, dispatchDo, user);
|
|
|
+ if(ObjectUtil.isNotNull(mailInfo4Cancel)) {
|
|
|
+ notifyDtoList.add(mailInfo4Cancel);
|
|
|
+ }
|
|
|
+
|
|
|
} else if ("20".equals(operType)) {
|
|
|
if("task".equals(vo.get(i).getPageType()) && !user.getId().equals(dispatchDo.getSupervisionuserid())){
|
|
|
sb.append("单据号:"+inspectioncode+"已被改派,不能拒收,请刷新数据查看<br>");
|
|
@@ -325,6 +345,18 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
|
|
|
// dispatchService.updateBatchById(dispatchDos);
|
|
|
// } else {
|
|
|
// dispatchService.saveBatch(dispatchDos);
|
|
|
+// }
|
|
|
+
|
|
|
+ log.info("邮件发送", JSONUtil.toJsonStr(notifyDtoList));
|
|
|
+ //邮件发送
|
|
|
+// if(ObjectUtil.isNotEmpty(notifyDtoList)) {
|
|
|
+// for(NotifyDto notifyDto : notifyDtoList) {
|
|
|
+// MailDo mainDo = new MailDo();
|
|
|
+// mainDo.setSubject(notifyDto.getSubject());
|
|
|
+// mainDo.setContent(notifyDto.getContent());
|
|
|
+// mainDo.setReceiveEmail(notifyDto.getReceiverIds().stream().toArray(String[]::new));
|
|
|
+// notifyFeginService.sendTextMail(mainDo);
|
|
|
+// }
|
|
|
// }
|
|
|
|
|
|
return R.ok();
|
|
@@ -375,6 +407,56 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
|
|
|
dispatchService.reInspection(dispatchDo.getId());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取取消发送邮件内容
|
|
|
+ *
|
|
|
+ * @param vo
|
|
|
+ * @param inspectionItpDo
|
|
|
+ * @param dispatchDo
|
|
|
+ */
|
|
|
+ private NotifyDto getMailInfo4Cancel(OperOutsideInspectionVo vo, ZhcxOutsideInspectionItpDo inspectionItpDo, ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo, SysUserVo user) {
|
|
|
+ NotifyDto notifyDto = NotifyDto.builder()
|
|
|
+ .subject("取消报验提醒")
|
|
|
+ .build();
|
|
|
+
|
|
|
+ List<String> userList = new ArrayList<>();
|
|
|
+ //检验员
|
|
|
+ if("checker".equals(vo.getPageType()) && "20".equals(dispatchDo.getDispatchstatus())) {
|
|
|
+ //派单后
|
|
|
+ userList.add(dispatchDo.getSupervisionuserid());
|
|
|
+ }
|
|
|
+ //主管
|
|
|
+ else if("supermanager".equals(vo.getPageType())) {
|
|
|
+ userList.add(inspectionItpDo.getCheckerid());
|
|
|
+ //派单后
|
|
|
+ if("20".equals(dispatchDo.getDispatchstatus())) {
|
|
|
+ userList.add(dispatchDo.getSupervisionuserid());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //监理用户
|
|
|
+ else if("task".equals(vo.getPageType())) {
|
|
|
+ userList.add(inspectionItpDo.getCheckerid());
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuilder msg = new StringBuilder();
|
|
|
+ msg.append("您好,报验单编号【");
|
|
|
+ msg.append(inspectionItpDo.getInspectioncode());
|
|
|
+ msg.append("】已被【");
|
|
|
+ msg.append(user.getName());
|
|
|
+ msg.append("】取消报验,联系方式:【");
|
|
|
+ msg.append(user.getPhone());
|
|
|
+ msg.append("】,取消原因");
|
|
|
+ msg.append(dispatchDo.getRefusereason());
|
|
|
+ msg.append("】,请知悉,谢谢。");
|
|
|
+
|
|
|
+ notifyDto.setContent(msg.toString());
|
|
|
+ notifyDto.setReceiverIds(userList);
|
|
|
+
|
|
|
+ return notifyDto;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存
|
|
|
*
|
|
@@ -412,6 +494,12 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
|
|
|
* @return
|
|
|
*/
|
|
|
private String genNewCode(ZhcxOutsideInspectionItpDo itpDo, ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo) {
|
|
|
+
|
|
|
+ //如果单号不存在重新生成一个
|
|
|
+ if(ObjectUtil.isEmpty(itpDo.getInspectioncode())) {
|
|
|
+ return genCode();
|
|
|
+ }
|
|
|
+
|
|
|
List<String> inspectionCodes = new ArrayList<>(Arrays.asList(itpDo.getInspectioncode().split("-")));;
|
|
|
|
|
|
//报验状态:取消状态
|