Chinaunix首页 | 论坛 | 博客
  • 博客访问: 213342
  • 博文数量: 178
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1880
  • 用 户 组: 普通用户
  • 注册时间: 2019-06-17 10:57
文章分类

全部博文(178)

文章存档

2021年(177)

2019年(1)

我的朋友

分类: Java

2021-11-01 13:19:33


点击(此处)折叠或打开


  1.     /**生成当前任务节点流程图片PNG
  2.      * @param PROC_INST_ID_ //流程实例ID
  3.      * @param FILENAME         //图片名称
  4.      * @from fhadmin.cn
  5.      */
  6.     protected void createXmlAndPngAtNowTask(String PROC_INST_ID_, String FILENAME) throws IOException{
  7.         DelFileUtil.delFolder(PathUtil.getProjectpath()+"uploadFiles/activitiFile");     //生成先清空之前生成的文件
  8.         InputStream in = getResourceDiagramInputStream(PROC_INST_ID_);
  9.         FileUpload.copyFile(in,PathUtil.getProjectpath()+Const.FILEACTIVITI,FILENAME);//把文件上传到文件目录里面
  10.         in.close();
  11.     }
  12.     
  13.     /**获取当前任务流程图片的输入流
  14.      * @param PROC_INST_ID_    //流程实例ID
  15.      * @from fhadmin.cn
  16.      */
  17.     private InputStream getResourceDiagramInputStream(String PROC_INST_ID_){
  18.         try {
  19.             HistoricProcessInstance hip = historyService.createHistoricProcessInstanceQuery().processInstanceId(PROC_INST_ID_).singleResult();             //获取历史流程实例
  20.             List<HistoricActivityInstance> hai = historyService.createHistoricActivityInstanceQuery().processInstanceId(PROC_INST_ID_)
  21.                                                                                                      .orderByHistoricActivityInstanceId().asc().list();    //获取流程中已经执行的节点,按照执行先后顺序排序
  22.             List<String> executedActivityIdList = new ArrayList<String>();                        // 构造已执行的节点ID集合
  23.             for (HistoricActivityInstance activityInstance : hai) {
  24.                 executedActivityIdList.add(activityInstance.getActivityId());
  25.             }
  26.             BpmnModel bpmnModel = repositoryService.getBpmnModel(hip.getProcessDefinitionId()); // 获取bpmnModel
  27.             List<String> flowIds = this.getExecutedFlows(bpmnModel, hai);                        // 获取流程已发生流转的线ID集合
  28.             ProcessDiagramGenerator processDiagramGenerator = processEngine.getProcessEngineConfiguration().getProcessDiagramGenerator();    
  29.             InputStream imageStream = processDiagramGenerator.generateDiagram(bpmnModel, "png", executedActivityIdList, flowIds, "宋体", "微软雅黑", "黑体", null, 2.0);    //使用默认配置获得流程图表生成器,并生成追踪图片字符流
  30.             return imageStream;
  31.         } catch (Exception e) {
  32.             e.printStackTrace();
  33.             return null;
  34.         }
  35.     }


阅读(1695) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~