zoukankan      html  css  js  c++  java
  • activiti 生成当前任务图片PNG

        /**生成当前任务节点流程图片PNG
         * @param PROC_INST_ID_ //流程实例ID
         * @param FILENAME         //图片名称
         * @from fhadmin.cn 
         */
        protected void createXmlAndPngAtNowTask(String PROC_INST_ID_, String FILENAME) throws IOException{
            DelFileUtil.delFolder(PathUtil.getProjectpath()+"uploadFiles/activitiFile");     //生成先清空之前生成的文件
            InputStream in = getResourceDiagramInputStream(PROC_INST_ID_); 
            FileUpload.copyFile(in,PathUtil.getProjectpath()+Const.FILEACTIVITI,FILENAME);//把文件上传到文件目录里面
            in.close();  
        }
        
        /**获取当前任务流程图片的输入流
         * @param PROC_INST_ID_    //流程实例ID
         * @from fhadmin.cn 
         */
        private InputStream getResourceDiagramInputStream(String PROC_INST_ID_){
            try {
                HistoricProcessInstance hip = historyService.createHistoricProcessInstanceQuery().processInstanceId(PROC_INST_ID_).singleResult();             //获取历史流程实例
                List<HistoricActivityInstance> hai = historyService.createHistoricActivityInstanceQuery().processInstanceId(PROC_INST_ID_)
                                                                                                         .orderByHistoricActivityInstanceId().asc().list();    //获取流程中已经执行的节点,按照执行先后顺序排序
                List<String> executedActivityIdList = new ArrayList<String>();                        // 构造已执行的节点ID集合
                for (HistoricActivityInstance activityInstance : hai) {
                    executedActivityIdList.add(activityInstance.getActivityId());
                }
                BpmnModel bpmnModel = repositoryService.getBpmnModel(hip.getProcessDefinitionId()); // 获取bpmnModel
                List<String> flowIds = this.getExecutedFlows(bpmnModel, hai);                        // 获取流程已发生流转的线ID集合
                ProcessDiagramGenerator processDiagramGenerator = processEngine.getProcessEngineConfiguration().getProcessDiagramGenerator();    
                InputStream imageStream = processDiagramGenerator.generateDiagram(bpmnModel, "png", executedActivityIdList, flowIds, "宋体", "微软雅黑", "黑体", null, 2.0);    //使用默认配置获得流程图表生成器,并生成追踪图片字符流
                return imageStream;
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }
        }
     
  • 相关阅读:
    java 测试 (junit+ junit 断言 + postman)
    junit 运行(eclipse + IDEA)
    junit 常用注解 + junit 断言详解
    工作周报模板
    spring boot tomcat 部署
    spring boot 集成JSP
    spring boot 集成 Mybatis,JPA
    JPA 常用注解
    员工年终绩效考核表模板
    2013 Noip提高组 Day1
  • 原文地址:https://www.cnblogs.com/m170981362621/p/15493130.html
Copyright © 2011-2022 走看看