|
@@ -84,6 +84,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
@@ -789,12 +790,16 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
|
|
|
/* ================ 处理颜色 ================ */
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
- List<NodeVO> nodeVOList = distinctNodesAll.stream().map(this::convertToNodeVO).collect(Collectors.toList());
|
|
|
- Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
|
|
|
+// List<NodeVO> nodeVOList = distinctNodesAll.stream().map(this::convertToNodeVO).collect(Collectors.toList());
|
|
|
+// Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
|
|
|
List<NodeVO> treeNodeVOList = this.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
|
|
|
- NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
|
|
|
- List<NodeVO> nodeVOS = this.flattenTree(treeNodeVOList);
|
|
|
- Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
|
|
|
+// NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
|
|
|
+ Map<Long, Integer> nodeColorStatusMap = new HashMap<>();
|
|
|
+ NodeVO.calculateStatusToDFS1(treeNodeVOList, nodeColorStatusMap);
|
|
|
+// buildNodeTreeByStream(distinctNodesAll, lowestNodesMap, nodeColorStatusMap);
|
|
|
+ // 将树形结构展开成列表
|
|
|
+// List<NodeVO> nodeVOS = this.flattenTree(treeNodeVOList);
|
|
|
+// Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
long executionTime = endTime - startTime;
|
|
|
_logger.info("合同段 " + contractId + " 处理颜色 执行时间:" + executionTime + " ms");
|
|
@@ -928,13 +933,15 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
}
|
|
|
}).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
|
|
|
|
|
|
- List<NodeVO> nodeVOList = distinctNodesAll.stream().map(this::convertToNodeVO).collect(Collectors.toList());
|
|
|
- Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
|
|
|
+// List<NodeVO> nodeVOList = distinctNodesAll.stream().map(this::convertToNodeVO).collect(Collectors.toList());
|
|
|
+// Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
|
|
|
List<NodeVO> treeNodeVOList = this.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
|
|
|
- NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
|
|
|
- List<NodeVO> nodeVOS = this.flattenTree(treeNodeVOList);
|
|
|
- Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
|
|
|
-
|
|
|
+// NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
|
|
|
+// List<NodeVO> nodeVOS = this.flattenTree(treeNodeVOList);
|
|
|
+// Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
|
|
|
+ Map<Long, Integer> nodeColorStatusMap = new HashMap<>();
|
|
|
+ NodeVO.calculateStatusToDFS1(treeNodeVOList, nodeColorStatusMap);
|
|
|
+// buildNodeTreeByStream(distinctNodesAll, lowestNodesMap, nodeColorStatusMap);
|
|
|
if (lazyNodes.size() > 0) {
|
|
|
Map<Long, Integer> countMap = new HashMap<>();
|
|
|
for (WbsTreeContractLazyVO node : resultParentNodesTB) {
|
|
@@ -1426,7 +1433,8 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
|
|
|
/*重新计算,进行递归获取父节点计数统计*/
|
|
|
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");
|
|
@@ -1482,6 +1490,37 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, Map<Long, List<WbsTreeContractLazyVO>> nodeMap) {
|
|
|
+ if (lowestNodeParentIds == null || lowestNodeParentIds.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<Long, Long> parentIdGroup = lowestNodeParentIds.stream()
|
|
|
+ .collect(Collectors.groupingByConcurrent(Function.identity(), Collectors.counting()));
|
|
|
+
|
|
|
+ List<WbsTreeContractLazyVO> collectedNodes = parentIdGroup.entrySet().stream()
|
|
|
+ .flatMap(entry -> {
|
|
|
+ List<WbsTreeContractLazyVO> nodes = nodeMap.get(entry.getKey());
|
|
|
+ if (nodes == null || nodes.isEmpty()) {
|
|
|
+ return Stream.empty();
|
|
|
+ }
|
|
|
+ if (entry.getValue() > 1L) {
|
|
|
+ nodes = nodes.stream().limit(1)
|
|
|
+ .flatMap(node -> Collections.nCopies(entry.getValue().intValue(), node).stream())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return nodes.stream();
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<Long> collect = collectedNodes.stream()
|
|
|
+ .map(WbsTreeContractLazyVO::getParentId).filter(Objects::nonNull).distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!collect.isEmpty()) {
|
|
|
+ result.addAll(collectedNodes);
|
|
|
+ this.recursiveGetParentNodes(result, collect, nodeMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 转换VO
|
|
|
*
|
|
@@ -1493,7 +1532,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
nodeVO.setId(wbsTreeContractLazyVO.getId());
|
|
|
nodeVO.setParentId(wbsTreeContractLazyVO.getParentId());
|
|
|
nodeVO.setPKeyId(wbsTreeContractLazyVO.getPKeyId());
|
|
|
- nodeVO.setStatus(cn.hutool.core.util.ObjectUtil.isNotEmpty(wbsTreeContractLazyVO.getColorStatus()) ? wbsTreeContractLazyVO.getColorStatus() : 1);
|
|
|
+ nodeVO.setStatus(wbsTreeContractLazyVO.getColorStatus() != null ? wbsTreeContractLazyVO.getColorStatus() : 1);
|
|
|
return nodeVO;
|
|
|
}
|
|
|
|
|
@@ -1517,7 +1556,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
for (WbsTreeContractLazyVO vo : list) {
|
|
|
if (vo.getHasChildren().equals(0)) {
|
|
|
WbsTreeContractLazyVO lowestNodeVO = lowestNodesMap.getOrDefault(vo.getPKeyId(), null);
|
|
|
- if (lowestNodeVO != null && cn.hutool.core.util.ObjectUtil.isNotEmpty(lowestNodeVO.getColorStatus())) {
|
|
|
+ if (lowestNodeVO != null && lowestNodeVO.getColorStatus() != null) {
|
|
|
//最底层颜色初始化
|
|
|
vo.setColorStatus(lowestNodeVO.getColorStatus());
|
|
|
}
|