liuyc 1 年間 前
コミット
59981095d8

+ 5 - 2
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -1370,7 +1370,7 @@ public class InformationWriteQueryController extends BladeController {
     @PostMapping("/copyContractTreeNode")
     @ApiOperationSupport(order = 15)
     @ApiOperation(value = "复制节点(新)")
-    @TreeCodeUpdate(type =ArgType.PKD,value="#vo.needCopyPrimaryKeyId")
+    @TreeCodeUpdate(type = ArgType.PKD, value = "#vo.needCopyPrimaryKeyId")
     public R<Boolean> copyContractTreeNode(@RequestBody CopyContractTreeNodeVO vo) {
         //表单所属方
         String tabOwner = "";
@@ -2954,7 +2954,7 @@ public class InformationWriteQueryController extends BladeController {
     @PostMapping("/saveContractTreeNode")
     @ApiOperationSupport(order = 10)
     @ApiOperation(value = "新增节点及其子节点")
-    @TreeCodeUpdate(type=ArgType.CID,value = "#vo.contractId")
+    @TreeCodeUpdate(type = ArgType.CID, value = "#vo.contractId")
     public R<Boolean> saveContractTreeNode(@RequestBody AddContractTreeNodeVO vo) {
         //先获取当前节点的信息
         WbsTreeContract treeContract = this.wbsTreeContractClient.getContractWbsTreeByPrimaryKeyId(Long.parseLong(vo.getCurrentNodePrimaryKeyId()));
@@ -3563,6 +3563,9 @@ public class InformationWriteQueryController extends BladeController {
         //查询当前节点下的所有填报节点
         WbsTreeContract node = this.wbsTreeContractClient.getContractWbsTreeByPrimaryKeyId(vo.getWbsId());
         if (node == null) {
+            if (StringUtils.isEmpty(vo.getContractIdRelation())) {
+                return null;
+            }
             //这一步主要是为了兼容监理合同段
             node = this.wbsTreeContractClient.getContractWbsTreeByContractIdAndId(vo.getWbsId(), Long.parseLong(vo.getContractIdRelation()));
         }

+ 22 - 34
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -1552,7 +1552,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
      * @param lowestNodeParentIds 最底层节点ParentIds
      * @param nodesAll            所有节点
      */
-    public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, List<WbsTreeContractLazyVO> nodesAll) {
+    /*public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, List<WbsTreeContractLazyVO> nodesAll) {
         if (lowestNodeParentIds.isEmpty()) {
             return;
         }
@@ -1587,52 +1587,40 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
             result.addAll(multipleParentNodes);
             this.recursiveGetParentNodes(result, collect, nodesAll);
         }
-    }
-
-    /*public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, List<WbsTreeContractLazyVO> nodesAll) {
+    }*/
+    public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, List<WbsTreeContractLazyVO> nodesAll) {
         if (lowestNodeParentIds.isEmpty()) {
             return;
         }
 
-        //并行粒度
-        ForkJoinPool customThreadPool = new ForkJoinPool(4);
-
-        //父级Id与出现的次数Map
-        Map<Long, Long> parentIdGroup = lowestNodeParentIds.parallelStream()
+        Map<Long, Long> parentIdGroup = lowestNodeParentIds.stream()
                 .collect(Collectors.groupingByConcurrent(Function.identity(), Collectors.counting()));
 
-        //批量查询单次节点
-        CompletableFuture<List<WbsTreeContractLazyVO>> parentNodesFuture = CompletableFuture.supplyAsync(() ->
-                parentIdGroup.entrySet().parallelStream()
-                        .filter(entry -> entry.getValue() == 1L)
-                        .flatMap(entry -> nodesAll.parallelStream()
-                                .filter(f -> entry.getKey().equals(f.getId())))
-                        .collect(Collectors.toList()), customThreadPool);
+        List<WbsTreeContractLazyVO> collectedNodes = parentIdGroup.entrySet().parallelStream()
+                .flatMap(entry -> {
+                    List<WbsTreeContractLazyVO> nodes = nodesAll.stream()
+                            .filter(f -> entry.getKey().equals(f.getId()))
+                            .collect(Collectors.toList());
 
-        //批量查询多次节点
-        CompletableFuture<List<WbsTreeContractLazyVO>> multipleParentNodesFuture = CompletableFuture.supplyAsync(() ->
-                parentIdGroup.entrySet().parallelStream()
-                        .filter(entry -> entry.getValue() > 1L)
-                        .flatMap(entry -> nodesAll.parallelStream()
-                                .filter(f -> entry.getKey().equals(f.getId()))
-                                .limit(1)
-                                .flatMap(node -> Collections.nCopies(entry.getValue().intValue(), node).parallelStream()))
-                        .collect(Collectors.toList()), customThreadPool);
+                    if (entry.getValue() > 1L) {
+                        nodes = nodes.stream().limit(1)
+                                .flatMap(node -> Collections.nCopies(entry.getValue().intValue(), node).stream())
+                                .collect(Collectors.toList());
+                    }
 
-        //结果集
-        CompletableFuture<List<Long>> collectFuture = parentNodesFuture.thenCombine(multipleParentNodesFuture, (parentNodes, multipleParentNodes) ->
-                Stream.concat(parentNodes.parallelStream(), multipleParentNodes.parallelStream())
-                        .map(WbsTreeContractLazyVO::getParentId)
-                        .collect(Collectors.toList()));
+                    return nodes.stream();
+                })
+                .collect(Collectors.toList());
 
-        List<Long> collect = collectFuture.join();
+        List<Long> collect = collectedNodes.stream()
+                .map(WbsTreeContractLazyVO::getParentId)
+                .collect(Collectors.toList());
 
         if (!collect.isEmpty()) {
-            result.addAll(parentNodesFuture.join());
-            result.addAll(multipleParentNodesFuture.join());
+            result.addAll(collectedNodes);
             this.recursiveGetParentNodes(result, collect, nodesAll);
         }
-    }*/
+    }
 
     @Override
     public boolean syncTabData(String pKeyId) throws Exception {