activiti高亮当前节点


有时候为了方便申请人查看当前流程走到哪个节点,比较直观的办法就是高亮当前节点,当然activiti也提供了API供我们调用

生成图片示例代码:

public  byte[] generateImage(String processInstanceId){
		  //1.创建核心引擎流程对象processEngine
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
		TaskService taskService = processEngine.getTaskService();
		Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
		//流程定义
		BpmnModel bpmnModel = processEngine.getRepositoryService().getBpmnModel(task.getProcessDefinitionId()); 
		
		//正在活动节点
		List activeActivityIds = processEngine.getRuntimeService().getActiveActivityIds(task.getExecutionId());

		ProcessDiagramGenerator pdg = processEngine.getProcessEngineConfiguration().getProcessDiagramGenerator();
		//生成流图片
        InputStream inputStream = pdg.generateDiagram(bpmnModel, "PNG", activeActivityIds, activeActivityIds,  
        		processEngine.getProcessEngineConfiguration().getActivityFontName(),  
        		processEngine.getProcessEngineConfiguration().getLabelFontName(),  
        		processEngine.getProcessEngineConfiguration().getActivityFontName(),
        		processEngine.getProcessEngineConfiguration().getProcessEngineConfiguration().getClassLoader(), 1.0);  
        try {  
        	//生成本地图片
        	File file = new File("D:/test.png");
        	FileUtils.copyInputStreamToFile(inputStream, file);
            return IOUtils.toByteArray(inputStream);  
         } catch (Exception e) {  
             throw new RuntimeException("生成流程图异常!", e);  
         } finally {  
             IOUtils.closeQuietly(inputStream); 
         }  
	}


你可能感兴趣的:(activiti)