Commit 7342db08 authored by 王飞's avatar 王飞

1、将启动子任务抽象到外部处理。

parent 3e7b5c16
......@@ -41,6 +41,11 @@ public interface CarReviewTaskService extends IService<CarReviewTask> {
*/
void startReviewTask(CarReviewTaskStartRequest request);
/**
* 开始一个车辆审查任务中的问卷任务
*/
void startReviewTask(Long id);
/**
* 确认一个车辆审查任务中的问卷任务
* @param request
......
......@@ -36,6 +36,12 @@ public interface SystemReviewTaskService extends IService<SystemReviewTask> {
*/
void start(SystemReviewTaskStartRequest request);
/**
* 开始一个任务
* @param id
*/
void start(Long id);
/**
* 根据状态查找体系审查任务
* @return
......
......@@ -113,7 +113,12 @@ public class CarReviewTaskServiceImpl extends ServiceImpl<CarReviewTaskMapper, C
@Override
public void startReviewTask(CarReviewTaskStartRequest request) {
CarReviewTask carReviewTask = carReviewTaskService.getById(request.getTaskId());
startReviewTask(request.getTaskId());
}
@Override
public void startReviewTask(Long id) {
CarReviewTask carReviewTask = carReviewTaskService.getById(id);
strategyCarReviewTaskContext.getResource(carReviewTask.getTaskStatus()).doStartReview(carReviewTask);
}
......
......@@ -102,7 +102,12 @@ public class SystemReviewTaskServiceImpl extends ServiceImpl<SystemReviewTaskMap
@Override
public void start(SystemReviewTaskStartRequest request) {
SystemReviewTask systemReviewTask = systemReviewTaskService.getById(request.getTaskId());
start(request.getTaskId());
}
@Override
public void start(Long id) {
SystemReviewTask systemReviewTask = systemReviewTaskService.getById(id);
strategySystemReviewTaskContext.getResource(systemReviewTask.getTaskStatus()).doStart(systemReviewTask);
}
......
......@@ -182,23 +182,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
@Override
public void startTask(TaskStartRequest request) {
Task task = taskMapper.selectById(request.getId());
SystemReviewTaskStartRequest systemRequest = new SystemReviewTaskStartRequest();
systemRequest.setTaskId(task.getSystemReviewTaskId());
CarReviewTaskStartRequest carRequest = new CarReviewTaskStartRequest();
carRequest.setTaskId(task.getCarReviewTaskId());
if (Objects.equals(task.getNextNode(), Task.SUB_TASK_SRAIF)) {
systemReviewTaskService.start(systemRequest);
} else if (Objects.equals(task.getNextNode(), Task.SUB_TASK_GRFIS)) {
carReviewTaskService.startReviewTask(carRequest);
}
taskStateFacade.doStart(task);
}
......
......@@ -3,6 +3,8 @@ package com.ruoyi.service.impl;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException;
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.InitializingBean;
......@@ -27,6 +29,12 @@ public class TaskStateNew implements TaskState, InitializingBean {
@Autowired
private TaskService taskService;
@Autowired
private SystemReviewTaskService systemReviewTaskService;
@Autowired
private CarReviewTaskService carReviewTaskService;
@Override
public void doCreate(Task task, List<String> taskList) {
......@@ -54,12 +62,12 @@ public class TaskStateNew implements TaskState, InitializingBean {
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);
......
......@@ -6,6 +6,8 @@ import com.ruoyi.domain.CarReviewTask;
import com.ruoyi.domain.SystemReviewTask;
import com.ruoyi.domain.Task;
import com.ruoyi.mapper.ReviewDetailsMapper;
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.InitializingBean;
......@@ -32,6 +34,12 @@ public class TaskStatePending implements TaskState, InitializingBean {
@Autowired
private ApplicationContext applicationContext;
@Autowired
private SystemReviewTaskService systemReviewTaskService;
@Autowired
private CarReviewTaskService carReviewTaskService;
@Override
public void doCreate(Task task, List<String> taskList) {
throw new ServiceException("不能创建一个已经开始的任务", HttpStatus.ERROR);
......@@ -44,12 +52,12 @@ public class TaskStatePending implements TaskState, InitializingBean {
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);
......
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