From 98998cff6ff7198ead930e7f17bb6782252a926c Mon Sep 17 00:00:00 2001 From: jason <2667446@qq.com> Date: Sun, 7 Apr 2024 22:20:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BF=E9=92=89=E9=92=89=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1-=E5=8C=85=E5=AE=B9=E7=BD=91=E5=85=B3?= =?UTF-8?q?=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../definition/BpmSimpleModelNodeType.java | 7 +++--- .../flowable/core/util/BpmnModelUtils.java | 25 ++++++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmSimpleModelNodeType.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmSimpleModelNodeType.java index af8ce3d6f..bfaad44c9 100644 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmSimpleModelNodeType.java +++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmSimpleModelNodeType.java @@ -25,6 +25,8 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable { EXCLUSIVE_GATEWAY_NODE(4, "排他网关"), PARALLEL_GATEWAY_FORK_NODE(5, "并行网关分叉节点"), PARALLEL_GATEWAY_JOIN_NODE(6, "并行网关聚合节点"), + INCLUSIVE_GATEWAY_FORK_NODE(7, "包容网关分叉节点"), + INCLUSIVE_GATEWAY_JOIN_NODE(8, "包容网关聚合节点"), END_EVENT_NODE(-2, "结束节点"); public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BpmSimpleModelNodeType::getType).toArray(); @@ -33,9 +35,8 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable { private final String name; public static boolean isGatewayNode(Integer type) { - // TODO 后续增加并行网关的支持 - return Objects.equals(EXCLUSIVE_GATEWAY_NODE.getType(), type) - || Objects.equals(PARALLEL_GATEWAY_FORK_NODE.getType(), type); + return Objects.equals(EXCLUSIVE_GATEWAY_NODE.getType(), type) || Objects.equals(PARALLEL_GATEWAY_FORK_NODE.getType(), type) + || Objects.equals(INCLUSIVE_GATEWAY_FORK_NODE.getType(), type) ; } public static BpmSimpleModelNodeType valueOf(Integer type) { diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java index c68908acf..47a6583d3 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java @@ -386,14 +386,16 @@ public class BpmnModelUtils { case START_EVENT_NODE: case APPROVE_USER_NODE: case SCRIPT_TASK_NODE: - case PARALLEL_GATEWAY_JOIN_NODE:{ + case PARALLEL_GATEWAY_JOIN_NODE: + case INCLUSIVE_GATEWAY_JOIN_NODE:{ addBpmnSequenceFlowElement(mainProcess, node.getId(), childNode.getId(), null, null); // 递归调用后续节点 addBpmnSequenceFlow(mainProcess, childNode, endId); break; } case PARALLEL_GATEWAY_FORK_NODE: - case EXCLUSIVE_GATEWAY_NODE: { + case EXCLUSIVE_GATEWAY_NODE: + case INCLUSIVE_GATEWAY_FORK_NODE:{ String gateWayEndId = (childNode == null || childNode.getId() == null) ? BpmnModelConstants.END_EVENT_ID : childNode.getId(); List conditionNodes = node.getConditionNodes(); Assert.notEmpty(conditionNodes, "网关节点的条件节点不能为空"); @@ -455,6 +457,12 @@ public class BpmnModelUtils { case PARALLEL_GATEWAY_JOIN_NODE: addBpmnParallelGatewayNode(mainProcess, simpleModelNode); break; + case INCLUSIVE_GATEWAY_FORK_NODE: + addBpmnInclusiveGatewayNode(mainProcess, simpleModelNode, Boolean.TRUE); + break; + case INCLUSIVE_GATEWAY_JOIN_NODE: + addBpmnInclusiveGatewayNode(mainProcess, simpleModelNode, Boolean.FALSE); + break; default: { // TODO 其它节点类型的实现 } @@ -507,11 +515,22 @@ public class BpmnModelUtils { Assert.notEmpty(node.getConditionNodes(), "网关节点的条件节点不能为空"); ExclusiveGateway exclusiveGateway = new ExclusiveGateway(); exclusiveGateway.setId(node.getId()); - // 条件节点的最后一个条件为 网关的 default sequence flow + // 网关的最后一个条件为 网关的 default sequence flow exclusiveGateway.setDefaultFlow(String.format("%s_SequenceFlow_%d", node.getId(), node.getConditionNodes().size())); mainProcess.addFlowElement(exclusiveGateway); } + private static void addBpmnInclusiveGatewayNode(Process mainProcess, BpmSimpleModelNodeVO node, Boolean isFork) { + InclusiveGateway inclusiveGateway = new InclusiveGateway(); + inclusiveGateway.setId(node.getId()); + if (isFork) { + Assert.notEmpty(node.getConditionNodes(), "网关节点的条件节点不能为空"); + // 网关的最后一个条件为 网关的 default sequence flow + inclusiveGateway.setDefaultFlow(String.format("%s_SequenceFlow_%d", node.getId(), node.getConditionNodes().size())); + } + mainProcess.addFlowElement(inclusiveGateway); + } + private static void addBpmnEndEventNode(Process mainProcess) { EndEvent endEvent = new EndEvent(); endEvent.setId(BpmnModelConstants.END_EVENT_ID);