Commit bdb1e0cc authored by 盖献康's avatar 盖献康

车型试验 - 状态(PENDING、SIGNED、FINISH) - 除了查看都完成

parent 20559352
......@@ -2,6 +2,7 @@ package com.ruoyi.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.domain.ModelTestTask;
import com.ruoyi.web.request.ModelTestTaskSubmitRequest;
import com.ruoyi.web.response.ModelTestTaskViewResponse;
import java.util.List;
......@@ -25,4 +26,17 @@ public interface ModelTestTaskService extends IService<ModelTestTask> {
* @param taskId
*/
void startModelTestTask(Long taskId);
/**
* 确认车型试验任务
* @param taskId
*/
void confirmModelTestTask(Long taskId);
/**
* 车型试验任务
* @param request
*/
void submitModelTestTask(ModelTestTaskSubmitRequest request);
}
......@@ -33,8 +33,7 @@ public interface StrategyModelTestTask {
* 提交测试
* @param modelTestTask
* @param imagesUrl
* @param testScenarioList
*/
void doSubmitTest(ModelTestTask modelTestTask, List<String> imagesUrl, List<Long> testScenarioList);
void doSubmitTest(ModelTestTask modelTestTask, List<String> imagesUrl);
}
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.domain.ModelTestTask;
import com.ruoyi.mapper.ModelTestTaskMapper;
import com.ruoyi.service.ModelTestTaskService;
import com.ruoyi.web.request.ModelTestTaskSubmitRequest;
import com.ruoyi.web.response.ModelTestTaskViewResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -46,4 +47,20 @@ public class ModelTestTaskServiceImpl extends ServiceImpl<ModelTestTaskMapper, M
ModelTestTask modelTestTask = modelTestTaskMapper.selectById(taskId);
strategyModelTestTaskContext.getResource(modelTestTask.getTaskStatus()).doStartTest(modelTestTask);
}
/**
* 确认车型试验任务
* @param taskId
*/
@Override
public void confirmModelTestTask(Long taskId) {
ModelTestTask modelTestTask = modelTestTaskMapper.selectById(taskId);
strategyModelTestTaskContext.getResource(modelTestTask.getTaskStatus()).doConfirmTest(modelTestTask);
}
@Override
public void submitModelTestTask(ModelTestTaskSubmitRequest request) {
ModelTestTask modelTestTask = modelTestTaskMapper.selectById(request.getTaskId());
strategyModelTestTaskContext.getResource(modelTestTask.getTaskStatus()).doSubmitTest(modelTestTask, request.getImagesUrl());
}
}
......@@ -39,7 +39,7 @@ public class StrategyModelTestTaskFinish implements StrategyModelTestTask, Initi
}
@Override
public void doSubmitTest(ModelTestTask modelTestTask, List<String> imagesUrl, List<Long> testScenarioList) {
public void doSubmitTest(ModelTestTask modelTestTask, List<String> imagesUrl) {
throw new ServiceException("不能提交一个结束的任务", HttpStatus.ERROR);
}
......
......@@ -111,10 +111,9 @@ public class StrategyModelTestTaskNew implements StrategyModelTestTask, Initiali
* 状态为NEW时的提交车型试验任务
* @param modelTestTask
* @param imagesUrl
* @param testScenarioList
*/
@Override
public void doSubmitTest(ModelTestTask modelTestTask, List<String> imagesUrl, List<Long> testScenarioList) {
public void doSubmitTest(ModelTestTask modelTestTask, List<String> imagesUrl) {
throw new ServiceException("不能提交一个尚未开始的任务", HttpStatus.ERROR);
}
......
package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.ModelTestTask;
import com.ruoyi.mapper.ModelTestTaskMapper;
import com.ruoyi.service.StrategyModelTestTask;
import com.ruoyi.web.response.ModelTestTaskViewResponse;
import org.springframework.beans.factory.InitializingBean;
......@@ -23,6 +25,9 @@ public class StrategyModelTestTaskPending implements StrategyModelTestTask, Init
@Autowired
private StrategyModelTestTaskContext strategyModelTestTaskContext;
@Autowired
private ModelTestTaskMapper modelTestTaskMapper;
@Override
public List<ModelTestTaskViewResponse> doView(ModelTestTask modelTestTask) {
throw new ServiceException("能查看一个进行中的任务", HttpStatus.ERROR);
......@@ -35,11 +40,15 @@ public class StrategyModelTestTaskPending implements StrategyModelTestTask, Init
@Override
public void doConfirmTest(ModelTestTask modelTestTask) {
throw new ServiceException("能确认一个进行中的任务", HttpStatus.ERROR);
// 进行中的任务, 点击确认后, 状态改为待签字
modelTestTaskMapper.update(new ModelTestTask(),
new LambdaUpdateWrapper<ModelTestTask>()
.set(ModelTestTask::getTaskStatus, ModelTestTask.TASK_STATUS_SIGNED)
.eq(ModelTestTask::getId, modelTestTask.getId()));
}
@Override
public void doSubmitTest(ModelTestTask modelTestTask, List<String> imagesUrl, List<Long> testScenarioList) {
public void doSubmitTest(ModelTestTask modelTestTask, List<String> imagesUrl) {
throw new ServiceException("不能提交一个进行中的任务", HttpStatus.ERROR);
}
......
package com.ruoyi.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.ModelTestTask;
import com.ruoyi.domain.Task;
import com.ruoyi.mapper.ModelTestTaskMapper;
import com.ruoyi.mapper.TaskMapper;
import com.ruoyi.service.StrategyModelTestTask;
import com.ruoyi.web.response.ModelTestTaskViewResponse;
import org.springframework.beans.factory.InitializingBean;
......@@ -11,6 +20,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
@Service
......@@ -23,6 +33,15 @@ public class StrategyModelTestTaskSigned implements StrategyModelTestTask, Initi
@Autowired
private StrategyModelTestTaskContext strategyModelTestTaskContext;
@Autowired
private ModelTestTaskMapper modelTestTaskMapper;
@Autowired
private TaskMapper taskMapper;
@Autowired
private TaskStateFacade taskStateFacade;
@Override
public List<ModelTestTaskViewResponse> doView(ModelTestTask modelTestTask) {
throw new ServiceException("能查看一个已确认的任务", HttpStatus.ERROR);
......@@ -39,8 +58,23 @@ public class StrategyModelTestTaskSigned implements StrategyModelTestTask, Initi
}
@Override
public void doSubmitTest(ModelTestTask modelTestTask, List<String> imagesUrl, List<Long> testScenarioList) {
throw new ServiceException("能提交一个已确认的任务", HttpStatus.ERROR);
public void doSubmitTest(ModelTestTask modelTestTask, List<String> imagesUrl) {
SysUser user = SecurityUtils.getLoginUser().getUser();
modelTestTaskMapper.update(new ModelTestTask(),
new LambdaUpdateWrapper<ModelTestTask>()
.set(ModelTestTask::getTaskStatus, ModelTestTask.TASK_STATUS_FINISH)
.set(ModelTestTask::getTaskEndTime, new Date())
.set(ModelTestTask::getSubmitId, user.getUserId())
.set(ModelTestTask::getSubmitName, user.getNickName())
.set(ModelTestTask::getImagesUrl, StringUtils.join(imagesUrl, ","))
.eq(ModelTestTask::getId, modelTestTask.getId()));
// 改总任务状态
// 通过modelId查询总任务ID
List<Task> taskList = taskMapper.selectList(new QueryWrapper<Task>().eq("model_test_task_id", modelTestTask.getId()));
if (CollUtil.isNotEmpty(taskList)) {
Task task = taskList.get(0);
taskStateFacade.doSubmit(task);
}
}
@Override
......
package com.ruoyi.web;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.service.ModelTestTaskService;
import com.ruoyi.web.request.CarReviewTaskViewRequest;
import com.ruoyi.web.request.ModelTestTaskConfirmRequest;
import com.ruoyi.web.request.ModelTestTaskSubmitRequest;
import com.ruoyi.web.response.ModelTestTaskViewResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -16,6 +17,10 @@ import java.util.List;
/**
* 车型试验任务Controller
* 总任务包含 (后)-> NEW (可以)-> 查看、开始
* 开始任务 -> PENDING -> 确认
* 确认任务 -> SIGNED -> 查看、提交
* 提交任务 -> FINISH -> 查看
* @author gxk
*/
@Api(tags = "车型试验子任务")
......@@ -31,7 +36,6 @@ public class ModelTestTaskController extends BaseController {
* @param request
* @return
*/
@Anonymous
@ApiOperation("查看车型试验任务详情")
@PostMapping("/getById")
public R<List<ModelTestTaskViewResponse>> view(@Validated @RequestBody CarReviewTaskViewRequest request) {
......@@ -44,12 +48,35 @@ public class ModelTestTaskController extends BaseController {
* @param request
* @return
*/
@Anonymous
@ApiOperation("开始车型试验任务")
@PostMapping("/start")
public R<String> startReview(@Validated @RequestBody CarReviewTaskViewRequest request) {
public R<String> startModel(@Validated @RequestBody CarReviewTaskViewRequest request) {
modelTestTaskService.startModelTestTask(request.getTaskId());
return R.ok();
}
/**
* 确认车型试验任务
* @param request
* @return
*/
@ApiOperation("确认车型试验任务")
@PostMapping("/confirm")
public R<String> confirmModel(@Validated @RequestBody ModelTestTaskConfirmRequest request) {
modelTestTaskService.confirmModelTestTask(request.getTaskId());
return R.ok();
}
/**
* 提交车型试验任务 - 在待签字页面进行
* @param request
* @return
*/
@ApiOperation("提交车型试验任务")
@PostMapping("/submit")
public R<String> submitModel(@Validated @RequestBody ModelTestTaskSubmitRequest request) {
modelTestTaskService.submitModelTestTask(request);
return R.ok();
}
}
package com.ruoyi.web.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 车型试验确认请求DTO
* @author gxk
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("车型试验确认请求DTO")
public class ModelTestTaskConfirmRequest {
@ApiModelProperty("任务id")
private Long taskId;
}
package com.ruoyi.web.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 车型试验提交DTO
* @author gxk
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("车型试验提交DTO")
public class ModelTestTaskSubmitRequest {
@ApiModelProperty("任务id")
private Long taskId;
@ApiModelProperty("图片地址")
private List<String> imagesUrl;
}
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