فهرست منبع

wbs划分相关

liuyc 3 سال پیش
والد
کامیت
f5aa4d67d2

+ 3 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ProjectInfoController.java

@@ -41,6 +41,7 @@ import org.springblade.manager.wrapper.ProjectInfoWrapper;
 import org.springblade.core.boot.ctrl.BladeController;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 客户级项目表 控制器
@@ -251,8 +252,8 @@ public class ProjectInfoController extends BladeController {
     @GetMapping("/findProjectAndContractList")
     @ApiOperationSupport(order = 12)
     @ApiOperation(value = "根据用户id查询项目合同岗位列表信息", notes = "传入用户id")
-    public R<List<SaveUserInfoByProjectVO2>> findProjectAndContractList(Long userId) {
-        List<SaveUserInfoByProjectVO2> result = wbsTreeService.findProjectAndContractList(userId);
+    public R<List<Map>> findProjectAndContractList(Long userId) {
+        List<Map> result = wbsTreeService.findProjectAndContractList(userId);
         return R.data(result);
     }
 }

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IWbsTreeService.java

@@ -104,7 +104,7 @@ public interface IWbsTreeService extends BaseService<WbsTree> {
 
     List<WbsTree> findByWbsTreeNode(String ids);
 
-    List<SaveUserInfoByProjectVO2> findProjectAndContractList(Long userId);
+    List<Map> findProjectAndContractList(Long userId);
 
     List<WbsTreeDTO2> findWbsTreeSameLevel(String parentId);
 

+ 71 - 90
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeServiceImpl.java

@@ -475,7 +475,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
             ArrayList<Map<String, String>> result = excelUtil.readExcelToObj(canonicalPath);
 
             //导入excel
-            return importExcel(result, wbsTreeFu, wbsTree1);
+            return importExcel2(result, wbsTreeFu, wbsTree1);
 
         } catch (Exception e) {
             e.printStackTrace();
@@ -517,9 +517,12 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                         updateData(ancestors, id);
                         wbsTreeFu.setParentId(id);
                         wbsTreeFu.setAncestors(ancestors);
+
                     } else {
+
                         wbsTreeFu.setParentId(wbsTree.getId());
                         wbsTreeFu.setAncestors(wbsTree.getAncestors());
+
                     }
                 }
             });
@@ -528,6 +531,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
         //修改projectNodeId
         int i = baseMapper.updateById(wbsTree1);
         return i > 0;
+
     }
 
     private WbsTree importTree(WbsTree wbsTreeZi) {
@@ -539,7 +543,9 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                 .eq(WbsTree::getProjectNodeId, wbsTreeZi.getProjectNodeId())
                 .ne(WbsTree::getAncestors, wbsTreeZi.getAncestors())
         );
+
         WbsTree trees = null;
+
         if (wbsTrees.size() <= 0) { //不重复-直接新增
             wbsTreeZi.setStatus(1);
             wbsTreeZi.setType(1);
@@ -548,13 +554,16 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                 wbsTreeZi.setIsConcrete(0);
                 wbsTreeZi.setIsExpernode(0);
             }
+
             baseMapper.insert(wbsTreeZi);
+
         } else { //重复-判断是否同级,同级跳过,不同级新增
             //获取当前相同节点对象信息
             for (WbsTree tree : wbsTrees) {
-                //判断2 3 4 5 6级节点类型的名称是否重复,可根据实际情况更改控制的层级
+                //判断2 3 4 5 6级节点类型的名称是否重复,可根据实际情况更改控制的层级
                 if (wbsTreeZi.getDeptCategory() == 2 || wbsTreeZi.getDeptCategory() == 3 || wbsTreeZi.getDeptCategory() == 4
                         || wbsTreeZi.getDeptCategory() == 5 || wbsTreeZi.getDeptCategory() == 6) {
+
                     if (!wbsTreeZi.getParentId().equals(tree.getParentId()) && wbsTreeZi.getDeptName().equals(tree.getDeptName())) {
                         wbsTreeZi.setStatus(1);
                         wbsTreeZi.setType(1);
@@ -563,21 +572,27 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                             wbsTreeZi.setIsConcrete(0);
                             wbsTreeZi.setIsExpernode(0);
                         }
+
                         baseMapper.insert(wbsTreeZi);
                         break;
+
                     }
                 }
+
                 trees = tree;
             }
         }
+
         return trees;
     }
 
 
-    //采用批量新增 默认排序 TODO
+    //采用批量 默认排序
     private boolean importExcel2(ArrayList<Map<String, String>> result, WbsTree wbsTreeFu, WbsTree wbsTree1) {
-        //解析list-map
+        WbsTree wbsTreeFu1 = new WbsTree();
+        BeanUtils.copyProperties(wbsTreeFu, wbsTreeFu1);
         List<WbsTree> allNodeData = new ArrayList<>();
+        //解析list-map
         for (Map<String, String> map : result) {
             for (Map.Entry<String, String> maps : map.entrySet()) {
                 if (StringUtils.isNotEmpty(maps.getValue())) {
@@ -593,63 +608,56 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                     wbsTreeZi.setProjectNodeId(wbsTree1.getProjectNodeId());
 
                     //构建参数
-                    WbsTree wbsTree = buildTreeNode(wbsTreeZi, allNodeData, wbsTreeFu);
-
-                    System.out.println("status : " + wbsTree.getStatus());
-
-                    if (wbsTree.getStatus() != null) {
-                        //构建成功
-                        System.out.println("构建成功: === " + wbsTree);
+                    WbsTree wbsTree = buildTreeNode(wbsTreeZi, allNodeData);
 
-                        wbsTreeFu = wbsTree;
+                    if (wbsTree == null) {
+                        //构建成功,后置赋值
+                        Long id = wbsTreeZi.getId();
+                        StringBuilder stringBuffer = new StringBuilder();
+                        StringBuilder appendStr = stringBuffer.append(",").append(wbsTreeZi.getParentId());
+                        String ancestors = wbsTreeZi.getAncestors() + appendStr;
+                        wbsTreeZi.setAncestors(ancestors);
 
-                        System.out.println("构建成功: === 重新赋值wbsFu " + wbsTreeFu);
+                        wbsTreeFu.setParentId(id);
+                        wbsTreeFu.setAncestors(ancestors);
 
                     } else {
-                        //构建失败 相同节点参数跳过
-                        System.out.println("构建失败: === 遇到相同的跳过了");
+                        //相同节点参数跳过
+                        wbsTreeFu.setParentId(wbsTree.getId());
+                        wbsTreeFu.setAncestors(wbsTree.getAncestors());
+
                     }
 
+                    //结果集
+                    allNodeData.add(wbsTreeZi);
 
                 }
             }
         }
 
-        boolean b = this.saveBatch(allNodeData, 10000);
-
-        int i = baseMapper.updateById(wbsTree1);
-
-        return i > 0 && b;
+        return this.saveBatch(allNodeData, 10000) && baseMapper.updateById(wbsTree1) > 0;
 
     }
 
-    private WbsTree buildTreeNode(WbsTree wbsTreeZi, List<WbsTree> allNodeData, WbsTree wbsTreeFu) {
+    private WbsTree buildTreeNode(WbsTree wbsTreeZi, List<WbsTree> allNodeData) {
         List<WbsTree> wbsTrees = new ArrayList<>();
-        //判断节点名称是否重复
-        if (allNodeData.size() > 0) {
-            /*wbsTrees = allNodeData.stream().filter(f -> f.getWbsId().equals(wbsTreeZi.getWbsId()))
-                    .filter(f -> f.getDeptName().equals(wbsTreeZi.getDeptName()))
-                    .filter(f -> f.getDeptCategory().equals(wbsTreeZi.getDeptCategory()))
-                    .filter(f -> f.getProjectNodeId().equals(wbsTreeZi.getProjectNodeId()))
-                    .filter(f -> !f.getAncestors().equals(wbsTreeZi.getAncestors())
-                    ).collect(Collectors.toList());*/
-
-            for (WbsTree tree : allNodeData) {
-                if (tree.getDeptName().equals(wbsTreeZi.getDeptName())
-                        && tree.getDeptCategory().equals(wbsTreeZi.getDeptCategory())
-                        && tree.getProjectNodeId().equals(wbsTreeZi.getProjectNodeId())
-                        && !tree.getAncestors().equals(wbsTreeZi.getAncestors())) {
-                    wbsTrees.add(tree);
-                }
+        //判重
+        for (WbsTree tree : allNodeData) {
+            if (tree.getDeptName().equals(wbsTreeZi.getDeptName())
+                    && tree.getDeptCategory().equals(wbsTreeZi.getDeptCategory())
+                    && tree.getProjectNodeId().equals(wbsTreeZi.getProjectNodeId())
+                    && !tree.getAncestors().equals(wbsTreeZi.getAncestors())) {
+
+                //判断上级节点不同,当前节点名相同的tree选择问题,采用倒序获取最新添加的一条,也就是相同父节点的一条 TODO
+                //第X跨的上级有上部构造现场浇筑、上部构造预制和安装,导致下方新增重复节点判断时找到的是前一个
+                wbsTrees.add(tree);
+                break;
             }
-
         }
 
-
+        WbsTree wbsTree = null;
         //不重复 直接新增
         if (wbsTrees.size() == 0) {
-            System.out.println("方法执行到111111 不重复节点,直接新增了");
-
             wbsTreeZi.setStatus(1);
             wbsTreeZi.setType(1);
             wbsTreeZi.setMajorDataType(0);
@@ -658,62 +666,34 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                 wbsTreeZi.setIsExpernode(0);
             }
 
-            StringBuilder stringBuffer = new StringBuilder();
-            StringBuilder appendStr = stringBuffer.append(",").append(wbsTreeZi.getParentId());
-            wbsTreeZi.setAncestors(wbsTreeZi.getAncestors() + appendStr);
-
-            System.out.println("wbsTreeZi 1 : " + wbsTreeZi);
-
-            allNodeData.add(wbsTreeZi);
-
-            wbsTreeFu.setParentId(wbsTreeZi.getId());
-            wbsTreeFu.setAncestors(wbsTreeZi.getAncestors());
-
-            return wbsTreeFu;
-
         } else {
 
             //重复 判断是否为同一父节点,相同父节点跳过,不同新增
             for (WbsTree tree : wbsTrees) {
-                //判断2 3 4 5 6级节点类型的名称是否重复,可根据实际情况更改控制的层级
-                /*if (wbsTreeZi.getDeptCategory() == 2 || wbsTreeZi.getDeptCategory() == 3 || wbsTreeZi.getDeptCategory() == 4
-                        || wbsTreeZi.getDeptCategory() == 5 || wbsTreeZi.getDeptCategory() == 6) {
-                */
-                System.out.println("存在的节点 " + tree.getDeptName() + " parentID " + tree.getParentId());
-                System.out.println("当前子节点 " + wbsTreeZi.getDeptName() + " parentID " + wbsTreeZi.getParentId());
-
-                if (!wbsTreeZi.getParentId().equals(tree.getParentId()) && wbsTreeZi.getDeptName().equals(tree.getDeptName())) {
-
-                    System.out.println("方法执行到222222遇到重复名称,但不同级的节点");
-                    wbsTreeZi.setStatus(1);
-                    wbsTreeZi.setType(1);
-                    wbsTreeZi.setMajorDataType(0);
-                    if (wbsTreeZi.getDeptCategory() == 6) {
-                        wbsTreeZi.setIsConcrete(0);
-                        wbsTreeZi.setIsExpernode(0);
+                if (wbsTreeZi.getDeptCategory() == 2 || wbsTreeZi.getDeptCategory() == 3
+                        || wbsTreeZi.getDeptCategory() == 4 || wbsTreeZi.getDeptCategory() == 5 || wbsTreeZi.getDeptCategory() == 6) {
+
+                    if (tree.getParentId().equals(wbsTreeZi.getParentId())) { //TODO
+
+                        if (!wbsTreeZi.getParentId().equals(tree.getParentId()) && wbsTreeZi.getDeptName().equals(tree.getDeptName())) {
+                            wbsTreeZi.setStatus(1);
+                            wbsTreeZi.setType(1);
+                            wbsTreeZi.setMajorDataType(0);
+                            if (wbsTreeZi.getDeptCategory() == 6) {
+                                wbsTreeZi.setIsConcrete(0);
+                                wbsTreeZi.setIsExpernode(0);
+                                break;
+                            }
+                        }
                     }
 
-                    StringBuilder stringBuffer = new StringBuilder();
-                    StringBuilder appendStr = stringBuffer.append(",").append(wbsTreeZi.getParentId());
-                    wbsTreeZi.setAncestors(wbsTreeZi.getAncestors() + appendStr);
-                    System.out.println("wbsTreeZi 2 : " + wbsTreeZi);
-
-                    allNodeData.add(wbsTreeZi);
-
-                    wbsTreeFu.setParentId(wbsTreeZi.getId());
-                    wbsTreeFu.setAncestors(wbsTreeZi.getAncestors());
-
-                    return wbsTreeFu;
-
                 }
-                //  }
+
+                wbsTree = tree;
             }
         }
 
-        System.out.println("方法执行到333333,遇到重复节点跳过了");
-        System.out.println("wbsTreeZi 3 : " + wbsTreeFu);
-        return wbsTreeFu;
-
+        return wbsTree;
     }
 
 
@@ -737,10 +717,10 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
     }
 
     @Override
-    public List<SaveUserInfoByProjectVO2> findProjectAndContractList(Long userId) {
+    public List<Map> findProjectAndContractList(Long userId) {
         List<SaveUserInfoByProjectVO2> list = baseMapper.selectListByUserId(userId);
 
-        //TODO 用户项目合同段角色返回Map
+        //用户项目合同段角色返回Map
         Map<String, List<SaveUserInfoByProjectVO2>> collect = list.stream().collect(Collectors.groupingBy(SaveUserInfoByProjectVO2::getProjectName));
         List<Map> collect1 = collect.entrySet().stream().map(entity -> {
             Map resultMap = new HashMap();
@@ -749,7 +729,8 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
             return resultMap;
         }).collect(Collectors.toList());
 
-        return list;
+        return collect1;
+
     }
 
     @Override