Commit 8e91fdbb authored by 王飞's avatar 王飞

1、修改nextNode属性的计算方式。

parent 7c5131da
...@@ -157,4 +157,20 @@ public class Task { ...@@ -157,4 +157,20 @@ public class Task {
@ApiModelProperty("选择的项目") @ApiModelProperty("选择的项目")
private String taskList; private String taskList;
@ApiModelProperty("指向待执行节点的指针[0、1、2]")
private int pointer;
@ApiModelProperty("子任务指针最大值")
private int maxPointer;
// 返回当前节点的下一个节点
public String getNextNode() {
String[] split = taskList.split(",");
if(pointer + 1 > maxPointer) {
return null;
} else {
return split[pointer + 1];
}
}
} }
...@@ -13,8 +13,10 @@ import org.springframework.context.ApplicationContext; ...@@ -13,8 +13,10 @@ import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
@Transactional @Transactional
@Service @Service
...@@ -38,21 +40,25 @@ public class TaskStateNew implements TaskState, InitializingBean { ...@@ -38,21 +40,25 @@ public class TaskStateNew implements TaskState, InitializingBean {
@Override @Override
public void doCreate(Task task, List<String> taskList) { public void doCreate(Task task, List<String> taskList) {
String nextNode = null; List<String> subTasks = new ArrayList<>();
if(taskList.contains(Task.SUB_TASK_TRFIS)) { // 保存体系审查任务
nextNode = Task.SUB_TASK_TRFIS; if(taskList.contains(Task.SUB_TASK_SRAIF)) {
subTasks.add(Task.SUB_TASK_SRAIF);
} }
if(taskList.contains(Task.SUB_TASK_GRFIS)) {
// 保存车型审查问卷任务 // 保存车型审查问卷任务
nextNode = Task.SUB_TASK_GRFIS;; if(taskList.contains(Task.SUB_TASK_GRFIS)) {
subTasks.add(Task.SUB_TASK_GRFIS);
} }
if(taskList.contains(Task.SUB_TASK_SRAIF)) {
// 保存体系审查任务 // 车型试验任务
nextNode = Task.SUB_TASK_SRAIF; if(taskList.contains(Task.SUB_TASK_TRFIS)) {
subTasks.add(Task.SUB_TASK_TRFIS);
} }
task.setNextNode(nextNode); task.setPointer(0);
task.setMaxPointer(subTasks.size());
taskService.updateById(task); taskService.updateById(task);
} }
...@@ -65,16 +71,15 @@ public class TaskStateNew implements TaskState, InitializingBean { ...@@ -65,16 +71,15 @@ public class TaskStateNew implements TaskState, InitializingBean {
if (Objects.equals(task.getNextNode(), Task.SUB_TASK_SRAIF)) { if (Objects.equals(task.getNextNode(), Task.SUB_TASK_SRAIF)) {
systemReviewTaskService.start(task.getSystemReviewTaskId()); systemReviewTaskService.start(task.getSystemReviewTaskId());
task.setNextNode(Task.SUB_TASK_GRFIS);
taskService.updateById(task); taskService.updateById(task);
} else if (Objects.equals(task.getNextNode(), Task.SUB_TASK_GRFIS)) { } else if (Objects.equals(task.getNextNode(), Task.SUB_TASK_GRFIS)) {
carReviewTaskService.startReviewTask(task.getCarReviewTaskId()); carReviewTaskService.startReviewTask(task.getCarReviewTaskId());
task.setNextNode(Task.SUB_TASK_TRFIS);
taskService.updateById(task); taskService.updateById(task);
} else {
throw new ServiceException("已没有可执行的子任务节点", HttpStatus.ERROR);
} }
task.setPointer(task.getPointer() + 1);
taskService.updateById(task); taskService.updateById(task);
} }
...@@ -87,4 +92,5 @@ public class TaskStateNew implements TaskState, InitializingBean { ...@@ -87,4 +92,5 @@ public class TaskStateNew implements TaskState, InitializingBean {
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
taskStateContext.putResource(Task.TASK_STATUS_NEW, applicationContext.getBean(this.getClass())); taskStateContext.putResource(Task.TASK_STATUS_NEW, applicationContext.getBean(this.getClass()));
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment