flowable-流程中心設計之會籤(一)

說明 

某些業務場景,審覈需要多個人審覈,然後根據審覈結果判定是通過還是拒絕,可以理解爲投票

會籤內置參數 

作用
 
用於會籤決策相關
 
 參數名字  說明
 nrOfInstances  一共多少實例
 nrOfCompletedInstances  已經完成審批數量(包含審批結果爲通過和拒絕的)
 nrOfActiveInstances
 還未完成審批數量
 ${taskName}_approved_count  完成審批 審覈結果爲通過的數量(注:自定義擴展)
 ${taskName}_rejected_count  完成審批 審覈結果爲拒絕的數量(注:自定義擴展)

 

 
nrOfInstances、nrOfCompletedInstances、nrOfActiveInstances 注:此3個變量只能用於會籤節點 如果需要應用全局則需要擴展因爲會籤節點是一個單獨的execution parent指向processInstance的execution children則是其他會籤任務的execution
這3個變量保存在會籤節點的execution 而不是processInstanc的execution
 

會籤相關配置

 

類型(多實例) 
Parallel
  並行,指的如果我們配置了3人會籤,3人可以同時在待辦看到此任務並處理
sequential
  串行,指的是如果我們配置了3人會籤,則會需要串行執行,前一個人辦理了後一個人才能看到
 
集合(多實例)
 
參與會籤的人員列表參數變量,發起流程傳入 如以下格式
{
    "startUserId":"張立秋",
    "businessKey":9072,
    "title":"張立秋[2022-01-12]發起的商品編輯流程9",
    "definitionKey":"test_3",
    "variables":{
        "managerUserIds":["小明1","小明2","小明3"]
    }
}
 
元素變量
 
遍歷集會籤人員集合的接收變量
 
任務派遣
 
集合(多實例) 和元素變量 任務派遣搭配則可以動態指定參與會籤的人
比如集合多實例配置:managerUserIds
元素變量 managerUserId
任務派遣配置 ${managerUserId}
 
 
完成條件
 
結合內置參數,可以設置會簽結束條件,比如會籤設置了1000人蔘與 有50%完成了審批則會簽結束
如:${nrOfInstances/nrOfCompletedInstances>=0.5}
不填寫則默認:100%完成審批
 
基數
 
限制任務的數量,比如我設置5 集合多實例配置了100 則只會發起5個流程
不填寫默認:不限制
 

結合自定義擴展變量完成流程判定

 

 
1.如果會簽結束,判定如果有70%的人同意則通過
${經理級會籤_approved_count/(經理級會籤_approved_count+經理級會籤_rejected_count)>=0.7}
2.小於70%則拒絕
${經理級會籤_approved_count/(經理級會籤_approved_count+經理級會籤_rejected_count)<0.7}
狀態判斷 爲自動完成節點 結果爲通過
注:因爲連線是表達式 所以藉助自動審批通過的任務來完成會籤任務的判斷,如果會簽結束還有正常任務則不需要此節點

 

後期擴展

增加一票否決權,和一票通過權
思路:發起流程調用方指定一票否決權和一票通過權的用戶id 

以上例子的xml配置

<?xml version="1.0" encoding="UTF-8"?>
<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:flowable="http://flowable.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.flowable.org/processdef">
    <process id="test_3" name="測試會籤" isExecutable="true">
        <documentation>測試會籤任務</documentation>
        <startEvent id="startEvent1" flowable:autocompletetask="false" flowable:startusercommitnode="false"></startEvent>
        <userTask id="sid-BE8425E7-EA27-4CE2-B245-FE273C21DF3C" name="發起人提交申請" flowable:assignee="${INITIATOR}" flowable:process_button="辦理,駁回,流程終止" flowable:autocompletetask="false" flowable:startusercommitnode="true">
            <extensionElements>
                <modeler:activiti-idm-initiator xmlns:modeler="http://flowable.org/modeler">
                    <![CDATA[true]]>
                </modeler:activiti-idm-initiator>
            </extensionElements>
        </userTask>
        <sequenceFlow id="sid-EF8EBBFA-F1F9-4437-8A5F-10805389759C" sourceRef="startEvent1" targetRef="sid-BE8425E7-EA27-4CE2-B245-FE273C21DF3C"></sequenceFlow>
        <userTask id="sid-6D334BCB-C5A9-4EB7-B0DD-D054BC2C84AC" name="經理級會籤" flowable:assignee="${managerUserId}" flowable:process_button="辦理,駁回,流程終止" flowable:autocompletetask="false" flowable:startusercommitnode="false">
            <extensionElements>
                <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler">
                    <![CDATA[false]]>
                </modeler:initiator-can-complete>
            </extensionElements>
            <multiInstanceLoopCharacteristics isSequential="false" flowable:collection="managerUserIds" flowable:elementVariable="managerUserId">
                <loopCardinality>3</loopCardinality>
                <completionCondition>${nrOfCompletedInstances/nrOfInstances &gt;= 1}</completionCondition>
            </multiInstanceLoopCharacteristics>
        </userTask>
        <endEvent id="sid-3A3BF6ED-BF71-49CA-B99D-3DD7F3D0008E"></endEvent>
        <sequenceFlow id="sid-71A15912-6A50-4A54-ABCE-A6350C00D823" name="拒絕" sourceRef="sid-6D334BCB-C5A9-4EB7-B0DD-D054BC2C84AC" targetRef="sid-3A3BF6ED-BF71-49CA-B99D-3DD7F3D0008E">
            <conditionExpression xsi:type="tFormalExpression">
                <![CDATA[${經理級會籤_approved_count/(經理級會籤_approved_count+經理級會籤_rejected_count)<0.7}]]>
            </conditionExpression>
        </sequenceFlow>
        <sequenceFlow id="sid-CD2ED5CC-1DDA-4F49-BE68-5292CC6B4403" sourceRef="sid-BE8425E7-EA27-4CE2-B245-FE273C21DF3C" targetRef="sid-6D334BCB-C5A9-4EB7-B0DD-D054BC2C84AC"></sequenceFlow>
        <userTask id="sid-386F4033-C7DD-4A87-A6C2-9B6B07D97EC1" name="狀態判定爲通過" flowable:assignee="system" flowable:process_button="辦理,駁回,流程終止" flowable:autocompletetask="true" flowable:startusercommitnode="false">
            <extensionElements>
                <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler">
                    <![CDATA[false]]>
                </modeler:initiator-can-complete>
            </extensionElements>
        </userTask>
        <sequenceFlow id="sid-7F0439EE-E9F1-4334-8CE4-FB723E98649B" name="70%贊成通過" sourceRef="sid-6D334BCB-C5A9-4EB7-B0DD-D054BC2C84AC" targetRef="sid-386F4033-C7DD-4A87-A6C2-9B6B07D97EC1">
            <conditionExpression xsi:type="tFormalExpression">
                <![CDATA[${經理級會籤_approved_count/(經理級會籤_approved_count+經理級會籤_rejected_count)>=0.7}]]>
            </conditionExpression>
        </sequenceFlow>
        <endEvent id="sid-9FE809C1-68EA-4A8F-B968-34BCD32D71D5"></endEvent>
        <sequenceFlow id="sid-63617A9E-40CD-4C62-AE0B-4BD5A221A506" sourceRef="sid-386F4033-C7DD-4A87-A6C2-9B6B07D97EC1" targetRef="sid-9FE809C1-68EA-4A8F-B968-34BCD32D71D5"></sequenceFlow>
    </process>
    <bpmndi:BPMNDiagram id="BPMNDiagram_test_3">
        <bpmndi:BPMNPlane bpmnElement="test_3" id="BPMNPlane_test_3">
            <bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1">
                <omgdc:Bounds height="30.0" width="30.0" x="100.0" y="145.0"></omgdc:Bounds>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="sid-BE8425E7-EA27-4CE2-B245-FE273C21DF3C" id="BPMNShape_sid-BE8425E7-EA27-4CE2-B245-FE273C21DF3C">
                <omgdc:Bounds height="80.0" width="100.0" x="165.0" y="120.0"></omgdc:Bounds>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="sid-6D334BCB-C5A9-4EB7-B0DD-D054BC2C84AC" id="BPMNShape_sid-6D334BCB-C5A9-4EB7-B0DD-D054BC2C84AC">
                <omgdc:Bounds height="80.0" width="100.0" x="315.0" y="120.0"></omgdc:Bounds>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="sid-3A3BF6ED-BF71-49CA-B99D-3DD7F3D0008E" id="BPMNShape_sid-3A3BF6ED-BF71-49CA-B99D-3DD7F3D0008E">
                <omgdc:Bounds height="28.0" width="28.0" x="225.0" y="300.0"></omgdc:Bounds>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="sid-386F4033-C7DD-4A87-A6C2-9B6B07D97EC1" id="BPMNShape_sid-386F4033-C7DD-4A87-A6C2-9B6B07D97EC1">
                <omgdc:Bounds height="80.0" width="100.0" x="510.0" y="120.0"></omgdc:Bounds>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="sid-9FE809C1-68EA-4A8F-B968-34BCD32D71D5" id="BPMNShape_sid-9FE809C1-68EA-4A8F-B968-34BCD32D71D5">
                <omgdc:Bounds height="28.0" width="28.0" x="670.0" y="146.0"></omgdc:Bounds>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNEdge bpmnElement="sid-63617A9E-40CD-4C62-AE0B-4BD5A221A506" id="BPMNEdge_sid-63617A9E-40CD-4C62-AE0B-4BD5A221A506">
                <omgdi:waypoint x="609.95" y="160.0"></omgdi:waypoint>
                <omgdi:waypoint x="670.0" y="160.0"></omgdi:waypoint>
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="sid-EF8EBBFA-F1F9-4437-8A5F-10805389759C" id="BPMNEdge_sid-EF8EBBFA-F1F9-4437-8A5F-10805389759C">
                <omgdi:waypoint x="129.94999817301806" y="160.0"></omgdi:waypoint>
                <omgdi:waypoint x="165.0" y="160.0"></omgdi:waypoint>
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="sid-71A15912-6A50-4A54-ABCE-A6350C00D823" id="BPMNEdge_sid-71A15912-6A50-4A54-ABCE-A6350C00D823">
                <omgdi:waypoint x="365.0" y="199.95"></omgdi:waypoint>
                <omgdi:waypoint x="365.0" y="250.0"></omgdi:waypoint>
                <omgdi:waypoint x="239.0" y="250.0"></omgdi:waypoint>
                <omgdi:waypoint x="239.0" y="300.0"></omgdi:waypoint>
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="sid-CD2ED5CC-1DDA-4F49-BE68-5292CC6B4403" id="BPMNEdge_sid-CD2ED5CC-1DDA-4F49-BE68-5292CC6B4403">
                <omgdi:waypoint x="264.9499999999581" y="160.0"></omgdi:waypoint>
                <omgdi:waypoint x="314.9999999999364" y="160.0"></omgdi:waypoint>
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="sid-7F0439EE-E9F1-4334-8CE4-FB723E98649B" id="BPMNEdge_sid-7F0439EE-E9F1-4334-8CE4-FB723E98649B">
                <omgdi:waypoint x="414.9499999999325" y="160.0"></omgdi:waypoint>
                <omgdi:waypoint x="509.9999999999882" y="160.0"></omgdi:waypoint>
            </bpmndi:BPMNEdge>
        </bpmndi:BPMNPlane>
    </bpmndi:BPMNDiagram>
</definitions>

 

 

 

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章