فهرست منبع

外部报验功能-单号后端生成

wangming 1 سال پیش
والد
کامیت
f9ed47df72

+ 20 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/feign/SysNotifyFeginService.java

@@ -0,0 +1,20 @@
+package com.rongwei.bscommon.sys.feign;
+
+import com.rongwei.rwcommon.base.R;
+import com.rongwei.rwcommon.vo.MailDo;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+@FeignClient(name = "rw-common-server", value = "rw-common-server")
+public interface SysNotifyFeginService {
+
+    /**
+     * 发送邮件
+     *
+     * @param Mail
+     * @return
+     */
+    @PostMapping("/mail/sendTextMail")
+    R sendTextMail(@RequestBody MailDo Mail);
+}

+ 103 - 15
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxOutsideInspectionItpServiceImpl.java

@@ -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("-")));;
 
         //报验状态:取消状态

+ 6 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxOutsideInspectionItpSupervisionDispatchServiceImpl.java

@@ -1,5 +1,6 @@
 package com.rongwei.bscommon.sys.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpSupervisionDispatchDo;
 import com.rongwei.bscommon.sys.dao.ZhcxOutsideInspectionItpSupervisionDispatchDao;
 import com.rongwei.bscommon.sys.service.ZhcxOutsideInspectionItpSupervisionDispatchService;
@@ -34,6 +35,11 @@ public class ZhcxOutsideInspectionItpSupervisionDispatchServiceImpl extends Serv
      */
     @Override
     public void reInspection(String id) {
+
+        if(ObjectUtil.isEmpty(id)) {
+            return ;
+        }
+
         ZhcxOutsideInspectionItpSupervisionDispatchDo entity = new ZhcxOutsideInspectionItpSupervisionDispatchDo();
         entity.setId(id);
         dao.reInspection(entity);

+ 18 - 0
business-entity/src/main/java/com/rongwei/bsentity/domain/ZhcxOutsideInspectionItpSupervisionDispatchDo.java

@@ -131,5 +131,23 @@ public class ZhcxOutsideInspectionItpSupervisionDispatchDo extends BaseDo {
     @TableField("SIGNATURE")
     private String signature;
 
+    /**
+     * 派单监理主管id
+     */
+    @TableField("DISPATCHSUPERVISIONID")
+    private String dispatchsupervisionid;
+
+    /**
+     * 派单监理主管
+     */
+    @TableField("DISPATCHSUPERVISION")
+    private String dispatchsupervision;
+
+    /**
+     * 派单监理主管userid
+     */
+    @TableField("DISPATCHSUPERVISIONUSERID")
+    private String dispatchsupervisionuserid;
+
 
 }

+ 28 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/NotifyDto.java

@@ -0,0 +1,28 @@
+package com.rongwei.bsentity.dto;
+
+import lombok.*;
+
+import java.util.List;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class NotifyDto {
+
+    /**
+     * 提醒内容
+     */
+    private String content;
+
+    /**
+     * 提醒标题
+     */
+    private String subject;
+
+    /**
+     * 接收用户id
+     */
+    private List<String> receiverIds;
+}

+ 5 - 0
business-entity/src/main/java/com/rongwei/bsentity/vo/OperOutsideInspectionVo.java

@@ -66,6 +66,11 @@ public class OperOutsideInspectionVo {
      */
     private String signature;
     /**
+     *
+     * checker: 检验员页面
+     * supermanager: 监理主管派单
+     * task: 监理执行任务
+     *
      * 页面类型
      */
     private String pageType;