Преглед изворни кода

内外部报验执行时添加报验点状态及明细

wangming пре 11 месеци
родитељ
комит
7a40c7b636

+ 8 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxItpProjectNodeStateService.java

@@ -4,6 +4,7 @@ import com.rongwei.bsentity.domain.ZhcxItpProjectNodeStateDo;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpDo;
 import com.rongwei.bsentity.dto.ZhcxItpProjectNodeStateResultDto;
+import com.rongwei.bsentity.dto.project.ProjectNodeStateBo;
 
 import java.util.List;
 
@@ -25,4 +26,11 @@ public interface ZhcxItpProjectNodeStateService extends IService<ZhcxItpProjectN
      * @return
      */
     List<ZhcxItpProjectNodeStateResultDto> getByItp(ZhcxOutsideInspectionItpDo itpDo, String operType);
+
+    /**
+     * 保存报验点状态
+     *
+     * @param nodeStateBo
+     */
+    void saveNode(ProjectNodeStateBo nodeStateBo);
 }

+ 72 - 58
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxInsideInspectionServiceImpl.java

@@ -20,6 +20,7 @@ import com.rongwei.bscommon.sys.dao.ZhcxInsideInspectionDao;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bsentity.dto.*;
 import com.rongwei.bsentity.dto.inside.*;
+import com.rongwei.bsentity.dto.project.ProjectNodeStateBo;
 import com.rongwei.bsentity.vo.ZhcxInsideInspectionVo;
 import com.rongwei.commonservice.serial.service.SysSerialNumberService;
 import com.rongwei.rwadmincommon.system.domain.SysRoleDo;
@@ -47,7 +48,6 @@ import java.io.*;
 import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -227,6 +227,12 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
         List<ZhcxInsideInspectionDispatchDo> dispatchList = new ArrayList<>();
         List<ZhcxInsideInspectionDo> inspectionList = new ArrayList<>();
         List<NotifyDto> notifyList = new ArrayList<>();
+        ProjectNodeStateBo nodeStateBo  = ProjectNodeStateBo.builder()
+                .insertList(new ArrayList<>())
+                .updateList(new ArrayList<>())
+                .insideStateList(new ArrayList<>())
+                .build();
+
 
         for(String insideId : req.getInsideIdList()) {
             InsideOperDto inOper = getInsideOperDto(insideId);
@@ -287,6 +293,8 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
 
             NotifyDto notify = getMailInfo4Cancel(inOper, req);
             notifyList.add(notify);
+
+            assembleResultToNodeState(inOper, nodeStateBo, null);
         }
 
         if(ObjectUtil.isNotEmpty(msgList)) {
@@ -304,10 +312,8 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
         //发送提醒
         zhcxCommon.sendMsg(notifyList);
 
-        // 写入ZHCX_ITP_PROJECT_NODE_STATE表
-        for (ZhcxInsideInspectionDo row : inspectionList) {
-            saveResultToNodeState(row, "10");
-        }
+        //保存报验点状态
+        itpProjectNodeStateService.saveNode(nodeStateBo);
     }
 
     /**
@@ -677,21 +683,17 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
             throw  new CustomException("请联系管理员,暂无报验单");
         }
         // 20: 拒收 50: 接收 60: 有条件接收
-        String es = "";
         OperDto operDto;
         //接收
         if("10".equals(req.getConclusion())) {
-            es = "50";
             operDto = getOper("50");
         }
         //拒收
         else if("20".equals(req.getConclusion())) {
-            es = "20";
             operDto = getOper("20");
         }
         //有条件接收
         else if("30".equals(req.getConclusion())) {
-            es = "60";
             operDto = getOper("60");
         }
         else {
@@ -701,6 +703,11 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
         List<String> msgList = new ArrayList<>();
         List<ZhcxInsideInspectionDispatchDo> dispatchList = new ArrayList<>();
         List<ZhcxInsideInspectionDo> inspectionList = new ArrayList<>();
+        ProjectNodeStateBo nodeStateBo  = ProjectNodeStateBo.builder()
+                .insertList(new ArrayList<>())
+                .updateList(new ArrayList<>())
+                .insideStateList(new ArrayList<>())
+                .build();
 
         for(String insideId : req.getInsideIdList()) {
             InsideOperDto inOper = getInsideOperDto(insideId);
@@ -754,6 +761,9 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
                 inspection.setInspectioncomplatetime(new Date());
             }
             inspectionList.add(inspection);
+
+            //报验点状态
+            assembleResultToNodeState(inOper, nodeStateBo, inspection.getInspectioncomplatetime());
         }
 
         if(ObjectUtil.isNotEmpty(msgList)) {
@@ -772,10 +782,8 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
             operLogService.saveOperLog(req, operDto, Collections.emptyMap());
         }
 
-        // 写入ZHCX_ITP_PROJECT_NODE_STATE表
-        for (ZhcxInsideInspectionDo row : inspectionList) {
-            saveResultToNodeState(row, es);
-        }
+        //保存报验点状态
+        itpProjectNodeStateService.saveNode(nodeStateBo);
     }
 
     /**
@@ -1585,25 +1593,23 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
 
     /**
      * 保存数据到ZHCX_ITP_PROJECT_NODE_STATE(项目各机号报验点状态)表
-     * @param operType 操作类型 10: 取消 20: 拒收 30: 派单 40: 转派 50: 接收 60: 有条件接收 70:修改检验开始结束时间
+     * operType 操作类型 10: 取消 20: 拒收 30: 派单 40: 转派 50: 接收 60: 有条件接收 70:修改检验开始结束时间
      */
-    private void saveResultToNodeState(ZhcxInsideInspectionDo itpDoPa, String operType) {
-        SysUserVo currUser = zhcxCommon.getCurrentUser();
-        ZhcxInsideInspectionDo itpDo = getById(itpDoPa.getId());
-
-        if(!"itp".equals(itpDo.getLaunchtype())) {
+    private void assembleResultToNodeState(InsideOperDto inOper, ProjectNodeStateBo nodeStateBo, Date complateTime) {
+        if(!"itp".equals(inOper.getInspection().getLaunchtype())) {
             return;
         }
-        String machineNo = itpDo.getMachineno();
+        ZhcxInsideInspectionDo itpDo = inOper.getInspection();
+
+        String machineNo = inOper.getInspection().getMachineno();
         if (StringUtils.isBlank(machineNo)) {
-            machineNo = itpDo.getStructuremachineno();
+            machineNo = inOper.getInspection().getStructuremachineno();
         }
         if (StringUtils.isBlank(machineNo)) {
             log.error("{}-{}:总装机号和结构机号都没有", itpDo.getId(), itpDo.getInspectioncode());
             return;
         }
         String[] machinenos = machineNo.split(",");
-        List<ZhcxItpProjectNodeStateResultDto> list = new ArrayList<>(machinenos.length);
         for (String mn : machinenos) {
             LambdaQueryWrapper<ZhcxItpProjectNodeStateDo> queryWrapper = Wrappers.lambdaQuery();
             queryWrapper.eq(ZhcxItpProjectNodeStateDo::getPrjid, itpDo.getProjectid())
@@ -1619,65 +1625,73 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
                 stateDo.setPrjid(itpDo.getProjectid());
                 stateDo.setNodeid(itpDo.getInspectioncontentid());
                 stateDo.setDeleted("0");
-//                entity.setIncompletetime(itpDoPa.getInspectioncomplatetime());
 
-                //接收
-                if("50".equals(operType)) {
-                    stateDo.setIncompletetime(itpDoPa.getInspectioncomplatetime());
-                }
-                //有条件接收
-                else if ("60".equals(operType)) {
-                    stateDo.setIncompletetime(itpDoPa.getInspectioncomplatetime());
-                }
+                stateDo.setCreatedate(inOper.getOperTime());
+                stateDo.setCreateuserid(inOper.getOperUser().getId());
+                stateDo.setCreateusername(inOper.getOperUser().getName());
+//                entity.setIncompletetime(itpDoPa.getInspectioncomplatetime());
+                assembleUpdateNodeState(stateDo, inOper, complateTime);
 
-                stateDo.setIntimes(itpDo.getInspectioncount());
-                stateDo.setCreatedate(new Date());
-                stateDo.setCreateuserid(currUser.getId());
-                stateDo.setCreateusername(currUser.getName());
-                updateNodeState(stateDo, operType);
-                itpProjectNodeStateService.save(stateDo);
+                nodeStateBo.getInsertList().add(stateDo);
             } else {
 //                stateDo.setIncompletetime(itpDoPa.getInspectioncomplatetime());
+                assembleUpdateNodeState(stateDo, inOper, complateTime);
 
-                //接收
-                if("50".equals(operType)) {
-                    stateDo.setIncompletetime(itpDoPa.getInspectioncomplatetime());
-                }
-                //有条件接收
-                else if ("60".equals(operType)) {
-                    stateDo.setIncompletetime(itpDoPa.getInspectioncomplatetime());
-                }
-
-                stateDo.setIntimes(itpDo.getInspectioncount());
-                updateNodeState(stateDo, operType);
-                itpProjectNodeStateService.updateById(stateDo);
+                nodeStateBo.getUpdateList().add(stateDo);
             }
+
+            // 报验点-内部报验单
+            ZhcxItpProjectNodeStateInsideDo stateInside = new ZhcxItpProjectNodeStateInsideDo();
+            stateInside.setId(SecurityUtil.getUUID());
+            stateInside.setDeleted("0");
+            stateInside.setInsideid(itpDo.getId());
+            stateInside.setStateid(stateDo.getId());
+            stateInside.setInspectioncode(itpDo.getInspectioncode());
+            stateInside.setLaunchtype(itpDo.getLaunchtype());
+            nodeStateBo.getInsideStateList().add(stateInside);
         }
     }
 
-    private void updateNodeState(ZhcxItpProjectNodeStateDo entity, String operType) {
-        SysUserVo currUser = zhcxCommon.getCurrentUser();
-        entity.setModifydate(new Date());
-        entity.setModifyuserid(currUser.getId());
-        entity.setModifyusername(currUser.getName());
+    /**
+     * 组装
+     *
+     * @param entity
+     * @param inOper
+     * @param complateTime
+     */
+    private void assembleUpdateNodeState(ZhcxItpProjectNodeStateDo entity, InsideOperDto inOper, Date complateTime) {
+        entity.setModifydate(inOper.getOperTime());
+        entity.setModifyuserid(inOper.getOperUser().getId());
+        entity.setModifyusername(inOper.getOperUser().getName());
         //取消
-        if("10".equals(operType)) {
+        if("10".equals(inOper.getOperType())) {
             entity.setInstate("40");
         }
         //拒收
-        if("20".equals(operType)) {
+        if("20".equals(inOper.getOperType())) {
             entity.setInstate("20");
         }
 
         //接收
-        if("50".equals(operType)) {
+        if("50".equals(inOper.getOperType())) {
             entity.setInstate("10");
         }
 
         //有条件接收
-        if ("60".equals(operType)) {
+        if ("60".equals(inOper.getOperType())) {
             entity.setInstate("30");
         }
+
+        //接收
+        if("50".equals(inOper.getOperType())) {
+            entity.setIncompletetime(complateTime);
+        }
+        //有条件接收
+        else if ("60".equals(inOper.getOperType())) {
+            entity.setIncompletetime(complateTime);
+        }
+
+        entity.setIntimes(inOper.getInspection().getInspectioncount());
     }
 
 }

+ 32 - 1
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxItpProjectNodeStateServiceImpl.java

@@ -3,6 +3,8 @@ package com.rongwei.bscommon.sys.service.impl;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.rongwei.bscommon.sys.service.ZhcxItpProjectNodeStateInsideService;
+import com.rongwei.bscommon.sys.service.ZhcxItpProjectNodeStateOutsideService;
 import com.rongwei.bscommon.sys.utils.BusinessFunUtils;
 import com.rongwei.bsentity.domain.ZhcxItpProjectNodeStateDo;
 import com.rongwei.bscommon.sys.dao.ZhcxItpProjectNodeStateDao;
@@ -10,13 +12,14 @@ import com.rongwei.bscommon.sys.service.ZhcxItpProjectNodeStateService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpDo;
 import com.rongwei.bsentity.dto.ZhcxItpProjectNodeStateResultDto;
+import com.rongwei.bsentity.dto.project.ProjectNodeStateBo;
 import com.rongwei.rwcommon.utils.SecurityUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -29,6 +32,11 @@ import java.util.stream.Collectors;
 @Service
 public class ZhcxItpProjectNodeStateServiceImpl extends ServiceImpl<ZhcxItpProjectNodeStateDao, ZhcxItpProjectNodeStateDo> implements ZhcxItpProjectNodeStateService {
 
+    @Autowired
+    private ZhcxItpProjectNodeStateOutsideService nodeStateOutsideService;
+
+    @Autowired
+    private ZhcxItpProjectNodeStateInsideService nodeStateInsideService;
     /**
      * 获取项目各机号报验点状态
      *
@@ -104,6 +112,29 @@ public class ZhcxItpProjectNodeStateServiceImpl extends ServiceImpl<ZhcxItpProje
         return list;
     }
 
+    /**
+     * 保存报验点状态
+     *
+     * @param nodeStateBo
+     */
+    @Override
+    public void saveNode(ProjectNodeStateBo nodeStateBo) {
+        //添加项目各机号报验点状态
+        if(ObjectUtil.isNotEmpty(nodeStateBo.getInsertList())) {
+            saveBatch(nodeStateBo.getInsertList());
+        }
+        if(ObjectUtil.isNotEmpty(nodeStateBo.getUpdateList())) {
+            updateBatchById(nodeStateBo.getUpdateList());
+        }
+        if(ObjectUtil.isNotEmpty(nodeStateBo.getOutsideStateList())) {
+            nodeStateOutsideService.saveBatch(nodeStateBo.getOutsideStateList());
+        }
+
+        if(ObjectUtil.isNotEmpty(nodeStateBo.getInsideStateList())) {
+            nodeStateInsideService.saveBatch(nodeStateBo.getInsideStateList());
+        }
+    }
+
     /**
      * 选择机号
      *

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

@@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bsentity.dto.*;
 import com.rongwei.bsentity.dto.outside.OutsideInspectionInsertRequest;
 import com.rongwei.bsentity.dto.outside.OutsideInspectionUpdateRequest;
+import com.rongwei.bsentity.dto.project.ProjectNodeStateBo;
 import com.rongwei.bsentity.vo.*;
 import com.rongwei.commonservice.serial.service.SysSerialNumberService;
 import com.rongwei.rwadmincommon.system.service.SysGeneralCRUDService;
@@ -229,10 +230,13 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
 //                hasJjyRole = true;
 //            }
 //        }
+        ProjectNodeStateBo nodeStateBo  = ProjectNodeStateBo.builder()
+                .insertList(new ArrayList<>())
+                .updateList(new ArrayList<>())
+                .outsideStateList(new ArrayList<>())
+                .build();
 
         List<ZhcxOutsideInspectionItpOperLogDo> logList = new ArrayList<>();
-        List<ZhcxItpProjectNodeStateDo> insertNodeStateList = new ArrayList<>();
-        List<ZhcxItpProjectNodeStateDo> updateNodeStateList = new ArrayList<>();
         Date nowDate = new Date();
 
         for(int i =0;i<vo.size();i++){
@@ -325,16 +329,7 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
 
                 //添加项目各机号报验点状态
                 List<ZhcxItpProjectNodeStateResultDto> nodeStateResultList = zhcxItpProjectNodeStateService.getByItp(inspectionItpDo, "10");
-
-                if(ObjectUtil.isNotEmpty(nodeStateResultList)) {
-                    for(ZhcxItpProjectNodeStateResultDto resultDto : nodeStateResultList) {
-                        if("insert".equals(resultDto.getSaveType())) {
-                            insertNodeStateList.add(resultDto.getEntity());
-                        } else if("update".equals(resultDto.getSaveType())) {
-                            updateNodeStateList.add(resultDto.getEntity());
-                        }
-                    }
-                }
+                assembleNodeState(nodeStateResultList, inspectionItpDo, nodeStateBo);
 
             }
             //拒收
@@ -412,16 +407,7 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
 
                 //添加项目各机号报验点状态
                 List<ZhcxItpProjectNodeStateResultDto> nodeStateResultList = zhcxItpProjectNodeStateService.getByItp(inspectionItpDo, operType);
-
-                if(ObjectUtil.isNotEmpty(nodeStateResultList)) {
-                    for(ZhcxItpProjectNodeStateResultDto resultDto : nodeStateResultList) {
-                        if("insert".equals(resultDto.getSaveType())) {
-                            insertNodeStateList.add(resultDto.getEntity());
-                        } else if("update".equals(resultDto.getSaveType())) {
-                            updateNodeStateList.add(resultDto.getEntity());
-                        }
-                    }
-                }
+                assembleNodeState(nodeStateResultList, inspectionItpDo, nodeStateBo);
 
             }
             /* 当前操作人 */
@@ -467,13 +453,8 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
         //发送提醒
         zhcxCommon.sendMsg(notifyDtoList);
 
-        //添加项目各机号报验点状态
-        if(ObjectUtil.isNotEmpty(insertNodeStateList)) {
-            zhcxItpProjectNodeStateService.saveBatch(insertNodeStateList);
-        }
-        if(ObjectUtil.isNotEmpty(updateNodeStateList)) {
-            zhcxItpProjectNodeStateService.updateBatchById(updateNodeStateList);
-        }
+        //保存节点状态
+        zhcxItpProjectNodeStateService.saveNode(nodeStateBo);
 
         //操作记录
         zhcxOutsideInspectionItpOperLogService.saveBatch(logList);
@@ -523,6 +504,36 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
         saveReNewItp(itpDo, dispatchDo, masterSlaveUpdate);
     }
 
+    /**
+     * 组装数据
+     *
+     * @param nodeStateResultList
+     * @param inspectionItpDo
+     * @param nodeStateBo
+     */
+    private void assembleNodeState(List<ZhcxItpProjectNodeStateResultDto> nodeStateResultList, ZhcxOutsideInspectionItpDo inspectionItpDo, ProjectNodeStateBo nodeStateBo) {
+        if(ObjectUtil.isEmpty(nodeStateResultList)) {
+            return ;
+        }
+
+        for(ZhcxItpProjectNodeStateResultDto resultDto : nodeStateResultList) {
+            if("insert".equals(resultDto.getSaveType())) {
+                nodeStateBo.getInsertList().add(resultDto.getEntity());
+            } else if("update".equals(resultDto.getSaveType())) {
+                nodeStateBo.getUpdateList().add(resultDto.getEntity());
+            }
+
+            ZhcxItpProjectNodeStateOutsideDo outsideState = new ZhcxItpProjectNodeStateOutsideDo();
+            outsideState.setId(SecurityUtil.getUUID());
+            outsideState.setInspectioncode(inspectionItpDo.getInspectioncode());
+            outsideState.setLaunchtype(inspectionItpDo.getLaunchtype());
+            outsideState.setDeleted("0");
+            outsideState.setOutsideid(resultDto.getEntity().getId());
+
+            nodeStateBo.getOutsideStateList().add(outsideState);
+        }
+    }
+
     /**
      * 保存修改历史记录
      *

+ 36 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/project/ProjectNodeStateBo.java

@@ -0,0 +1,36 @@
+package com.rongwei.bsentity.dto.project;
+
+import com.rongwei.bsentity.domain.ZhcxItpProjectNodeStateDo;
+import com.rongwei.bsentity.domain.ZhcxItpProjectNodeStateInsideDo;
+import com.rongwei.bsentity.domain.ZhcxItpProjectNodeStateOutsideDo;
+import lombok.*;
+
+import java.util.List;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class ProjectNodeStateBo {
+
+    /**
+     * insert点
+     */
+    private List<ZhcxItpProjectNodeStateDo> insertList;
+
+    /**
+     * update点
+     */
+    private List<ZhcxItpProjectNodeStateDo> updateList;
+
+    /**
+     * 外部报验点
+     */
+    private List<ZhcxItpProjectNodeStateOutsideDo> outsideStateList;
+
+    /**
+     * 外部报验单
+     */
+    private List<ZhcxItpProjectNodeStateInsideDo> insideStateList;
+}