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 >= 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>