流程分支、聚合。流程每个分支节点都全部处理完成后,聚合到下一个节点。
JPDL
<?xml version="1.0" encoding="UTF-8"?>
<process key="fork" name="fork" xmlns="http://jbpm.org/4.4/jpdl">
<start g="56,154,48,48" name="start1">
<transition g="-63,-25" name="to fork1" to="fork1"/>
</start>
<end g="623,278,48,48" name="end1"/>
<fork g="191,158,48,48" name="fork1">
<transition g="-36,-25" name="to A" to="A"/>
<transition g="-34,-25" name="to B" to="B"/>
<transition g="-35,-25" name="to C" to="C"/>
</fork>
<join g="509,168,48,48" name="join1">
<transition g="-25,-26" name="to task1" to="合并"/>
</join>
<task assignee="userA" g="362,54,92,52" name="A">
<transition g="-61,-25" name="to join1" to="join1"/>
</task>
<task assignee="userB" g="360,160,92,52" name="B">
<transition g="-61,-25" name="to join1" to="join1"/>
</task>
<task assignee="userC" g="369,270,92,52" name="C">
<transition g="-61,-25" name="to join1" to="join1"/>
</task>
<task assignee="userM" g="607,167,92,52" name="合并">
<transition g="-54,-12" name="to end1" to="end1"/>
</task>
</process>
流程操作代码
//流程部署
public void deploy() {
super.startUp();
repositoryService.createDeployment().addResourceFromClasspath("com/tgb/node/fork/fork.jpdl.xml").deploy();
}
//创建流程实例
public void createInstance() {
super.startUp();
ProcessInstance processInstance = executionService.startProcessInstanceByKey("fork");
print("流程实例ID",processInstance.getId());
}
获取当前节点
public void getCurrectActivity() {
super.startUp();
String name = executionService.createProcessInstanceQuery().processInstanceId("fork.10001").uniqueResult().findActiveActivityNames().toString();
print("当前节点",name);
}
//获取任务列表
public void getTask() {
super.startUp();
List<Task> tasks = taskService.findPersonalTasks("userM");
print("任务节点名称",tasks.get(0).getActivityName());
print("任务节点ID",tasks.get(0).getId());
}
//完成任务
public void completeTask() {
super.startUp();
taskService.completeTask("20001");
}