@Test
@Deployment(resources="diagrams/troubleHoliday.bpmn")
public void deployTroubleHoliday(){
org.activiti.engine.repository.Deployment deployment = engine.getRepositoryService().createDeployment().addClasspathResource("diagrams/troubleHoliday.bpmn").deploy();
}
@Test
@Deployment(resources="diagrams/troubleHoliday.bpmn")
public void startProcess(){
Map variables = new HashMap();
variables.put("userId", "1");
ProcessInstance instance = engine.getRuntimeService().startProcessInstanceByKey("troubleHoliday",variables);
}
@Test
@Deployment(resources="diagrams/troubleHoliday.bpmn")
public void panDuan(){
Task task = engine.getTaskService().createTaskQuery().processInstanceId("167501").active().singleResult();
Map variables = new HashMap();
variables.put("days", 0.5);//条件
variables.put("projectGroup", "12");//指定项目组长
engine.getTaskService().complete(task.getId(),variables);
Task task2 = engine.getTaskService().createTaskQuery().processInstanceId("167501").active().singleResult();
engine.getTaskService().claim(task2.getId(), "2");//签收,用于指定下一步由谁来办理(只针对于candidateUsers和candidateGroups属性)
}
每一步对应act_ru_task(执行中的任务)
、act_re_deployment(已部署的流程模版)
和act_ru_variable(模版中的变量赋值情况)
查看记录。
该配置文件详细
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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/test">
<process id="troubleHoliday" name="startHoliday" isExecutable="true">
<startEvent id="startevent1" name="Start">startEvent>
<userTask id="submit" name="提交请假申请" activiti:assignee="#{userId}">
<documentation>提交请假申请documentation>
userTask>
<sequenceFlow id="flow1" sourceRef="startevent1" targetRef="submit">sequenceFlow>
<exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway" default="flow11">exclusiveGateway>
<sequenceFlow id="flow2" sourceRef="submit" targetRef="exclusivegateway1">sequenceFlow>
<userTask id="usertask1" name="【项目组长】审核" activiti:candidateUsers="#{projectGroup}">
<documentation>项目组长审核documentation>
userTask>
<sequenceFlow id="flow3" name="${days<=0.5}" sourceRef="exclusivegateway1" targetRef="usertask1">
<conditionExpression xsi:type="tFormalExpression">conditionExpression>
sequenceFlow>
<userTask id="usertask2" name="【总经理】审核" activiti:candidateUsers="#{lead}">
<documentation>总经理审核documentation>
userTask>
<sequenceFlow id="flow4" name="${days>1}" sourceRef="exclusivegateway1" targetRef="usertask2">
<conditionExpression xsi:type="tFormalExpression">1}]]>conditionExpression>
sequenceFlow>
<sequenceFlow id="flow5" name="同意" sourceRef="usertask1" targetRef="usertask2">
<conditionExpression xsi:type="tFormalExpression">conditionExpression>
sequenceFlow>
<userTask id="usertask3" name="【项目经理】审核" activiti:candidateUsers="#{leadGroup}">
<documentation>项目经理审核documentation>
userTask>
<sequenceFlow id="flow6" name="${days>0.5 && days<=1}" sourceRef="exclusivegateway1" targetRef="usertask3">
<conditionExpression xsi:type="tFormalExpression">0.5 && days<=1}]]>conditionExpression>
sequenceFlow>
<sequenceFlow id="flow7" name="同意" sourceRef="usertask3" targetRef="usertask2">
<conditionExpression xsi:type="tFormalExpression">conditionExpression>
sequenceFlow>
<endEvent id="endevent1" name="End">endEvent>
<sequenceFlow id="flow8" name="同意" sourceRef="usertask2" targetRef="endevent1">
<conditionExpression xsi:type="tFormalExpression">conditionExpression>
sequenceFlow>
<sequenceFlow id="flow9" name="驳回" sourceRef="usertask2" targetRef="submit">
<conditionExpression xsi:type="tFormalExpression">conditionExpression>
sequenceFlow>
<sequenceFlow id="flow10" name="驳回" sourceRef="usertask1" targetRef="submit">
<conditionExpression xsi:type="tFormalExpression">conditionExpression>
sequenceFlow>
<sequenceFlow id="flow11" name="驳回" sourceRef="usertask3" targetRef="submit">
<conditionExpression xsi:type="tFormalExpression">conditionExpression>
sequenceFlow>
process>
<bpmndi:BPMNDiagram id="BPMNDiagram_troubleHoliday">
<bpmndi:BPMNPlane bpmnElement="troubleHoliday" id="BPMNPlane_troubleHoliday">
<bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
<omgdc:Bounds height="35.0" width="35.0" x="20.0" y="319.0">omgdc:Bounds>
bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="submit" id="BPMNShape_submit">
<omgdc:Bounds height="55.0" width="105.0" x="100.0" y="309.0">omgdc:Bounds>
bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
<omgdc:Bounds height="35.0" width="35.0" x="700.0" y="319.0">omgdc:Bounds>
bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
<omgdc:Bounds height="40.0" width="40.0" x="260.0" y="316.0">omgdc:Bounds>
bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
<omgdc:Bounds height="55.0" width="105.0" x="370.0" y="200.0">omgdc:Bounds>
bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
<omgdc:Bounds height="55.0" width="105.0" x="540.0" y="309.0">omgdc:Bounds>
bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask3" id="BPMNShape_usertask3">
<omgdc:Bounds height="55.0" width="105.0" x="380.0" y="430.0">omgdc:Bounds>
bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="55.0" y="336.0">omgdi:waypoint>
<omgdi:waypoint x="100.0" y="336.0">omgdi:waypoint>
bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="205.0" y="336.0">omgdi:waypoint>
<omgdi:waypoint x="260.0" y="336.0">omgdi:waypoint>
bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
<omgdi:waypoint x="280.0" y="356.0">omgdi:waypoint>
<omgdi:waypoint x="432.0" y="430.0">omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="42.0" width="100.0" x="10.0" y="0.0">omgdc:Bounds>
bpmndi:BPMNLabel>
bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
<omgdi:waypoint x="432.0" y="430.0">omgdi:waypoint>
<omgdi:waypoint x="592.0" y="364.0">omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="24.0" x="10.0" y="0.0">omgdc:Bounds>
bpmndi:BPMNLabel>
bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
<omgdi:waypoint x="645.0" y="336.0">omgdi:waypoint>
<omgdi:waypoint x="700.0" y="336.0">omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="24.0" x="10.0" y="0.0">omgdc:Bounds>
bpmndi:BPMNLabel>
bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
<omgdi:waypoint x="592.0" y="309.0">omgdi:waypoint>
<omgdi:waypoint x="592.0" y="192.0">omgdi:waypoint>
<omgdi:waypoint x="152.0" y="194.0">omgdi:waypoint>
<omgdi:waypoint x="152.0" y="309.0">omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="24.0" x="10.0" y="0.0">omgdc:Bounds>
bpmndi:BPMNLabel>
bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
<omgdi:waypoint x="370.0" y="227.0">omgdi:waypoint>
<omgdi:waypoint x="152.0" y="227.0">omgdi:waypoint>
<omgdi:waypoint x="152.0" y="309.0">omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="24.0" x="10.0" y="0.0">omgdc:Bounds>
bpmndi:BPMNLabel>
bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">
<omgdi:waypoint x="380.0" y="457.0">omgdi:waypoint>
<omgdi:waypoint x="152.0" y="457.0">omgdi:waypoint>
<omgdi:waypoint x="152.0" y="364.0">omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="24.0" x="10.0" y="0.0">omgdc:Bounds>
bpmndi:BPMNLabel>
bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="280.0" y="316.0">omgdi:waypoint>
<omgdi:waypoint x="422.0" y="255.0">omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="65.0" x="10.0" y="0.0">omgdc:Bounds>
bpmndi:BPMNLabel>
bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
<omgdi:waypoint x="300.0" y="336.0">omgdi:waypoint>
<omgdi:waypoint x="540.0" y="336.0">omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="50.0" x="10.0" y="0.0">omgdc:Bounds>
bpmndi:BPMNLabel>
bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
<omgdi:waypoint x="422.0" y="255.0">omgdi:waypoint>
<omgdi:waypoint x="592.0" y="309.0">omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="100.0" x="10.0" y="0.0">omgdc:Bounds>
bpmndi:BPMNLabel>
bpmndi:BPMNEdge>
bpmndi:BPMNPlane>
bpmndi:BPMNDiagram>
definitions>