1. 说明
回退操作是指,将流程退回到上一个节点,基本思路是通过审批历史服务HistoryService找到审批审批的上一节点,然后跟通用拒绝操作类似,将流程拨回到该节点,要注意的一个问题是,如果碰到并行审批,在并行线上回退应该回退到哪里呢?
如图,如果审批顺序为主管审批->上级领导审批->董事长审批,这时候总监审批执行回退操作,应该回退到哪个节点呢,显然不是董事长,因为这是两个并行互不干扰的审批,正常应该回退到主管审批这里,所以回退操作应该是基于execution的回退。
2. 实现
Bpmn文件:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" 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" xmlns:tns="http://www.activiti.org/test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1597729482723" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema">
<process id="parallel" isClosed="false" isExecutable="true" processType="None">
<startEvent id="_2" name="开始"/>
<userTask activiti:assignee="user1" activiti:exclusive="true" id="_3" name="项目经理审批"/>
<parallelGateway gatewayDirection="Unspecified" id="_4" name="ParallelGateway"/>
<userTask activiti:assignee="user2" activiti:exclusive="true" id="_5" name="上级领导审批"/>
<userTask activiti:assignee="user3" activiti:exclusive="true" id="_6" name="董事长审批"/>
<userTask activiti:assignee="user4" activiti:exclusive="true" id="_7" name="主管审批"/>
<userTask activiti:assignee="user5" activiti:exclusive="true" id="_8" name="总监审批"/>
<parallelGateway gatewayDirection="Unspecified" id="_9" name="ParallelGateway"/>
<endEvent id="_10" name="结束"/>
<sequenceFlow id="_11" sourceRef="_2" targetRef="_3"/>
<sequenceFlow id="_12" sourceRef="_3" targetRef="_4"/>
<sequenceFlow id="_13" sourceRef="_4" targetRef="_5"/>
<sequenceFlow id="_14" sourceRef="_4" targetRef="_7"/>
<sequenceFlow id="_15" sourceRef="_5" targetRef="_6"/>
<sequenceFlow id="_16" sourceRef="_7" targetRef="_8"/>
<sequenceFlow id="_17" sourceRef="_6" targetRef="_9"/>
<sequenceFlow id="_18" sourceRef="_8" targetRef="_9"/>
<sequenceFlow id="_19" sourceRef="_9" targetRef="_10"/>
</process>
<bpmndi:BPMNDiagram documentation="background=#000000;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram">
<bpmndi:BPMNPlane bpmnElement="parallel">
<bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
<omgdc:Bounds height="32.0" width="32.0" x="285.0" y="-10.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" id="Shape-_3">
<omgdc:Bounds height="55.0" width="85.0" x="260.0" y="60.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi