flowable 多实例流程

<?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="多实例测试" name="多实例测试" isExecutable="true">
    <documentation>多实例测试</documentation>
    <startEvent id="startEvent1"></startEvent>
    <userTask id="sid-69B389BF-845E-45FA-A44A-8A44A1F12286" name="多实例" flowable:candidateUsers="test1,test2,test3,test4">
      <multiInstanceLoopCharacteristics isSequential="false">
        <loopCardinality>4</loopCardinality>
        <completionCondition>${nrOfCompletedInstances/nrOfInstances &gt;= 0.25}</completionCondition>
      </multiInstanceLoopCharacteristics>
    </userTask>
    <sequenceFlow id="sid-B19A4BBB-F31D-493E-AFF7-B3FC0B3B6F6F" sourceRef="startEvent1" targetRef="sid-69B389BF-845E-45FA-A44A-8A44A1F12286"></sequenceFlow>
    <userTask id="sid-23E2155A-0DC7-47D4-A7D5-AF7BE11F5414" name="多实例完成" flowable:assignee="${assignee}">
      <extensionElements>
        <flowable:taskListener event="create" class="com.flowable.conf.TaskListener"></flowable:taskListener>
        <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
      </extensionElements>
    </userTask>
    <sequenceFlow id="sid-653E21AF-A7C4-4939-8EF5-7C18478686B4" sourceRef="sid-69B389BF-845E-45FA-A44A-8A44A1F12286" targetRef="sid-23E2155A-0DC7-47D4-A7D5-AF7BE11F5414"></sequenceFlow>
    <endEvent id="sid-203FE8C0-11FD-4264-A2D1-1AD3B7194832"></endEvent>
    <sequenceFlow id="sid-A4710C6E-E9FB-4004-A588-6C21A712591E" sourceRef="sid-23E2155A-0DC7-47D4-A7D5-AF7BE11F5414" targetRef="sid-203FE8C0-11FD-4264-A2D1-1AD3B7194832"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_多实例测试">
    <bpmndi:BPMNPlane bpmnElement="多实例测试" id="BPMNPlane_多实例测试">
      <bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1">
        <omgdc:Bounds height="30.0" width="30.0" x="100.0" y="163.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-69B389BF-845E-45FA-A44A-8A44A1F12286" id="BPMNShape_sid-69B389BF-845E-45FA-A44A-8A44A1F12286">
        <omgdc:Bounds height="80.0" width="100.0" x="175.0" y="138.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-23E2155A-0DC7-47D4-A7D5-AF7BE11F5414" id="BPMNShape_sid-23E2155A-0DC7-47D4-A7D5-AF7BE11F5414">
        <omgdc:Bounds height="80.0" width="100.0" x="320.0" y="138.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-203FE8C0-11FD-4264-A2D1-1AD3B7194832" id="BPMNShape_sid-203FE8C0-11FD-4264-A2D1-1AD3B7194832">
        <omgdc:Bounds height="28.0" width="28.0" x="465.0" y="164.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="sid-653E21AF-A7C4-4939-8EF5-7C18478686B4" id="BPMNEdge_sid-653E21AF-A7C4-4939-8EF5-7C18478686B4">
        <omgdi:waypoint x="274.9499999999907" y="178.0"></omgdi:waypoint>
        <omgdi:waypoint x="319.9999999999807" y="178.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-B19A4BBB-F31D-493E-AFF7-B3FC0B3B6F6F" id="BPMNEdge_sid-B19A4BBB-F31D-493E-AFF7-B3FC0B3B6F6F">
        <omgdi:waypoint x="129.9499984899576" y="178.0"></omgdi:waypoint>
        <omgdi:waypoint x="174.9999999999917" y="178.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-A4710C6E-E9FB-4004-A588-6C21A712591E" id="BPMNEdge_sid-A4710C6E-E9FB-4004-A588-6C21A712591E">
        <omgdi:waypoint x="419.95000000000005" y="178.0"></omgdi:waypoint>
        <omgdi:waypoint x="465.0" y="178.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

  

/**
 * 启动流程
 *
 * @param userId      用户Id
 * @param processName 流程key
 */
public String startProcess(String userId, String processName) {
    //启动流程
    HashMap<String, Object> map = new HashMap<>();
    map.put("assignee", userId);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processName, map);
    return "提交成功.流程Id为:" + processInstance.getId();
}

 多实例需要给用户组签收任务

/**
 * 签收任务
 */
public void claim(String taskId, String userId) {
    taskService.claim(taskId, userId);
}
查看用户未签收的任务

/**
 * 待签收任务查询
 */
public List<Task> getNotClaim(String userId) {
    return taskService.createTaskQuery().taskCandidateUser(userId).list();
}

  查看 ACT_RU_IDENTITYLINK 表

nr_of_instances 实例总数
nr_of_completed_instances 当前还没有完成的实例 nr是number单词缩写 
loop_counter 已经循环的次数
nr_of_active_instances 已经完成的实例个数
${nrofcompletedinstances/nrofinstances >= 0.25}  //条件表达式 总共4个人大于0.25,也就是一个人通过流程便通过
Loop cardinality 用户数量,用于标识起单次数

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值