<?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="${assigneeList}"><multiInstanceLoopCharacteristics isSequential="false"><completionCondition>${nrOfCompletedInstances/nrOfInstances >= 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="165.0" y="135.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="315.0" y="135.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="264.9499999999581" y="175.0"></omgdi:waypoint><omgdi:waypoint x="315.0" y="175.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.94340692927761" y="177.55019845363262"></omgdi:waypoint><omgdi:waypoint x="164.99999999999906" y="176.4985"></omgdi:waypoint></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="sid-A4710C6E-E9FB-4004-A588-6C21A712591E" id="BPMNEdge_sid-A4710C6E-E9FB-4004-A588-6C21A712591E"><omgdi:waypoint x="414.95000000000005" y="175.0"></omgdi:waypoint><omgdi:waypoint x="440.0" y="175.0"></omgdi:waypoint><omgdi:waypoint x="440.0" y="178.0"></omgdi:waypoint><omgdi:waypoint x="465.0" y="178.0"></omgdi:waypoint></bpmndi:BPMNEdge></bpmndi:BPMNPlane></bpmndi:BPMNDiagram>
</definitions>
/*** 启动流程** @param users 用户组* @param processName 流程key* @return 流程id*/
@PostMapping("startGroup")
@ResponseBody
public String start_process_group(@RequestParam(value = "users", required = false) String[] users, @RequestParam(value = "processName", required = false) String processName) {List<String> assigneeList = Arrays.asList("group1", "group2", "group3", "group4", "group5");String s = flowableUtil.startProcess(assigneeList, processName);return s;
}
/*** 启动流程** @param assigneeList 候选组* @param processName 流程key*/
public String startProcess(List<String> assigneeList, String processName) {//启动流程Map<String, Object> map = CollectionUtil.singletonMap("assigneeList", assigneeList);map.put("num", assigneeList.size());ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processName, map);saveFLowModel(processInstance.getId(), processName);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,也就是一个人通过流程便通过