Activiti⼯作流--并⾏⽹关--之九
流程的业务描述会议记录会签
并⾏⽹关是不需要设置流程变量的,并⾏⽹关不在流程变量的范围内
⽐如:
在开完某个产品设计会以后,需要对会议约定⼀些事项进⾏签字画押涉及到两个部门(产品部/研发部)的主管和经理
确认的顺序:
a:产品部的主管确认然后产品部的经理确认
b:研发部的主管确认 然后研发部的经理确认
注意:以上两个处理步骤可以同时进⾏,都完成以后,代表流程结束
先获取连接
private ProcessEngine processEngine;
@Before
public void intiProcessEngine(){
processEngine = DefaultProcessEngine();
}
流程定义与部署
@Test
public void testProcessEngine(){
Deployment deployment = RepositoryService()
.createDeployment()
.addClasspathResource("diagram/parallelGateWay.bpmn")
.addClasspathResource("diagram/parallelGateWay.png")
.
name("并⾏会签")
.deploy();
System.out.println("流程部署ID:"+Id());//152501
System.out.println("流程部署名称:"+Name());
}
流程图
parallelGateWay.bpmn代码
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="/spec/BPMN/20100524/MODEL" xmlns:xsi="/2001/XMLSchema-instance" xmlns:xsd="www. w3.org/2001/XMLSchema" xmlns:activiti="/bpmn" xmlns:bpmndi="/spec/BPMN/20100524/DI" xmlns:omgdc="www. /s
pec/DD/20100524/DC" xmlns:omgdi="/spec/DD/20100524/DI" typeLanguage="/2001/XMLSchema" express ionLanguage="/1999/XPath" targetNamespace="/test">
<process id="parallelGateWay" name="parallelGateWayProcess" isExecutable="true">
<startEvent id="startevent1" name="Start"></startEvent>
<parallelGateway id="parallelgateway1" name="Parallel Gateway"></parallelGateway>
<sequenceFlow id="flow1" sourceRef="startevent1" targetRef="parallelgateway1"></sequenceFlow>
<userTask id="usertask1" name="产品主管确认" activiti:assignee="张三"></userTask>
<sequenceFlow id="flow2" sourceRef="parallelgateway1" targetRef="usertask1"></sequenceFlow>
<userTask id="usertask2" name="研发主管确认" activiti:assignee="王五"></userTask>
<sequenceFlow id="flow3" sourceRef="parallelgateway1" targetRef="usertask2"></sequenceFlow>
<userTask id="usertask3" name="产品经理确认" activiti:assignee="李四"></userTask>
<sequenceFlow id="flow4" sourceRef="usertask1" targetRef="usertask3"></sequenceFlow>
<userTask id="usertask4" name="研发经理确认" activiti:assignee="赵六"></userTask>
<sequenceFlow id="flow5" sourceRef="usertask2" targetRef="usertask4"></sequenceFlow>
<parallelGateway id="parallelgateway2" name="Parallel Gateway"></parallelGateway>
<sequenceFlow id="flow6" sourceRef="usertask3" targetRef="parallelgateway2"></sequenceFlow>
<sequenceFlow id="flow7" sourceRef="usertask4" targetRef="parallelgateway2"></sequenceFlow>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow8" sourceRef="parallelgateway2" targetRef="endevent1"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_parallelGateWay">
<bpmndi:BPMNPlane bpmnElement="parallelGateWay" id="BPMNPlane_parallelGateWay"> <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
<omgdc:Bounds height="35.0" width="35.0" x="80.0" y="160.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="parallelgateway1" id="BPMNShape_parallelgateway1"> <omgdc:Bounds height="40.0" width="40.0" x="160.0" y="158.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
<omgdc:Bounds height="55.0" width="105.0" x="240.0" y="60.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
<omgdc:Bounds height="55.0" width="105.0" x="240.0" y="240.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask3" id="BPMNShape_usertask3">
<omgdc:Bounds height="55.0" width="105.0" x="390.0" y="60.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask4" id="BPMNShape_usertask4">
<omgdc:Bounds height="55.0" width="105.0" x="390.0" y="240.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="parallelgateway2" id="BPMNShape_parallelgateway2"> <omgdc:Bounds height="40.0" width="40.0" x="540.0" y="158.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
<omgdc:Bounds height="35.0" width="35.0" x="625.0" y="161.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="115.0" y="177.0"></omgdi:waypoint>
<omgdi:waypoint x="160.0" y="178.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="180.0" y="158.0"></omgdi:waypoint>
<omgdi:waypoint x="292.0" y="115.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="180.0" y="198.0"></omgdi:waypoint>
<omgdi:waypoint x="292.0" y="240.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
<omgdi:waypoint x="345.0" y="87.0"></omgdi:waypoint>
<omgdi:waypoint x="390.0" y="87.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
<omgdi:waypoint x="345.0" y="267.0"></omgdi:waypoint>
<omgdi:waypoint x="390.0" y="267.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
<omgdi:waypoint x="442.0" y="115.0"></omgdi:waypoint>
<omgdi:waypoint x="560.0" y="158.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
<omgdi:waypoint x="442.0" y="240.0"></omgdi:waypoint>
<omgdi:waypoint x="560.0" y="198.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
<omgdi:waypoint x="580.0" y="178.0"></omgdi:waypoint>
<omgdi:waypoint x="625.0" y="178.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
启动流程
@Test
public void testStartTask(){
String processDefinitionKey ="parallelGateWay";
ProcessInstance processInstance = RuntimeService()
.startProcessInstanceByKey(processDefinitionKey);
System.out.println("流程部署ID:"+DeploymentId());
System.out.println("流程定义ID:"+ProcessDefinitionId());
System.out.println("流程实例ID:"+ProcessInstanceId());//155001 }
查询个⼈,完成个⼈任务
/**
* 流程处理过程:查询个⼈任务
*/
@Test
public void testTaskQuery(){
String assignee ="赵六";
String processInstanceId ="155001";
List<Task> taskList = TaskService()
.createTaskQuery()
.taskAssignee(assignee)
.processInstanceId(processInstanceId)
.list();
if(taskList !=null&& taskList.size()>0){
for(Task task : taskList){
System.out.println("流程定义ID:"+ProcessDefinitionId());
System.out.println("流程实例ID:"+ProcessInstanceId());
System.out.println("执⾏对象ID:"+ExecutionId());
System.out.println("任务ID:"+Id());//155007
System.out.println("任务名称:"+Name());
System.out.println("任务创建时间:"+CreateTime());
}
}
}
/**
* 流程处理过程:完成个⼈任务
*/
@Test
public void testCompleteTask(){
String taskId ="162502";
System.out.println("财务主管审批完成");
}
/**createprocessa
* 在流程的执⾏过程中,我们需要查询流程执⾏到了哪⼀个状态
* 查询的是act_ru_execution  流程实例表
* 当流程结束了那么在act_ru_execution 在这张表中就没有了数据记录
*/
@Test
public void testQueryProinsatanceState(){
String processInstanceId ="155001";
ProcessInstance singleResult = RuntimeService() .createProcessInstanceQuery()
.processInstanceId(processInstanceId)
.singleResult();
if(singleResult !=null){
System.out.println("流程执⾏到:"+ActivityId());
}else{
System.out.println("流程执⾏完毕");
}
}
总结
并⾏⽹关的分⽀和汇聚都是同⼀个图元符号(图标)
并⾏⽹关不会解析条件,所以流程变量的设置不会引起流程的其他选择并⾏⽹关的分⽀⾥⾯可以再进⾏分⽀和聚合

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。