feat: [BPM 工作流] 并行分支使用包容网关实现

This commit is contained in:
jason
2025-07-24 22:23:15 +08:00
parent a4244ab999
commit 97cec2897b
2 changed files with 22 additions and 12 deletions

View File

@@ -35,7 +35,7 @@ public enum BpmSimpleModelNodeTypeEnum implements ArrayValuable<Integer> {
// 50 ~ 条件分支 // 50 ~ 条件分支
CONDITION_NODE(50, "条件", "sequenceFlow"), // 用于构建流转条件的表达式 CONDITION_NODE(50, "条件", "sequenceFlow"), // 用于构建流转条件的表达式
CONDITION_BRANCH_NODE(51, "条件分支", "exclusiveGateway"), CONDITION_BRANCH_NODE(51, "条件分支", "exclusiveGateway"),
PARALLEL_BRANCH_NODE(52, "并行分支", "parallelGateway"), PARALLEL_BRANCH_NODE(52, "并行分支", "inclusiveGateway"), // 并行分支使用包容网关实现,条件表达式结果设置为 true
INCLUSIVE_BRANCH_NODE(53, "包容分支", "inclusiveGateway"), INCLUSIVE_BRANCH_NODE(53, "包容分支", "inclusiveGateway"),
ROUTER_BRANCH_NODE(54, "路由分支", "exclusiveGateway") ROUTER_BRANCH_NODE(54, "路由分支", "exclusiveGateway")
; ;

View File

@@ -239,13 +239,13 @@ public class SimpleModelUtils {
// 3.1 分支有后续节点。即分支 1: A->B->C->D 的情况 // 3.1 分支有后续节点。即分支 1: A->B->C->D 的情况
if (isValidNode(conditionChildNode)) { if (isValidNode(conditionChildNode)) {
// 3.1.1 建立与后续的节点的连线。例如说,建立 A->B 的连线 // 3.1.1 建立与后续的节点的连线。例如说,建立 A->B 的连线
SequenceFlow sequenceFlow = ConditionNodeConvert.buildSequenceFlow(node.getId(), conditionChildNode.getId(), item); SequenceFlow sequenceFlow = ConditionNodeConvert.buildSequenceFlow(node.getId(), conditionChildNode.getId(), nodeType, item);
process.addFlowElement(sequenceFlow); process.addFlowElement(sequenceFlow);
// 3.1.2 递归调用后续节点连线。例如说,建立 B->C->D 的连线 // 3.1.2 递归调用后续节点连线。例如说,建立 B->C->D 的连线
traverseNodeToBuildSequenceFlow(process, conditionChildNode, branchEndNodeId); traverseNodeToBuildSequenceFlow(process, conditionChildNode, branchEndNodeId);
} else { } else {
// 3.2 分支没有后续节点。例如说,建立 A->D 的连线 // 3.2 分支没有后续节点。例如说,建立 A->D 的连线
SequenceFlow sequenceFlow = ConditionNodeConvert.buildSequenceFlow(node.getId(), branchEndNodeId, item); SequenceFlow sequenceFlow = ConditionNodeConvert.buildSequenceFlow(node.getId(), branchEndNodeId, nodeType, item);
process.addFlowElement(sequenceFlow); process.addFlowElement(sequenceFlow);
} }
} }
@@ -591,17 +591,22 @@ public class SimpleModelUtils {
private static class ParallelBranchNodeConvert implements NodeConvert { private static class ParallelBranchNodeConvert implements NodeConvert {
/**
* 并行分支使用包容网关。需要设置所有出口条件表达式的值为 true.
* 参见: {@link ConditionNodeConvert#buildSequenceFlow}
*/
@Override @Override
public List<ParallelGateway> convertList(BpmSimpleModelNodeVO node) { public List<InclusiveGateway> convertList(BpmSimpleModelNodeVO node) {
ParallelGateway parallelGateway = new ParallelGateway();
parallelGateway.setId(node.getId()); InclusiveGateway inclusiveGateway = new InclusiveGateway();
inclusiveGateway.setId(node.getId());
// TODO @jasonsetName // TODO @jasonsetName
// 并行聚合网关由程序创建,前端不需要传入 // 合网关 由程序创建,前端不需要传入
ParallelGateway joinParallelGateway = new ParallelGateway(); InclusiveGateway joinParallelGateway = new InclusiveGateway();
joinParallelGateway.setId(buildGatewayJoinId(node.getId())); joinParallelGateway.setId(buildGatewayJoinId(node.getId()));
// TODO @jasonsetName // TODO @jasonsetName
return CollUtil.newArrayList(parallelGateway, joinParallelGateway); return CollUtil.newArrayList(inclusiveGateway, joinParallelGateway);
} }
@Override @Override
@@ -652,8 +657,14 @@ public class SimpleModelUtils {
} }
public static SequenceFlow buildSequenceFlow(String sourceId, String targetId, public static SequenceFlow buildSequenceFlow(String sourceId, String targetId,
BpmSimpleModelNodeVO node) { BpmSimpleModelNodeTypeEnum nodeType, BpmSimpleModelNodeVO node) {
String conditionExpression = buildConditionExpression(node.getConditionSetting()); String conditionExpression;
// 并行分支,使用包容网关实现,强制设置条件表达式为 true
if (BpmSimpleModelNodeTypeEnum.PARALLEL_BRANCH_NODE == nodeType) {
conditionExpression ="${true}";
} else {
conditionExpression = buildConditionExpression(node.getConditionSetting());
}
return buildBpmnSequenceFlow(sourceId, targetId, node.getId(), node.getName(), conditionExpression); return buildBpmnSequenceFlow(sourceId, targetId, node.getId(), node.getName(), conditionExpression);
} }
} }
@@ -662,7 +673,6 @@ public class SimpleModelUtils {
* 构造条件表达式 * 构造条件表达式
*/ */
public static String buildConditionExpression(BpmSimpleModelNodeVO.ConditionSetting conditionSetting) { public static String buildConditionExpression(BpmSimpleModelNodeVO.ConditionSetting conditionSetting) {
// 并行网关不需要设置条件
if (conditionSetting == null) { if (conditionSetting == null) {
return null; return null;
} }