Flowable通过api查询流程返回流程图节点

通过传入流程启动id去查询当前流执行节点

返回流程图 到期节点 标红显示

	    /**
	     * 生成流程图
	     *
	     * @param processId 任务ID
	     */
	    @RequestMapping(value = "processDiagram")
	    public void genProcessDiagram(HttpServletResponse httpServletResponse, String processId) throws Exception {
	        ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processId).singleResult();
	 
	        //流程走完的不显示图
	        if (pi == null) {
	            return;
	        }
	        Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
	        //使用流程实例ID,查询正在执行的执行对象表,返回流程实例对象
	        String InstanceId = task.getProcessInstanceId();
	        List executions = runtimeService.createExecutionQuery().processInstanceId(InstanceId).list();
	 
	        //得到正在执行的Activity的Id
	        List activityIds = new ArrayList<>();
	        List flows = new ArrayList<>();
	        for (Execution exe : executions) {
	            List ids = runtimeService.getActiveActivityIds(exe.getId());
	            activityIds.addAll(ids);
	        }
	 
	        //获取流程图
	        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, false);
	        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();
	            }
	        }
	    }

以上如有问题可评论 如有错误欢迎指教  我看到立马回答

请不要转载 !!!

你可能感兴趣的:(flowable)