Commit 9f66b059 authored by 盖献康's avatar 盖献康

Merge branch 'dev' of...

Merge branch 'dev' of ssh://gitlab.91isoft.com:10022/wangfei/vehicle-quality-review into gaixiankang

# Conflicts:
#	quality-review/src/main/java/com/ruoyi/service/impl/TaskServiceImpl.java
parents b1a7c4d7 12fc0de8
......@@ -74,6 +74,9 @@ public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, Init
@Autowired
private TaskUserRelationMapper taskUserRelationMapper;
@Autowired
private AutomobileEnterpriseMapper automobileEnterpriseMapper;
// PENDING状态下
// 1.standard字段查询当前最新问卷
// 2.查询场景变更任务
......@@ -86,9 +89,6 @@ public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, Init
// 获取当前问卷答案
List<ReviewDetailsResult> results = reviewDetailsResultService.findByTaskId(carReviewTask.getId());
// 任务样品关系
List<TaskSampleRelation> relations = taskSampleRelationMapper.selectByTaskId(taskMapper.findByCarReviewTaskId(carReviewTask.getId()),TaskSampleRelation.COMPLETE_VEHICLE_SAMPLE);
// 绑定问卷与答案
setDetailsResult(standardTree, results,carReviewTask);
......@@ -98,14 +98,17 @@ public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, Init
// 查询场景变更任务便于提醒用户场景变动
List<ReviewSceneChangeTask> lastChanges = reviewSceneChangeTaskService.findLastChangeByTaskId(carReviewTask.getId());
// 任务样品关系
List<TaskSampleRelation> sampleRelations = taskSampleRelationMapper.selectByTaskId(taskMapper.findByCarReviewTaskId(carReviewTask.getId()),TaskSampleRelation.COMPLETE_VEHICLE_SAMPLE);
// 获取第一个整车样品对应的生产企业
TaskSampleRelation taskSampleRelation = sampleRelations.get(0);
Sample sample = sampleManagementMapper.selectSampleManagementById(taskSampleRelation.getSampleId());
AutomobileEnterprise automobileEnterprise = automobileEnterpriseMapper.selectAutomobileEnterpriseById(sample.getManufacturingEnterpriseId());
carReviewTask.setEnterpriseName(sample.getManufacturingEnterprise());
carReviewTask.setEnterpriseName(automobileEnterprise.getEnterpriseName());
// 构建返回结果
CarReviewTaskViewResponse response = new CarReviewTaskViewResponse();
carReviewTask.setImagesUrl("/vehicle-quality-review-oss/2024/03/04/qianzi1_20240304104011A001.jpg,/vehicle-quality-review-oss/2024/03/04/qianzi2_20240304104121A002.jpg");
response.setCarReviewTask(carReviewTask);
......
......@@ -66,6 +66,9 @@ public class StrategySystemReviewTaskPending implements StrategySystemReviewTask
@Autowired
private TaskUserRelationMapper taskUserRelationMapper;
@Autowired
private AutomobileEnterpriseMapper automobileEnterpriseMapper;
@Override
public void doStart(SystemReviewTask systemReviewTask) {
throw new ServiceException("不能开始一个已经开始的任务", HttpStatus.ERROR);
......@@ -129,9 +132,6 @@ public class StrategySystemReviewTaskPending implements StrategySystemReviewTask
// 获取当前问卷答案
List<ReviewDetailsResult> results = reviewDetailsResultService.findByTaskId(systemReviewTask.getId());
// 任务样品关系
List<TaskSampleRelation> relations = taskSampleRelationMapper.selectByTaskId(taskMapper.findBySystemReviewTaskId(systemReviewTask.getId()),TaskSampleRelation.COMPLETE_VEHICLE_SAMPLE);
// 绑定问卷与答案
setDetailsResult(standardTree, results, systemReviewTask);
......@@ -141,12 +141,15 @@ public class StrategySystemReviewTaskPending implements StrategySystemReviewTask
// 查询场景变更任务便于提醒用户场景变动
List<ReviewSceneChangeTask> lastChanges = reviewSceneChangeTaskService.findLastChangeByTaskId(systemReviewTask.getId());
// 任务样品关系
List<TaskSampleRelation> sampleRelations = taskSampleRelationMapper.selectByTaskId(taskMapper.findBySystemReviewTaskId(systemReviewTask.getId()),TaskSampleRelation.COMPLETE_VEHICLE_SAMPLE);
// 获取第一个整车样品对应的生产企业
TaskSampleRelation taskSampleRelation = sampleRelations.get(0);
Sample sample = sampleManagementMapper.selectSampleManagementById(taskSampleRelation.getSampleId());
AutomobileEnterprise automobileEnterprise = automobileEnterpriseMapper.selectAutomobileEnterpriseById(sample.getManufacturingEnterpriseId());
systemReviewTask.setEnterpriseName(sample.getManufacturingEnterprise());
systemReviewTask.setEnterpriseName(automobileEnterprise.getEnterpriseName());
// 构建返回结果
SystemReviewTaskViewResponse response = new SystemReviewTaskViewResponse();
......
......@@ -85,6 +85,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
@Autowired
private ReviewDetailsResultService reviewDetailsResultService;
@Autowired
private AutomobileEnterpriseMapper automobileEnterpriseMapper;
@Autowired
private ModelTestTaskService modelTestTaskService;
......@@ -160,31 +163,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
}
// 构建并保存该任务所关联的审核组信息
for(TaskUserRelation auditor : auditors) {
auditor.setTaskId(task.getId());
}
taskUserRelationService.saveBatch(auditors);
saveUserRelation(auditors,task);
// 保存关联的整车样品信息
// 保存关联的整车样品信息和零部件样品信息
List<TaskSampleRelation> relations = request.getSample();
if (relations.size() != 0 && relations != null) {
for (TaskSampleRelation sampleRelation : relations) {
sampleRelation.setTaskId(task.getId());
}
taskSampleRelationService.saveBatch(relations);
}
// 保存关联的零部件样品信息
List<TaskSampleRelation> partRelations = request.getPartSample();
if (partRelations.size() != 0 && partRelations != null) {
for (TaskSampleRelation sampleRelation : partRelations) {
sampleRelation.setTaskId(task.getId());
}
taskSampleRelationService.saveBatch(partRelations);
}
saveSampleRelation(relations,partRelations,task);
taskStateFacade.doCreate(task, request.getTaskList());
......@@ -242,98 +226,23 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
task.setTaskList(joinTaskList);
BeanUtils.copyBeanProp(task, request);
if (Objects.equals(task.getTaskStatus(), Task.TASK_STATUS_NEW)) {
if(request.getTaskList().contains(Task.SUB_TASK_GRFIS) && task.getCarReviewTaskId() == null) {
// 保存车型审查问卷任务
TaskCreateRequest createRequest = new TaskCreateRequest();
BeanUtils.copyBeanProp(createRequest, request);
task.setCarReviewTaskId(saveCarReview(createRequest,initiator,standard,leader));
}
if ( !request.getTaskList().contains(Task.SUB_TASK_GRFIS) && task.getCarReviewTaskId() != null) {
carReviewTaskMapper.deleteById(task.getCarReviewTaskId());
task.setCarReviewTaskIdNull();
}
if(request.getTaskList().contains(Task.SUB_TASK_SRAIF) && task.getSystemReviewTaskId() == null) {
// 保存体系审查任务
TaskCreateRequest createRequest = new TaskCreateRequest();
BeanUtils.copyBeanProp(createRequest, request);
task.setSystemReviewTaskId(saveSystemReview(createRequest,initiator,standard,leader));
}
if ( !request.getTaskList().contains(Task.SUB_TASK_SRAIF) && task.getSystemReviewTaskId() != null) {
systemReviewTaskMapper.deleteById(task.getSystemReviewTaskId());
task.setSystemReviewTaskIdNull();
}
}
// 子任务发送变化
changeSubTask(request,task,initiator,standard,leader);
task.setMaxPointer(request.getTaskList().size());
taskService.updateById(task);
// 构建并保存该任务所关联的审核组信息
List<TaskUserRelation> list = taskUserRelationService.selectQTeamMembers(request.getId());
taskUserRelationService.removeBatchByIds(list);
for(TaskUserRelation auditor : auditors) {
auditor.setTaskId(task.getId());
}
taskUserRelationService.saveBatch(auditors);
// 获取传入的样品列表
List<TaskSampleRelation> relations = request.getSample();
// 任务样品关系
List<TaskSampleRelation> sampleRelations = taskSampleRelationMapper.selectByTaskId(request.getId(),TaskSampleRelation.COMPLETE_VEHICLE_SAMPLE);
if (sampleRelations.size() != 0 && sampleRelations != null) {
// 获取之前的第一个企业名称
TaskSampleRelation taskSampleRelation = sampleRelations.get(0);
Sample oldSample = sampleManagementMapper.selectSampleManagementById(taskSampleRelation.getSampleId());
// 获取编辑任务后的第一个企业名称
TaskSampleRelation newTaskSampleRelation = relations.get(0);
Sample newSample = sampleManagementMapper.selectSampleManagementById(newTaskSampleRelation.getSampleId());
// 第一个企业名称不相同则修改
if (!Objects.equals(oldSample.getManufacturingEnterprise(), newSample.getManufacturingEnterprise())){
// 留档文件
List<ReviewEnterpriseArchive> reviewEnterpriseArchiveList = reviewEnterpriseArchiveMapper.findList(request.getId());
saveUserRelation(auditors,task);
if (reviewEnterpriseArchiveList.size() != 0 && reviewEnterpriseArchiveList != null) {
for (ReviewEnterpriseArchive reviewEnterpriseArchive : reviewEnterpriseArchiveList) {
reviewEnterpriseArchive.setEnterpriseName(newSample.getManufacturingEnterprise());
}
// 判断第一个整车样品的生产企业是否变化
judgmentSample(request);
reviewEnterpriseArchiveService.updateBatchById(reviewEnterpriseArchiveList);
}
}
}
// 保存关联的整车样品信息
List<TaskSampleRelation> partRelationList = taskSampleRelationService.selectByTaskId(request.getId(),TaskSampleRelation.COMPLETE_VEHICLE_SAMPLE);
taskSampleRelationService.removeBatchByIds(partRelationList);
if (relations.size() != 0 && relations != null) {
for (TaskSampleRelation sampleRelation : relations) {
sampleRelation.setTaskId(task.getId());
}
taskSampleRelationService.saveBatch(relations);
}
// 保存关联的零部件样品信息
List<TaskSampleRelation> relationList = taskSampleRelationService.selectByTaskId(request.getId(),TaskSampleRelation.PART_VEHICLE_SAMPLE);
taskSampleRelationService.removeBatchByIds(relationList);
// 保存关联的整车样品信息和零部件样品信息
List<TaskSampleRelation> relations = request.getSample();
List<TaskSampleRelation> partRelations = request.getPartSample();
if (partRelations.size() != 0 && partRelations != null) {
for (TaskSampleRelation partSampleRelation : partRelations) {
partSampleRelation.setTaskId(task.getId());
}
taskSampleRelationService.saveBatch(partRelations);
}
saveSampleRelation(relations,partRelations,task);
}
......@@ -454,37 +363,14 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
// 暂存
taskService.save(task);
if (auditors.size() != 0 && auditors != null) {
// 构建并保存该任务所关联的审核组信息
for(TaskUserRelation auditor : auditors) {
auditor.setTaskId(task.getId());
}
taskUserRelationService.saveBatch(auditors);
}
// 保存任务与小组信息
saveUserRelation(auditors,task);
// 保存关联的整车样品信息
// 保存关联的整车样品信息和零部件样品信息
List<TaskSampleRelation> relations = request.getSample();
if (relations.size() != 0 && relations != null) {
for (TaskSampleRelation sampleRelation : relations) {
sampleRelation.setTaskId(task.getId());
}
taskSampleRelationService.saveBatch(relations);
}
// 保存关联的零部件样品信息
List<TaskSampleRelation> partRelations = request.getPartSample();
if (partRelations.size() != 0 && partRelations != null) {
for (TaskSampleRelation sampleRelation : partRelations) {
sampleRelation.setTaskId(task.getId());
}
saveSampleRelation(relations,partRelations,task);
taskSampleRelationService.saveBatch(partRelations);
}
}
@Override
......@@ -514,54 +400,29 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors();
if (auditors.size() != 0 && auditors != null) {
List<TaskUserRelation> list = taskUserRelationService.selectQTeamMembers(request.getId());
taskUserRelationService.removeBatchByIds(list);
for(TaskUserRelation auditor : auditors) {
if(auditor.getIsLeader() == 1) {
leader = auditor;
break;
}
}
// 构建并保存该任务所关联的审核组信息
for(TaskUserRelation auditor : auditors) {
auditor.setTaskId(task.getId());
}
taskUserRelationService.saveBatch(auditors);
// 任务组长
task.setLeaderId(leader.getUserId());
task.setLeader(leader.getName());
}
// 暂存
// 更新暂存
taskService.updateById(task);
// 保存任务与小组信息
saveUserRelation(auditors,task);
// 保存关联的整车样品信息
List<TaskSampleRelation> partRelationList = taskSampleRelationService.selectByTaskId(request.getId(),TaskSampleRelation.COMPLETE_VEHICLE_SAMPLE);
taskSampleRelationService.removeBatchByIds(partRelationList);
List<TaskSampleRelation> relations = request.getSample();
if (relations.size() != 0 && relations != null) {
for (TaskSampleRelation sampleRelation : relations) {
sampleRelation.setTaskId(task.getId());
}
taskSampleRelationService.saveBatch(relations);
}
// 保存关联的零部件样品信息
List<TaskSampleRelation> relationList = taskSampleRelationService.selectByTaskId(request.getId(),TaskSampleRelation.PART_VEHICLE_SAMPLE);
taskSampleRelationService.removeBatchByIds(relationList);
List<TaskSampleRelation> partRelations = request.getPartSample();
if (partRelations.size() != 0 && partRelations != null) {
for (TaskSampleRelation sampleRelation : partRelations) {
sampleRelation.setTaskId(task.getId());
}
saveSampleRelation(relations,partRelations,task);
taskSampleRelationService.saveBatch(partRelations);
}
}
@Override
......@@ -657,6 +518,119 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
}
// 保存任务与小组信息
private void saveUserRelation(List<TaskUserRelation> auditors,Task task) {
// 构建并保存该任务所关联的审核组信息
List<TaskUserRelation> list = taskUserRelationService.selectQTeamMembers(task.getId());
if (list.size() != 0 && list != null) {
taskUserRelationService.removeBatchByIds(list);
}
if (auditors.size() != 0 && auditors != null) {
// 构建并保存该任务所关联的审核组信息
for(TaskUserRelation auditor : auditors) {
auditor.setTaskId(task.getId());
}
taskUserRelationService.saveBatch(auditors);
}
}
// 保存任务与样品信息
private void saveSampleRelation(List<TaskSampleRelation> relations,List<TaskSampleRelation> partRelations,Task task) {
// 整车
List<TaskSampleRelation> relationList = taskSampleRelationService.selectByTaskId(task.getId(),TaskSampleRelation.COMPLETE_VEHICLE_SAMPLE);
if (relationList.size() != 0 && relationList != null) {
taskSampleRelationService.removeBatchByIds(relationList);
}
if (relations.size() != 0 && relations != null) {
for (TaskSampleRelation sampleRelation : relations) {
sampleRelation.setTaskId(task.getId());
}
taskSampleRelationService.saveBatch(relations);
}
// 零件
List<TaskSampleRelation> partRelationList = taskSampleRelationService.selectByTaskId(task.getId(),TaskSampleRelation.PART_VEHICLE_SAMPLE);
if (partRelationList.size() != 0 && partRelationList != null) {
taskSampleRelationService.removeBatchByIds(partRelationList);
}
if (partRelations.size() != 0 && partRelations != null) {
for (TaskSampleRelation sampleRelation : partRelations) {
sampleRelation.setTaskId(task.getId());
}
taskSampleRelationService.saveBatch(partRelations);
}
}
// 判断编辑任务时,第一整车样品的生成企业有无变化
private void judgmentSample(TaskEditRequest request) {
// 获取传入的样品列表
List<TaskSampleRelation> relations = request.getSample();
// 任务与整车样品关系
List<TaskSampleRelation> sampleRelations = taskSampleRelationMapper.selectByTaskId(request.getId(),TaskSampleRelation.COMPLETE_VEHICLE_SAMPLE);
if (sampleRelations.size() != 0 && sampleRelations != null) {
// 获取之前的第一个企业名称
TaskSampleRelation taskSampleRelation = sampleRelations.get(0);
Sample oldSample = sampleManagementMapper.selectSampleManagementById(taskSampleRelation.getSampleId());
AutomobileEnterprise oldAutomobileEnterprise = automobileEnterpriseMapper.selectAutomobileEnterpriseById(oldSample.getManufacturingEnterpriseId());
// 获取编辑任务后的第一个企业名称
TaskSampleRelation newTaskSampleRelation = relations.get(0);
Sample newSample = sampleManagementMapper.selectSampleManagementById(newTaskSampleRelation.getSampleId());
AutomobileEnterprise newAutomobileEnterprise = automobileEnterpriseMapper.selectAutomobileEnterpriseById(newSample.getManufacturingEnterpriseId());
// 第一个企业名称不相同则修改
if (!Objects.equals(oldAutomobileEnterprise.getEnterpriseName(), newAutomobileEnterprise.getEnterpriseName())){
// 留档文件
List<ReviewEnterpriseArchive> reviewEnterpriseArchiveList = reviewEnterpriseArchiveMapper.findList(request.getId());
if (reviewEnterpriseArchiveList.size() != 0 && reviewEnterpriseArchiveList != null) {
for (ReviewEnterpriseArchive reviewEnterpriseArchive : reviewEnterpriseArchiveList) {
reviewEnterpriseArchive.setEnterpriseName(newAutomobileEnterprise.getEnterpriseName());
}
reviewEnterpriseArchiveService.updateBatchById(reviewEnterpriseArchiveList);
}
}
}
}
// 编辑任务时子任务发送变化
private void changeSubTask(TaskEditRequest request,Task task,SysUser initiator,Standard standard,TaskUserRelation leader) {
if (Objects.equals(task.getTaskStatus(), Task.TASK_STATUS_NEW)) {
if(request.getTaskList().contains(Task.SUB_TASK_GRFIS) && task.getCarReviewTaskId() == null) {
// 保存车型审查问卷任务
TaskCreateRequest createRequest = new TaskCreateRequest();
BeanUtils.copyBeanProp(createRequest, request);
task.setCarReviewTaskId(saveCarReview(createRequest,initiator,standard,leader));
}
if ( !request.getTaskList().contains(Task.SUB_TASK_GRFIS) && task.getCarReviewTaskId() != null) {
carReviewTaskMapper.deleteById(task.getCarReviewTaskId());
task.setCarReviewTaskIdNull();
}
if(request.getTaskList().contains(Task.SUB_TASK_SRAIF) && task.getSystemReviewTaskId() == null) {
// 保存体系审查任务
TaskCreateRequest createRequest = new TaskCreateRequest();
BeanUtils.copyBeanProp(createRequest, request);
task.setSystemReviewTaskId(saveSystemReview(createRequest,initiator,standard,leader));
}
if ( !request.getTaskList().contains(Task.SUB_TASK_SRAIF) && task.getSystemReviewTaskId() != null) {
systemReviewTaskMapper.deleteById(task.getSystemReviewTaskId());
task.setSystemReviewTaskIdNull();
}
}
}
private void setSystemDataStatistics(List<ReviewStandard> standards, List<ReviewDetailsResult> results,DataStatisticsResponse response,SystemReviewTask systemReviewTask) {
Map<Long, ReviewDetailsResult> resultMap = results.stream().collect(Collectors.toMap(ReviewDetailsResult::getReviewDetailsId, Function.identity(), (v1, v2) -> v1));
......
......@@ -104,7 +104,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="enterpriseId != null">#{enterpriseId}</if>
<if test="remark != null">#{remark},</if>
<if test="trademark != null">#{trademark},</if>
<if test="samplePhotos != null">#{samplePhotos},</if>
......@@ -177,7 +176,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select t.id,t.identification_code,t.sample_number,t.sample_name,t.manufacturing_enterprise_id,t.trademark,t.sample_photos,t.number_of_samples,t.delivery_date,t.sample_sender,t.manufacturing_enterprise,t.manufacture_date
from t_sample t
left join t_task_sample_relation ts on ts.sample_id = t.id and ts.task_id = #{id}
WHERE t.id IN
WHERE t.deleted = 0
AND t.id IN
<foreach collection="relationList" item="relation" open="(" separator="," close=")">
#{relation.sampleId}
</foreach>
......
......@@ -15,13 +15,14 @@
select id,task_id,sample_id,flag from t_task_sample_relation
</sql>
<select id="selectByTaskId" resultType="com.ruoyi.domain.TaskSampleRelation">
<include refid="Base_Column_List"/>
select ts.id,ts.task_id,ts.sample_id,ts.flag from t_task_sample_relation ts
left join t_sample t on t.id = ts.sample_id and t.deleted = 0
where
<if test="taskId != null and taskId != ''">
task_id = #{taskId}
ts.task_id = #{taskId}
</if>
<if test="flag != null and flag != ''">
and flag = #{flag}
and ts.flag = #{flag}
</if>
</select>
......
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