Ver Fonte

仿钉钉流程设计-并行网关的实现

jason há 1 ano atrás
pai
commit
df936deeca

+ 5 - 2
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmSimpleModelNodeType.java

@@ -19,10 +19,12 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable {
 
     // TODO @jaosn:-1、0、1、4、-2 是前端已经定义好的么?感觉未来可以考虑搞成和 BPMN 尽量一致的单词哈;类似 usertask 用户审批;
     START_EVENT_NODE(0, "开始节点"),
-    APPROVE_USER_NODE (1, "审批人节点"),
+    APPROVE_USER_NODE(1, "审批人节点"),
     // 抄送人节点、对应 BPMN 的 ScriptTask. 使用ScriptTask 原因。好像 ServiceTask 自定义属性不能写入 XML
     SCRIPT_TASK_NODE(2, "抄送人节点"),
     EXCLUSIVE_GATEWAY_NODE(4, "排他网关"),
+    PARALLEL_GATEWAY_FORK_NODE(5, "并行网关分叉节点"),
+    PARALLEL_GATEWAY_JOIN_NODE(6, "并行网关聚合节点"),
     END_EVENT_NODE(-2, "结束节点");
 
     public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BpmSimpleModelNodeType::getType).toArray();
@@ -32,7 +34,8 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable {
 
     public static boolean isGatewayNode(Integer type) {
         // TODO 后续增加并行网关的支持
-        return Objects.equals(EXCLUSIVE_GATEWAY_NODE.getType(), type);
+        return Objects.equals(EXCLUSIVE_GATEWAY_NODE.getType(), type)
+                || Objects.equals(PARALLEL_GATEWAY_FORK_NODE.getType(), type);
     }
 
     public static BpmSimpleModelNodeType valueOf(Integer type) {

+ 13 - 1
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java

@@ -385,12 +385,14 @@ public class BpmnModelUtils {
         switch (nodeType) {
             case START_EVENT_NODE:
             case APPROVE_USER_NODE:
-            case SCRIPT_TASK_NODE: {
+            case SCRIPT_TASK_NODE:
+            case PARALLEL_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: {
                 String gateWayEndId = (childNode == null || childNode.getId() == null) ? BpmnModelConstants.END_EVENT_ID : childNode.getId();
                 List<BpmSimpleModelNodeVO> conditionNodes = node.getConditionNodes();
@@ -449,6 +451,10 @@ public class BpmnModelUtils {
             case EXCLUSIVE_GATEWAY_NODE:
                 addBpmnExclusiveGatewayNode(mainProcess, simpleModelNode);
                 break;
+            case PARALLEL_GATEWAY_FORK_NODE:
+            case PARALLEL_GATEWAY_JOIN_NODE:
+                addBpmnParallelGatewayNode(mainProcess, simpleModelNode);
+                break;
             default: {
                 // TODO 其它节点类型的实现
             }
@@ -472,6 +478,12 @@ public class BpmnModelUtils {
         }
     }
 
+    private static void addBpmnParallelGatewayNode(Process mainProcess, BpmSimpleModelNodeVO node) {
+        ParallelGateway parallelGateway = new ParallelGateway();
+        parallelGateway.setId(node.getId());
+        mainProcess.addFlowElement(parallelGateway);
+    }
+
     private static void addBpmnScriptTaSskNode(Process mainProcess, BpmSimpleModelNodeVO node) {
         ScriptTask scriptTask = new ScriptTask();
         scriptTask.setId(node.getId());