1. 程式人生 > >activiti 開發筆記-----根據流程例項id查詢流程歷史步驟資訊記錄

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()
		}

​