這篇文章主要介紹“如何實(shí)現(xiàn)flowable工作流辦理過的節(jié)點(diǎn)描高亮顏色”,在日常操作中,相信很多人在如何實(shí)現(xiàn)flowable工作流辦理過的節(jié)點(diǎn)描高亮顏色問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”如何實(shí)現(xiàn)flowable工作流辦理過的節(jié)點(diǎn)描高亮顏色”的疑惑有所幫助!接下來(lái),請(qǐng)跟著小編一起來(lái)學(xué)習(xí)吧!
創(chuàng)新互聯(lián):成立于2013年為各行業(yè)開拓出企業(yè)自己的“網(wǎng)站建設(shè)”服務(wù),為上1000+公司企業(yè)提供了專業(yè)的網(wǎng)站設(shè)計(jì)、成都網(wǎng)站設(shè)計(jì)、網(wǎng)頁(yè)設(shè)計(jì)和網(wǎng)站推廣服務(wù), 按需搭建網(wǎng)站由設(shè)計(jì)師親自精心設(shè)計(jì),設(shè)計(jì)的效果完全按照客戶的要求,并適當(dāng)?shù)奶岢龊侠淼慕ㄗh,擁有的視覺效果,策劃師分析客戶的同行競(jìng)爭(zhēng)對(duì)手,根據(jù)客戶的實(shí)際情況給出合理的網(wǎng)站構(gòu)架,制作客戶同行業(yè)具有領(lǐng)先地位的。
在正常的flowable就是顯示當(dāng)前節(jié)點(diǎn),路徑需要我們自己獲取,特別是來(lái)回的駁回會(huì)導(dǎo)致節(jié)點(diǎn)混亂,這里主要就是如何正確的顯示流程圖
效果:
已經(jīng)結(jié)束的流程
正在執(zhí)行的流程
代碼:1、生成圖片
// 源碼 www.fhadmin.orgpublic byte[] createImage2(String processInstanceId) {//1.獲取當(dāng)前的流程實(shí)例ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); String processDefinitionId = null;ListactiveActivityIds = null;//2.獲取所有的歷史軌跡對(duì)象List list = historyService.createHistoricActivityInstanceQuery() .processInstanceId(processInstanceId).list(); Map hisActivityMap = new HashMap<>();list.forEach(historicActivityInstance -> {if (!hisActivityMap.containsKey(historicActivityInstance.getActivityId())) { hisActivityMap.put(historicActivityInstance.getActivityId(), historicActivityInstance); } });//3. 獲取流程定義id和高亮的節(jié)點(diǎn)idif (processInstance != null) {//3.1. 正在運(yùn)行的流程實(shí)例processDefinitionId = processInstance.getProcessDefinitionId(); activeActivityIds = runtimeService.getActiveActivityIds(processInstanceId); } else {//3.2. 已經(jīng)結(jié)束的流程實(shí)例HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); processDefinitionId = historicProcessInstance.getProcessDefinitionId(); activeActivityIds = new ArrayList<>();List endEvents = bpmnModelService.findEndFlowElement(processDefinitionId);List finalActiveActivityIds = activeActivityIds; endEvents.forEach(endEvent -> {if (hisActivityMap.containsKey(endEvent.getId())) { finalActiveActivityIds.add(endEvent.getId()); } }); }//4. 獲取流程定義的所有節(jié)點(diǎn)信息List flowNodes = bpmnModelService.findFlowNodes(processDefinitionId); Map activityMap = flowNodes.stream().collect(Collectors.toMap(FlowNode::getId, flowNode -> flowNode));List highLightedFlows = new ArrayList<>();//5. 遞歸得到高亮線activeActivityIds.forEach(activeActivityId -> this.getHighLightedFlows(activityMap, hisActivityMap, activeActivityId, highLightedFlows, activeActivityId));//6. 獲取bpmnModel對(duì)象BpmnModel bpmnModel = bpmnModelService.getBpmnModelByProcessDefId(processDefinitionId);//7. 生成圖片流InputStream inputStream = flowProcessDiagramGenerator.generateDiagram(bpmnModel, activeActivityIds, highLightedFlows);//8. 轉(zhuǎn)化成byte便于網(wǎng)絡(luò)傳輸byte[] datas = IoUtil.readInputStream(inputStream, "image inputStream name");return datas; }
遞歸獲取高
//java項(xiàng)目 www.fhadmin.orgprivate void getHighLightedFlows(MapflowNodeMap,Map hisActivityMap,String activeActivityId, List highLightedFlows,String oldActivityId) { FlowNode flowNode = flowNodeMap.get(activeActivityId); List incomingFlows = flowNode.getIncomingFlows();for (SequenceFlow sequenceFlow : incomingFlows) {String sourceRefId = sequenceFlow.getSourceRef();if (hisActivityMap.containsKey(sourceRefId) && !oldActivityId.equals(sourceRefId)) { highLightedFlows.add(sequenceFlow.getId());this.getHighLightedFlows(flowNodeMap, hisActivityMap, sourceRefId, highLightedFlows, oldActivityId); } else { if (hisActivityMap.containsKey(sourceRefId)){ highLightedFlows.add(sequenceFlow.getId()); } break; } } }
到此,關(guān)于“如何實(shí)現(xiàn)flowable工作流辦理過的節(jié)點(diǎn)描高亮顏色”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!