|
|
|
@@ -355,49 +355,55 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void genProcessDiagram(HttpServletResponse httpServletResponse, String processInstanceId) throws Exception { |
|
|
|
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); |
|
|
|
|
|
|
|
//流程走完的不显示图 |
|
|
|
if (pi == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult(); |
|
|
|
//使用流程实例ID,查询正在执行的执行对象表,返回流程实例对象 |
|
|
|
String InstanceId = task.getProcessInstanceId(); |
|
|
|
List<Execution> executions = runtimeService |
|
|
|
.createExecutionQuery() |
|
|
|
.processInstanceId(InstanceId) |
|
|
|
.list(); |
|
|
|
|
|
|
|
//得到正在执行的Activity的Id |
|
|
|
List<String> activityIds = new ArrayList<>(); |
|
|
|
List<String> flows = new ArrayList<>(); |
|
|
|
for (Execution exe : executions) { |
|
|
|
List<String> ids = runtimeService.getActiveActivityIds(exe.getId()); |
|
|
|
activityIds.addAll(ids); |
|
|
|
} |
|
|
|
public void genProcessDiagram(HttpServletResponse httpServletResponse,String businessId) throws Exception { |
|
|
|
List<WxFlowRecord> result = wxFlowRecordService.findList(new WxFlowRecord(Long.parseLong(businessId))); |
|
|
|
if(CollectionUtils.isNotEmpty(result)) { |
|
|
|
String processInstanceId = result.get(0).getProcessInstanceId(); |
|
|
|
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); |
|
|
|
|
|
|
|
//获取流程图 |
|
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(pi.getProcessDefinitionId()); |
|
|
|
ProcessEngineConfiguration engconf = processEngine.getProcessEngineConfiguration(); |
|
|
|
ProcessDiagramGenerator diagramGenerator = engconf.getProcessDiagramGenerator(); |
|
|
|
InputStream in = diagramGenerator.generateDiagram(bpmnModel, "png", activityIds, flows, engconf.getActivityFontName(), engconf.getLabelFontName(), engconf.getAnnotationFontName(), engconf.getClassLoader(), 1.0,true); |
|
|
|
OutputStream out = null; |
|
|
|
byte[] buf = new byte[1024]; |
|
|
|
int legth = 0; |
|
|
|
try { |
|
|
|
out = httpServletResponse.getOutputStream(); |
|
|
|
while ((legth = in.read(buf)) != -1) { |
|
|
|
out.write(buf, 0, legth); |
|
|
|
//流程走完的不显示图 |
|
|
|
if (pi == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
} finally { |
|
|
|
if (in != null) { |
|
|
|
in.close(); |
|
|
|
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult(); |
|
|
|
//使用流程实例ID,查询正在执行的执行对象表,返回流程实例对象 |
|
|
|
String InstanceId = task.getProcessInstanceId(); |
|
|
|
List<Execution> executions = runtimeService |
|
|
|
.createExecutionQuery() |
|
|
|
.processInstanceId(InstanceId) |
|
|
|
.list(); |
|
|
|
|
|
|
|
//得到正在执行的Activity的Id |
|
|
|
List<String> activityIds = new ArrayList<>(); |
|
|
|
List<String> flows = new ArrayList<>(); |
|
|
|
for (Execution exe : executions) { |
|
|
|
List<String> ids = runtimeService.getActiveActivityIds(exe.getId()); |
|
|
|
activityIds.addAll(ids); |
|
|
|
} |
|
|
|
if (out != null) { |
|
|
|
out.close(); |
|
|
|
|
|
|
|
//获取流程图 |
|
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(pi.getProcessDefinitionId()); |
|
|
|
ProcessEngineConfiguration engconf = processEngine.getProcessEngineConfiguration(); |
|
|
|
ProcessDiagramGenerator diagramGenerator = engconf.getProcessDiagramGenerator(); |
|
|
|
InputStream in = diagramGenerator.generateDiagram(bpmnModel, "png", activityIds, flows, engconf.getActivityFontName(), engconf.getLabelFontName(), engconf.getAnnotationFontName(), engconf.getClassLoader(), 1.0,true); |
|
|
|
OutputStream out = null; |
|
|
|
byte[] buf = new byte[1024]; |
|
|
|
int legth = 0; |
|
|
|
try { |
|
|
|
out = httpServletResponse.getOutputStream(); |
|
|
|
while ((legth = in.read(buf)) != -1) { |
|
|
|
out.write(buf, 0, legth); |
|
|
|
} |
|
|
|
} finally { |
|
|
|
if (in != null) { |
|
|
|
in.close(); |
|
|
|
} |
|
|
|
if (out != null) { |
|
|
|
out.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
throw new MallinkException(Result.ERROR, "找不到审批历史"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|