public static void getFloawableImgae(HttpServletResponse response,String processInstanceId) throws Exception{
HistoricProcessInstance his = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
BpmnModel bpmnModel = repositoryService.getBpmnModel(his.getProcessDefinitionId());
DefaultProcessDiagramGenerator defaultProcessDiagramGenerator = new DefaultProcessDiagramGenerator();
//得到高亮的流程 processInstanceId这个应该是executionId
List<String>
highLightedActivities=runtimeService.getActiveActivityIds(processInstanceId);
List<String> highLightedFlows=new ArrayList<String>();
//防止图片乱码
InputStream in = defaultProcessDiagramGenerator.generateDiagram(bpmnModel, "png", highLightedActivities,
highLightedFlows,"宋体","宋体","宋体",null, 1.0);
byte data[] = readInputStream(in);
ServletOutputStream os = response.getOutputStream();
os.write(data);
os.flush();
}
public static byte[] readInputStream(InputStream inStream) throws Exception{
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[2048];
int len = 0;
while( (len=inStream.read(buffer)) != -1 ){
outStream.write(buffer, 0, len);
}
inStream.close();
return outStream.toByteArray();
}