1、首先是根據流程ID獲取當前任務: List<Task> tasks = taskService.createTaskQuery().processInstanceId(procInstanceId).list();
2、然後根據當前任務獲取當前流程的流程定義,然後根據流程定義獲得所有的節點: ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl)rs).getDeployedProcessDefinition(task.getProcessDefinitionId()); List<ActivityImpl> activitiList = def.getActivities(); //rs是指RepositoryService的例項
3、根據任務獲取當前流程執行ID,執行例項以及當前流程節點的ID:String excId = task.getExecutionId(); ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(excId).singleResult(); String activitiId = execution.getActivityId();
4、然後迴圈activitiList 並判斷出當前流程所處節點,然後得到當前節點例項,根據節點例項獲取所有從當前節點出發的路徑,然後根據路徑獲得下一個節點例項: for(ActivityImpl activityImpl:activitiList){ String id = activityImpl.getId(); if(activitiId.equals(id)){ System.out.println("當前任務:"+activityImpl.getProperty("name")); //輸出某個節點的某種屬性 List<PvmTransition> outTransitions = activityImpl.getOutgoingTransitions();//獲取從某個節點出來的所有線路 for(PvmTransition tr:outTransitions){ PvmActivity ac = tr.getDestination(); //獲取線路的終點節點 System.out.println("下一步任務任務:"+ac.getProperty("name")); } break; } }
1、首先是根據流程ID獲取當前任務: List<Task> tasks = taskService.createTaskQuery().processInstanceId(procInstanceId).list();
2、然後根據當前任務獲取當前流程的流程定義,然後根據流程定義獲得所有的節點: ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl)rs).getDeployedProcessDefinition(task.getProcessDefinitionId()); List<ActivityImpl> activitiList = def.getActivities(); //rs是指RepositoryService的例項
3、根據任務獲取當前流程執行ID,執行例項以及當前流程節點的ID:String excId = task.getExecutionId(); ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(excId).singleResult(); String activitiId = execution.getActivityId();
4、然後迴圈activitiList 並判斷出當前流程所處節點,然後得到當前節點例項,根據節點例項獲取所有從當前節點出發的路徑,然後根據路徑獲得下一個節點例項: for(ActivityImpl activityImpl:activitiList){ String id = activityImpl.getId(); if(activitiId.equals(id)){ System.out.println("當前任務:"+activityImpl.getProperty("name")); //輸出某個節點的某種屬性 List<PvmTransition> outTransitions = activityImpl.getOutgoingTransitions();//獲取從某個節點出來的所有線路 for(PvmTransition tr:outTransitions){ PvmActivity ac = tr.getDestination(); //獲取線路的終點節點 System.out.println("下一步任務任務:"+ac.getProperty("name")); } break; } }