activiti 开发笔记-----根据流程实例id查询流程历史步骤信息记录

1.根据流程实例id(processInstanceId)获取流程的历史记录,并按照发起时间排序

List<HistoricTaskInstance> historicTaskInstanceList = ProcessEngines.getDefaultProcessEngine().
getHistoryService().createHistoricTaskInstanceQuery().
processInstanceId(processInstanceId).
orderByTaskCreateTime().asc().list();

2.通过for each 循环遍历列表 通过historicTaskInstanceLis.get*** 方法即可取出单个历史任务的属性,并设置一个index来标记步骤的编号

​
		    index=1;
            for (HistoricTaskInstance historicTaskInstance : historicTaskInstanceList) {
			//父级流程任务Id
			historicTaskInstance.getParentTaskId();
			//taskId 活动ID
			historicTaskInstance.getId();
			//任务序号
			processHistoryDTO.setIndexKey(index);
			index+=1;
			//节点ID
			historicTaskInstance.getTaskDefinitionKey();
			//办理时间
			historicTaskInstance.getEndTime();
			//接收时间
			historicTaskInstance.getStartTime();
			//节点名称
			historicTaskInstance.getName();
			//节点状态
			if (endTimeDate != null) {
				processHistoryDTO.setStates("已结束");
			}else{
				processHistoryDTO.setStates("运行中");
			}
			//会签、绿色通道等消息(需要取出getDescription的内容进行判断)
            historicTaskInstance.getDescription()
		}

​

猜你喜欢

转载自blog.csdn.net/suzhenchao/article/details/84108613