feat: [BPM 工作流] 并行分支使用包容网关实现
This commit is contained in:
@@ -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")
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -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 @jason:setName
|
// TODO @jason:setName
|
||||||
|
|
||||||
// 并行聚合网关由程序创建,前端不需要传入
|
// 合并网关 由程序创建,前端不需要传入
|
||||||
ParallelGateway joinParallelGateway = new ParallelGateway();
|
InclusiveGateway joinParallelGateway = new InclusiveGateway();
|
||||||
joinParallelGateway.setId(buildGatewayJoinId(node.getId()));
|
joinParallelGateway.setId(buildGatewayJoinId(node.getId()));
|
||||||
// TODO @jason:setName
|
// TODO @jason:setName
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user