Compare commits

...

2 Commits

View File

@@ -434,7 +434,6 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
}
// 查询子节点,可能是同类型节点也可能是不同类型节点
// 先查同类型节点当前标签下包含currentNodeTagId且深度+1
// int depth = finalCurrentNodeTagId.split(",").length;
int depth = getCurrentNodeDepth(projectNodePo);
String finalCurrentTag = currentTag;
List<ProjectNodePo> sameTypeNodeList = taskTreeNodeList.stream().filter(node -> {
@@ -450,22 +449,6 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
}).collect(Collectors.toList());
// 再查不同类型的节点:下一标签下的节点
TaskNodeTag finalNextNodeTag = nextNodeTag;
// List<ProjectNodePo> childrenTypeNodeList = taskTreeNodeList.stream().filter(node -> {
// try {
// String nodeTagId = getTagProperty(node, currentTag);
// if (StringUtils.isBlank(nodeTagId)) {
// return false;
// }
// // tagId相同且当前深度 = task深度 + 1
// // tagId相同且nodeType是nextNodeTag类型且子tagId的深度最少
// return nodeTagId.equals(finalCurrentNodeTagId) && node.getNodeType().equals(finalNextNodeTag.getKey());
//// return nodeTagId.equals(finalCurrentNodeTagId) && currentNodeDepth == getCurrentNodeDepth(node) - 1;
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }).collect(Collectors.toList());
// maxNodeTagSize
List<NodeAllBase> children = new ArrayList<>();
if (CollectionUtils.isNotEmpty(sameTypeNodeList)) {
// 递归
@@ -475,9 +458,12 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
if (CollectionUtils.isNotEmpty(sameTypeNodeList)) {
children.addAll(sameTypeNodeList);
}
}else if (!currentTag.equals(finalNextNodeTag.getValue()) && !lastNodeTag.equals(currentTag)){
}
if (!currentTag.equals(finalNextNodeTag.getValue()) && !lastNodeTag.equals(currentTag)){
List<ProjectNodePo> childrenTypeNodeList = getChildrenTypeNodeList(currentTag,finalNextNodeTag,finalCurrentNodeTagId);
List<Long> childrenTypeNodeIdList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(childrenTypeNodeList)) {
childrenTypeNodeIdList = childrenTypeNodeList.stream().map(ProjectNodePo::getId).toList();
int firstLayerNodeDepth = getFirstLayerNodeDepth(childrenTypeNodeList);
childrenTypeNodeList = childrenTypeNodeList.stream().filter(node -> getCurrentNodeDepth(node) == firstLayerNodeDepth).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(childrenTypeNodeList)) {
@@ -485,13 +471,34 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
for (ProjectNodePo nodePo : childrenTypeNodeList) {
generateTaskTree(nodePo);
}
children.addAll(childrenTypeNodeList);
}
}
if (CollectionUtils.isNotEmpty(childrenTypeNodeList)) {
children.addAll(childrenTypeNodeList);
// 查找当前节点的其他子节点(非直接顺序子节点)
List<Long> finalChildrenTypeNodeIdList = childrenTypeNodeIdList;
List<ProjectNodePo> otherChildrenNodeList = taskTreeNodeList.stream().filter(node -> {
try {
String nodeTagId = getTagProperty(node, finalCurrentTag);
if (StringUtils.isBlank(nodeTagId)) {
return false;
}
return !node.getNodeType().equals(currentNodeType) && nodeTagId.equals(finalCurrentNodeTagId) && getCurrentNodeDepth(node) == depth + 1 && !finalChildrenTypeNodeIdList.contains(node.getId());
} catch (Exception e) {
throw new RuntimeException(e);
}
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(otherChildrenNodeList)) {
int firstLayerNodeDepth = getFirstLayerNodeDepth(otherChildrenNodeList);
otherChildrenNodeList = otherChildrenNodeList.stream().filter(node -> getCurrentNodeDepth(node) == firstLayerNodeDepth).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(otherChildrenNodeList)) {
// 递归
for (ProjectNodePo nodePo : otherChildrenNodeList) {
generateTaskTree(nodePo);
}
children.addAll(otherChildrenNodeList);
}
}
}
if (CollectionUtils.isNotEmpty(currentNodeAssociatedTaskList)) {
currentNodeAssociatedTaskList.forEach(task -> task.setNodeName(task.getTaskName()));
children.addAll(currentNodeAssociatedTaskList);