引言
书接上回,继续三国流程系列教程。 本文主要讲解并行网关。
并行网关允许流程中的多个任务同时执行,从而提高流程的执行效率。
并行网关会忽视序列流上的条件设置。
并行网关分为两部分。
Fork: 用于任务开始
Join:用于任务结束
体验文章demo演示站点: JeecgFlow
需求
假设作为将军的张飞要发动一个出征,填写出兵人数和攻占城市
先左右军师并行审核
再由主公进行最后决断。
BPMN建模
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0h8qtyr" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.10.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.19.0">
<bpmn:process id="Process_1f40ryt" name="出征并行流程" isExecutable="true">
<bpmn:startEvent id="StartEvent_1" camunda:initiator="start">
<bpmn:outgoing>Flow_18wovhb</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_18wovhb" sourceRef="StartEvent_1" targetRef="Activity_0ytoxfo" />
<bpmn:userTask id="Activity_0ytoxfo" name="出征申请" camunda:assignee="${general}">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="number" label="出兵人数" type="long" />
<camunda:formField id="city" label="城市" type="string" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>Flow_18wovhb</bpmn:incoming>
<bpmn:outgoing>Flow_04b290y</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="Flow_04b290y" sourceRef="Activity_0ytoxfo" targetRef="Gateway_0hlq55i" />
<bpmn:parallelGateway id="Gateway_0hlq55i">
<bpmn:incoming>Flow_04b290y</bpmn:incoming>
<bpmn:outgoing>Flow_0iqw5r6</bpmn:outgoing>
<bpmn:outgoing>Flow_18hrbjg</bpmn:outgoing>
</bpmn:parallelGateway>
<bpmn:sequenceFlow id="Flow_0iqw5r6" sourceRef="Gateway_0hlq55i" targetRef="Activity_0y1hr3s" />
<bpmn:userTask id="Activity_0y1hr3s" name="左军师" camunda:assignee="${leftGuide}">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="comment" label="评论" type="string" />
<camunda:formField id="imageUrl" label="图片" type="string" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>Flow_0iqw5r6</bpmn:incoming>
<bpmn:outgoing>Flow_0hiapj2</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="Flow_18hrbjg" sourceRef="Gateway_0hlq55i" targetRef="Activity_17fwc6q" />
<bpmn:userTask id="Activity_17fwc6q" name="右军师" camunda:assignee="${rightGuide}">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="comment" label="评论" type="string" />
<camunda:formField id="imageUrl" label="图片" type="string" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>Flow_18hrbjg</bpmn:incoming>
<bpmn:outgoing>Flow_1ozncyr</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="Flow_0hiapj2" sourceRef="Activity_0y1hr3s" targetRef="Gateway_0oz16w0" />
<bpmn:parallelGateway id="Gateway_0oz16w0">
<bpmn:incoming>Flow_0hiapj2</bpmn:incoming>
<bpmn:incoming>Flow_1ozncyr</bpmn:incoming>
<bpmn:outgoing>Flow_0t30p7o</bpmn:outgoing>
</bpmn:parallelGateway>
<bpmn:sequenceFlow id="Flow_1ozncyr" sourceRef="Activity_17fwc6q" targetRef="Gateway_0oz16w0" />
<bpmn:sequenceFlow id="Flow_0t30p7o" sourceRef="Gateway_0oz16w0" targetRef="Activity_0s9d8t2" />
<bpmn:userTask id="Activity_0s9d8t2" name="主公" camunda:assignee="${leader}">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="comment" label="评论" type="string" />
<camunda:formField id="imageUrl" label="图片" type="string" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>Flow_0t30p7o</bpmn:incoming>
<bpmn:outgoing>Flow_0nkb62t</bpmn:outgoing>
</bpmn:userTask>
<bpmn:endEvent id="Event_0ik6407">
<bpmn:incoming>Flow_0nkb62t</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_0nkb62t" sourceRef="Activity_0s9d8t2" targetRef="Event_0ik6407" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1f40ryt">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="219" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1sh9j2d_di" bpmnElement="Activity_0ytoxfo">
<dc:Bounds x="270" y="197" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_04uj71o_di" bpmnElement="Gateway_0hlq55i">
<dc:Bounds x="425" y="212" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_199rpkp_di" bpmnElement="Activity_17fwc6q">
<dc:Bounds x="550" y="300" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0xwo1vg_di" bpmnElement="Activity_0y1hr3s">
<dc:Bounds x="550" y="80" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_188eea0_di" bpmnElement="Gateway_0oz16w0">
<dc:Bounds x="735" y="212" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1sdf99a_di" bpmnElement="Activity_0s9d8t2">
<dc:Bounds x="870" y="197" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0ik6407_di" bpmnElement="Event_0ik6407">
<dc:Bounds x="1062" y="219" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_18wovhb_di" bpmnElement="Flow_18wovhb">
<di:waypoint x="215" y="237" />
<di:waypoint x="270" y="237" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_04b290y_di" bpmnElement="Flow_04b290y">
<di:waypoint x="370" y="237" />
<di:waypoint x="425" y="237" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0iqw5r6_di" bpmnElement="Flow_0iqw5r6">
<di:waypoint x="450" y="212" />
<di:waypoint x="450" y="120" />
<di:waypoint x="550" y="120" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_18hrbjg_di" bpmnElement="Flow_18hrbjg">
<di:waypoint x="450" y="262" />
<di:waypoint x="450" y="340" />
<di:waypoint x="550" y="340" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1ozncyr_di" bpmnElement="Flow_1ozncyr">
<di:waypoint x="650" y="340" />
<di:waypoint x="760" y="340" />
<di:waypoint x="760" y="262" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0hiapj2_di" bpmnElement="Flow_0hiapj2">
<di:waypoint x="650" y="120" />
<di:waypoint x="760" y="120" />
<di:waypoint x="760" y="212" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0t30p7o_di" bpmnElement="Flow_0t30p7o">
<di:waypoint x="785" y="237" />
<di:waypoint x="870" y="237" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0nkb62t_di" bpmnElement="Flow_0nkb62t">
<di:waypoint x="970" y="237" />
<di:waypoint x="1062" y="237" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
角色扮演
将军
张飞发动一个并行网关流程。如图
填写表单信息,用于启动流程。
在我发起的菜单中可以看到刚刚发起的流程。
在预览页面可以看到流程当前的运行情况。
军师
左军师诸葛亮,右军师庞统。都需要对这个流程进行审批。 此处只说明诸葛的操作。
在待办任务中可以看到详情可以看到审批详情。进行同意操作。
在已办流程可以自己的审批信息。
庞统操作一样。
主公
刘备登录系统, 同样面对待办任务。
与上图军师操作一样
扩展
JeecgBoot集成camuda工作流引擎-并行网关-视频教程