Commit bcbfe9de authored by 王飞's avatar 王飞

1、封装nextNode计算方式。

parent 8e91fdbb
...@@ -8,7 +8,8 @@ public interface TaskState { ...@@ -8,7 +8,8 @@ public interface TaskState {
void doCreate(Task task, List<String> taskList); void doCreate(Task task, List<String> taskList);
void doStart(Task task); void doStart(Task task);
void doSubmit(Task task); void doSubmit(Task task);
} }
...@@ -55,9 +55,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -55,9 +55,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
@Autowired @Autowired
private ReviewDetailsMapper reviewDetailsMapper; private ReviewDetailsMapper reviewDetailsMapper;
@Autowired
private AutomobileEnterpriseMapper automobileEnterpriseMapper;
@Autowired @Autowired
private TaskStateFacade taskStateFacade; private TaskStateFacade taskStateFacade;
......
package com.ruoyi.service.impl;
import com.ruoyi.domain.Task;
import com.ruoyi.service.CarReviewTaskService;
import com.ruoyi.service.SystemReviewTaskService;
import com.ruoyi.service.TaskService;
import com.ruoyi.service.TaskState;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Objects;
@Component
public abstract class TaskStateAdapter implements TaskState {
@Autowired
private SystemReviewTaskService systemReviewTaskService;
@Autowired
private CarReviewTaskService carReviewTaskService;
@Autowired
private TaskService taskService;
@Override
public void doStart(Task task) {
task.setTaskStatus(Task.TASK_STATUS_PENDING);
task.setRunStatus(Task.RUN_STATUS_STATUS_RUNNING);
if (Objects.equals(task.getNextNode(), Task.SUB_TASK_SRAIF)) {
systemReviewTaskService.start(task.getSystemReviewTaskId());
task.setNextNode(Task.SUB_TASK_GRFIS);
taskService.updateById(task);
} else if (Objects.equals(task.getNextNode(), Task.SUB_TASK_GRFIS)) {
carReviewTaskService.startReviewTask(task.getCarReviewTaskId());
task.setNextNode(Task.SUB_TASK_TRFIS);
taskService.updateById(task);
}
}
}
...@@ -3,8 +3,6 @@ package com.ruoyi.service.impl; ...@@ -3,8 +3,6 @@ package com.ruoyi.service.impl;
import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.Task; import com.ruoyi.domain.Task;
import com.ruoyi.service.CarReviewTaskService;
import com.ruoyi.service.SystemReviewTaskService;
import com.ruoyi.service.TaskService; import com.ruoyi.service.TaskService;
import com.ruoyi.service.TaskState; import com.ruoyi.service.TaskState;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
...@@ -15,12 +13,10 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -15,12 +13,10 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@Transactional @Transactional
@Service @Service
public class TaskStateNew implements TaskState, InitializingBean { public class TaskStateNew extends TaskStateAdapter implements TaskState, InitializingBean {
@Autowired @Autowired
private TaskStateContext taskStateContext; private TaskStateContext taskStateContext;
...@@ -31,12 +27,6 @@ public class TaskStateNew implements TaskState, InitializingBean { ...@@ -31,12 +27,6 @@ public class TaskStateNew implements TaskState, InitializingBean {
@Autowired @Autowired
private TaskService taskService; private TaskService taskService;
@Autowired
private SystemReviewTaskService systemReviewTaskService;
@Autowired
private CarReviewTaskService carReviewTaskService;
@Override @Override
public void doCreate(Task task, List<String> taskList) { public void doCreate(Task task, List<String> taskList) {
...@@ -63,26 +53,6 @@ public class TaskStateNew implements TaskState, InitializingBean { ...@@ -63,26 +53,6 @@ public class TaskStateNew implements TaskState, InitializingBean {
taskService.updateById(task); taskService.updateById(task);
} }
@Override
public void doStart(Task task) {
task.setTaskStatus(Task.TASK_STATUS_PENDING);
task.setRunStatus(Task.RUN_STATUS_STATUS_RUNNING);
if (Objects.equals(task.getNextNode(), Task.SUB_TASK_SRAIF)) {
systemReviewTaskService.start(task.getSystemReviewTaskId());
taskService.updateById(task);
} else if (Objects.equals(task.getNextNode(), Task.SUB_TASK_GRFIS)) {
carReviewTaskService.startReviewTask(task.getCarReviewTaskId());
taskService.updateById(task);
} else {
throw new ServiceException("已没有可执行的子任务节点", HttpStatus.ERROR);
}
task.setPointer(task.getPointer() + 1);
taskService.updateById(task);
}
@Override @Override
public void doSubmit(Task task) { public void doSubmit(Task task) {
throw new ServiceException("不能提交一个尚未开始的任务", HttpStatus.ERROR); throw new ServiceException("不能提交一个尚未开始的任务", HttpStatus.ERROR);
......
...@@ -6,8 +6,7 @@ import com.ruoyi.domain.CarReviewTask; ...@@ -6,8 +6,7 @@ import com.ruoyi.domain.CarReviewTask;
import com.ruoyi.domain.SystemReviewTask; import com.ruoyi.domain.SystemReviewTask;
import com.ruoyi.domain.Task; import com.ruoyi.domain.Task;
import com.ruoyi.mapper.ReviewDetailsMapper; import com.ruoyi.mapper.ReviewDetailsMapper;
import com.ruoyi.service.CarReviewTaskService;
import com.ruoyi.service.SystemReviewTaskService;
import com.ruoyi.service.TaskService; import com.ruoyi.service.TaskService;
import com.ruoyi.service.TaskState; import com.ruoyi.service.TaskState;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
...@@ -17,11 +16,10 @@ import org.springframework.stereotype.Service; ...@@ -17,11 +16,10 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.Objects;
@Transactional @Transactional
@Service @Service
public class TaskStatePending implements TaskState, InitializingBean { public class TaskStatePending extends TaskStateAdapter implements TaskState, InitializingBean {
@Autowired @Autowired
private TaskStateContext taskStateContext; private TaskStateContext taskStateContext;
...@@ -35,37 +33,13 @@ public class TaskStatePending implements TaskState, InitializingBean { ...@@ -35,37 +33,13 @@ public class TaskStatePending implements TaskState, InitializingBean {
@Autowired @Autowired
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
@Autowired
private SystemReviewTaskService systemReviewTaskService;
@Autowired
private CarReviewTaskService carReviewTaskService;
@Override @Override
public void doCreate(Task task, List<String> taskList) { public void doCreate(Task task, List<String> taskList) {
throw new ServiceException("不能创建一个已经开始的任务", HttpStatus.ERROR); throw new ServiceException("不能创建一个已经开始的任务", HttpStatus.ERROR);
} }
@Override
public void doStart(Task task) {
task.setTaskStatus(Task.TASK_STATUS_PENDING);
task.setRunStatus(Task.RUN_STATUS_STATUS_RUNNING);
if (Objects.equals(task.getNextNode(), Task.SUB_TASK_SRAIF)) {
systemReviewTaskService.start(task.getSystemReviewTaskId());
task.setNextNode(Task.SUB_TASK_GRFIS);
taskService.updateById(task);
} else if (Objects.equals(task.getNextNode(), Task.SUB_TASK_GRFIS)) {
carReviewTaskService.startReviewTask(task.getCarReviewTaskId());
task.setNextNode(Task.SUB_TASK_TRFIS);
taskService.updateById(task);
}
}
@Override @Override
public void doSubmit(Task task) { public void doSubmit(Task task) {
......
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