flowable 获取当前任务流程图片的输入流

/**
     * 获取当前任务流程图片的输入流
     * @param PROC_INST_ID_ 流程实例ID
     * @from  fhadmin.cn
     */
    public InputStream genProcessDiagram(String PROC_INST_ID_, String type){
        /* 获得活动的节点  */
        String processDefinitionId = "";
        if (this.isFinished(PROC_INST_ID_)) {    // 如果流程已经结束,则得到结束节点
            HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().processInstanceId(PROC_INST_ID_).singleResult();
            processDefinitionId=pi.getProcessDefinitionId();
        } else {                            // 如果流程没有结束,则取当前活动节点
            /* 根据流程实例ID获得当前处于活动状态的ActivityId合集  */
            ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(PROC_INST_ID_).singleResult();
            processDefinitionId = pi.getProcessDefinitionId();
        }
        /* 获得活动的节点对象  */
        List<HistoricActivityInstance> highLightedActivitList =  historyService.createHistoricActivityInstanceQuery().processInstanceId(PROC_INST_ID_).orderByHistoricActivityInstanceStartTime().asc().list();
        List<String> highLightedActivitis = new ArrayList<String>();                //节点对象ID
        for(HistoricActivityInstance tempActivity : highLightedActivitList){
            String activityId = tempActivity.getActivityId();
            highLightedActivitis.add(activityId);
        }
        BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);    //获取流程图
        ProcessEngineConfiguration engconf = processEngine.getProcessEngineConfiguration();
        /* 获得活动的连线对象  */
        List<String> flows = new ArrayList<>();                                        //连线ID
        if("RU".equals(type)) {
            List<ActivityInstance> highLightedFlowInstances = runtimeService.createActivityInstanceQuery().activityType(BpmnXMLConstants.ELEMENT_SEQUENCE_FLOW).processInstanceId(PROC_INST_ID_).list();
            for(ActivityInstance ai : highLightedFlowInstances) {
                flows.add(ai.getActivityId());    
            }
        }else {
            List<HistoricActivityInstance> highLightedFlowInstances = historyService.createHistoricActivityInstanceQuery().activityType(BpmnXMLConstants.ELEMENT_SEQUENCE_FLOW).processInstanceId(PROC_INST_ID_).list();
            for(HistoricActivityInstance ha : highLightedFlowInstances) {
                flows.add(ha.getActivityId());    
            }
        }
        ProcessDiagramGenerator diagramGenerator = engconf.getProcessDiagramGenerator();
        InputStream in = diagramGenerator.generateDiagram(bpmnModel, "png", highLightedActivitis, flows, engconf.getActivityFontName(), engconf.getLabelFontName(), engconf.getAnnotationFontName(), engconf.getClassLoader(), 1.0, true);
        return in;
     }
本作品采用《CC 协议》,转载必须注明作者和本文链接
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!