/**
* 查找历史指定环节的处理人账号
*
* @param processInstanceId
* @param taskName
* @return
*/
public String findHisTaskAssignee(String processInstanceId, String taskName) {
String assignee = "";
List list = this.getHistoryTaskInstanceByProcessInstanceIdDesc(processInstanceId);
for (HistoricTaskInstance hti : list) {
if (taskName.equals(hti.getName())) {
assignee = hti.getAssignee();
break;
}
}
return assignee;
}
/**
* 获取发起人
*
* @param processInstanceId //流程实例ID
*/
public String getInitiator(String processInstanceId) {
HistoricProcessInstance hip = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); //获取历史流程实例
//获取流程中已经执行的节点,按照执行先后顺序排序
List hais = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId)
.orderByHistoricActivityInstanceId().asc().list();
// 获取bpmnModel
BpmnModel bpmnModel = repositoryService.getBpmnModel(hip.getProcessDefinitionId());
//全部活动实例
List historicFlowNodeList = new LinkedList<>();
for (HistoricActivityInstance hai : hais) {
historicFlowNodeList.add((FlowNode) bpmnModel.getMainProcess().getFlowElement(hai.getActivityId(), true));
if (hai.getAssignee() != null) {
//不为空的第一个节点办理人就是发起人
return hai.getAssignee();
}
}
return null;
}