当前位置:网站首页>Flowable get the input stream of the current task process picture

Flowable get the input stream of the current task process picture

2022-06-24 02:01:00 FHAdmin

/**
	 *  Gets the input stream of the current task process picture 
	 * @param PROC_INST_ID_  Process instance ID
	 * @from  fhadmin.cn
	 */
	public InputStream genProcessDiagram(String PROC_INST_ID_, String type){
		/*  Get the active node   */
        String processDefinitionId = "";
        if (this.isFinished(PROC_INST_ID_)) {	//  If the process has ended , End node 
            HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().processInstanceId(PROC_INST_ID_).singleResult();
            processDefinitionId=pi.getProcessDefinitionId();
        } else {							//  If the process does not end , Then take the current active node 
        	/*  According to the process example ID Get the currently active ActivityId Collection   */
            ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(PROC_INST_ID_).singleResult();
            processDefinitionId = pi.getProcessDefinitionId();
        }
        /*  Get the active node object   */
        List<HistoricActivityInstance> highLightedActivitList =  historyService.createHistoricActivityInstanceQuery().processInstanceId(PROC_INST_ID_).orderByHistoricActivityInstanceStartTime().asc().list();
        List<String> highLightedActivitis = new ArrayList<String>();				// Node object ID
        for(HistoricActivityInstance tempActivity : highLightedActivitList){
            String activityId = tempActivity.getActivityId();
            highLightedActivitis.add(activityId);
        }
        BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);	// Get the flow chart 
        ProcessEngineConfiguration engconf = processEngine.getProcessEngineConfiguration();
        /*  Get active connection object   */
        List<String> flows = new ArrayList<>();										// attachment 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;
	 }
原网站

版权声明
本文为[FHAdmin]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/11/20211108174741292m.html