项目地址 | https://gitee.com/lwj/flowable.git |
---|
代码分支 | flowable-base |
视频讲解地址 | https://space.bilibili.com/485524575/channel/detail?cid=94579 |
用户名 | 密码 |
---|
0000001 | test |
0000002 | test |
0000003 | test |
0000004 | test |
1. 演示
2. 代码分享
public byte[] createImage(String processInstanceId) {//1.获取当前的流程实例ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();String processDefinitionId = null;List<String> activeActivityIds = new ArrayList<>();List<String> highLightedFlows = new ArrayList<>();//2.获取所有的历史轨迹线对象List<HistoricActivityInstance> historicSquenceFlows = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).activityType(BpmnXMLConstants.ELEMENT_SEQUENCE_FLOW).list();historicSquenceFlows.forEach(historicActivityInstance -> highLightedFlows.add(historicActivityInstance.getActivityId()));//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();//3.3. 获取结束节点列表List<HistoricActivityInstance> historicEnds = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).activityType(BpmnXMLConstants.ELEMENT_EVENT_END).list();List<String> finalActiveActivityIds = activeActivityIds;historicEnds.forEach(historicActivityInstance -> finalActiveActivityIds.add(historicActivityInstance.getActivityId()));}//4. 获取bpmnModel对象BpmnModel bpmnModel = flowableBpmnModelService.getBpmnModelByProcessDefId(processDefinitionId);//5. 生成图片流InputStream inputStream = flowProcessDiagramGenerator.generateDiagram(bpmnModel, activeActivityIds, highLightedFlows);//6. 转化成byte便于网络传输byte[] datas = IoUtil.readInputStream(inputStream, "image inputStream name");return datas;}