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

Merge branch 'gaixiankang' into 'dev'

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

See merge request !188
parents 6658a3e7 e6ae0ce3
...@@ -195,4 +195,8 @@ public class Task { ...@@ -195,4 +195,8 @@ public class Task {
public void setCarReviewTaskIdNull() { public void setCarReviewTaskIdNull() {
this.carReviewTaskId = null; this.carReviewTaskId = null;
} }
public void setModelTestTaskIdNull() {
this.modelTestTaskId = null;
}
} }
package com.ruoyi.service.impl; package com.ruoyi.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.DataStatisticsUtils; import com.ruoyi.common.DataStatisticsUtils;
...@@ -153,15 +154,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas ...@@ -153,15 +154,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
taskService.save(task); taskService.save(task);
// 总任务包含车型试验,添加任务-场景关联信息 // 总任务包含车型试验,添加任务-场景关联信息
if (CollUtil.isNotEmpty(request.getTestScenarioList())) { saveTaskScenario(task.getId(), request.getTestScenarioList());
for (Long sceneId : request.getTestScenarioList()) {
TaskScenarioRelation taskScenario = TaskScenarioRelation.builder()
.taskId(task.getId())
.testScenarioId(sceneId)
.build();
taskScenarioRelationMapper.insert(taskScenario);
}
}
// 构建并保存该任务所关联的审核组信息 // 构建并保存该任务所关联的审核组信息
saveUserRelation(auditors,task); saveUserRelation(auditors,task);
...@@ -287,15 +280,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas ...@@ -287,15 +280,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
BeanUtils.copyBeanProp(response, task); BeanUtils.copyBeanProp(response, task);
// 测试场景 // 测试场景
List<String> taskList = Arrays.asList(task.getTaskList().split(",")); response.setTestScenarioList(selectTestScenarioList(task));
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.setAuditors(setAuditors(request.getId())); response.setAuditors(setAuditors(request.getId()));
...@@ -313,6 +298,24 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas ...@@ -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 @Override
public List<Task> findUserFinish(TaskFindFinishRequest request,Long userId) { public List<Task> findUserFinish(TaskFindFinishRequest request,Long userId) {
...@@ -365,6 +368,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas ...@@ -365,6 +368,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
// 暂存 // 暂存
taskService.save(task); taskService.save(task);
// 测试场景
saveTaskScenario(task.getId(), request.getTestScenarioList());
// 保存任务与小组信息 // 保存任务与小组信息
saveUserRelation(auditors,task); saveUserRelation(auditors,task);
...@@ -395,6 +401,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas ...@@ -395,6 +401,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
task.setFile(standard.getFile()); task.setFile(standard.getFile());
} }
taskScenarioRelationMapper.delete(new QueryWrapper<TaskScenarioRelation>().lambda().eq(TaskScenarioRelation::getTaskId, task.getId()));
saveTaskScenario(task.getId(), request.getTestScenarioList());
// 找到审查组长 // 找到审查组长
TaskUserRelation leader = null; TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors(); List<TaskUserRelation> auditors = request.getAuditors();
...@@ -434,6 +443,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas ...@@ -434,6 +443,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
BeanUtils.copyBeanProp(response, task); BeanUtils.copyBeanProp(response, task);
// 测试场景
response.setTestScenarioList(selectTestScenarioList(task));
// 小组成员 // 小组成员
response.setAuditors(setAuditors(task.getId())); response.setAuditors(setAuditors(task.getId()));
...@@ -647,7 +659,31 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas ...@@ -647,7 +659,31 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
systemReviewTaskMapper.deleteById(task.getSystemReviewTaskId()); systemReviewTaskMapper.deleteById(task.getSystemReviewTaskId());
task.setSystemReviewTaskIdNull(); 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());
}
} }
} }
...@@ -799,4 +835,21 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas ...@@ -799,4 +835,21 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
return modelTestTask.getId(); 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 { ...@@ -66,4 +66,7 @@ public class TaskEditRequest {
@ApiModelProperty("选择的任务") @ApiModelProperty("选择的任务")
List<String> taskList; 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