activiti之排他网关,流程变量

请假流程
利用junit4测试
1. 部署流程模版

@Test
    @Deployment(resources="diagrams/troubleHoliday.bpmn")
    public void deployTroubleHoliday(){
        org.activiti.engine.repository.Deployment deployment = engine.getRepositoryService().createDeployment().addClasspathResource("diagrams/troubleHoliday.bpmn").deploy();
    }
  1. 启动流程
@Test
    @Deployment(resources="diagrams/troubleHoliday.bpmn")
    public void startProcess(){
        Map<String, Object> variables = new HashMap<String, Object>();
        variables.put("userId", "1");
        ProcessInstance instance = engine.getRuntimeService().startProcessInstanceByKey("troubleHoliday",variables);
    }
  1. 下一步排他网关过滤条件
@Test
    @Deployment(resources="diagrams/troubleHoliday.bpmn")
    public void panDuan(){
        Task task = engine.getTaskService().createTaskQuery().processInstanceId("167501").active().singleResult();
        Map<String, Object> variables = new HashMap<String, Object>();
        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(模版中的变量赋值情况)查看记录。
该配置文件详细

<?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: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&lt;=0.5}" sourceRef="exclusivegateway1" targetRef="usertask1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${days<=0.5}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="usertask2" name="【总经理】审核" activiti:candidateUsers="#{lead}">
      <documentation>总经理审核</documentation>
    </userTask>
    <sequenceFlow id="flow4" name="${days&gt;1}" sourceRef="exclusivegateway1" targetRef="usertask2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${days>1}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow5" name="同意" sourceRef="usertask1" targetRef="usertask2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action=='同意'}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="usertask3" name="【项目经理】审核" activiti:candidateUsers="#{leadGroup}">
      <documentation>项目经理审核</documentation>
    </userTask>
    <sequenceFlow id="flow6" name="${days&gt;0.5 &amp;&amp; days&lt;=1}" sourceRef="exclusivegateway1" targetRef="usertask3">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${days>0.5 && days<=1}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow7" name="同意" sourceRef="usertask3" targetRef="usertask2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action=='同意'}]]></conditionExpression>
    </sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow8" name="同意" sourceRef="usertask2" targetRef="endevent1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action=='同意'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow9" name="驳回" sourceRef="usertask2" targetRef="submit">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action=='驳回'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow10" name="驳回" sourceRef="usertask1" targetRef="submit">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action=='驳回'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow11" name="驳回" sourceRef="usertask3" targetRef="submit">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action=='驳回'}]]></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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值