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)){
taskInstances.add(taskInstanceEntity);
}else{
//分支走到合并的时候的处理.
if(tokenEntity==null){
if(taskInstanceEntity.getCreateTime().compareTo(taskInstance.getCreateTime())>=0){
taskInstances.add(taskInstanceEntity);
}
}
else{