首页 > 其他 > 详细

flowable 多实例动态添加人

时间:2019-01-24 18:20:28      阅读:1263      评论:0      收藏:0      [点我收藏+]

背景:

由于在日常情况下,我们的多实例要动态添加人员的场景,有没有这样的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) "对象值"));

 

flowable 多实例动态添加人

原文:https://www.cnblogs.com/liuwenjun/p/10315993.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!