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 {
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>();
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<>();
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;
}
本作品採用《CC 協議》,轉載必須註明作者和本文連結