Commit 8bbf0af3 authored by 盖献康's avatar 盖献康

总任务下第三个子任务的开始执行,以及返回详情

parent 710df484
...@@ -115,4 +115,7 @@ public class ModelTestTask { ...@@ -115,4 +115,7 @@ public class ModelTestTask {
@ApiModelProperty("车型试验标准条款数") @ApiModelProperty("车型试验标准条款数")
private Integer standards; private Integer standards;
@ApiModelProperty("试验方案ID")
private String testSchemeId;
} }
package com.ruoyi.service; package com.ruoyi.service;
import com.ruoyi.domain.Task; import com.ruoyi.domain.Task;
import com.ruoyi.web.request.TaskStartRequest;
import java.util.List; import java.util.List;
public interface TaskState { 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, TaskStartRequest request);
void doSubmit(Task task); void doSubmit(Task task);
......
...@@ -267,7 +267,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas ...@@ -267,7 +267,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
@Override @Override
public void startTask(TaskStartRequest request) { public void startTask(TaskStartRequest request) {
Task task = taskMapper.selectById(request.getId()); Task task = taskMapper.selectById(request.getId());
taskStateFacade.doStart(task); taskStateFacade.doStart(task, request);
} }
@Override @Override
......
package com.ruoyi.service.impl; package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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.ModelTestTask;
import com.ruoyi.domain.Task; import com.ruoyi.domain.Task;
import com.ruoyi.service.CarReviewTaskService; import com.ruoyi.service.*;
import com.ruoyi.service.SystemReviewTaskService; import com.ruoyi.web.request.TaskStartRequest;
import com.ruoyi.service.TaskService;
import com.ruoyi.service.TaskState;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -24,8 +24,12 @@ public abstract class TaskStateAdapter implements TaskState { ...@@ -24,8 +24,12 @@ public abstract class TaskStateAdapter implements TaskState {
@Autowired @Autowired
private TaskService taskService; private TaskService taskService;
@Autowired
private ModelTestTaskService modelTestTaskService;
@Override @Override
public void doStart(Task task) { public void doStart(Task task, TaskStartRequest request) {
task.setTaskStatus(Task.TASK_STATUS_PENDING); task.setTaskStatus(Task.TASK_STATUS_PENDING);
task.setRunStatus(Task.RUN_STATUS_STATUS_RUNNING); task.setRunStatus(Task.RUN_STATUS_STATUS_RUNNING);
...@@ -36,6 +40,14 @@ public abstract class TaskStateAdapter implements TaskState { ...@@ -36,6 +40,14 @@ public abstract class TaskStateAdapter implements TaskState {
} 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());
taskService.updateById(task); taskService.updateById(task);
} else if (Objects.equals(task.getNextNode(), Task.SUB_TASK_TRFIS)) {
modelTestTaskService.startModelTestTask(task.getModelTestTaskId());
// 更新车型试验的试验方案ID
modelTestTaskService.update(new ModelTestTask(),
new LambdaUpdateWrapper<ModelTestTask>()
.set(ModelTestTask::getTestSchemeId, request.getTestSchemeId())
.eq(ModelTestTask::getId, task.getModelTestTaskId()));
taskService.updateById(task);
} else { } else {
throw new ServiceException("已没有可执行的子任务节点", HttpStatus.ERROR); throw new ServiceException("已没有可执行的子任务节点", HttpStatus.ERROR);
} }
......
...@@ -2,6 +2,7 @@ package com.ruoyi.service.impl; ...@@ -2,6 +2,7 @@ package com.ruoyi.service.impl;
import com.ruoyi.domain.Task; import com.ruoyi.domain.Task;
import com.ruoyi.service.TaskState; import com.ruoyi.service.TaskState;
import com.ruoyi.web.request.TaskStartRequest;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -21,8 +22,8 @@ public class TaskStateFacade implements TaskState { ...@@ -21,8 +22,8 @@ public class TaskStateFacade implements TaskState {
} }
@Override @Override
public void doStart(Task task) { public void doStart(Task task, TaskStartRequest request) {
taskStateContext.getResource(task.getTaskStatus()).doStart(task); taskStateContext.getResource(task.getTaskStatus()).doStart(task, request);
} }
@Override @Override
......
...@@ -4,6 +4,7 @@ import com.ruoyi.common.constant.HttpStatus; ...@@ -4,6 +4,7 @@ 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.TaskState; import com.ruoyi.service.TaskState;
import com.ruoyi.web.request.TaskStartRequest;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
...@@ -28,7 +29,7 @@ public class TaskStateFinish extends TaskStateAdapter implements TaskState, Init ...@@ -28,7 +29,7 @@ public class TaskStateFinish extends TaskStateAdapter implements TaskState, Init
} }
@Override @Override
public void doStart(Task task) { public void doStart(Task task, TaskStartRequest request) {
throw new ServiceException("不能开始一个已经结束的任务", HttpStatus.ERROR); throw new ServiceException("不能开始一个已经结束的任务", HttpStatus.ERROR);
} }
......
...@@ -10,4 +10,8 @@ public class TaskStartRequest { ...@@ -10,4 +10,8 @@ public class TaskStartRequest {
@ApiModelProperty("ID") @ApiModelProperty("ID")
private Long id; private Long id;
@ApiModelProperty("试验方案ID")
private String testSchemeId;
} }
...@@ -118,4 +118,7 @@ public class TaskFindResponse { ...@@ -118,4 +118,7 @@ public class TaskFindResponse {
@ApiModelProperty("指向待执行节点的指针[0、1、2]") @ApiModelProperty("指向待执行节点的指针[0、1、2]")
private int pointer; private int pointer;
@ApiModelProperty("试验方案ID")
private String testSchemeId;
} }
...@@ -106,7 +106,8 @@ ...@@ -106,7 +106,8 @@
crt.task_status car_review_status, crt.task_status car_review_status,
mtt.task_begin_time test_begin_time, mtt.task_begin_time test_begin_time,
mtt.task_end_time test_end_time, mtt.task_end_time test_end_time,
mtt.task_status test_status mtt.task_status test_status,
mtt.test_scheme_id testSchemeId
FROM t_task t FROM t_task t
left join t_system_review_task srt on t.system_review_task_id = srt.id left join t_system_review_task srt on t.system_review_task_id = srt.id
left join t_car_review_task crt on t.car_review_task_id = crt.id left join t_car_review_task crt on t.car_review_task_id = crt.id
......
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