fix[project]: 仿真执行只显示有任务的节点
This commit is contained in:
@@ -290,10 +290,7 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
|||||||
if (CollectionUtils.isNotEmpty(taskExecutorMemberVoList)) {
|
if (CollectionUtils.isNotEmpty(taskExecutorMemberVoList)) {
|
||||||
// 根据仿真执行人过滤任务
|
// 根据仿真执行人过滤任务
|
||||||
taskExecutorMemberVoList = taskExecutorMemberVoList.stream().filter(member -> curUserId.equals(member.getUserId())).toList();
|
taskExecutorMemberVoList = taskExecutorMemberVoList.stream().filter(member -> curUserId.equals(member.getUserId())).toList();
|
||||||
if (CollectionUtils.isEmpty(taskExecutorMemberVoList)) {
|
if (CollectionUtils.isNotEmpty(taskExecutorMemberVoList)) {
|
||||||
log.error("任务列表中未查询到仿真执行人为当前用户的数据");
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
List<String> myTaskIdList = taskExecutorMemberVoList.stream().map(SimulationTaskMember::getTaskId).toList();
|
List<String> myTaskIdList = taskExecutorMemberVoList.stream().map(SimulationTaskMember::getTaskId).toList();
|
||||||
currentNodeAssociatedTaskList = currentNodeAssociatedTaskList.stream().filter(task -> myTaskIdList.contains(task.getUuid())).toList();
|
currentNodeAssociatedTaskList = currentNodeAssociatedTaskList.stream().filter(task -> myTaskIdList.contains(task.getUuid())).toList();
|
||||||
if (CollectionUtils.isNotEmpty(currentNodeAssociatedTaskList)) {
|
if (CollectionUtils.isNotEmpty(currentNodeAssociatedTaskList)) {
|
||||||
@@ -362,6 +359,9 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
|||||||
}else {
|
}else {
|
||||||
currentNodeAssociatedTaskList = new ArrayList<>();
|
currentNodeAssociatedTaskList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
currentNodeAssociatedTaskList = new ArrayList<>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 查询子节点,可能是同类型节点也可能是不同类型节点
|
// 查询子节点,可能是同类型节点也可能是不同类型节点
|
||||||
@@ -623,7 +623,51 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
|||||||
sortWorkspaceNode(projectNodePo);
|
sortWorkspaceNode(projectNodePo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SdmResponse.success(realTopProjectNodeList.stream().flatMap(item -> item.getChildren().stream().filter(Objects::nonNull)).toList());
|
List<NodeAllBase> nodeAllBaseList = realTopProjectNodeList.stream().flatMap(item -> item.getChildren().stream().filter(Objects::nonNull)).collect(Collectors.toList());
|
||||||
|
return SdmResponse.success(filterNodesWithTaskChildren(nodeAllBaseList));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤节点列表:仅保留任意层级children包含nodeType=task的节点
|
||||||
|
* @param nodeList 原始节点列表
|
||||||
|
* @return 过滤后的节点列表
|
||||||
|
*/
|
||||||
|
public static List<NodeAllBase> filterNodesWithTaskChildren(List<NodeAllBase> nodeList) {
|
||||||
|
if (nodeList == null || nodeList.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 仅保留包含task子节点的节点
|
||||||
|
return nodeList.stream()
|
||||||
|
.filter(SimulationRunServiceImpl::hasTaskNodeInChildren)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归判断:当前节点的任意层级children中是否存在nodeType=task的节点
|
||||||
|
* @param node 待判断的节点
|
||||||
|
* @return true=存在,false=不存在
|
||||||
|
*/
|
||||||
|
private static boolean hasTaskNodeInChildren(NodeAllBase node) {
|
||||||
|
// 边界条件:节点为空 或 子节点为空 → 直接返回false
|
||||||
|
if (node == null || node.getChildren() == null || node.getChildren().isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 遍历当前节点的直接子节点
|
||||||
|
for (NodeAllBase child : node.getChildren()) {
|
||||||
|
// 1. 当前子节点的type是task → 直接返回true
|
||||||
|
if ("task".equals(child.getNodeType())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// 2. 递归检查当前子节点的子节点 → 如果存在task,返回true
|
||||||
|
if (hasTaskNodeInChildren(child)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 所有层级都没有task节点 → 返回false
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sortWorkspaceNode(ProjectNodePo projectNodePo) {
|
private void sortWorkspaceNode(ProjectNodePo projectNodePo) {
|
||||||
|
|||||||
Reference in New Issue
Block a user