Commit 0fdd324f authored by 盖献康's avatar 盖献康

把车型试验(第三个子任务)融合到总任务的 新增、编辑、详情、暂存

parent 9f66b059
......@@ -195,4 +195,8 @@ public class Task {
public void setCarReviewTaskIdNull() {
this.carReviewTaskId = null;
}
public void setModelTestTaskIdNull() {
this.modelTestTaskId = null;
}
}
package com.ruoyi.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.DataStatisticsUtils;
......@@ -152,15 +153,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
taskService.save(task);
// 总任务包含车型试验,添加任务-场景关联信息
if (CollUtil.isNotEmpty(request.getTestScenarioList())) {
for (Long sceneId : request.getTestScenarioList()) {
TaskScenarioRelation taskScenario = TaskScenarioRelation.builder()
.taskId(task.getId())
.testScenarioId(sceneId)
.build();
taskScenarioRelationMapper.insert(taskScenario);
}
}
saveTaskScenario(task.getId(), request.getTestScenarioList());
// 构建并保存该任务所关联的审核组信息
saveUserRelation(auditors,task);
......@@ -287,15 +280,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
BeanUtils.copyBeanProp(response, task);
// 测试场景
List<String> taskList = Arrays.asList(task.getTaskList().split(","));
if (taskList.contains(Task.SUB_TASK_TRFIS) && taskList.size() == 1) {
List<Long> testkScenarioList = taskScenarioRelationMapper
.selectList(new QueryWrapper<TaskScenarioRelation>().eq("task_id", request.getId()))
.stream()
.map(TaskScenarioRelation::getTestScenarioId)
.collect(Collectors.toList());
response.setTestScenarioList(testkScenarioList);
}
response.setTestScenarioList(selectTestScenarioList(task));
// 小组成员
response.setAuditors(setAuditors(request.getId()));
......@@ -313,6 +298,24 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
}
/**
* 查询测试列表
* @param task
* @return
*/
private List<Long> selectTestScenarioList(Task task) {
List<Long> list = new ArrayList<>();
List<String> taskList = Arrays.asList(task.getTaskList().split(","));
if (taskList.contains(Task.SUB_TASK_TRFIS) && taskList.size() == 1) {
list = taskScenarioRelationMapper
.selectList(new QueryWrapper<TaskScenarioRelation>().eq("task_id", task.getId()))
.stream()
.map(TaskScenarioRelation::getTestScenarioId)
.collect(Collectors.toList());
}
return list;
}
@Override
public List<Task> findUserFinish(TaskFindFinishRequest request,Long userId) {
......@@ -363,6 +366,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
// 暂存
taskService.save(task);
// 测试场景
saveTaskScenario(task.getId(), request.getTestScenarioList());
// 保存任务与小组信息
saveUserRelation(auditors,task);
......@@ -396,6 +402,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
task.setFile(standard.getFile());
}
taskScenarioRelationMapper.delete(new QueryWrapper<TaskScenarioRelation>().lambda().eq(TaskScenarioRelation::getTaskId, task.getId()));
saveTaskScenario(task.getId(), request.getTestScenarioList());
// 找到审查组长
TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors();
......@@ -435,6 +444,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
BeanUtils.copyBeanProp(response, task);
// 测试场景
response.setTestScenarioList(selectTestScenarioList(task));
// 小组成员
response.setAuditors(setAuditors(task.getId()));
......@@ -627,7 +639,31 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
systemReviewTaskMapper.deleteById(task.getSystemReviewTaskId());
task.setSystemReviewTaskIdNull();
}
// 判断车型试验
if (request.getTaskList().contains(Task.SUB_TASK_TRFIS) && ObjectUtil.isNull(task.getModelTestTaskId())) {
// 新增
TaskCreateRequest createRequest = new TaskCreateRequest();
BeanUtils.copyBeanProp(createRequest, request);
task.setModelTestTaskId(saveModelTest(createRequest,initiator,standard,leader));
// 任务-场景
saveTaskScenario(task.getId(), createRequest.getTestScenarioList());
}
if (!request.getTaskList().contains(Task.SUB_TASK_TRFIS) && ObjectUtil.isNotNull(task.getModelTestTaskId())) {
// 删除
modelTestTaskService.removeById(task.getModelTestTaskId());
task.setModelTestTaskIdNull();
// 删除 任务-场景
taskScenarioRelationMapper.delete(new QueryWrapper<TaskScenarioRelation>().lambda().eq(TaskScenarioRelation::getTaskId, task.getId()));
}
if (request.getTaskList().contains(Task.SUB_TASK_TRFIS) &&
!request.getTaskList().contains(Task.SUB_TASK_GRFIS) &&
!request.getTaskList().contains(Task.SUB_TASK_SRAIF) &&
ObjectUtil.isNotNull(task.getModelTestTaskId())) {
TaskCreateRequest createRequest = new TaskCreateRequest();
BeanUtils.copyBeanProp(createRequest, request);
taskScenarioRelationMapper.delete(new QueryWrapper<TaskScenarioRelation>().lambda().eq(TaskScenarioRelation::getTaskId, task.getId()));
saveTaskScenario(task.getId(), createRequest.getTestScenarioList());
}
}
}
......@@ -779,4 +815,21 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
return modelTestTask.getId();
}
/**
* 保存任务-测试场景中间表数据
* @param taskId 总任务ID
* @param testScenarioList 测试场景集合
*/
private void saveTaskScenario(Long taskId, List<Long> testScenarioList) {
if (CollUtil.isNotEmpty(testScenarioList)) {
for (Long sceneId : testScenarioList) {
TaskScenarioRelation taskScenario = TaskScenarioRelation.builder()
.taskId(taskId)
.testScenarioId(sceneId)
.build();
taskScenarioRelationMapper.insert(taskScenario);
}
}
}
}
......@@ -66,4 +66,7 @@ public class TaskEditRequest {
@ApiModelProperty("选择的任务")
List<String> taskList;
@ApiModelProperty("选择的测试场景")
private List<Long> testScenarioList;
}
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