Browse Source

wbs数据加载优化

lvy 1 month ago
parent
commit
826c116fea

+ 10 - 12
blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java

@@ -767,7 +767,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                                         Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
                                         ArrayList::new
                                 ));
-
                         /*获取当前合同段节点对应的资料填报QueryInfo本地缓存信息*/
                         List<WbsTreeContractLazyQueryInfoVO> queryInfoList = this.getQueryInfoList(contractId, tableOwner);
                         Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> Func.isNotEmpty(f.getWbsId())&&Func.isNotEmpty(f.getStatus()))
@@ -775,7 +774,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                         List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
 
                         /* ================ 处理数量 ================ */
-                        List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.parallelStream().filter(f -> pKeyIdList.contains(f.getPKeyId())).collect(Collectors.toList());
+                        List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.parallelStream().filter(f -> queryInfoMaps.containsKey(f.getPKeyId())).collect(Collectors.toList());
                         List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
                         List<WbsTreeContractLazyVO> resultParentNodesTB = this.getCachedParentCountNodes(contractId, lowestNodeParentIdsTB, nodesAll, tableOwner);
                         Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
@@ -803,7 +802,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                         long endTime = System.currentTimeMillis();
                         long executionTime = endTime - startTime;
                         _logger.info("合同段 " + contractId + " 处理颜色 执行时间:" + executionTime + " ms");
-
                         /* ================ 处理最终结果集 ================ */
                         if (lazyNodes.size() > 0) {
                             Map<Long, Integer> countMap = new HashMap<>();
@@ -1357,7 +1355,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                     }
                 }
                 //更新本地缓存
-                localCacheNodes.put(contractId, nodesAll);
+//                localCacheNodes.put(contractId, nodesAll);
             }
         }
         return nodesAll;
@@ -1407,7 +1405,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
 
         if (queryInfoList.size() > 0) {
             //更新本地缓存
-            localCacheQueryInfos.put(cacheKey, queryInfoList);
+//            localCacheQueryInfos.put(cacheKey, queryInfoList);
         }
         return queryInfoList;
     }
@@ -1432,17 +1430,17 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
             long startTime = System.currentTimeMillis();
 
             /*重新计算,进行递归获取父节点计数统计*/
-            this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
-//            Map<Long, List<WbsTreeContractLazyVO>> map = nodesAll.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getId));
-//            recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, map);
+//            this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
+            Map<Long, List<WbsTreeContractLazyVO>> map = nodesAll.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getId));
+            recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, map);
             long endTime = System.currentTimeMillis();
             long executionTime = endTime - startTime;
             _logger.info("合同段 " + contractId + " wbs节点树 数量计算 执行时间:" + executionTime + " ms");
 
-            if (resultParentNodesTB.size() > 0) {
-                //更新本地缓存
-                localCacheParentCountNodes.put(cacheKey, resultParentNodesTB);
-            }
+//            if (resultParentNodesTB.size() > 0) {
+//                //更新本地缓存
+//                localCacheParentCountNodes.put(cacheKey, resultParentNodesTB);
+//            }
         }
         return resultParentNodesTB;
     }