查询历史流程实例
@Test
public void historyProcessInstince() {
List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery()
.list();
if(null!=list&&list.size()>0) {
for (HistoricProcessInstance hpi : list) {
System.out.println("历史流程实例ID:" + hpi.getId());
System.out.println("流程定义ID:" + hpi.getProcessDefinitionId());
System.out.println("历史流程实例的业务ID:" + hpi.getBusinessKey());
System.out.println("流程部署ID:" + hpi.getDeploymentId());
System.out.println("流程定义KEY:" + hpi.getProcessDefinitionKey());
System.out.println("开始活动ID:" + hpi.getStartActivityId());
System.out.println("结束活动ID:" + hpi.getEndActivityId());
System.out.println("########################");
}
}
}
查询历史活动
@Test
public void queryHistoryAct() {
List<HistoricActivityInstance> list = this.historyService.createHistoricActivityInstanceQuery()
.list();
if(null!=list&&list.size()>0)
{
for (HistoricActivityInstance hai : list) {
System.out.println("ID:"+hai.getId());
System.out.println("流程定义ID:"+hai.getProcessDefinitionId());
System.out.println("流程实例ID:"+hai.getProcessInstanceId());
System.out.println("执行实例ID:"+hai.getExecutionId());
System.out.println("活动ID:"+hai.getActivityId());
System.out.println("任务ID:"+hai.getTaskId());
System.out.println("活动名称:"+hai.getActivityName());
System.out.println("活动类型:"+hai.getActivityType());
System.out.println("任务办理人:"+hai.getAssignee());
System.out.println("开始时间:"+hai.getStartTime());
System.out.println("结束时间:"+hai.getEndTime());
System.out.println("持续时间:"+hai.getDurationInMillis());
System.out.println("#######################################");
}
}
}
查询历史任务
processDefinitionKeyLike="%Hello%"
@Test
public void queryHistoryTask() {
List<HistoricTaskInstance> list = this.historyService.createHistoricTaskInstanceQuery()
.list();
if(null!=list&&list.size()>0)
{
for (HistoricTaskInstance task : list) {
System.out.println("任务ID:" + task.getId());
System.out.println("任务办理人:" + task.getAssignee());
System.out.println("执行实例ID:" + task.getExecutionId());
System.out.println("任务名称:" + task.getName());
System.out.println("流程定义ID:" + task.getProcessDefinitionId());
System.out.println("流程实例ID:" + task.getProcessInstanceId());
System.out.println("任务创建时间:" + task.getCreateTime());
System.out.println("任务结束时间:" + task.getEndTime());
System.out.println("#######################################");
}
}
}
查询历史流程变量
- 历史的流程变量查询,指定流程变量的名称,查询
act_hi_varinst
表(也可以针对,流程实例ID,执行对象ID,任务ID查询)
@Test
public void getHistoryVariables() {
HistoryService historyService = this.processEngine.getHistoryService();
String processInstanceId="2501";
List<HistoricVariableInstance> list = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).list();
for (HistoricVariableInstance hvs : list) {
System.out.println("ID"+hvs.getId());
System.out.println("变量值"+hvs.getValue());
System.out.println("变量名"+hvs.getVariableName());
System.out.println("变量类型"+hvs.getVariableTypeName());
System.out.println("#####################");
}
}