生活随笔
收集整理的這篇文章主要介紹了
activiti学习--08 连线
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
測試數據
sequenceFlow.bpmn
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test"><process id="sequenceFlow" name="sequenceFlowProcess" isExecutable="true"><startEvent id="startevent1" name="Start"></startEvent><userTask id="usertask1" name="部門經理審批" activiti:assignee="陳經理"></userTask><sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow><endEvent id="endevent1" name="End"></endEvent><sequenceFlow id="flow2" name="二級費用" sourceRef="usertask1" targetRef="endevent1"><conditionExpression xsi:type="tFormalExpression"><![CDATA[${message=="二級費用"}]]></conditionExpression></sequenceFlow><userTask id="usertask2" name="總經理審批" activiti:assignee="陳總裁"></userTask><sequenceFlow id="flow3" name="一級費用" sourceRef="usertask1" targetRef="usertask2"><conditionExpression xsi:type="tFormalExpression"><![CDATA[${message=="一級費用"}]]></conditionExpression></sequenceFlow><sequenceFlow id="flow4" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow></process><bpmndi:BPMNDiagram id="BPMNDiagram_sequenceFlow"><bpmndi:BPMNPlane bpmnElement="sequenceFlow" id="BPMNPlane_sequenceFlow"><bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1"><omgdc:Bounds height="35.0" width="35.0" x="340.0" y="100.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1"><omgdc:Bounds height="55.0" width="105.0" x="305.0" y="180.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1"><omgdc:Bounds height="35.0" width="35.0" x="340.0" y="390.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2"><omgdc:Bounds height="55.0" width="105.0" x="510.0" y="260.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1"><omgdi:waypoint x="357.0" y="135.0"></omgdi:waypoint><omgdi:waypoint x="357.0" y="180.0"></omgdi:waypoint></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2"><omgdi:waypoint x="357.0" y="235.0"></omgdi:waypoint><omgdi:waypoint x="357.0" y="390.0"></omgdi:waypoint><bpmndi:BPMNLabel><omgdc:Bounds height="14.0" width="48.0" x="308.0" y="300.0"></omgdc:Bounds></bpmndi:BPMNLabel></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3"><omgdi:waypoint x="357.0" y="235.0"></omgdi:waypoint><omgdi:waypoint x="562.0" y="260.0"></omgdi:waypoint><bpmndi:BPMNLabel><omgdc:Bounds height="14.0" width="48.0" x="387.0" y="241.0"></omgdc:Bounds></bpmndi:BPMNLabel></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4"><omgdi:waypoint x="562.0" y="315.0"></omgdi:waypoint><omgdi:waypoint x="357.0" y="390.0"></omgdi:waypoint></bpmndi:BPMNEdge></bpmndi:BPMNPlane></bpmndi:BPMNDiagram>
</definitions> /**部署流程定義(從inputStream)*/@Testpublic void deploymentProcessDefinition_inputStream(){InputStream inputStreamBpmn =
this.getClass().getResourceAsStream(
"sequenceFlow.bpmn");InputStream inputStreamPng =
this.getClass().getResourceAsStream(
"sequenceFlow.png");Deployment deployment = processEngine.getRepositoryService().createDeployment().name(
"連線").addInputStream(
"sequenceFlow.bpmn", inputStreamBpmn).addInputStream(
"sequenceFlow.png", inputStreamPng).deploy();System.out.println(
"部署ID:"+deployment.getId());System.out.println(
"部署名稱:"+deployment.getName()); System.out.println(
"部署時間:"+deployment.getDeploymentTime());
}
/**啟動流程實例*/@Testpublic void startProcessInstance(){String processDefinitionKey =
"sequenceFlow";ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey(processDefinitionKey);System.out.println(
"流程實例ID:"+pi.getId());System.out.println(
"流程定義ID:"+pi.getProcessDefinitionId());
}
測試
1先查看陳經理的當前任務
/**查詢當前人的個人任務*/@Testpublic void findMyPersonalTask(){String assignee =
"陳經理";List<Task> list = processEngine.getTaskService().createTaskQuery()
/**查詢條件(where部分)*/.taskAssignee(assignee)
/**排序*/.orderByTaskCreateTime().asc()
/**返回結果集*/
.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());
}}}
2通過流程變量來控制流程連線
/**完成我的任務*/@Testpublic void completeMyPersonalTask(){String taskId =
"2704";Map<String, Object> variables =
new HashMap<String, Object>();variables.put(
"message",
"一級費用");processEngine.getTaskService().complete(taskId,variables);System.out.println(
"完成任務:任務ID:"+taskId);
}
查看數據庫當前運行的任務表
可以看到任務已經走到總經理審批了。
同理當完成任務那里設置流程變量為二級費用,那么任務就走向結束
轉載于:https://www.cnblogs.com/feiZhou/p/9344112.html
新人創作打卡挑戰賽發博客就能抽獎!定制產品紅包拿不停!
總結
以上是生活随笔為你收集整理的activiti学习--08 连线的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。