|
|
@ -414,7 +414,7 @@ public class DagHelper { |
|
|
|
return conditionTaskList; |
|
|
|
return conditionTaskList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static List<Long> skipTaskNode4Switch(TaskNode taskNode, |
|
|
|
public static List<Long> skipTaskNode4Switch(TaskNode taskNode, |
|
|
|
Map<Long, TaskNode> skipTaskNodeList, |
|
|
|
Map<Long, TaskNode> skipTaskNodeList, |
|
|
|
Map<Long, TaskInstance> completeTaskList, |
|
|
|
Map<Long, TaskInstance> completeTaskList, |
|
|
|
DAG<Long, TaskNode, TaskNodeRelation> dag) { |
|
|
|
DAG<Long, TaskNode, TaskNodeRelation> dag) { |
|
|
@ -424,19 +424,62 @@ public class DagHelper { |
|
|
|
int resultConditionLocation = switchParameters.getResultConditionLocation(); |
|
|
|
int resultConditionLocation = switchParameters.getResultConditionLocation(); |
|
|
|
List<SwitchResultVo> conditionResultVoList = switchParameters.getDependTaskList(); |
|
|
|
List<SwitchResultVo> conditionResultVoList = switchParameters.getDependTaskList(); |
|
|
|
List<Long> switchTaskList = conditionResultVoList.get(resultConditionLocation).getNextNode(); |
|
|
|
List<Long> switchTaskList = conditionResultVoList.get(resultConditionLocation).getNextNode(); |
|
|
|
|
|
|
|
Set<Long> switchNeedWorkCodes = new HashSet<>(); |
|
|
|
if (CollectionUtils.isEmpty(switchTaskList)) { |
|
|
|
if (CollectionUtils.isEmpty(switchTaskList)) { |
|
|
|
switchTaskList = new ArrayList<>(); |
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// get all downstream nodes of the branch that the switch node needs to execute
|
|
|
|
|
|
|
|
for (Long switchTaskCode : switchTaskList) { |
|
|
|
|
|
|
|
getSwitchNeedWorkCodes(switchTaskCode, dag, switchNeedWorkCodes); |
|
|
|
} |
|
|
|
} |
|
|
|
// conditionResultVoList.remove(resultConditionLocation);
|
|
|
|
// conditionResultVoList.remove(resultConditionLocation);
|
|
|
|
for (SwitchResultVo info : conditionResultVoList) { |
|
|
|
for (SwitchResultVo info : conditionResultVoList) { |
|
|
|
if (CollectionUtils.isEmpty(info.getNextNode())) { |
|
|
|
if (CollectionUtils.isEmpty(info.getNextNode())) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
setTaskNodeSkip(info.getNextNode().get(0), dag, completeTaskList, skipTaskNodeList); |
|
|
|
for (Long nextNode : info.getNextNode()) { |
|
|
|
|
|
|
|
setSwitchTaskNodeSkip(nextNode, dag, completeTaskList, skipTaskNodeList, |
|
|
|
|
|
|
|
switchNeedWorkCodes); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return switchTaskList; |
|
|
|
return switchTaskList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* get all downstream nodes of the branch that the switch node needs to execute |
|
|
|
|
|
|
|
* @param taskCode |
|
|
|
|
|
|
|
* @param dag |
|
|
|
|
|
|
|
* @param switchNeedWorkCodes |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static void getSwitchNeedWorkCodes(Long taskCode, DAG<Long, TaskNode, TaskNodeRelation> dag, |
|
|
|
|
|
|
|
Set<Long> switchNeedWorkCodes) { |
|
|
|
|
|
|
|
switchNeedWorkCodes.add(taskCode); |
|
|
|
|
|
|
|
Set<Long> subsequentNodes = dag.getSubsequentNodes(taskCode); |
|
|
|
|
|
|
|
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(subsequentNodes)) { |
|
|
|
|
|
|
|
for (Long subCode : subsequentNodes) { |
|
|
|
|
|
|
|
getSwitchNeedWorkCodes(subCode, dag, switchNeedWorkCodes); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void setSwitchTaskNodeSkip(Long skipNodeCode, |
|
|
|
|
|
|
|
DAG<Long, TaskNode, TaskNodeRelation> dag, |
|
|
|
|
|
|
|
Map<Long, TaskInstance> completeTaskList, |
|
|
|
|
|
|
|
Map<Long, TaskNode> skipTaskNodeList, |
|
|
|
|
|
|
|
Set<Long> switchNeedWorkCodes) { |
|
|
|
|
|
|
|
// ignore when the node that needs to be skipped exists on the branch that the switch type node needs to execute
|
|
|
|
|
|
|
|
if (!dag.containsNode(skipNodeCode) || switchNeedWorkCodes.contains(skipNodeCode)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
skipTaskNodeList.putIfAbsent(skipNodeCode, dag.getNode(skipNodeCode)); |
|
|
|
|
|
|
|
Collection<Long> postNodeList = dag.getSubsequentNodes(skipNodeCode); |
|
|
|
|
|
|
|
for (Long post : postNodeList) { |
|
|
|
|
|
|
|
TaskNode postNode = dag.getNode(post); |
|
|
|
|
|
|
|
if (isTaskNodeNeedSkip(postNode, skipTaskNodeList)) { |
|
|
|
|
|
|
|
setTaskNodeSkip(post, dag, completeTaskList, skipTaskNodeList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
/** |
|
|
|
/** |
|
|
|
* set task node and the post nodes skip flag |
|
|
|
* set task node and the post nodes skip flag |
|
|
|
*/ |
|
|
|
*/ |
|
|
|