当前位置:网站首页>Activiti obtains the initiator based on the process instance ID

Activiti obtains the initiator based on the process instance ID

2022-06-24 02:35:00 FHAdmin

   /** Get originator 
	 * @param PROC_INST_ID_ // Process instance ID
	 * @from  fhadmin.cn
	 */
   protected String getInitiator(String PROC_INST_ID_) {
		HistoricProcessInstance hip = historyService.createHistoricProcessInstanceQuery().processInstanceId(PROC_INST_ID_).singleResult(); 			// Get historical process instances 
		List<HistoricActivityInstance> hais = historyService.createHistoricActivityInstanceQuery().processInstanceId(PROC_INST_ID_)
		   																						 .orderByHistoricActivityInstanceId().asc().list();	// Get the nodes that have been executed in the process , According to the order of execution 
		BpmnModel bpmnModel = repositoryService.getBpmnModel(hip.getProcessDefinitionId()); //  obtain bpmnModel
		List<FlowNode> historicFlowNodeList = new LinkedList<FlowNode>();					// All examples of activities 
		for(HistoricActivityInstance hai : hais) {
		    historicFlowNodeList.add((FlowNode) bpmnModel.getMainProcess().getFlowElement(hai.getActivityId(), true));
		    if(hai.getAssignee() != null) {
		    	return hai.getAssignee();	// The first node handler that is not empty is the initiator 
		    }
		}
		return null;
    }
原网站

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

随机推荐