liuyc 1 an în urmă
părinte
comite
e1215502f3

+ 19 - 9
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -68,6 +68,11 @@ import java.util.stream.Stream;
 @AllArgsConstructor
 public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractMapper, WbsTreeContract> implements IWbsTreeContractService {
 
+    static {
+        /*parallelStream并行流粒度*/
+        System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", "4");
+    }
+
     private static final Logger logger = LoggerFactory.getLogger(WbsTreeContractServiceImpl.class);
     private final ConstructionLedgerFeignClient constructionLedgerFeign;
     private final WbsTreePrivateMapper wbsTreePrivateMapper;
@@ -773,8 +778,13 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                         List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
                         //获取本地缓存节点数量统计
                         List<WbsTreeContractLazyVO> resultParentNodesTB = this.getCachedParentCountNodes(contractId, lowestNodeParentIdsTB, nodesAll, tableOwner);
-                        //List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
-                        //this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
+
+                        /*List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
+                        long startTime1 = System.currentTimeMillis();
+                        this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
+                        long endTime1 = System.currentTimeMillis();
+                        long executionTime1 = endTime1 - startTime1;
+                        logger.info("合同段 " + contractId + " wbs节点树 数量计算 耗时:" + executionTime1 + " ms");*/
 
                         //最底层节点颜色构造后Map
                         Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
@@ -1542,24 +1552,24 @@ 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;
         }
 
         //父级Id与出现的次数Map
-        Map<Long, Long> parentIdGroup = lowestNodeParentIds.stream()
+        Map<Long, Long> parentIdGroup = lowestNodeParentIds.parallelStream()
                 .collect(Collectors.groupingByConcurrent(Function.identity(), Collectors.counting()));
 
         //批量查询单次节点
-        List<WbsTreeContractLazyVO> parentNodes = parentIdGroup.entrySet().stream()
+        List<WbsTreeContractLazyVO> parentNodes = parentIdGroup.entrySet().parallelStream()
                 .filter(entry -> entry.getValue() == 1L)
                 .flatMap(entry -> nodesAll.stream()
                         .filter(f -> entry.getKey().equals(f.getId())))
                 .collect(Collectors.toList());
 
         //批量查询多次节点
-        List<WbsTreeContractLazyVO> multipleParentNodes = parentIdGroup.entrySet().stream()
+        List<WbsTreeContractLazyVO> multipleParentNodes = parentIdGroup.entrySet().parallelStream()
                 .filter(entry -> entry.getValue() > 1L)
                 .flatMap(entry -> nodesAll.stream()
                         .filter(f -> entry.getKey().equals(f.getId()))
@@ -1577,9 +1587,9 @@ 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;
         }
@@ -1622,7 +1632,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
             result.addAll(multipleParentNodesFuture.join());
             this.recursiveGetParentNodes(result, collect, nodesAll);
         }
-    }
+    }*/
 
     @Override
     public boolean syncTabData(String pKeyId) throws Exception {