您好,登錄后才能下訂單哦!
這篇文章主要介紹“如何實現flowable工作流辦理過的節點描高亮顏色”,在日常操作中,相信很多人在如何實現flowable工作流辦理過的節點描高亮顏色問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”如何實現flowable工作流辦理過的節點描高亮顏色”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
在正常的flowable就是顯示當前節點,路徑需要我們自己獲取,特別是來回的駁回會導致節點混亂,這里主要就是如何正確的顯示流程圖
效果:
已經結束的流程
正在執行的流程
代碼:1、生成圖片
// 源碼 www.fhadmin.orgpublic byte[] createImage2(String processInstanceId) {//1.獲取當前的流程實例ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); String processDefinitionId = null;List<String> activeActivityIds = null;//2.獲取所有的歷史軌跡對象List<HistoricActivityInstance> list = historyService.createHistoricActivityInstanceQuery() .processInstanceId(processInstanceId).list(); Map<String, HistoricActivityInstance> hisActivityMap = new HashMap<>();list.forEach(historicActivityInstance -> {if (!hisActivityMap.containsKey(historicActivityInstance.getActivityId())) { hisActivityMap.put(historicActivityInstance.getActivityId(), historicActivityInstance); } });//3. 獲取流程定義id和高亮的節點idif (processInstance != null) {//3.1. 正在運行的流程實例processDefinitionId = processInstance.getProcessDefinitionId(); activeActivityIds = runtimeService.getActiveActivityIds(processInstanceId); } else {//3.2. 已經結束的流程實例HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); processDefinitionId = historicProcessInstance.getProcessDefinitionId(); activeActivityIds = new ArrayList<>();List<EndEvent> endEvents = bpmnModelService.findEndFlowElement(processDefinitionId);List<String> finalActiveActivityIds = activeActivityIds; endEvents.forEach(endEvent -> {if (hisActivityMap.containsKey(endEvent.getId())) { finalActiveActivityIds.add(endEvent.getId()); } }); }//4. 獲取流程定義的所有節點信息List<FlowNode> flowNodes = bpmnModelService.findFlowNodes(processDefinitionId); Map<String, FlowNode> activityMap = flowNodes.stream().collect(Collectors.toMap(FlowNode::getId, flowNode -> flowNode));List<String> highLightedFlows = new ArrayList<>();//5. 遞歸得到高亮線activeActivityIds.forEach(activeActivityId -> this.getHighLightedFlows(activityMap, hisActivityMap, activeActivityId, highLightedFlows, activeActivityId));//6. 獲取bpmnModel對象BpmnModel bpmnModel = bpmnModelService.getBpmnModelByProcessDefId(processDefinitionId);//7. 生成圖片流InputStream inputStream = flowProcessDiagramGenerator.generateDiagram(bpmnModel, activeActivityIds, highLightedFlows);//8. 轉化成byte便于網絡傳輸byte[] datas = IoUtil.readInputStream(inputStream, "image inputStream name");return datas; }
遞歸獲取高
//java項目 www.fhadmin.orgprivate void getHighLightedFlows(Map<String, FlowNode> flowNodeMap,Map<String, HistoricActivityInstance> hisActivityMap,String activeActivityId, List<String> highLightedFlows,String oldActivityId) { FlowNode flowNode = flowNodeMap.get(activeActivityId); List<SequenceFlow> 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; } } }
到此,關于“如何實現flowable工作流辦理過的節點描高亮顏色”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。