|
@@ -792,7 +792,7 @@ 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> treeNodeVOList = this.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
|
|
|
+ List<NodeVO> treeNodeVOList = this.buildNodeTreeByStream1(distinctNodesAll, lowestNodesMap);
|
|
|
// NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
|
|
|
Map<Long, Integer> nodeColorStatusMap = new HashMap<>();
|
|
|
NodeVO.calculateStatusToDFS1(treeNodeVOList, nodeColorStatusMap);
|
|
@@ -935,7 +935,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
|
|
|
// 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);
|
|
|
+ List<NodeVO> treeNodeVOList = this.buildNodeTreeByStream1(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));
|
|
@@ -1511,11 +1511,8 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
return nodes.stream();
|
|
|
})
|
|
|
.collect(Collectors.toList());
|
|
|
- if (collectedNodes.isEmpty()) {
|
|
|
- return;
|
|
|
- }
|
|
|
List<Long> collect = collectedNodes.stream()
|
|
|
- .map(WbsTreeContractLazyVO::getParentId).filter(Objects::nonNull).distinct()
|
|
|
+ .map(WbsTreeContractLazyVO::getParentId).filter(Objects::nonNull)
|
|
|
.collect(Collectors.toList());
|
|
|
if (!collect.isEmpty()) {
|
|
|
result.addAll(collectedNodes);
|
|
@@ -1578,6 +1575,51 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 构造树形结构数据 (解决节点颜色问题)
|
|
|
+ *
|
|
|
+ * @param distinctNodesAll 去重后所有节点数据
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<NodeVO> buildNodeTreeByStream1(List<WbsTreeContractLazyVO> distinctNodesAll,
|
|
|
+ Map<Long, WbsTreeContractLazyVO> lowestNodesMap) {
|
|
|
+ List<WbsTreeContractLazyVO> list = distinctNodesAll.stream().filter(f->f.getParentId()!=null).filter(f -> f.getParentId().equals(0L)).collect(Collectors.toList());
|
|
|
+ Map<Long, List<WbsTreeContractLazyVO>> map = distinctNodesAll.stream().filter(f->f.getParentId()!=null).collect(Collectors.groupingBy(WbsTreeContractLazyVO::getParentId));
|
|
|
+ Map<Long, NodeVO> nodeVOMap = new HashMap<>();
|
|
|
+ return recursionFnNodeTree(list, map, lowestNodesMap,nodeVOMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<NodeVO> recursionFnNodeTree
|
|
|
+ (List<WbsTreeContractLazyVO> list, Map<Long, List<WbsTreeContractLazyVO>> map,
|
|
|
+ Map<Long, WbsTreeContractLazyVO> lowestNodesMap, Map<Long, NodeVO> nodeVOMap) {
|
|
|
+ List<NodeVO> result = new ArrayList<>();
|
|
|
+ for (WbsTreeContractLazyVO vo : list) {
|
|
|
+ if (vo.getHasChildren().equals(0)) {
|
|
|
+ WbsTreeContractLazyVO lowestNodeVO = lowestNodesMap.getOrDefault(vo.getPKeyId(), null);
|
|
|
+ if (lowestNodeVO != null && lowestNodeVO.getColorStatus() != null) {
|
|
|
+ //最底层颜色初始化
|
|
|
+ vo.setColorStatus(lowestNodeVO.getColorStatus());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //非最底层节点,颜色默认=1黑色
|
|
|
+ vo.setColorStatus(1);
|
|
|
+ }
|
|
|
+ //转换为NodeVO
|
|
|
+ NodeVO nodeVO = convertToNodeVO(vo);
|
|
|
+ nodeVOMap.put(nodeVO.getPKeyId(), nodeVO);
|
|
|
+ List<WbsTreeContractLazyVO> childrenList = map.get(vo.getId());
|
|
|
+ if (childrenList != null && !childrenList.isEmpty()) {
|
|
|
+ List<WbsTreeContractLazyVO> collect = childrenList.stream().filter(child -> !nodeVOMap.containsKey(child.getPKeyId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!collect.isEmpty()) {
|
|
|
+ nodeVO.setChildren(recursionFnNodeTree(collect, map, lowestNodesMap, nodeVOMap));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.add(nodeVO);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 树形层级结构转为普通List
|
|
|
*
|