/**
* 获取当前任务流程图片的输入流
* @param PROC_INST_ID_ 流程实例ID
* @from fhadmin.cn
*/
public InputStream genProcessDiagram(String PROC_INST_ID_, String type){
/* 获得活动的节点 */
String processDefinitionId = "";
if (this.isFinished(PROC_INST_ID_)) { // 如果流程已经结束,则得到结束节点
HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().processInstanceId(PROC_INST_ID_).singleResult();
processDefinitionId=pi.getProcessDefinitionId();
} else { // 如果流程没有结束,则取当前活动节点
/* 根据流程实例ID获得当前处于活动状态的ActivityId合集 */
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(PROC_INST_ID_).singleResult();
processDefinitionId = pi.getProcessDefinitionId();
}
/* 获得活动的节点对象 */
List<HistoricActivityInstance> highLightedActivitList = historyService.createHistoricActivityInstanceQuery().processInstanceId(PROC_INST_ID_).orderByHistoricActivityInstanceStartTime().asc().list();
List<String> highLightedActivitis = new ArrayList<String>(); //节点对象ID
for(HistoricActivityInstance tempActivity : highLightedActivitList){
String activityId = tempActivity.getActivityId();
highLightedActivitis.add(activityId);
}
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId); //获取流程图
ProcessEngineConfiguration engconf = processEngine.getProcessEngineConfiguration();
/* 获得活动的连线对象 */
List<String> flows = new ArrayList<>(); //连线ID
if("RU".equals(type)) {
List<ActivityInstance> highLightedFlowInstances = runtimeService.createActivityInstanceQuery().activityType(BpmnXMLConstants.ELEMENT_SEQUENCE_FLOW).processInstanceId(PROC_INST_ID_).list();
for(ActivityInstance ai : highLightedFlowInstances) {
flows.add(ai.getActivityId());
}
}else {
List<HistoricActivityInstance> highLightedFlowInstances = historyService.createHistoricActivityInstanceQuery().activityType(BpmnXMLConstants.ELEMENT_SEQUENCE_FLOW).processInstanceId(PROC_INST_ID_).list();
for(HistoricActivityInstance ha : highLightedFlowInstances) {
flows.add(ha.getActivityId());
}
}
ProcessDiagramGenerator diagramGenerator = engconf.getProcessDiagramGenerator();
InputStream in = diagramGenerator.generateDiagram(bpmnModel, "png", highLightedActivitis, flows, engconf.getActivityFontName(), engconf.getLabelFontName(), engconf.getAnnotationFontName(), engconf.getClassLoader(), 1.0, true);
return in;
}
hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 »
flowable 获取当前任务流程图片的输入流