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

全部博文(298)

文章存档

2022年(96)

2021年(201)

2019年(1)

我的朋友

分类: Java

2021-11-08 16:44:55


点击(此处)折叠或打开


  1. /**
  2.      * 获取当前任务流程图片的输入流
  3.      * @param PROC_INST_ID_ 流程实例ID
  4.      * @from fhadmin.cn
  5.      */
  6.     public InputStream genProcessDiagram(String PROC_INST_ID_, String type){
  7.         /* 获得活动的节点 */
  8.         String processDefinitionId = "";
  9.         if (this.isFinished(PROC_INST_ID_)) {    // 如果流程已经结束,则得到结束节点
  10.             HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().processInstanceId(PROC_INST_ID_).singleResult();
  11.             processDefinitionId=pi.getProcessDefinitionId();
  12.         } else {                            // 如果流程没有结束,则取当前活动节点
  13.             /* 根据流程实例ID获得当前处于活动状态的ActivityId合集 */
  14.             ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(PROC_INST_ID_).singleResult();
  15.             processDefinitionId = pi.getProcessDefinitionId();
  16.         }
  17.         /* 获得活动的节点对象 */
  18.         List<HistoricActivityInstance> highLightedActivitList = historyService.createHistoricActivityInstanceQuery().processInstanceId(PROC_INST_ID_).orderByHistoricActivityInstanceStartTime().asc().list();
  19.         List<String> highLightedActivitis = new ArrayList<String>();                //节点对象ID
  20.         for(HistoricActivityInstance tempActivity : highLightedActivitList){
  21.             String activityId = tempActivity.getActivityId();
  22.             highLightedActivitis.add(activityId);
  23.         }
  24.         BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);    //获取流程图
  25.         ProcessEngineConfiguration engconf = processEngine.getProcessEngineConfiguration();
  26.         /* 获得活动的连线对象 */
  27.         List<String> flows = new ArrayList<>();                                        //连线ID
  28.         if("RU".equals(type)) {
  29.             List<ActivityInstance> highLightedFlowInstances = runtimeService.createActivityInstanceQuery().activityType(BpmnXMLConstants.ELEMENT_SEQUENCE_FLOW).processInstanceId(PROC_INST_ID_).list();
  30.             for(ActivityInstance ai : highLightedFlowInstances) {
  31.                 flows.add(ai.getActivityId());    
  32.             }
  33.         }else {
  34.             List<HistoricActivityInstance> highLightedFlowInstances = historyService.createHistoricActivityInstanceQuery().activityType(BpmnXMLConstants.ELEMENT_SEQUENCE_FLOW).processInstanceId(PROC_INST_ID_).list();
  35.             for(HistoricActivityInstance ha : highLightedFlowInstances) {
  36.                 flows.add(ha.getActivityId());    
  37.             }
  38.         }
  39.         ProcessDiagramGenerator diagramGenerator = engconf.getProcessDiagramGenerator();
  40.         InputStream in = diagramGenerator.generateDiagram(bpmnModel, "png", highLightedActivitis, flows, engconf.getActivityFontName(), engconf.getLabelFontName(), engconf.getAnnotationFontName(), engconf.getClassLoader(), 1.0, true);
  41.         return in;
  42.      }


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