|
@@ -809,8 +809,7 @@ public class BpmnModelUtils {
|
|
|
if (currentElement instanceof ExclusiveGateway) {
|
|
|
// 查找满足条件的 SequenceFlow 路径
|
|
|
Gateway gateway = (Gateway) currentElement;
|
|
|
- // TODO @小北:当一个网关节点下存在多个满足的并行节点时,只查询一个节点流程流转会存在问题,需要优化,
|
|
|
- // TODO 具体见issue:https://github.com/YunaiV/ruoyi-vue-pro/issues/761
|
|
|
+ // TODO @小北:当一个网关节点下存在多个满足的并行节点时,只查询一个节点流程流转会存在问题。需要优化,具体见issue:https://github.com/YunaiV/ruoyi-vue-pro/issues/761
|
|
|
SequenceFlow matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
|
|
|
flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
|
|
|
&& (evalConditionExpress(variables, flow.getConditionExpression())));
|
|
@@ -866,27 +865,27 @@ public class BpmnModelUtils {
|
|
|
* @param bpmnModel BPMN模型
|
|
|
* @param variables 流程变量
|
|
|
*/
|
|
|
+ @SuppressWarnings("PatternVariableCanBeUsed")
|
|
|
public static List<FlowNode> getNextFlowNodes(FlowElement currentElement, BpmnModel bpmnModel,
|
|
|
Map<String, Object> variables){
|
|
|
- // 下一个执行的流程节点集合
|
|
|
- List<FlowNode> nextFlowNodes = new ArrayList<>();
|
|
|
- // 当前执行节点的基本属性
|
|
|
- FlowNode currentNode = (FlowNode) currentElement;
|
|
|
- // 获取当前节点的关联节点
|
|
|
- List<SequenceFlow> outgoingFlows = currentNode.getOutgoingFlows();
|
|
|
- if (CollUtil.isEmpty(outgoingFlows)){
|
|
|
+ List<FlowNode> nextFlowNodes = new ArrayList<>(); // 下一个执行的流程节点集合
|
|
|
+ FlowNode currentNode = (FlowNode) currentElement; // 当前执行节点的基本属性
|
|
|
+ List<SequenceFlow> outgoingFlows = currentNode.getOutgoingFlows(); // 当前节点的关联节点
|
|
|
+ if (CollUtil.isEmpty(outgoingFlows)) {
|
|
|
log.warn("[getNextFlowNodes][当前节点({}) 的 outgoingFlows 为空]", currentNode.getId());
|
|
|
return nextFlowNodes;
|
|
|
}
|
|
|
+
|
|
|
// 遍历每个出口流
|
|
|
for (SequenceFlow outgoingFlow : outgoingFlows) {
|
|
|
// 获取目标节点的基本属性
|
|
|
FlowElement targetElement = bpmnModel.getFlowElement(outgoingFlow.getTargetRef());
|
|
|
- if (targetElement == null){
|
|
|
+ if (targetElement == null) {
|
|
|
continue;
|
|
|
}
|
|
|
- if (targetElement instanceof Gateway gateway) {
|
|
|
- // 处理不同类型的网关
|
|
|
+ // 情况一:处理不同类型的网关
|
|
|
+ if (targetElement instanceof Gateway) {
|
|
|
+ Gateway gateway = (Gateway) targetElement;
|
|
|
if (gateway instanceof ExclusiveGateway) {
|
|
|
handleExclusiveGateway(gateway, bpmnModel, variables, nextFlowNodes);
|
|
|
} else if (gateway instanceof InclusiveGateway) {
|
|
@@ -895,7 +894,7 @@ public class BpmnModelUtils {
|
|
|
handleParallelGateway(gateway, bpmnModel, variables, nextFlowNodes);
|
|
|
}
|
|
|
} else {
|
|
|
- // 如果不是网关,直接添加到下一个节点列表
|
|
|
+ // 情况二:如果不是网关,直接添加到下一个节点列表
|
|
|
nextFlowNodes.add((FlowNode) targetElement);
|
|
|
}
|
|
|
}
|
|
@@ -903,15 +902,17 @@ public class BpmnModelUtils {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 处理排他网关
|
|
|
+ * 处理排它网关
|
|
|
*
|
|
|
* @param gateway 排他网关
|
|
|
* @param bpmnModel BPMN模型
|
|
|
* @param variables 流程变量
|
|
|
* @param nextFlowNodes 下一个执行的流程节点集合
|
|
|
*/
|
|
|
- private static void handleExclusiveGateway(Gateway gateway, BpmnModel bpmnModel, Map<String, Object> variables, List<FlowNode> nextFlowNodes) {
|
|
|
- // TODO @小北: 这里和simulateNextFlowElements中有重复代码,是否重构??每个网关节点拆分出方法应该比较合理化,@芋道
|
|
|
+ private static void handleExclusiveGateway(Gateway gateway, BpmnModel bpmnModel,
|
|
|
+ Map<String, Object> variables, List<FlowNode> nextFlowNodes) {
|
|
|
+ // TODO @小北: 这里和 simulateNextFlowElements 中有重复代码,是否重构??每个网关节点拆分出方法应该比较合理化,@芋艿
|
|
|
+ // TODO @小北:ok,把 simulateNextFlowElements 里面处理网关的,复用这个方法,可以么?
|
|
|
SequenceFlow matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
|
|
|
flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
|
|
|
&& (evalConditionExpress(variables, flow.getConditionExpression())));
|
|
@@ -940,7 +941,8 @@ public class BpmnModelUtils {
|
|
|
* @param variables 流程变量
|
|
|
* @param nextFlowNodes 下一个执行的流程节点集合
|
|
|
*/
|
|
|
- private static void handleInclusiveGateway(Gateway gateway, BpmnModel bpmnModel, Map<String, Object> variables, List<FlowNode> nextFlowNodes) {
|
|
|
+ private static void handleInclusiveGateway(Gateway gateway, BpmnModel bpmnModel,
|
|
|
+ Map<String, Object> variables, List<FlowNode> nextFlowNodes) {
|
|
|
Collection<SequenceFlow> matchSequenceFlows = CollUtil.filterNew(gateway.getOutgoingFlows(),
|
|
|
flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
|
|
|
&& evalConditionExpress(variables, flow.getConditionExpression()));
|
|
@@ -960,6 +962,7 @@ public class BpmnModelUtils {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 处理并行网关
|
|
|
*
|
|
@@ -968,7 +971,8 @@ public class BpmnModelUtils {
|
|
|
* @param variables 流程变量
|
|
|
* @param nextFlowNodes 下一个执行的流程节点集合
|
|
|
*/
|
|
|
- private static void handleParallelGateway(Gateway gateway, BpmnModel bpmnModel, Map<String, Object> variables, List<FlowNode> nextFlowNodes) {
|
|
|
+ private static void handleParallelGateway(Gateway gateway, BpmnModel bpmnModel,
|
|
|
+ Map<String, Object> variables, List<FlowNode> nextFlowNodes) {
|
|
|
// 并行网关,遍历所有出口路径,获取目标节点
|
|
|
gateway.getOutgoingFlows().forEach(flow -> {
|
|
|
FlowElement targetElement = bpmnModel.getFlowElement(flow.getTargetRef());
|