• Activiti7工作流引擎:生成实时的流程图片


    实时获取当前流程对应的流程图片,并对当前正在审批的节点进行高亮显示。

    public class ActivitiController {
        @Autowired
        private ProcessEngine processEngine;
    
        @Autowired
        private RepositoryService repositoryService;
    
        @Autowired
        private RuntimeService runtimeService;
        
    
        /**
         * 生成正在执行的流程图
         */
        @RequestMapping(value = "processDiagram")
        public void genProcessDiagram(HttpServletResponse httpServletResponse, String processInstanceId) throws Exception {
            List<Execution> executions = runtimeService.createExecutionQuery()
                    .processInstanceId(processInstanceId)
                    .list();
    
            List<String> highLightedActivities = new ArrayList<>();
            List<String> highLightedFlows = new ArrayList<>();
            for (Execution exe : executions) {
                List<String> ids = runtimeService.getActiveActivityIds(exe.getId());
                highLightedActivities.addAll(ids);
            }
    
            //获取流程图
            ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
            BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
            ProcessEngineConfiguration engconf = processEngine.getProcessEngineConfiguration();
            ProcessDiagramGenerator diagramGenerator = engconf.getProcessDiagramGenerator();
            InputStream in = diagramGenerator.generateDiagram(bpmnModel,
                    "png",
                    highLightedActivities,
                    highLightedFlows,
                    engconf.getActivityFontName(), engconf.getLabelFontName(),
                    engconf.getAnnotationFontName(), engconf.getClassLoader(),
                    1.0);
    
            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();
                }
            }
        }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59

    在这里插入图片描述

  • 相关阅读:
    探讨基于IEC61499开发类似LabVIEW图形编程工具
    10月21日,每日信息差
    估计流量矩阵的方法
    电平转换器IC
    IDENTITY_INSERT 设置为 OFF 时,不能为表 ‘t_user‘ 中的标识列插入显式值
    修改oem.img镜像文件
    Nginx - 反向代理与负载均衡
    【unity3D】Rect Transform组件
    干货 | 读懂这篇文,玩游戏还会卡顿?
    Git常用的命令有哪些?
  • 原文地址:https://blog.csdn.net/vbirdbest/article/details/134549679