Procházet zdrojové kódy

项目、合同段删除相关

liuyc před 3 roky
rodič
revize
0c1e5d0a41

+ 5 - 5
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreeContractMapper.xml

@@ -94,19 +94,20 @@
     </insert>
 
     <update id="deleteBatch">
-        UPDATE m_wbs_tree_contract
-        SET is_deleted = 1
-        WHERE id IN
+        DELETE FROM m_wbs_tree_contract
+        WHERE ( id IN
         <foreach item="ids" collection="ids" open="(" close=")" separator=",">
             #{ids}
         </foreach>
-        OR parent_id IN
+        OR (parent_id IN
         <foreach item="ids" collection="ids" open="(" close=")" separator=",">
             #{ids}
         </foreach>
+        ) )
         AND wbs_id = #{wbsId}
         AND project_id = #{projectId}
         AND contract_id = #{contractId}
+        AND contract_type = 1
     </update>
 
     <update id="updateByCondition">
@@ -139,7 +140,6 @@
         AND status = 1
     </update>
 
-
     <select id="selectAll" resultMap="resultMap2">
         SELECT
             wtc.id,

+ 2 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreeMapper.xml

@@ -165,7 +165,7 @@
     </delete>
 
     <delete id="deleteBatch" parameterType="java.util.List">
-        UPDATE m_wbs_tree_private SET is_deleted = 1
+        DELETE FROM m_wbs_tree_private
         WHERE id IN
         <foreach item="ids" collection="ids" open="(" close=")" separator=",">
             #{ids}
@@ -175,7 +175,7 @@
     </delete>
 
     <delete id="deleteBatch2" parameterType="java.util.List">
-        UPDATE m_wbs_tree_private SET is_deleted = 1
+        DELETE FROM m_wbs_tree_private
         WHERE parent_id IN
         <foreach item="ids" collection="ids" open="(" close=")" separator=",">
             #{ids}

+ 7 - 32
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -132,36 +132,6 @@ public class WbsTreeContractServiceImpl
                     });
                 });
 
-
-                /**
-                 * 不清楚为什么之前要节点+表分开判断
-                 */
-                /*//获取wbs私有树下节点+表
-                List<WbsTreePrivate> wbsTreePrivateList = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
-                        .eq(WbsTreePrivate::getProjectId, pawDTO.getProjectId())
-                        .eq(WbsTreePrivate::getWbsId, pawDTO.getWbsId())
-                );
-
-                List<WbsTreePrivate> wbsTreePrivateListTable = wbsTreePrivateList.stream().filter(f -> f.getType() == 2).collect(Collectors.toList());
-                List<WbsTreePrivate> listTree = new ArrayList<>();
-                wbsTreePrivateList.stream().map(tree -> {
-                    diffRent.stream().forEach(id -> {
-                        if (id.equals(String.valueOf(tree.getId()))) {
-                            listTree.add(tree);
-                        }
-                    });
-                    return null;
-                }).collect(Collectors.toList());
-                //初始化
-                listTree.stream().forEach(wbsTreePrivate -> {
-                    WbsTreeContract wbsTreeContract = getWbsTreePrivate(wbsTreePrivate, pawDTO);
-                    wbsTreeContractList.add(wbsTreeContract);
-                });
-                wbsTreePrivateListTable.stream().forEach(wbsTreePrivate -> {
-                    WbsTreeContract wbsTreeContract = getWbsTreePrivate(wbsTreePrivate, pawDTO);
-                    wbsTreeContractList.add(wbsTreeContract);
-                });*/
-
                 //新增
                 this.saveBatch(wbsTreeContractList, 10000);
 
@@ -180,7 +150,13 @@ public class WbsTreeContractServiceImpl
 
             } else {
                 //删除
-
+                List<WbsTreeContract> wbsTreeContracts = baseMapper.selectList(Wrappers.<WbsTreeContract>query().lambda()
+                        .eq(WbsTreeContract::getContractIdRelation, pawDTO.getContractId())
+                        .in(WbsTreeContract::getContractType, "2,3")
+                );
+                if (wbsTreeContracts.size() > 0) {
+                    throw new ServiceException("当前施工合同段wbs树被监理或业主合同段引用中,删除失败!");
+                }
                 List<Long> ids1 = diffRent.stream().map(Long::parseLong).collect(Collectors.toList());
                 baseMapper.deleteBatch(ids1, pawDTO.getWbsId(), pawDTO.getProjectId(), pawDTO.getContractId());
 
@@ -318,7 +294,6 @@ public class WbsTreeContractServiceImpl
         return wbsTreeContractList;
     }
 
-
     @Override
     public List<WbsTreeContract> searchParentAllNode(long primaryKeyId, Long contractId) {
         return baseMapper.searchParentAllNode(primaryKeyId, contractId);

+ 18 - 73
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeServiceImpl.java

@@ -572,13 +572,10 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                             wbsTreeZi.setIsConcrete(0);
                             wbsTreeZi.setIsExpernode(0);
                         }
-
                         baseMapper.insert(wbsTreeZi);
                         break;
-
                     }
                 }
-
                 trees = tree;
             }
         }
@@ -601,9 +598,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                     wbsTreeZi.setDeptName(maps.getValue());
                     wbsTreeZi.setDeptCategory(Integer.valueOf(maps.getKey()));
                     wbsTreeZi.setWbsId(wbsTreeFu.getWbsId());
-
                     wbsTreeZi.setParentId(wbsTreeFu.getParentId());
-
                     wbsTreeZi.setAncestors(wbsTreeFu.getAncestors());
                     wbsTreeZi.setProjectNodeId(wbsTree1.getProjectNodeId());
 
@@ -616,6 +611,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                         StringBuilder stringBuffer = new StringBuilder();
                         StringBuilder appendStr = stringBuffer.append(",").append(wbsTreeZi.getParentId());
                         String ancestors = wbsTreeZi.getAncestors() + appendStr;
+
                         wbsTreeZi.setAncestors(ancestors);
 
                         wbsTreeFu.setParentId(id);
@@ -640,23 +636,32 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
     }
 
     private WbsTree buildTreeNode(WbsTree wbsTreeZi, List<WbsTree> allNodeData) {
-        List<WbsTree> wbsTrees = new ArrayList<>();
+        /*List<WbsTree> wbsTrees = new ArrayList<>();
         //判重
         for (WbsTree tree : allNodeData) {
             if (tree.getDeptName().equals(wbsTreeZi.getDeptName())
+                    && tree.getWbsId().equals(wbsTreeZi.getWbsId())
                     && tree.getDeptCategory().equals(wbsTreeZi.getDeptCategory())
                     && tree.getProjectNodeId().equals(wbsTreeZi.getProjectNodeId())
-                    && !tree.getAncestors().equals(wbsTreeZi.getAncestors())
-            ) {
+                    && !tree.getAncestors().equals(wbsTreeZi.getAncestors())) {
                 //判断上级节点不同,当前节点名相同的tree选择问题,例如:第X跨的上级有上部构造现场浇筑、上部构造预制和安装,导致下方新增重复节点判断时找到的是前一个
                 wbsTrees.add(tree);
                 break;
             }
-        }
+        }*/
+
+        List<WbsTree> wbsTrees = allNodeData.stream().filter(f ->
+                f.getWbsId().equals(wbsTreeZi.getWbsId()) &&
+                        f.getDeptName().equals(wbsTreeZi.getDeptName()) &&
+                        f.getDeptCategory().equals(wbsTreeZi.getDeptCategory()) &&
+                        f.getProjectNodeId().equals(wbsTreeZi.getProjectNodeId()) &&
+                        !f.getAncestors().equals(wbsTreeZi.getAncestors())
+        ).collect(Collectors.toList());
 
         WbsTree wbsTree = null;
+
         //不重复 直接新增
-        if (wbsTrees.size() == 0) {
+        if (wbsTrees.size() <= 0) {
             wbsTreeZi.setStatus(1);
             wbsTreeZi.setType(1);
             wbsTreeZi.setMajorDataType(0);
@@ -679,10 +684,12 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                         if (wbsTreeZi.getDeptCategory() == 6) {
                             wbsTreeZi.setIsConcrete(0);
                             wbsTreeZi.setIsExpernode(0);
-                            break;
                         }
+                        // wbsTree = null;
+                        break;
                     }
                 }
+
                 wbsTree = tree;
             }
         }
@@ -921,37 +928,6 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                         });
                     });
 
-                    /**
-                     * 不清楚为什么之前要节点+表分开判断
-                     */
-                    /*
-                    //公有
-                    //查询所有公共节点+表单
-                    List<WbsTree> trees = baseMapper.selectList(Wrappers.<WbsTree>query().lambda().eq(WbsTree::getWbsId, pawDTO.getWbsId()));
-                    List<WbsTree> treesTable = trees.stream().filter(f -> f.getType() == 2).collect(Collectors.toList());
-                    //根据id获取指定WbsTree节点数据
-                    List<WbsTree> listTree = new ArrayList<>();
-                    trees.stream().map(tree -> {
-                        diffRent.stream().forEach(id -> {
-                            if (id.equals(String.valueOf(tree.getId()))) {
-                                listTree.add(tree);
-                            }
-                        });
-                        return null;
-                    }).collect(Collectors.toList());
-                    //初始化
-                    //节点
-                    listTree.stream().forEach(tree -> {
-                        WbsTreePrivate wbsTreePrivate2 = getWbsTreePrivate1(tree, pawDTO);
-                        insertData.add(wbsTreePrivate2);
-                    });
-                    //元素表
-                    treesTable.stream().forEach(tree -> {
-                        WbsTreePrivate wbsTreePrivate2 = getWbsTreePrivate1(tree, pawDTO);
-                        insertData.add(wbsTreePrivate2);
-                    });
-                    */
-
                 } else if (pawDTO.getReferenceType().equals("private")) {
                     //引用私有
 
@@ -971,37 +947,6 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                             insertData2.add(wbsTreePrivate2);
                         });
                     });
-
-                    /**
-                     * 不清楚为什么之前要节点+表分开判断
-                     */
-                   /* List<WbsTreePrivate> wbsTreePrivatesList = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
-                            .eq(WbsTreePrivate::getWbsId, pawDTO.getWbsId())
-                            .eq(WbsTreePrivate::getProjectId, pawDTO.getReferencePrivateWbsProjectId())
-                    );
-                    //表单
-                    List<WbsTreePrivate> wbsTreePrivatesListTable = wbsTreePrivatesList.stream().filter(f -> f.getType() == 2).collect(Collectors.toList());
-                    List<WbsTreePrivate> listTree = new ArrayList<>();
-                    wbsTreePrivatesList.stream().map(tree -> {
-                        diffRent.stream().forEach(id -> {
-                            if (id.equals(String.valueOf(tree.getId()))) {
-                                listTree.add(tree);
-                            }
-                        });
-                        return null;
-                    }).collect(Collectors.toList());
-                    //初始化
-                    //节点
-                    listTree.stream().forEach(wbsTreePrivate -> {
-                        WbsTreePrivate wbsTreePrivate2 = getWbsTreePrivate2(wbsTreePrivate, pawDTO);
-                        insertData2.add(wbsTreePrivate2);
-                    });
-                    //元素表
-                    wbsTreePrivatesListTable.stream().forEach(wbsTreePrivate -> {
-                        WbsTreePrivate wbsTreePrivate2 = getWbsTreePrivate2(wbsTreePrivate, pawDTO);
-                        insertData2.add(wbsTreePrivate2);
-                    });*/
-
                 }
 
                 if (pawDTO.getReferenceType().equals("public")) {