activiti7查看当前流程图,解决.getProcessDiagramGenerator()报错问题。ProcessDiagramGenerator API不能用了

ProcessDiagramGenerator这个类已经移出来了,单独是一个依赖。
那么,在Pom.xml中增加


    org.activiti
    activiti-image-generator
    5.19.0.2

写法也有点变化,原来是静态方法调用,现在得new一个了。

 @Override
    public InputStream lookCurrentProcessImage(String taskId) {
        HistoricTaskInstance task = historyService// 与历史数据(历史表)相关的Service
                .createHistoricTaskInstanceQuery()// 创建历史任务实例查询
                .taskId(taskId)// 指定历史任务的办理人
                .singleResult();
        // 流程定义
        BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
        ProcessDiagramGenerator ge = new DefaultProcessDiagramGenerator();
        InputStream resource = ge.generateDiagram(bpmnModel, "png",
                runtimeService.getActiveActivityIds(task.getExecutionId()),
                new ArrayList(), "宋体", "宋体", null, 1.0d);
        return resource;
    }
/**
    * 查看当前流程图
	 */
    @GetMapping("/lookCurrentProcessImage")
    public void lookCurrentProcessImage(HttpServletRequest request, HttpServletResponse response,String taskId)throws IOException {
        InputStream imageStream = qingjiaService.lookCurrentProcessImage(taskId);
        byte[] b = new byte[1024];
        int len;
        while ((len = imageStream.read(b, 0, 1024)) != -1) {
            response.getOutputStream().write(b, 0, len);
        }
    }

activiti7查看当前流程图,解决.getProcessDiagramGenerator()报错问题。ProcessDiagramGenerator API不能用了_第1张图片

你可能感兴趣的:(java,java,activiti)