1、任务树的工位根据工位号排序
This commit is contained in:
@@ -601,9 +601,54 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
|
||||
for (ProjectNodePo projectNodePo : realTopProjectNodeList) {
|
||||
summaryWorkspaceNode(projectNodePo,projectNodePo.getChildren());
|
||||
}
|
||||
// 对工位进行排序,-M工位顺序排第一个
|
||||
for (ProjectNodePo projectNodePo : realTopProjectNodeList) {
|
||||
sortWorkspaceNode(projectNodePo);
|
||||
}
|
||||
return SdmResponse.success(realTopProjectNodeList.stream().flatMap(item -> item.getChildren().stream().filter(Objects::nonNull)).toList());
|
||||
}
|
||||
|
||||
private void sortWorkspaceNode(ProjectNodePo projectNodePo) {
|
||||
List<NodeAllBase> children = projectNodePo.getChildren();
|
||||
if (CollectionUtils.isEmpty(children)) {
|
||||
return;
|
||||
}
|
||||
List<NodeAllBase> workspaceNodeList = children.stream().filter(node -> NodeTypeEnum.WORKSPACE.getValue().equals(node.getNodeType())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(workspaceNodeList)) {
|
||||
return;
|
||||
}
|
||||
// 对工位进行排序,-M工位顺序排第一个
|
||||
workspaceNodeList = workspaceNodeList.stream().sorted(Comparator.comparing(NodeAllBase::getNodeCode)).collect(Collectors.toList());
|
||||
NodeAllBase specialWorkspaceNode = workspaceNodeList.stream().filter(workspaceNode -> workspaceNode.getNodeCode().contains("-M")).findFirst().orElse(null);
|
||||
log.info("specialWorkspaceNode为:{}",specialWorkspaceNode);
|
||||
if (specialWorkspaceNode != null) {
|
||||
moveTargetToFirst(workspaceNodeList,specialWorkspaceNode.getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
public static void moveTargetToFirst(List<NodeAllBase> nodeList, String targetId) {
|
||||
// 空值判断
|
||||
if (nodeList == null || nodeList.isEmpty() || targetId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 遍历找到目标对象
|
||||
NodeAllBase targetNode = null;
|
||||
for (NodeAllBase node : nodeList) {
|
||||
if (targetId.equals(node.getUuid())) {
|
||||
targetNode = node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果找到目标对象,先移除再添加到首位
|
||||
if (targetNode != null) {
|
||||
nodeList.remove(targetNode);
|
||||
nodeList.add(0, targetNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void summaryWorkspaceNode(ProjectNodePo projectNodePo,List<NodeAllBase> children) {
|
||||
if (!NodeTypeEnum.WORKSPACE.getValue().equals(projectNodePo.getNodeType())) {
|
||||
List<NodeAllBase> fChildren = projectNodePo.getChildren();
|
||||
|
||||
@@ -601,9 +601,53 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
for (ProjectNodePo projectNodePo : realTopProjectNodeList) {
|
||||
generateTaskTree(projectNodePo, taskTreeNodeList, taskTreeTaskList, taskTreeTagMap, firstNodeTag, lastNodeTag, taskTreeNodeTypeTagMap, taskTreeRunList);
|
||||
}
|
||||
// 对工位进行排序,-M工位顺序排第一个
|
||||
for (ProjectNodePo projectNodePo : realTopProjectNodeList) {
|
||||
sortWorkspaceNode(projectNodePo);
|
||||
}
|
||||
return SdmResponse.success(realTopProjectNodeList.stream().flatMap(item -> item.getChildren().stream().filter(Objects::nonNull)).toList());
|
||||
}
|
||||
|
||||
private void sortWorkspaceNode(ProjectNodePo projectNodePo) {
|
||||
List<NodeAllBase> children = projectNodePo.getChildren();
|
||||
if (CollectionUtils.isEmpty(children)) {
|
||||
return;
|
||||
}
|
||||
List<NodeAllBase> workspaceNodeList = children.stream().filter(node -> NodeTypeEnum.WORKSPACE.getValue().equals(node.getNodeType())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(workspaceNodeList)) {
|
||||
return;
|
||||
}
|
||||
// 对工位进行排序,-M工位顺序排第一个
|
||||
workspaceNodeList = workspaceNodeList.stream().sorted(Comparator.comparing(NodeAllBase::getNodeCode)).collect(Collectors.toList());
|
||||
NodeAllBase specialWorkspaceNode = workspaceNodeList.stream().filter(workspaceNode -> workspaceNode.getNodeCode().contains("-M")).findFirst().orElse(null);
|
||||
log.info("specialWorkspaceNode为:{}",specialWorkspaceNode);
|
||||
if (specialWorkspaceNode != null) {
|
||||
moveTargetToFirst(workspaceNodeList,specialWorkspaceNode.getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
public static void moveTargetToFirst(List<NodeAllBase> nodeList, String targetId) {
|
||||
// 空值判断
|
||||
if (nodeList == null || nodeList.isEmpty() || targetId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 遍历找到目标对象
|
||||
NodeAllBase targetNode = null;
|
||||
for (NodeAllBase node : nodeList) {
|
||||
if (targetId.equals(node.getUuid())) {
|
||||
targetNode = node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果找到目标对象,先移除再添加到首位
|
||||
if (targetNode != null) {
|
||||
nodeList.remove(targetNode);
|
||||
nodeList.add(0, targetNode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SdmResponse addTaskRun(SpdmAddTaskRunReq req) {
|
||||
|
||||
Reference in New Issue
Block a user