相关代码参考GitHub:https://github.com/q850963704/activiti-demo.git
本例子以请假流程为例,流程设计图如下图所示:
具体判断条件参考xml文件,Exclusive Gateway的判断条件为 day<=2 和 day>2,经理审批和总经理审批判断条件均为 flag=true 和 flag=false
leave.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="m1561702890882" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema">
<process id="leave" isClosed="false" isExecutable="true" name="请假流程图" processType="None">
<documentation id="leave_D_1"><![CDATA[请假流程图]]></documentation>
<startEvent id="startevent1" name="Start"/>
<endEvent id="endevent1" name="End"/>
<userTask activiti:assignee="employee" activiti:exclusive="true" id="usertask1" name="员工请假"/>
<userTask activiti:candidateGroups="manager" activiti:exclusive="true" id="usertask2" name="经理审批"/>
<userTask activiti:candidateGroups="boss" activiti:exclusive="true" id="usertask3" name="总经理审批"/>
<sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"/>
<sequenceFlow id="flow2" name="${flag == true}" sourceRef="usertask2" targetRef="endevent1">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${flag == true}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow3" name="${flag == true}" sourceRef="usertask3" targetRef="endevent1">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${flag == true}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow4" name="${flag == false}" sourceRef="usertask2" targetRef="usertask1">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${flag == false}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow5" name="${flag == false}" sourceRef="usertask3" targetRef="usertask1">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${flag == false}]]></conditionExpression>
</sequenceFlow>
<exclusiveGateway gatewayDirection="Unspecified" id="exclusivegateway1" name="Exclusive Gateway"/>
<sequenceFlow id="flow6" sourceRef="usertask1" targetRef="exclusivegateway1"/>
<sequenceFlow id="flow7" name="${day <= 2}" sourceRef="exclusivegateway1" targetRef="usertask2">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${day <= 2}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow8" name="${day > 2}" sourceRef="exclusivegateway1" targetRef="usertask3">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${day > 2}]]></conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram documentation="background=#3C3F41;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="leave">
<bpmndi:BPMNShape bpmnElement="startevent1" id="Shape-startevent1">
<omgdc:Bounds height="3