包容網關 Inclusive Gateway 作者:鄧家海 2018年3月25日 22:59:56 什麼是包容網關? 包容網關(Inclusive Gateway)就是並行網關(Parallel Gateway)和排他網關(Exclusive Gateway)的組合。可以在出口順序流上定義條件,包容 ...
包容網關 Inclusive Gateway
作者:鄧家海
2018年3月25日 22:59:56
什麼是包容網關?
包容網關(Inclusive Gateway)就是並行網關(Parallel Gateway)和排他網關(Exclusive Gateway)的組合。可以在出口順序流上定義條件,包容網關會計算它們。然而主要的區別是,包容網關與並行網關一樣,可以選擇多於一條(出口)順序流
包容網關、並行網關和排他網關的異同:
同:
1.都有出口順序流和入口順序流。
2.至少有一個分支
異:
1.排他網關只有一條分支被執行,如果有多條符合條件的分支,流程會預設走第一條。並行網關至少有一條分支被執行,而且所有的分支都會被執行。包容網關有多條或者一條分支會被執行。
2.包容網關包括了並行網關和排他網關的所有功能。
使用場合:
不確定分支的情形下麵。
例如:
審批部門領導根據不同的條件確定。
審批的會簽根據不同的條件確定。
包容網關兩個重要的特性
分支(fork):所有出口順序流都會被計算,對於計算為true的分支都會被執行。
聚合(join):所有到達包容網關的並行執行,都會在網關處等待,直到每一條具有流程標誌的入口順序流,都有一個執行到達。這是與並行網關的重要區別。換句話說,包容網關只會等待將會被執行的入口順序流。在合併後,流程穿過合併並行網關繼續
註意:
1.包容網關基於出口順序流和入口順序流。
圖標:
包容網關,用內部帶有’圓圈’圖標的網關(菱形)表示。
定義:
1 <inclusiveGateway id="myInclusiveGateway" />
案例:
現在一家公司的業務不斷擴展,單筆業務涉及到的資金也來越多,合同簽訂也是這個公司比較擔心的事情,生怕合同簽訂的中間環節由於責任不明確或者層層疏忽而出現漏洞。所以該公司花高價錢買了一套合同呈批系統。使得合同的呈批流程化。需求如下
先是由合同部起草合同
當金額大於0的時候小於1000萬,律師1和律師2先仔細初審,律師顧問覆核。
當金額大於5000萬的時候,律師一和律師二、法律顧問。法律代表團一起審核。
當金額是1000萬到5000萬的時候,法律代表團決定。
流程設計:
三個分支條件:
1.${momey<1000||money>5000}
2.${momey<1000||money>5000}
3. ${momey>1000}
流程代碼:
1 <?xml version='1.0' encoding='UTF-8'?> 2 3 <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/processdef"> 4 5 <process id="process" isExecutable="true"> 6 7 <startEvent id="sid-33E1F524-C016-49C3-97D5-97AC90206D75" /> 8 9 <userTask id="sid-AECF19D2-3743-43B2-9F6D-8F08BFE4108A" name="起草合同" activiti:assignee="admin" /> 10 11 <sequenceFlow id="sid-A63E67C5-E7E3-4A9C-9A35-7B98211DDDB9" sourceRef="sid-33E1F524-C016-49C3-97D5-97AC90206D75" targetRef="sid-AECF19D2-3743-43B2-9F6D-8F08BFE4108A" /> 12 13 <inclusiveGateway id="sid-C0E2C8D9-CE23-4E4C-A8CE-7B488B4075C5" /> 14 15 <sequenceFlow id="sid-95958564-1A4F-4518-ABF8-137A3E43D483" sourceRef="sid-AECF19D2-3743-43B2-9F6D-8F08BFE4108A" targetRef="sid-C0E2C8D9-CE23-4E4C-A8CE-7B488B4075C5" /> 16 17 <userTask id="sid-3116DBE9-BD59-417A-9DCE-09CDAE6020B1" name="律師1" activiti:assignee="admin" /> 18 19 <userTask id="sid-7CA796A7-F6D4-4204-938D-89EAB826196F" name="律師2" activiti:assignee="admin" /> 20 21 <inclusiveGateway id="sid-E3E3A0C8-77DC-4898-BC24-D790C4688FD5" /> 22 23 <userTask id="sid-E2A0931F-56FD-4F2B-9876-570A93D617E9" name="法律顧問" activiti:assignee="admin" /> 24 25 <sequenceFlow id="sid-2FFF2523-0CDE-4C50-906C-97E82371BA89" sourceRef="sid-E3E3A0C8-77DC-4898-BC24-D790C4688FD5" targetRef="sid-E2A0931F-56FD-4F2B-9876-570A93D617E9" /> 26 27 <userTask id="sid-64B3C09A-2446-431F-962A-43022FCDA61B" name="律師代表團" activiti:assignee="admin" /> 28 29 <userTask id="sid-6908E784-3D2A-4FCB-9947-AD1C999CC444" name="簽訂合同" activiti:assignee="admin" /> 30 31 <inclusiveGateway id="sid-40BDCB3D-EA22-4FC0-985D-8E926FD43296" /> 32 33 <sequenceFlow id="sid-8D279A66-35FF-41D5-81C5-45D6CB4456D9" sourceRef="sid-E2A0931F-56FD-4F2B-9876-570A93D617E9" targetRef="sid-40BDCB3D-EA22-4FC0-985D-8E926FD43296" /> 34 35 <sequenceFlow id="sid-CFE29827-C014-4890-9135-9E5C6E4B9ACA" sourceRef="sid-40BDCB3D-EA22-4FC0-985D-8E926FD43296" targetRef="sid-6908E784-3D2A-4FCB-9947-AD1C999CC444" /> 36 37 <endEvent id="sid-FB66A49B-68FC-429C-9492-A02642F1FAEB" /> 38 39 <sequenceFlow id="sid-52E3DEB1-C564-4A69-8C0B-F6AC43AB7BAB" sourceRef="sid-6908E784-3D2A-4FCB-9947-AD1C999CC444" targetRef="sid-FB66A49B-68FC-429C-9492-A02642F1FAEB" /> 40 41 <sequenceFlow id="sid-3226BACB-CB22-437F-A34D-4FA927921D06" sourceRef="sid-3116DBE9-BD59-417A-9DCE-09CDAE6020B1" targetRef="sid-E3E3A0C8-77DC-4898-BC24-D790C4688FD5" /> 42 43 <sequenceFlow id="sid-CA6AE2C3-9E4B-41A6-A79D-67E932D4AF52" sourceRef="sid-7CA796A7-F6D4-4204-938D-89EAB826196F" targetRef="sid-E3E3A0C8-77DC-4898-BC24-D790C4688FD5" /> 44 45 <sequenceFlow id="sid-E7B2EFDF-C859-48D5-A091-9FD84ED3BB0E" sourceRef="sid-64B3C09A-2446-431F-962A-43022FCDA61B" targetRef="sid-40BDCB3D-EA22-4FC0-985D-8E926FD43296" /> 46 47 <sequenceFlow id="sid-29AC8F78-9D48-41DE-AE15-F4BED0250695" name="小於1000萬,大於5000萬" sourceRef="sid-C0E2C8D9-CE23-4E4C-A8CE-7B488B4075C5" targetRef="sid-3116DBE9-BD59-417A-9DCE-09CDAE6020B1"> 48 49 <conditionExpression xsi:type="tFormalExpression"><![CDATA[${money<1000||money>5000}]]></conditionExpression> 50 51 </sequenceFlow> 52 53 <sequenceFlow id="sid-00D368BC-9FDF-49C3-AE22-D7D376F15BE6" name="小於1000萬,大於5000萬" sourceRef="sid-C0E2C8D9-CE23-4E4C-A8CE-7B488B4075C5" targetRef="sid-7CA796A7-F6D4-4204-938D-89EAB826196F"> 54 55 <conditionExpression xsi:type="tFormalExpression"><![CDATA[${money<1000||money>5000}]]></conditionExpression> 56 57 </sequenceFlow> 58 59 <sequenceFlow id="sid-09BD3F0B-960D-475F-B0FC-70942F0F0CCE" name="大於1000萬" sourceRef="sid-C0E2C8D9-CE23-4E4C-A8CE-7B488B4075C5" targetRef="sid-64B3C09A-2446-431F-962A-43022FCDA61B"> 60 61 <conditionExpression xsi:type="tFormalExpression"><![CDATA[${money>1000}]]></conditionExpression> 62 63 </sequenceFlow> 64 65 <textAnnotation id="sid-BA9B328D-7723-46D7-9DAF-28D49F06D175"> 66 67 <text>小於1000萬,律師一和律師二 68 69 1000-5000萬,律師代表團 70 71 大於5000萬,律師一、律師二和律師代表團</text> 72 73 </textAnnotation> 74 75 </process> 76 77 <bpmndi:BPMNDiagram id="BPMNDiagram_process"> 78 79 <bpmndi:BPMNPlane bpmnElement="process" id="BPMNPlane_process"> 80 81 <bpmndi:BPMNShape bpmnElement="sid-33E1F524-C016-49C3-97D5-97AC90206D75" id="BPMNShape_sid-33E1F524-C016-49C3-97D5-97AC90206D75"> 82 83 <omgdc:Bounds height="30.0" width="30.0" x="45.0" y="190.0" /> 84 85 </bpmndi:BPMNShape> 86 87 <bpmndi:BPMNShape bpmnElement="sid-AECF19D2-3743-43B2-9F6D-8F08BFE4108A" id="BPMNShape_sid-AECF19D2-3743-43B2-9F6D-8F08BFE4108A"> 88 89 <omgdc:Bounds height="80.0" width="100.0" x="120.0" y="165.0" /> 90 91 </bpmndi:BPMNShape> 92 93 <bpmndi:BPMNShape bpmnElement="sid-C0E2C8D9-CE23-4E4C-A8CE-7B488B4075C5" id="BPMNShape_sid-C0E2C8D9-CE23-4E4C-A8CE-7B488B4075C5"> 94 95 <omgdc:Bounds height="40.0" width="40.0" x="255.0" y="185.0" /> 96 97 </bpmndi:BPMNShape> 98 99 <bpmndi:BPMNShape bpmnElement="sid-3116DBE9-BD59-417A-9DCE-09CDAE6020B1" id="BPMNShape_sid-3116DBE9-BD59-417A-9DCE-09CDAE6020B1"> 100 101 <omgdc:Bounds height="80.0" width="100.0" x="387.0" y="30.0" /> 102 103 </bpmndi:BPMNShape> 104 105 <bpmndi:BPMNShape bpmnElement="sid-7CA796A7-F6D4-4204-938D-89EAB826196F" id="BPMNShape_sid-7CA796A7-F6D4-4204-938D-89EAB826196F"> 106 107 <omgdc:Bounds height="80.0" width="100.0" x="387.0" y="165.0" /> 108 109 </bpmndi:BPMNShape> 110 111 <bpmndi:BPMNShape bpmnElement="sid-E3E3A0C8-77DC-4898-BC24-D790C4688FD5" id="BPMNShape_sid-E3E3A0C8-77DC-4898-BC24-D790C4688FD5"> 112 113 <omgdc:Bounds height="40.0" width="40.0" x="525.0" y="185.0" /> 114 115 </bpmndi:BPMNShape> 116 117 <bpmndi:BPMNShape bpmnElement="sid-E2A0931F-56FD-4F2B-9876-570A93D617E9" id="BPMNShape_sid-E2A0931F-56FD-4F2B-9876-570A93D617E9"> 118 119 <omgdc:Bounds height="80.0" width="100.0" x="585.0" y="60.0" /> 120 121 </bpmndi:BPMNShape> 122 123 <bpmndi:BPMNShape bpmnElement="sid-64B3C09A-2446-431F-962A-43022FCDA61B" id="BPMNShape_sid-64B3C09A-2446-431F-962A-43022FCDA61B"> 124 125 <omgdc:Bounds height="80.0" width="100.0" x="387.0" y="315.0" /> 126 127 </bpmndi:BPMNShape> 128 129 <bpmndi:BPMNShape bpmnElement="sid-6908E784-3D2A-4FCB-9947-AD1C999CC444" id="BPMNShape_sid-6908E784-3D2A-4FCB-9947-AD1C999CC444"> 130 131 <omgdc:Bounds height="80.0" width="100.0" x="780.0" y="165.0" /> 132 133 </bpmndi:BPMNShape> 134 135 <bpmndi:BPMNShape bpmnElement="sid-40BDCB3D-EA22-4FC0-985D-8E926FD43296" id="BPMNShape_sid-40BDCB3D-EA22-4FC0-985D-8E926FD43296"> 136 137 <omgdc:Bounds height="40.0" width="40.0" x="705.0" y="255.0" /> 138 139 </bpmndi:BPMNShape> 140 141 <bpmndi:BPMNShape bpmnElement="sid-FB66A49B-68FC-429C-9492-A02642F1FAEB" id="BPMNShape_sid-FB66A49B-68FC-429C-9492-A02642F1FAEB"> 142 143 <omgdc:Bounds height="28.0" width="28.0" x="955.0" y="191.0" /> 144 145 </bpmndi:BPMNShape> 146 147 <bpmndi:BPMNShape bpmnElement="sid-BA9B328D-7723-46D7-9DAF-28D49F06D175" id="BPMNShape_sid-BA9B328D-7723-46D7-9DAF-28D49F06D175"> 148 149 <omgdc:Bounds height="69.0" width="262.0" x="217.0" y="428.0" /> 150 151 </bpmndi:BPMNShape> 152 153 <bpmndi:BPMNEdge bpmnElement="sid-3226BACB-CB22-437F-A34D-4FA927921D06" id="BPMNEdge_sid-3226BACB-CB22-437F-A34D-4FA927921D06"> 154 155 <omgdi:waypoint x="487.0" y="70.0" /> 156 157 <omgdi:waypoint x="545.0" y="70.0" /> 158 159 <omgdi:waypoint x="545.0" y="185.0" /> 160 161 </bpmndi:BPMNEdge> 162 163 <bpmndi:BPMNEdge bpmnElement="sid-09BD3F0B-960D-475F-B0FC-70942F0F0CCE" id="BPMNEdge_sid-09BD3F0B-960D-475F-B0FC-70942F0F0CCE"> 164 165 <omgdi:waypoint x="275.5" y="224.5" /> 166 167 <omgdi:waypoint x="275.5" y="355.0" /> 168 169 <omgdi:waypoint x="387.0" y="355.0" /> 170 171 </bpmndi:BPMNEdge> 172 173 <bpmndi:BPMNEdge bpmnElement="sid-52E3DEB1-C564-4A69-8C0B-F6AC43AB7BAB" id="BPMNEdge_sid-52E3DEB1-C564-4A69-8C0B-F6AC43AB7BAB"> 174 175 <omgdi:waypoint x="880.0" y="205.0" /> 176 177 <omgdi:waypoint x="955.0" y="205.0" /> 178 179 </bpmndi:BPMNEdge> 180 181 <bpmndi:BPMNEdge bpmnElement="sid-2FFF2523-0CDE-4C50-906C-97E82371BA89" id="BPMNEdge_sid-2FFF2523-0CDE-4C50-906C-97E82371BA89"> 182 183 <omgdi:waypoint x="564.5" y="205.5" /> 184 185 <omgdi:waypoint x="635.0" y="205.5" /> 186 187 <omgdi:waypoint x="635.0" y="140.0" /> 188 189 </bpmndi:BPMNEdge> 190 191 <bpmndi:BPMNEdge bpmnElement="sid-8D279A66-35FF-41D5-81C5-45D6CB4456D9" id="BPMNEdge_sid-8D279A66-35FF-41D5-81C5-45D6CB4456D9"> 192 193 <omgdi:waypoint x="685.0" y="100.0" /> 194 195 <omgdi:waypoint x="725.0" y="100.0" /> 196 197 <omgdi:waypoint x="725.0" y="255.0" /> 198 199 </bpmndi:BPMNEdge> 200 201 <bpmndi:BPMNEdge bpmnElement="sid-CFE29827-C014-4890-9135-9E5C6E4B9ACA" id="BPMNEdge_sid-CFE29827-C014-4890-9135-9E5C6E4B9ACA"> 202 203 <omgdi:waypoint x="744.5" y="275.5" /> 204 205 <omgdi:waypoint x="830.0" y="275.5" /> 206 207 <omgdi:waypoint x="830.0" y="245.0" /> 208 209 </bpmndi:BPMNEdge> 210 211 <bpmndi:BPMNEdge bpmnElement="sid-29AC8F78-9D48-41DE-AE15-F4BED0250695" id="BPMNEdge_sid-29AC8F78-9D48-41DE-AE15-F4BED0250695"> 212 213 <omgdi:waypoint x="275.5" y="185.5" /> 214 215 <omgdi:waypoint x="275.5" y="70.0" /> 216 217 <omgdi:waypoint x="387.0" y="70.0" /> 218 219 </bpmndi:BPMNEdge> 220 221 <bpmndi:BPMNEdge bpmnElement="sid-95958564-1A4F-4518-ABF8-137A3E43D483" id="BPMNEdge_sid-95958564-1A4F-4518-ABF8-137A3E43D483"> 222 223 <omgdi:waypoint x="220.0" y="205.0" /> 224 225 <omgdi:waypoint x="255.0" y="205.0" /> 226 227 </bpmndi:BPMNEdge> 228 229 <bpmndi:BPMNEdge bpmnElement="sid-E7B2EFDF-C859-48D5-A091-9FD84ED3BB0E" id="BPMNEdge_sid-E7B2EFDF-C859-48D5-A091-9FD84ED3BB0E"> 230 231 <omgdi:waypoint x="487.0" y="355.0" /> 232 233 <omgdi:waypoint x="725.0" y="355.0" /> 234 235 <omgdi:waypoint x="725.0" y="295.0" /> 236 237 </bpmndi:BPMNEdge> 238 239 <bpmndi:BPMNEdge bpmnElement="sid-00D368BC-9FDF-49C3-AE22-D7D376F15BE6" id="BPMNEdge_sid-00D368BC-9FDF-49C3-AE22-D7D376F15BE6"> 240 241 <omgdi:waypoint x="294.55900621118013" y="205.44099378881987" /> 242 243 <omgdi:waypoint x="387.0" y="205.15479876160992" /> 244 245 </bpmndi:BPMNEdge> 246 247 <bpmndi:BPMNEdge bpmnElement="sid-CA6AE2C3-9E4B-41A6-A79D-67E932D4AF52" id="BPMNEdge_sid-CA6AE2C3-9E4B-41A6-A79D-67E932D4AF52"> 248 249 <omgdi:waypoint x="487.0" y="205.0" /> 250 251 <omgdi:waypoint x="525.0" y="205.0" /> 252 253 </bpmndi:BPMNEdge> 254 255 <bpmndi:BPMNEdge bpmnElement="sid-A63E67C5-E7E3-4A9C-9A35-7B98211DDDB9" id="BPMNEdge_sid-A63E67C5-E7E3-4A9C-9A35-7B98211DDDB9"> 256 257 <omgdi:waypoint x="75.0" y="205.0" /> 258 259 <omgdi:waypoint x="120.0" y="205.0" /> 260 261 </bpmndi:BPMNEdge> 262 263 </bpmndi:BPMNPlane> 264 265 </bpmndi:BPMNDiagram> 266 267 </definitions>
啟動流程
起草合同:
1 /**查詢當前人的個人任務*/ 2 3 @Test 4 5 public void findMyPersonalTask(){ 6 7 ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); 8 9 String assignee="admin"; 10 11 List<Task> list=processEngine.getTaskService()//與正在執行的任務管理相關的Service 12 13 .createTaskQuery() //創建任務查詢對象 14 15 .taskAssignee(assignee) 16 17 .list(); 18 19 if(list!=null&& list.size()>0){ 20 21 for(Task task:list){ 22 23 System.out.println("任務的ID:"+task.getId()); 24 25 System.out.println("任務的名稱:"+task.getName()); 26