Переглянути джерело

ITP模板新增节点更新到项目中

fangpy 1 рік тому
батько
коміт
c5f7ff7391

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

@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.rongwei.bscommon.sys.service.ZhcxItpProjectNodesService;
 import com.rongwei.bscommon.sys.service.ZhcxProjectDeviceNumberService;
+import com.rongwei.bscommon.sys.utils.CxConstants;
 import com.rongwei.bsentity.domain.ZhcxItpProjectNodesDo;
 import com.rongwei.bsentity.domain.ZhcxItpTemplateNodesDo;
 import com.rongwei.bscommon.sys.dao.ZhcxItpTemplateNodesDao;
@@ -45,6 +46,7 @@ public class ZhcxItpTemplateNodesServiceImpl extends ServiceImpl<ZhcxItpTemplate
                 && zhcxItpTemplateNodeSyncProjectVo.getProjectids() != null && zhcxItpTemplateNodeSyncProjectVo.getProjectids().size()>0){
             // 待保存的项目ITP节点
             List<ZhcxItpProjectNodesDo> toSaveNodes = new ArrayList<>();
+            List<ZhcxItpProjectNodesDo> toUpdateNodes = new ArrayList<>();
             // 模板节点ID和项目节点ID的映射关系
             Map<String,String> tempProMap = new HashMap<>();
             // 获取当前报验点
@@ -82,6 +84,7 @@ public class ZhcxItpTemplateNodesServiceImpl extends ServiceImpl<ZhcxItpTemplate
                         eq(ZhcxItpProjectNodesDo::getProjectid, projectid).in(ZhcxItpProjectNodesDo::getItpnodeid, nodeids));
                 for (ZhcxItpTemplateNodesDo nodess : templateNodess) {
                     List<ZhcxItpProjectNodesDo> hasProNodes = projectNodesDos.stream().filter(v -> v.getItpnodeid().equals(nodess.getId())).collect(Collectors.toList());
+                    // 不存在直接新增
                     if(hasProNodes == null && hasProNodes.size() == 0){
                         // 相关属性复制
                         ZhcxItpProjectNodesDo zhcxItpProjectNodesDo = new ZhcxItpProjectNodesDo();
@@ -100,6 +103,29 @@ public class ZhcxItpTemplateNodesServiceImpl extends ServiceImpl<ZhcxItpTemplate
                         // 映射关系建立
                         tempProMap.put(nodess.getId(),zhcxItpProjectNodesDo.getId());
                     }
+                    // 存在则更新
+                    else{
+                        ZhcxItpProjectNodesDo itpProjectNodesDo = hasProNodes.get(0);
+                        ZhcxItpProjectNodesDo toUpdateNode = new ZhcxItpProjectNodesDo();
+                        toUpdateNode.setId(itpProjectNodesDo.getId());
+                        // 报验点更新
+                        if(CxConstants.ITP_NODETYPE_CHECKPOINT.equals(nodess.getNodetype())){
+                            toUpdateNode.setIsneedout(nodess.getIsneedout());
+                            toUpdateNode.setInspectiontype(nodess.getInspectiontype());
+                            toUpdateNode.setIssupp(nodess.getIssupp());
+                            toUpdateNode.setChecktmpid(nodess.getChecktmpid());
+                            toUpdateNode.setCheckrole(nodess.getCheckrole());
+                            toUpdateNode.setCheckroleid(nodess.getCheckroleid());
+                            toUpdateNode.setOrgid(nodess.getOrgid());
+                            toUpdateNode.setOrgname(nodess.getOrgname());
+                            toUpdateNode.setCheckfile(nodess.getCheckfile());
+                            toUpdateNode.setNodename(nodess.getNodename());
+                        }else{
+                            // 阶段和构建更新
+                            toUpdateNode.setNodename(nodess.getNodename());
+                        }
+                        toUpdateNodes.add(toUpdateNode);
+                    }
                 }
             }
             // 项目节点相关ID替换
@@ -139,6 +165,10 @@ public class ZhcxItpTemplateNodesServiceImpl extends ServiceImpl<ZhcxItpTemplate
             if(toSaveNodes != null && toSaveNodes.size()>0){
                 zhcxItpProjectNodesService.saveBatch(toSaveNodes);
             }
+            // 数据更新
+            if(toUpdateNodes != null && toUpdateNodes.size()>0){
+                zhcxItpProjectNodesService.updateBatchById(toUpdateNodes);
+            }
         }
     }
 

+ 17 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/utils/CxConstants.java

@@ -0,0 +1,17 @@
+package com.rongwei.bscommon.sys.utils;
+
+/**
+ * 长兴业务常量类
+ */
+public class CxConstants {
+
+    // ITP节点类型:报验点
+    public final static String ITP_NODETYPE_CHECKPOINT = "checkpoint";
+    // ITP节点类型:阶段
+    public final static String ITP_NODETYPE_PHASE = "phase";
+    // ITP节点类型:小构件
+    public final static String ITP_NODETYPE_SMALL = "small";
+    // ITP节点类型:大构件
+    public final static String ITP_NODETYPE_BIG = "big";
+
+}