Commit 98998cff6ff7198ead930e7f17bb6782252a926c

Authored by jason
1 parent df936dee

仿钉钉流程设计-包容网关的实现

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 { @@ -25,6 +25,8 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable {
25 EXCLUSIVE_GATEWAY_NODE(4, "排他网关"), 25 EXCLUSIVE_GATEWAY_NODE(4, "排他网关"),
26 PARALLEL_GATEWAY_FORK_NODE(5, "并行网关分叉节点"), 26 PARALLEL_GATEWAY_FORK_NODE(5, "并行网关分叉节点"),
27 PARALLEL_GATEWAY_JOIN_NODE(6, "并行网关聚合节点"), 27 PARALLEL_GATEWAY_JOIN_NODE(6, "并行网关聚合节点"),
  28 + INCLUSIVE_GATEWAY_FORK_NODE(7, "包容网关分叉节点"),
  29 + INCLUSIVE_GATEWAY_JOIN_NODE(8, "包容网关聚合节点"),
28 END_EVENT_NODE(-2, "结束节点"); 30 END_EVENT_NODE(-2, "结束节点");
29 31
30 public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BpmSimpleModelNodeType::getType).toArray(); 32 public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BpmSimpleModelNodeType::getType).toArray();
@@ -33,9 +35,8 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable { @@ -33,9 +35,8 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable {
33 private final String name; 35 private final String name;
34 36
35 public static boolean isGatewayNode(Integer type) { 37 public static boolean isGatewayNode(Integer type) {
36 - // TODO 后续增加并行网关的支持  
37 - return Objects.equals(EXCLUSIVE_GATEWAY_NODE.getType(), type)  
38 - || Objects.equals(PARALLEL_GATEWAY_FORK_NODE.getType(), type); 38 + return Objects.equals(EXCLUSIVE_GATEWAY_NODE.getType(), type) || Objects.equals(PARALLEL_GATEWAY_FORK_NODE.getType(), type)
  39 + || Objects.equals(INCLUSIVE_GATEWAY_FORK_NODE.getType(), type) ;
39 } 40 }
40 41
41 public static BpmSimpleModelNodeType valueOf(Integer type) { 42 public static BpmSimpleModelNodeType valueOf(Integer type) {
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 { @@ -386,14 +386,16 @@ public class BpmnModelUtils {
386 case START_EVENT_NODE: 386 case START_EVENT_NODE:
387 case APPROVE_USER_NODE: 387 case APPROVE_USER_NODE:
388 case SCRIPT_TASK_NODE: 388 case SCRIPT_TASK_NODE:
389 - case PARALLEL_GATEWAY_JOIN_NODE:{ 389 + case PARALLEL_GATEWAY_JOIN_NODE:
  390 + case INCLUSIVE_GATEWAY_JOIN_NODE:{
390 addBpmnSequenceFlowElement(mainProcess, node.getId(), childNode.getId(), null, null); 391 addBpmnSequenceFlowElement(mainProcess, node.getId(), childNode.getId(), null, null);
391 // 递归调用后续节点 392 // 递归调用后续节点
392 addBpmnSequenceFlow(mainProcess, childNode, endId); 393 addBpmnSequenceFlow(mainProcess, childNode, endId);
393 break; 394 break;
394 } 395 }
395 case PARALLEL_GATEWAY_FORK_NODE: 396 case PARALLEL_GATEWAY_FORK_NODE:
396 - case EXCLUSIVE_GATEWAY_NODE: { 397 + case EXCLUSIVE_GATEWAY_NODE:
  398 + case INCLUSIVE_GATEWAY_FORK_NODE:{
397 String gateWayEndId = (childNode == null || childNode.getId() == null) ? BpmnModelConstants.END_EVENT_ID : childNode.getId(); 399 String gateWayEndId = (childNode == null || childNode.getId() == null) ? BpmnModelConstants.END_EVENT_ID : childNode.getId();
398 List<BpmSimpleModelNodeVO> conditionNodes = node.getConditionNodes(); 400 List<BpmSimpleModelNodeVO> conditionNodes = node.getConditionNodes();
399 Assert.notEmpty(conditionNodes, "网关节点的条件节点不能为空"); 401 Assert.notEmpty(conditionNodes, "网关节点的条件节点不能为空");
@@ -455,6 +457,12 @@ public class BpmnModelUtils { @@ -455,6 +457,12 @@ public class BpmnModelUtils {
455 case PARALLEL_GATEWAY_JOIN_NODE: 457 case PARALLEL_GATEWAY_JOIN_NODE:
456 addBpmnParallelGatewayNode(mainProcess, simpleModelNode); 458 addBpmnParallelGatewayNode(mainProcess, simpleModelNode);
457 break; 459 break;
  460 + case INCLUSIVE_GATEWAY_FORK_NODE:
  461 + addBpmnInclusiveGatewayNode(mainProcess, simpleModelNode, Boolean.TRUE);
  462 + break;
  463 + case INCLUSIVE_GATEWAY_JOIN_NODE:
  464 + addBpmnInclusiveGatewayNode(mainProcess, simpleModelNode, Boolean.FALSE);
  465 + break;
458 default: { 466 default: {
459 // TODO 其它节点类型的实现 467 // TODO 其它节点类型的实现
460 } 468 }
@@ -507,11 +515,22 @@ public class BpmnModelUtils { @@ -507,11 +515,22 @@ public class BpmnModelUtils {
507 Assert.notEmpty(node.getConditionNodes(), "网关节点的条件节点不能为空"); 515 Assert.notEmpty(node.getConditionNodes(), "网关节点的条件节点不能为空");
508 ExclusiveGateway exclusiveGateway = new ExclusiveGateway(); 516 ExclusiveGateway exclusiveGateway = new ExclusiveGateway();
509 exclusiveGateway.setId(node.getId()); 517 exclusiveGateway.setId(node.getId());
510 - // 条件节点的最后一个条件为 网关的 default sequence flow 518 + // 网关的最后一个条件为 网关的 default sequence flow
511 exclusiveGateway.setDefaultFlow(String.format("%s_SequenceFlow_%d", node.getId(), node.getConditionNodes().size())); 519 exclusiveGateway.setDefaultFlow(String.format("%s_SequenceFlow_%d", node.getId(), node.getConditionNodes().size()));
512 mainProcess.addFlowElement(exclusiveGateway); 520 mainProcess.addFlowElement(exclusiveGateway);
513 } 521 }
514 522
  523 + private static void addBpmnInclusiveGatewayNode(Process mainProcess, BpmSimpleModelNodeVO node, Boolean isFork) {
  524 + InclusiveGateway inclusiveGateway = new InclusiveGateway();
  525 + inclusiveGateway.setId(node.getId());
  526 + if (isFork) {
  527 + Assert.notEmpty(node.getConditionNodes(), "网关节点的条件节点不能为空");
  528 + // 网关的最后一个条件为 网关的 default sequence flow
  529 + inclusiveGateway.setDefaultFlow(String.format("%s_SequenceFlow_%d", node.getId(), node.getConditionNodes().size()));
  530 + }
  531 + mainProcess.addFlowElement(inclusiveGateway);
  532 + }
  533 +
515 private static void addBpmnEndEventNode(Process mainProcess) { 534 private static void addBpmnEndEventNode(Process mainProcess) {
516 EndEvent endEvent = new EndEvent(); 535 EndEvent endEvent = new EndEvent();
517 endEvent.setId(BpmnModelConstants.END_EVENT_ID); 536 endEvent.setId(BpmnModelConstants.END_EVENT_ID);