1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > activiti学习--10 并行网关

activiti学习--10 并行网关

时间:2024-06-28 10:36:41

相关推荐

activiti学习--10 并行网关

parallelGateWay.bpmn

<?xml version="1.0" encoding="UTF-8"?><definitions xmlns="/spec/BPMN/0524/MODEL" xmlns:xsi="/2001/XMLSchema-instance" xmlns:activiti="/bpmn" xmlns:bpmndi="/spec/BPMN/0524/DI" xmlns:omgdc="/spec/DD/0524/DC" xmlns:omgdi="/spec/DD/0524/DI" typeLanguage="/2001/XMLSchema" expressionLanguage="/1999/XPath" targetNamespace="/test"><process id="parallelGateWay" name="parallelGateWayProcess" isExecutable="true"><startEvent id="startevent1" name="Start"></startEvent><endEvent id="endevent1" name="End"></endEvent><userTask id="usertask1" name="付款" activiti:assignee="买家"></userTask><userTask id="usertask2" name="发货" activiti:assignee="商家"></userTask><userTask id="usertask3" name="收款" activiti:assignee="商家"></userTask><userTask id="usertask4" name="收货" activiti:assignee="买家"></userTask><parallelGateway id="parallelgateway1" name="Parallel Gateway"></parallelGateway><parallelGateway id="parallelgateway2" name="Parallel Gateway"></parallelGateway><sequenceFlow id="flow1" sourceRef="startevent1" targetRef="parallelgateway1"></sequenceFlow><sequenceFlow id="flow2" sourceRef="parallelgateway1" targetRef="usertask1"></sequenceFlow><sequenceFlow id="flow3" sourceRef="usertask1" targetRef="usertask3"></sequenceFlow><sequenceFlow id="flow4" sourceRef="usertask3" targetRef="parallelgateway2"></sequenceFlow><sequenceFlow id="flow5" sourceRef="parallelgateway2" targetRef="endevent1"></sequenceFlow><sequenceFlow id="flow6" sourceRef="parallelgateway1" targetRef="usertask2"></sequenceFlow><sequenceFlow id="flow7" sourceRef="usertask2" targetRef="usertask4"></sequenceFlow><sequenceFlow id="flow8" sourceRef="usertask4" targetRef="parallelgateway2"></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="323.0" y="20.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1"><omgdc:Bounds height="55.0" width="105.0" x="150.0" y="180.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2"><omgdc:Bounds height="55.0" width="105.0" x="450.0" y="180.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1"><omgdc:Bounds height="35.0" width="35.0" x="330.0" y="460.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="usertask3" id="BPMNShape_usertask3"><omgdc:Bounds height="55.0" width="105.0" x="150.0" y="280.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="usertask4" id="BPMNShape_usertask4"><omgdc:Bounds height="55.0" width="105.0" x="450.0" y="280.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="parallelgateway1" id="BPMNShape_parallelgateway1"><omgdc:Bounds height="40.0" width="40.0" x="320.0" y="100.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="parallelgateway2" id="BPMNShape_parallelgateway2"><omgdc:Bounds height="40.0" width="40.0" x="330.0" y="380.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1"><omgdi:waypoint x="340.0" y="55.0"></omgdi:waypoint><omgdi:waypoint x="340.0" y="100.0"></omgdi:waypoint></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2"><omgdi:waypoint x="340.0" y="140.0"></omgdi:waypoint><omgdi:waypoint x="202.0" y="180.0"></omgdi:waypoint></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3"><omgdi:waypoint x="202.0" y="235.0"></omgdi:waypoint><omgdi:waypoint x="202.0" y="280.0"></omgdi:waypoint></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4"><omgdi:waypoint x="202.0" y="335.0"></omgdi:waypoint><omgdi:waypoint x="350.0" y="380.0"></omgdi:waypoint></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5"><omgdi:waypoint x="350.0" y="420.0"></omgdi:waypoint><omgdi:waypoint x="347.0" y="460.0"></omgdi:waypoint></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6"><omgdi:waypoint x="340.0" y="140.0"></omgdi:waypoint><omgdi:waypoint x="502.0" y="180.0"></omgdi:waypoint></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7"><omgdi:waypoint x="502.0" y="235.0"></omgdi:waypoint><omgdi:waypoint x="502.0" y="280.0"></omgdi:waypoint></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8"><omgdi:waypoint x="502.0" y="335.0"></omgdi:waypoint><omgdi:waypoint x="350.0" y="380.0"></omgdi:waypoint></bpmndi:BPMNEdge></bpmndi:BPMNPlane></bpmndi:BPMNDiagram></definitions>

测试数据

/**部署流程定义(从inputStream)*/@Testpublic void deploymentProcessDefinition_inputStream(){InputStream inputStreamBpmn = this.getClass().getResourceAsStream("parallelGateWay.bpmn");InputStream inputStreamPng = this.getClass().getResourceAsStream("parallelGateWay.png");Deployment deployment = processEngine.getRepositoryService()//与流程定义和部署对象相关的Service.createDeployment()//创建一个部署对象.name("并行网关")//添加部署的名称.addInputStream("parallelGateWay.bpmn", inputStreamBpmn)//.addInputStream("parallelGateWay.png", inputStreamPng)//.deploy();//完成部署System.out.println("部署ID:"+deployment.getId());System.out.println("部署名称:"+deployment.getName()); System.out.println("部署时间:"+deployment.getDeploymentTime()); //部署ID:3201//部署名称:并行网关//部署时间:Wed Sep 06 21:02:53 CST }/**启动流程实例*/@Testpublic void startProcessInstance(){//流程定义的key.,key对应helloworld.bpmn文件中id的属性值,使用key值启动,默认是按照最新版本的流程定义启动String processDefinitionKey = "parallelGateWay";ProcessInstance pi = processEngine.getRuntimeService()//与正在执行的流程实例和执行对象相关的Service.startProcessInstanceByKey(processDefinitionKey);//使用流程定义的key启动流程实例,System.out.println("流程实例ID:"+pi.getId());// System.out.println("流程定义ID:"+pi.getProcessDefinitionId());// //流程实例ID:3301//流程定义ID:parallelGateWay:1:3204}/**查询当前人的个人任务*/@Testpublic void findMyPersonalTask(){String assignee = "商家";List<Task> list = processEngine.getTaskService()//与正在执行的任务管理相关的Service.createTaskQuery()//创建任务查询对象/**查询条件(where部分)*/.taskAssignee(assignee)//指定个人任务查询,指定办理人// .taskCandidateUser(candidateUser)//组任务的办理人查询// .processDefinitionId(processDefinitionId)//使用流程定义ID查询// .processInstanceId(processInstanceId)//使用流程实例ID查询// .executionId(executionId)//使用执行对象ID查询/**排序*/.orderByTaskCreateTime().asc()//使用创建时间的升序排列/**返回结果集*/// .singleResult()//返回惟一结果集// .count()//返回结果集的数量// .listPage(firstResult, maxResults);//分页查询.list();//返回列表if(list!=null && list.size()>0){System.out.println("--关联表: ACT_RU_TASK----");for(Task task:list){System.out.println("--------"+task.getAssignee()+"任务:"+task.getName()+"-----------------");System.out.println("任务ID:"+task.getId());System.out.println("任务名称:"+task.getName());System.out.println("任务的创建时间:"+task.getCreateTime());System.out.println("任务的办理人:"+task.getAssignee());System.out.println("流程实例ID:"+task.getProcessInstanceId());System.out.println("执行对象ID:"+task.getExecutionId());System.out.println("流程定义ID:"+task.getProcessDefinitionId());//--关联表: ACT_RU_TASK----//--------商家任务:发货-----------------//任务ID:3310//任务名称:发货//任务的创建时间:Wed Sep 06 21:03:06 CST //任务的办理人:商家//流程实例ID:3301//执行对象ID:3305//流程定义ID:parallelGateWay:1:3204}}}

分析:

1用户已经开启实例,流程走到付款节点和发货节点,这时商家和买家都要相应的任务,上面的测试数据只打印了商家数据

2下面的流程是不管商家还是买家,他们都要一步一步走下去,知道商家或买家走到聚合节点,他们相应的任务才走完,也只有商家和买家都走到聚合几点,才能通过聚合节点继续走下去,否者,都要等待对方走到聚合节点。

数据库正在执行的任务情况

当商家买家任务都执行完,数据库任务历史情况

历史活动节点情况

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。