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

This commit is contained in:
jason 2024-04-07 15:37:25 +08:00
parent 32809c3edb
commit df936deeca
2 changed files with 18 additions and 3 deletions

View File

@ -19,10 +19,12 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable {
// TODO @jaosn-1014-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) {

View File

@ -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());