日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

activiti学习--08 连线

發布時間:2025/3/17 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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()//與流程定義和部署對象相關的Service.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()); // 部署ID:2601 // 部署名稱:連線 // 部署時間:Wed Sep 06 20:23:15 CST 2017}/**啟動流程實例*/@Testpublic void startProcessInstance(){//流程定義的key.,key對應helloworld.bpmn文件中id的屬性值,使用key值啟動,默認是按照最新版本的流程定義啟動String processDefinitionKey = "sequenceFlow";ProcessInstance pi = processEngine.getRuntimeService()//與正在執行的流程實例和執行對象相關的Service.startProcessInstanceByKey(processDefinitionKey);//使用流程定義的key啟動流程實例,System.out.println("流程實例ID:"+pi.getId());// System.out.println("流程定義ID:"+pi.getProcessDefinitionId());// // 流程實例ID:2701 // 流程定義ID:sequenceFlow:4:2604}

測試
1先查看陳經理的當前任務

/**查詢當前人的個人任務*/@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()); // 任務ID:2704 // 任務名稱:部門經理審批 // 任務的創建時間:Wed Sep 06 20:23:31 CST 2017 // 任務的辦理人:陳經理 // 流程實例ID:2701 // 執行對象ID:2701 // 流程定義ID:sequenceFlow:4:2604}}}

2通過流程變量來控制流程連線

/**完成我的任務*/@Testpublic void completeMyPersonalTask(){//任務IDString taskId = "2704";//完成任務的同時,設置流程變量,使用流程變量用來指定完成任務后,下一個連線,對應sequenceFlow.bpmn文件中${message=='不重要'}Map<String, Object> variables = new HashMap<String, Object>();variables.put("message", "一級費用");//通過流程變量來控制流程的路線processEngine.getTaskService()//與正在執行的任務管理相關的Service.complete(taskId,variables);System.out.println("完成任務:任務ID:"+taskId); // 完成任務:任務ID:2704}

查看數據庫當前運行的任務表

可以看到任務已經走到總經理審批了。

同理當完成任務那里設置流程變量為二級費用,那么任務就走向結束

轉載于:https://www.cnblogs.com/feiZhou/p/9344112.html

新人創作打卡挑戰賽發博客就能抽獎!定制產品紅包拿不停!

總結

以上是生活随笔為你收集整理的activiti学习--08 连线的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。