ProcessInstance processInstance=commandContext.getProcessInstanceManager().findProcessInstanceById(processInstanceId);
if(processInstance==null){
throw new FixFlowBizException("流程实例没找到");
}
ProcessInstanceEntity processInstanceEntity=(ProcessInstanceEntity)processInstance;
List<TaskInstanceEntity> taskInstanceEntities= processInstanceEntity.getTaskMgmtInstance().getTaskInstanceEntitys();
List<TaskInstance> taskInstances=new ArrayList<TaskInstance>();
for (TaskInstanceEntity taskInstanceEntity : taskInstanceEntities) {
if(!taskInstanceEntity.hasEnded()){
taskInstances.add(taskInstanceEntity);
}
}
return taskInstances;
}
else{
if(taskId==null||taskId.equals("")){
throw new FixFlowBizException("模拟执行的任务编号不能为空!");
}
TaskInstance taskInstance=commandContext.getTaskManager().findTaskById(taskId);
if(taskInstance==null){
throw new FixFlowBizException("模拟执行的任务无法找到!");
}
String tokenIdString=taskInstance.getTokenId();
if(!taskInstance.hasEnded()){
throw new FixFlowBizException("模拟执行的当前任务必须已经结束!");
}
ProcessInstance processInstance=commandContext.getProcessInstanceManager().findProcessInstanceById(taskInstance.getProcessInstanceId());
if(processInstance==null){
throw new FixFlowBizException("未能找到任务对应的流程实例");
}
ProcessInstanceEntity processInstanceEntity=(ProcessInstanceEntity)processInstance;
TokenEntity tokenEntity=processInstanceEntity.getTokenMap().get(tokenIdString);
List<TaskInstanceEntity> taskInstanceEntities= processInstanceEntity.getTaskMgmtInstance().getTaskInstanceEntitys();
List<TaskInstance> taskInstances=new ArrayList<TaskInstance>();
for (TaskInstanceEntity taskInstanceEntity : taskInstanceEntities) {
if(!taskInstanceEntity.hasEnded()){
String nextTokenId=taskInstanceEntity.getTokenId();
if(tokenIdString.equals(nextTokenId)){