Camunda工作流网关(三)-Inclusive Gateway(包容性网关)


在Camunda的 Modeler工具中提供了5种类型的网关:

  1. Exclusive Gateway(独占网关或排他网关)
  2. Parallel Gateway(并行网关)
  3. Inclusive Gateway(包容性网关)
  4. Complex Gateway(复杂网关)
  5. Event-based Gateway(基于事件的网关)

每一个网关都有自己独特的功能,本章主要介绍Inclusive Gateway(包容性网关)的使用方式。

1、Inclusive Gateway(包容性网关)

在这里插入图片描述

The inclusive gateway (or OR-gateway) allows for making multiple decisions based on data (i.e. on process instance variables).
包容性网关(或or网关)允许根据数据(即流程实例变量)做出多个决策。

If an inclusive gateway has multiple outgoing sequence flows, all sequence flows must have a condition to define when the flow is taken. If the inclusive gateway only has one outgoing sequence flow, then it does not need to have a condition.
如果包含网关具有多个传出序列流,则所有序列流都必须有一个条件来定义何时采用该流。如果包含网关只有一个传出序列流,那么它不需要有条件。

Optionally, one of the sequence flows can be marked as the default flow. This sequence flow should not have a condition, because its behavior depends on the other conditions.
可以选择将其中一个序列流标记为默认流。这个序列流不应该有条件,因为它的行为取决于其他条件。

When an inclusive gateway is entered, the conditions are evaluated. The process instance takes all sequence flows where the condition is fulfilled.
当进入包容性网关时,将评估条件。流程实例获取满足条件的所有序列流。

包容网关两个重要的特性

分支(fork):所有出口顺序流都会被计算,对于计算为true的分支都会被执行。

聚合(join):所有到达包容网关的并行执行,都会在网关处等待,直到每一条具有流程标志的入口顺序流,都有一个执行到达。这是与并行网关的重要区别。换句话说,包容网关只会等待将会被执行的入口顺序流。在合并后,流程穿过合并并行网关继续

重点1:
排他网关只有一条分支被执行,如果有多条符合条件的分支,流程会默认走第一条
并行网关至少有一条分支被执行,而且所有的分支都会被执行。
包容网关有多条或者一条分支会被执行。

重点2:
包容网关包括了并行网关和排他网关的所有功能。

2、业务场景

公司里有个用章的流程,先是部门主任审批,然后判断使用天数如果小于1天的需要后勤行政审批,判断使用天数如果大于1天的需要项目经理审批,而对大于2天的需要综合办审批 。

在这里插入图片描述
同时满足两个条件时,需要所有条件多审批完成电子流才继续往下走,如下,判断同时符合【项目经理审批】和【综合办审批】,则项目经理和综合办审批完成后,电子流会流转到【HR审批】环节。
在这里插入图片描述

3、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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_14x7iqb" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.12.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.19.0">
  <bpmn:process id="flow_xmgs_tylc03" name="通用流程03" isExecutable="true" camunda:historyTimeToLive="100">
    <bpmn:sequenceFlow id="flow_emg_flag01" name="判断" sourceRef="Gateway_1hrtclm" targetRef="task_xmjl">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${amount&gt;1}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="flow_emg_flag03" name="判断" sourceRef="Gateway_1hrtclm" targetRef="task_zhb">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${amount&gt;2}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_0oqjdy0" sourceRef="task_xmjl" targetRef="Gateway_13u1zae" />
    <bpmn:sequenceFlow id="Flow_07f6i9q" sourceRef="task_zhb" targetRef="Gateway_13u1zae" />
    <bpmn:inclusiveGateway id="Gateway_13u1zae">
      <bpmn:incoming>Flow_0oqjdy0</bpmn:incoming>
      <bpmn:incoming>Flow_07f6i9q</bpmn:incoming>
      <bpmn:incoming>Flow_1h9dpm3</bpmn:incoming>
      <bpmn:outgoing>Flow_0rsdjw3</bpmn:outgoing>
    </bpmn:inclusiveGateway>
    <bpmn:sequenceFlow id="Flow_0rsdjw3" sourceRef="Gateway_13u1zae" targetRef="task_hr" />
    <bpmn:inclusiveGateway id="Gateway_1hrtclm" name="包容性网关">
      <bpmn:incoming>Flow_1q25zh3</bpmn:incoming>
      <bpmn:outgoing>flow_emg_flag01</bpmn:outgoing>
      <bpmn:outgoing>flow_emg_flag03</bpmn:outgoing>
      <bpmn:outgoing>flow_emg_flag02</bpmn:outgoing>
    </bpmn:inclusiveGateway>
    <bpmn:startEvent id="StartEvent_1" name="提交">
      <bpmn:outgoing>Flow_16rj62y</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="Flow_16rj62y" sourceRef="StartEvent_1" targetRef="task_bmzr" />
    <bpmn:sequenceFlow id="Flow_1q25zh3" sourceRef="task_bmzr" targetRef="Gateway_1hrtclm" />
    <bpmn:userTask id="task_bmzr" name="部门主任审批" camunda:assignee="${bmzrapprover}">
      <bpmn:incoming>Flow_16rj62y</bpmn:incoming>
      <bpmn:outgoing>Flow_1q25zh3</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:sequenceFlow id="flow_emg_flag02" name="判断" sourceRef="Gateway_1hrtclm" targetRef="task_zhbgs">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${amount&lt;1}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_1h9dpm3" sourceRef="task_zhbgs" targetRef="Gateway_13u1zae" />
    <bpmn:endEvent id="Event_0gas727" name="结束">
      <bpmn:incoming>Flow_12p2tkj</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_12p2tkj" sourceRef="task_hr" targetRef="Event_0gas727" />
    <bpmn:userTask id="task_zhb" name="综合办审批" camunda:assignee="${bmzrapprover}">
      <bpmn:incoming>flow_emg_flag03</bpmn:incoming>
      <bpmn:outgoing>Flow_07f6i9q</bpmn:outgoing>
      <bpmn:multiInstanceLoopCharacteristics camunda:collection="zhbList" camunda:elementVariable="bmzrapprover">
        <bpmn:completionCondition xsi:type="bpmn:tFormalExpression">${nrOfCompletedInstances ==1}</bpmn:completionCondition>
      </bpmn:multiInstanceLoopCharacteristics>
    </bpmn:userTask>
    <bpmn:userTask id="task_zhbgs" name="后勤行政主管" camunda:assignee="${hqxzzgapprover}">
      <bpmn:incoming>flow_emg_flag02</bpmn:incoming>
      <bpmn:outgoing>Flow_1h9dpm3</bpmn:outgoing>
      <bpmn:multiInstanceLoopCharacteristics camunda:collection="hqxzzgList" camunda:elementVariable="hqxzzgapprover" />
    </bpmn:userTask>
    <bpmn:userTask id="task_xmjl" name="项目经理审批" camunda:assignee="${xmjlapprover}">
      <bpmn:incoming>flow_emg_flag01</bpmn:incoming>
      <bpmn:outgoing>Flow_0oqjdy0</bpmn:outgoing>
      <bpmn:multiInstanceLoopCharacteristics isSequential="true" camunda:collection="xmjlList" camunda:elementVariable="xmjlapprover" />
    </bpmn:userTask>
    <bpmn:userTask id="task_hr" name="HR审批" camunda:assignee="${hrapprover}">
      <bpmn:incoming>Flow_0rsdjw3</bpmn:incoming>
      <bpmn:outgoing>Flow_12p2tkj</bpmn:outgoing>
    </bpmn:userTask>
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="flow_xmgs_tylc03">
      <bpmndi:BPMNShape id="Gateway_1qn9l1m_di" bpmnElement="Gateway_13u1zae">
        <dc:Bounds x="675" y="235" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_0tszln6_di" bpmnElement="Gateway_1hrtclm">
        <dc:Bounds x="395" y="235" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="393" y="292" width="55" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_1t88lug_di" bpmnElement="StartEvent_1">
        <dc:Bounds x="152" y="242" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="159" y="285" width="22" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_15aiw85_di" bpmnElement="task_bmzr">
        <dc:Bounds x="240" y="220" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0gas727_di" bpmnElement="Event_0gas727">
        <dc:Bounds x="962" y="242" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="969" y="285" width="22" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_19snylo_di" bpmnElement="task_zhb">
        <dc:Bounds x="510" y="360" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0nv0kdy_di" bpmnElement="task_zhbgs">
        <dc:Bounds x="510" y="220" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0by0ucb_di" bpmnElement="task_xmjl">
        <dc:Bounds x="510" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1khnqkx_di" bpmnElement="task_hr">
        <dc:Bounds x="790" y="220" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_0oqjdy0_di" bpmnElement="Flow_0oqjdy0">
        <di:waypoint x="610" y="120" />
        <di:waypoint x="700" y="120" />
        <di:waypoint x="700" y="235" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_07f6i9q_di" bpmnElement="Flow_07f6i9q">
        <di:waypoint x="610" y="400" />
        <di:waypoint x="700" y="400" />
        <di:waypoint x="700" y="285" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1h9dpm3_di" bpmnElement="Flow_1h9dpm3">
        <di:waypoint x="610" y="260" />
        <di:waypoint x="675" y="260" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0rsdjw3_di" bpmnElement="Flow_0rsdjw3">
        <di:waypoint x="725" y="260" />
        <di:waypoint x="790" y="260" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_12p2tkj_di" bpmnElement="Flow_12p2tkj">
        <di:waypoint x="890" y="260" />
        <di:waypoint x="962" y="260" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1q25zh3_di" bpmnElement="Flow_1q25zh3">
        <di:waypoint x="340" y="260" />
        <di:waypoint x="395" y="260" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0sp8g9y_di" bpmnElement="flow_emg_flag01">
        <di:waypoint x="420" y="235" />
        <di:waypoint x="420" y="120" />
        <di:waypoint x="510" y="120" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="425" y="175" width="23" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1l2flu1_di" bpmnElement="flow_emg_flag03">
        <di:waypoint x="420" y="285" />
        <di:waypoint x="420" y="400" />
        <di:waypoint x="510" y="400" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="425" y="340" width="23" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0rdmtha_di" bpmnElement="flow_emg_flag02">
        <di:waypoint x="445" y="260" />
        <di:waypoint x="510" y="260" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="469" y="243" width="23" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_16rj62y_di" bpmnElement="Flow_16rj62y">
        <di:waypoint x="188" y="260" />
        <di:waypoint x="240" y="260" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hardworkl

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值