flowable交流群:633168411

flowable 多实例动态添加人

背景:

由于在日常情况下,我们的多实例要动态添加人员的场景,有没有这样的api呢?新的flowable有这样的功能。

具体实现

xml 

<userTask id="miTasks" name="My Task ${loopCounter}" activiti:assignee="${assignee}">
      <multiInstanceLoopCharacteristics isSequential="false">
        <loopDataInputRef>assigneeList</loopDataInputRef>
        <inputDataItem name="assignee" />
        <completionCondition>${nrOfCompletedInstances/nrOfInstances >= 0.6 }</completionCondition>
      </multiInstanceLoopCharacteristics>
    </userTask>

具体实现

List<String> assigneeList = Arrays.asList("kermit", "gonzo", "mispiggy", "fozzie", "bubba");
String procId = runtimeService.startProcessInstanceByKey("miParallelUserTasksBasedOnCollection", CollectionUtil.singletonMap("assigneeList", assigneeList)).getId();
        
List<org.flowable.task.api.Task> tasks = taskService.createTaskQuery().orderByTaskAssignee().asc().list();
assertEquals(5, tasks.size());
assertEquals("bubba", tasks.get(0).getAssignee());
assertEquals("fozzie", tasks.get(1).getAssignee());
assertEquals("gonzo", tasks.get(2).getAssignee());
assertEquals("kermit", tasks.get(3).getAssignee());
assertEquals("mispiggy", tasks.get(4).getAssignee());
            
runtimeService.addMultiInstanceExecution("miTasks", procId, Collections.singletonMap("assignee", (Object) "johndoe"));
tasks = taskService.createTaskQuery().orderByTaskAssignee().asc().list();
assertEquals(6, tasks.size());

说明:

runtimeService.addMultiInstanceExecution(要加签的节点id,流程实例id, Collections.singletonMap("单个对象的别名", (Object) "对象值"));

 

posted @ 2019-01-24 17:58  小学生05101  阅读(9824)  评论(0编辑  收藏  举报
flowable交流群:633168411