Commit 958b2fab authored by 盖献康's avatar 盖献康

Merge branch 'dev' of...

Merge branch 'dev' of ssh://gitlab.91isoft.com:10022/wangfei/vehicle-quality-review into gaixiankang
parents 46573d01 beff6744
package com.ruoyi.common;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.domain.*;
import com.ruoyi.mapper.TaskMapper;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class DataStatisticsUtils {
public static int calculateStandards(List<ReviewStandard> standards) {
return standards.size();
}
public static int calculateStandardsPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
int standardsPass = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
boolean isPass = true;
for(ReviewDetails reviewDetails : details) {
Integer passed = detailsIsPass(reviewDetails, resultMap);
if(passed == null) {
isPass = false;
}
if(passed == ReviewStandard.NO_PASSED) {
isPass = false;
}
}
if(isPass) {
standardsPass = standardsPass + 1;
}
}
return standardsPass;
}
public static int calculateStandardsNoPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
int standardsNoPass = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
boolean isPass = true;
for(ReviewDetails reviewDetails : details) {
Integer passed = detailsIsPass(reviewDetails, resultMap);
if(passed == null) {
isPass = false;
}
if(passed == ReviewStandard.PASSED) {
isPass = false;
}
}
if(isPass) {
standardsNoPass = standardsNoPass + 1;
}
}
return standardsNoPass;
}
public static int calculateDetails(List<ReviewStandard> standards) {
//审查细则(条)
int detailsNum = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
detailsNum = detailsNum + details.size();
}
return detailsNum;
}
public static int calculateDetailsPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
int detailsPass = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
for(ReviewDetails reviewDetails : details) {
if (detailsIsPass(reviewDetails, resultMap) == null) {
continue;
}
if(detailsIsPass(reviewDetails, resultMap) == ReviewStandard.PASSED) {
detailsPass = detailsPass + 1;
}
}
}
return detailsPass;
}
public static int calculateDetailsNoPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
int detailsNoPass = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
for(ReviewDetails reviewDetails : details) {
if(detailsIsPass(reviewDetails, resultMap) == ReviewStandard.NO_PASSED) {
detailsNoPass = detailsNoPass + 1;
}
}
}
return detailsNoPass;
}
public static List<ReviewDetails> getDetailsByStandard(ReviewStandard standard) {
List<ReviewDetails> details = new ArrayList();
List<ReviewKeyPoint> keyPointList = standard.getKeyPointList();
for(ReviewKeyPoint keyPoint : keyPointList) {
details.addAll(keyPoint.getReviewDetailsList());
}
return details;
}
public static Integer detailsIsPass(ReviewDetails reviewDetails, Map<Long, ReviewDetailsResult> resultMap) {
ReviewDetailsResult result = resultMap.get(reviewDetails.getId());
if(result == null) {
return null;
}
return result.getPassed();
}
}
...@@ -14,5 +14,5 @@ import java.util.List; ...@@ -14,5 +14,5 @@ import java.util.List;
public class SampleTaskVo { public class SampleTaskVo {
private Long taskId; private Long taskId;
private Long SampleId; private Long SampleId;
private String taskName; private String taskNo;
} }
...@@ -3,6 +3,7 @@ package com.ruoyi.service; ...@@ -3,6 +3,7 @@ package com.ruoyi.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.domain.Task; import com.ruoyi.domain.Task;
import com.ruoyi.web.request.*; import com.ruoyi.web.request.*;
import com.ruoyi.web.response.DataStatisticsResponse;
import com.ruoyi.web.response.TaskFindResponse; import com.ruoyi.web.response.TaskFindResponse;
import com.ruoyi.web.response.TaskGetInfoResponse; import com.ruoyi.web.response.TaskGetInfoResponse;
...@@ -17,7 +18,7 @@ public interface TaskService extends IService<Task> { ...@@ -17,7 +18,7 @@ public interface TaskService extends IService<Task> {
*/ */
List<Task> findList(TaskListRequest request); List<Task> findList(TaskListRequest request);
void createTask(TaskCreateRequest request); void createTask(TaskCreateRequest request,Long userId);
/** /**
* 查询进行中的任务 * 查询进行中的任务
...@@ -57,7 +58,11 @@ public interface TaskService extends IService<Task> { ...@@ -57,7 +58,11 @@ public interface TaskService extends IService<Task> {
void temporaryStorageTask(TaskCreateRequest request); void temporaryStorageTask(TaskCreateRequest request);
void editTemporaryStorageTask(TaskEditRequest request);
TaskGetInfoResponse getByUserId(Long userId); TaskGetInfoResponse getByUserId(Long userId);
TaskGetInfoResponse getBySubtaskId(TaskSubGetInfoRequest request); TaskGetInfoResponse getBySubtaskId(TaskSubGetInfoRequest request);
DataStatisticsResponse dataStatistics(TaskGetInfoRequest request);
} }
package com.ruoyi.service.impl; package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.annotation.TableField; import com.ruoyi.common.DataStatisticsUtils;
import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.domain.*; import com.ruoyi.domain.*;
import com.ruoyi.mapper.*; import com.ruoyi.mapper.*;
import com.ruoyi.service.*; import com.ruoyi.service.*;
import com.ruoyi.web.response.CarReviewTaskViewResponse; import com.ruoyi.web.response.CarReviewTaskViewResponse;
import io.swagger.annotations.ApiModelProperty;
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;
...@@ -21,6 +18,8 @@ import java.util.*; ...@@ -21,6 +18,8 @@ import java.util.*;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.ruoyi.common.DataStatisticsUtils.calculateStandardsPass;
@Transactional @Transactional
@Service @Service
public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, InitializingBean { public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, InitializingBean {
...@@ -190,98 +189,16 @@ public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, Init ...@@ -190,98 +189,16 @@ public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, Init
List<TaskUserRelation> relationList = taskUserRelationMapper.selectQTeamMembers(taskMapper.findByCarReviewTaskId(carReviewTask.getId())); List<TaskUserRelation> relationList = taskUserRelationMapper.selectQTeamMembers(taskMapper.findByCarReviewTaskId(carReviewTask.getId()));
carReviewTask.setStandards(calculateStandards(standards)); carReviewTask.setStandards(DataStatisticsUtils.calculateStandards(standards));
BigDecimal standardPass = new BigDecimal(calculateStandardsPass(standards, resultMap) / (double) carReviewTask.getStandards()); BigDecimal standardPass = new BigDecimal(calculateStandardsPass(standards, resultMap) / (double) carReviewTask.getStandards());
carReviewTask.setStandardsPass(standardPass.setScale(3,BigDecimal.ROUND_UP).doubleValue() * 100); carReviewTask.setStandardsPass(standardPass.setScale(3,BigDecimal.ROUND_UP).doubleValue() * 100);
carReviewTask.setDetails(calculateDetails(standards)); carReviewTask.setDetails(DataStatisticsUtils.calculateDetails(standards));
BigDecimal detailsPass = new BigDecimal(calculateDetailsPass(standards, resultMap) / (double) carReviewTask.getDetails()); BigDecimal detailsPass = new BigDecimal(DataStatisticsUtils.calculateDetailsPass(standards, resultMap) / (double) carReviewTask.getDetails());
carReviewTask.setDetailsPass(detailsPass.setScale(3,BigDecimal.ROUND_UP).doubleValue() * 100); carReviewTask.setDetailsPass(detailsPass.setScale(3,BigDecimal.ROUND_UP).doubleValue() * 100);
carReviewTask.setPerson(relationList.size()); carReviewTask.setPerson(relationList.size());
} }
private int calculateStandards(List<ReviewStandard> standards) {
return standards.size();
}
private long calculateStandardsPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
long standardsPass = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
boolean isPass = true;
for(ReviewDetails reviewDetails : details) {
if(!detailsIsPass(reviewDetails, resultMap)) {
isPass = false;
}
}
if(isPass) {
standardsPass = standardsPass + 1;
}
}
return standardsPass;
}
private int calculateDetails(List<ReviewStandard> standards) {
//审查细则(条)
int detailsNum = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
detailsNum = detailsNum + details.size();
}
return detailsNum;
}
private long calculateDetailsPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
long detailsPass = 0L;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
for(ReviewDetails reviewDetails : details) {
if(detailsIsPass(reviewDetails, resultMap)) {
detailsPass = detailsPass + 1;
}
}
}
return detailsPass;
}
private List<ReviewDetails> getDetailsByStandard(ReviewStandard standard) {
List<ReviewDetails> details = new ArrayList();
List<ReviewKeyPoint> keyPointList = standard.getKeyPointList();
for(ReviewKeyPoint keyPoint : keyPointList) {
details.addAll(keyPoint.getReviewDetailsList());
}
return details;
}
private boolean detailsIsPass(ReviewDetails reviewDetails, Map<Long, ReviewDetailsResult> resultMap) {
ReviewDetailsResult result = resultMap.get(reviewDetails.getId());
if (result != null ) {
return Objects.equals(result.getPassed(), ReviewStandard.PASSED);
} else {
return false;
}
}
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
......
package com.ruoyi.service.impl; package com.ruoyi.service.impl;
import com.ruoyi.common.DataStatisticsUtils;
import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
...@@ -185,97 +186,15 @@ public class StrategySystemReviewTaskPending implements StrategySystemReviewTask ...@@ -185,97 +186,15 @@ public class StrategySystemReviewTaskPending implements StrategySystemReviewTask
List<TaskUserRelation> relationList = taskUserRelationMapper.selectQTeamMembers(taskMapper.findBySystemReviewTaskId(systemReviewTask.getId())); List<TaskUserRelation> relationList = taskUserRelationMapper.selectQTeamMembers(taskMapper.findBySystemReviewTaskId(systemReviewTask.getId()));
systemReviewTask.setStandards(calculateStandards(standards)); systemReviewTask.setStandards(DataStatisticsUtils.calculateStandards(standards));
BigDecimal standardPass = new BigDecimal(calculateStandardsPass(standards, resultMap) / (double) systemReviewTask.getStandards()); BigDecimal standardPass = new BigDecimal(DataStatisticsUtils.calculateStandardsPass(standards, resultMap) / (double) systemReviewTask.getStandards());
systemReviewTask.setStandardsPass(standardPass.setScale(3,BigDecimal.ROUND_UP).doubleValue() * 100); systemReviewTask.setStandardsPass(standardPass.setScale(3,BigDecimal.ROUND_UP).doubleValue() * 100);
systemReviewTask.setDetails(calculateDetails(standards)); systemReviewTask.setDetails(DataStatisticsUtils.calculateDetails(standards));
BigDecimal detailsPass = new BigDecimal(calculateDetailsPass(standards, resultMap) / (double) systemReviewTask.getDetails()); BigDecimal detailsPass = new BigDecimal(DataStatisticsUtils.calculateDetailsPass(standards, resultMap) / (double) systemReviewTask.getDetails());
systemReviewTask.setDetailsPass(detailsPass.setScale(3,BigDecimal.ROUND_UP).doubleValue() * 100); systemReviewTask.setDetailsPass(detailsPass.setScale(3,BigDecimal.ROUND_UP).doubleValue() * 100);
systemReviewTask.setPerson(relationList.size()); systemReviewTask.setPerson(relationList.size());
} }
private int calculateStandards(List<ReviewStandard> standards) {
return standards.size();
}
private long calculateStandardsPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
long standardsPass = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
boolean isPass = true;
for(ReviewDetails reviewDetails : details) {
if(!detailsIsPass(reviewDetails, resultMap)) {
isPass = false;
}
}
if(isPass) {
standardsPass = standardsPass + 1;
}
}
return standardsPass;
}
private int calculateDetails(List<ReviewStandard> standards) {
//审查细则(条)
int detailsNum = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
detailsNum = detailsNum + details.size();
}
return detailsNum;
}
private long calculateDetailsPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
long detailsPass = 0L;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
for(ReviewDetails reviewDetails : details) {
if(detailsIsPass(reviewDetails, resultMap)) {
detailsPass = detailsPass + 1;
}
}
}
return detailsPass;
}
private List<ReviewDetails> getDetailsByStandard(ReviewStandard standard) {
List<ReviewDetails> details = new ArrayList();
List<ReviewKeyPoint> keyPointList = standard.getKeyPointList();
for(ReviewKeyPoint keyPoint : keyPointList) {
details.addAll(keyPoint.getReviewDetailsList());
}
return details;
}
private boolean detailsIsPass(ReviewDetails reviewDetails, Map<Long, ReviewDetailsResult> resultMap) {
ReviewDetailsResult result = resultMap.get(reviewDetails.getId());
if (result != null ) {
return Objects.equals(result.getPassed(), ReviewStandard.PASSED);
} else {
return false;
}
}
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
......
package com.ruoyi.service.impl; package com.ruoyi.service.impl;
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.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
...@@ -11,19 +12,24 @@ import com.ruoyi.mapper.*; ...@@ -11,19 +12,24 @@ import com.ruoyi.mapper.*;
import com.ruoyi.service.*; import com.ruoyi.service.*;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.web.request.*; import com.ruoyi.web.request.*;
import com.ruoyi.web.response.DataStatisticsResponse;
import com.ruoyi.web.response.TaskFindResponse; import com.ruoyi.web.response.TaskFindResponse;
import com.ruoyi.web.response.TaskGetInfoResponse; import com.ruoyi.web.response.TaskGetInfoResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
@Transactional @Transactional
@Service @Service
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService { public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements TaskService {
@Autowired @Autowired
private TaskMapper taskMapper; private TaskMapper taskMapper;
...@@ -73,6 +79,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -73,6 +79,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
@Autowired @Autowired
private ReviewEnterpriseArchiveService reviewEnterpriseArchiveService; private ReviewEnterpriseArchiveService reviewEnterpriseArchiveService;
@Autowired
private ReviewStandardService reviewStandardService;
@Autowired
private ReviewDetailsResultService reviewDetailsResultService;
@Override @Override
public List<Task> findList(TaskListRequest request) { public List<Task> findList(TaskListRequest request) {
...@@ -80,7 +92,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -80,7 +92,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
} }
@Override @Override
public void createTask(TaskCreateRequest request) { public void createTask(TaskCreateRequest request,Long userId) {
// 构建任务创建者 // 构建任务创建者
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
...@@ -155,6 +167,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -155,6 +167,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
taskStateFacade.doCreate(task, request.getTaskList()); taskStateFacade.doCreate(task, request.getTaskList());
TaskGetInfoResponse temporaryStorageTask = taskService.getByUserId(userId);
taskMapper.deleteById(temporaryStorageTask.getId());
} }
@Override @Override
...@@ -179,6 +194,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -179,6 +194,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
@Override @Override
public void editTask(TaskEditRequest request) { public void editTask(TaskEditRequest request) {
// 构建任务创建者
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser initiator = sysUserService.selectUserById(loginUser.getUserId());
Standard standard = standardService.findListById(request.getStandardId());
// 找到审查组长 // 找到审查组长
TaskUserRelation leader = null; TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors(); List<TaskUserRelation> auditors = request.getAuditors();
...@@ -198,6 +218,27 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -198,6 +218,27 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
task.setTaskList(joinTaskList); task.setTaskList(joinTaskList);
BeanUtils.copyBeanProp(task, request); BeanUtils.copyBeanProp(task, request);
Task oldTask = taskMapper.selectById(request.getId());
if(request.getTaskList().contains(Task.SUB_TASK_GRFIS) && oldTask.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) && oldTask.getCarReviewTaskId() != null) {
carReviewTaskMapper.deleteById(oldTask.getCarReviewTaskId());
}
if(request.getTaskList().contains(Task.SUB_TASK_SRAIF) && oldTask.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) && oldTask.getSystemReviewTaskId() != null) {
systemReviewTaskMapper.deleteById(oldTask.getSystemReviewTaskId());
}
taskService.updateById(task); taskService.updateById(task);
// 构建并保存该任务所关联的审核组信息 // 构建并保存该任务所关联的审核组信息
...@@ -209,8 +250,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -209,8 +250,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
taskUserRelationService.saveBatch(auditors); taskUserRelationService.saveBatch(auditors);
// 保存关联的整车样品信息 // 保存关联的整车样品信息
List<TaskSampleRelation> partRelationList = taskSampleRelationService.selectByTaskId(request.getId(),TaskSampleRelation.PART_VEHICLE_SAMPLE); List<TaskSampleRelation> partRelationList = taskSampleRelationService.selectByTaskId(request.getId(),TaskSampleRelation.COMPLETE_VEHICLE_SAMPLE);
taskSampleRelationService.removeBatchByIds(partRelationList); taskSampleRelationService.removeBatchByIds(partRelationList);
List<TaskSampleRelation> relations = request.getSample(); List<TaskSampleRelation> relations = request.getSample();
if (relations.size() != 0 && relations != null) { if (relations.size() != 0 && relations != null) {
for (TaskSampleRelation sampleRelation : relations) { for (TaskSampleRelation sampleRelation : relations) {
...@@ -220,40 +262,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -220,40 +262,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
taskSampleRelationService.saveBatch(relations); taskSampleRelationService.saveBatch(relations);
} }
// 任务样品关系
List<TaskSampleRelation> sampleRelations = taskSampleRelationMapper.selectByTaskId(request.getId(),TaskSampleRelation.COMPLETE_VEHICLE_SAMPLE);
// 获取之前的第一个企业名称
TaskSampleRelation taskSampleRelation = sampleRelations.get(0);
Sample sample = sampleManagementMapper.selectSampleManagementById(taskSampleRelation.getSampleId());
// 获取编辑任务后的第一个企业名称
TaskSampleRelation taskSampleRelation1 = relations.get(0);
Sample sample1 = sampleManagementMapper.selectSampleManagementById(taskSampleRelation1.getSampleId());
// 第一个企业名称不相同则修改
if (!Objects.equals(sample.getManufacturingEnterprise(), sample1.getManufacturingEnterprise())){
Task task1 = taskMapper.selectById(request.getId());
// 体系审查对应的留档文件
List<ReviewEnterpriseArchive> reviewEnterpriseArchiveList = reviewEnterpriseArchiveMapper.findList(task1.getSystemReviewTaskId());
for (ReviewEnterpriseArchive reviewEnterpriseArchive : reviewEnterpriseArchiveList) {
reviewEnterpriseArchive.setEnterpriseName(sample1.getManufacturingEnterprise());
}
reviewEnterpriseArchiveService.updateBatchById(reviewEnterpriseArchiveList);
// 车辆对应的留档文件
List<ReviewEnterpriseArchive> reviewEnterpriseArchiveList1 = reviewEnterpriseArchiveMapper.findList(task1.getCarReviewTaskId());
for (ReviewEnterpriseArchive reviewEnterpriseArchive1 : reviewEnterpriseArchiveList1) {
reviewEnterpriseArchive1.setEnterpriseName(sample1.getManufacturingEnterprise());
}
reviewEnterpriseArchiveService.updateBatchById(reviewEnterpriseArchiveList1);
}
// 保存关联的零部件样品信息 // 保存关联的零部件样品信息
List<TaskSampleRelation> relationList = taskSampleRelationService.selectByTaskId(request.getId(),TaskSampleRelation.COMPLETE_VEHICLE_SAMPLE); List<TaskSampleRelation> relationList = taskSampleRelationService.selectByTaskId(request.getId(),TaskSampleRelation.PART_VEHICLE_SAMPLE);
taskSampleRelationService.removeBatchByIds(relationList); taskSampleRelationService.removeBatchByIds(relationList);
List<TaskSampleRelation> partRelations = request.getPartSample(); List<TaskSampleRelation> partRelations = request.getPartSample();
if (partRelations.size() != 0 && partRelations != null) { if (partRelations.size() != 0 && partRelations != null) {
...@@ -263,6 +273,40 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -263,6 +273,40 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
taskSampleRelationService.saveBatch(partRelations); taskSampleRelationService.saveBatch(partRelations);
} }
// 任务样品关系
List<TaskSampleRelation> sampleRelations = taskSampleRelationMapper.selectByTaskId(request.getId(),TaskSampleRelation.COMPLETE_VEHICLE_SAMPLE);
if (sampleRelations.size() != 0 && sampleRelations != null) {
// 获取之前的第一个企业名称
TaskSampleRelation taskSampleRelation = sampleRelations.get(0);
Sample sample = sampleManagementMapper.selectSampleManagementById(taskSampleRelation.getSampleId());
// 获取编辑任务后的第一个企业名称
TaskSampleRelation taskSampleRelation1 = relations.get(0);
Sample sample1 = sampleManagementMapper.selectSampleManagementById(taskSampleRelation1.getSampleId());
// 第一个企业名称不相同则修改
if (!Objects.equals(sample.getManufacturingEnterprise(), sample1.getManufacturingEnterprise())){
Task task1 = taskMapper.selectById(request.getId());
// 体系审查对应的留档文件
List<ReviewEnterpriseArchive> reviewEnterpriseArchiveList = reviewEnterpriseArchiveMapper.findList(task1.getSystemReviewTaskId());
for (ReviewEnterpriseArchive reviewEnterpriseArchive : reviewEnterpriseArchiveList) {
reviewEnterpriseArchive.setEnterpriseName(sample1.getManufacturingEnterprise());
}
reviewEnterpriseArchiveService.updateBatchById(reviewEnterpriseArchiveList);
// 车辆对应的留档文件
List<ReviewEnterpriseArchive> reviewEnterpriseArchiveList1 = reviewEnterpriseArchiveMapper.findList(task1.getCarReviewTaskId());
for (ReviewEnterpriseArchive reviewEnterpriseArchive1 : reviewEnterpriseArchiveList1) {
reviewEnterpriseArchive1.setEnterpriseName(sample1.getManufacturingEnterprise());
}
reviewEnterpriseArchiveService.updateBatchById(reviewEnterpriseArchiveList1);
}
}
} }
@Override @Override
...@@ -340,13 +384,16 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -340,13 +384,16 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
task.setTaskInitiator(initiator.getNickName()); task.setTaskInitiator(initiator.getNickName());
task.setTaskInitiatorDept(initiator.getDept().getDeptName()); task.setTaskInitiatorDept(initiator.getDept().getDeptName());
task.setTaskStatus(Task.TASK_STATUS_TEMPORARILY); task.setTaskStatus(Task.TASK_STATUS_TEMPORARILY);
task.setName(standard.getName());
task.setStandardNo(standard.getStandardNo());
task.setFile(standard.getFile());
String joinTaskList = StringUtils.join(request.getTaskList(),","); String joinTaskList = StringUtils.join(request.getTaskList(),",");
task.setTaskList(joinTaskList); task.setTaskList(joinTaskList);
BeanUtils.copyBeanProp(task, request); BeanUtils.copyBeanProp(task, request);
if (standard != null) {
task.setName(standard.getName());
task.setStandardNo(standard.getStandardNo());
task.setFile(standard.getFile());
}
// 找到审查组长 // 找到审查组长
TaskUserRelation leader = null; TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors(); List<TaskUserRelation> auditors = request.getAuditors();
...@@ -395,6 +442,83 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -395,6 +442,83 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
} }
} }
@Override
public void editTemporaryStorageTask(TaskEditRequest request) {
// 构建任务创建者
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser initiator = sysUserService.selectUserById(loginUser.getUserId());
Standard standard = standardService.findListById(request.getStandardId());
// 构建并保存任务信息
// 总任务
Task task = new Task();
task.setTaskInitiatorId(loginUser.getUserId());
task.setTaskInitiator(initiator.getNickName());
task.setTaskInitiatorDept(initiator.getDept().getDeptName());
String joinTaskList = StringUtils.join(request.getTaskList(),",");
task.setTaskList(joinTaskList);
BeanUtils.copyBeanProp(task, request);
if (standard != null) {
task.setName(standard.getName());
task.setStandardNo(standard.getStandardNo());
task.setFile(standard.getFile());
}
// 找到审查组长
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);
// 保存关联的整车样品信息
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());
}
taskSampleRelationService.saveBatch(partRelations);
}
}
@Override @Override
public TaskGetInfoResponse getByUserId(Long userId) { public TaskGetInfoResponse getByUserId(Long userId) {
...@@ -445,6 +569,75 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -445,6 +569,75 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
} }
@Override
public DataStatisticsResponse dataStatistics(TaskGetInfoRequest request) {
Task task = taskMapper.selectById(request.getId());
SystemReviewTask systemReviewTask = systemReviewTaskMapper.selectById(task.getSystemReviewTaskId());
CarReviewTask carReviewTask = carReviewTaskMapper.selectById(task.getCarReviewTaskId());
DataStatisticsResponse response = new DataStatisticsResponse();
// 获取最新问卷
List<ReviewStandard> standardTree = reviewStandardService.findTree(systemReviewTask.getStandardId(), ReviewStandard.TYPE_SYSTEM);
// 获取当前问卷答案
List<ReviewDetailsResult> results = reviewDetailsResultService.findByTaskId(systemReviewTask.getId());
// 体系审查
setSystemDataStatistics(standardTree,results,response);
// 获取最新问卷
List<ReviewStandard> carStandardTree = reviewStandardService.findTree(carReviewTask.getStandardId(), ReviewStandard.TYPE_CAR);
// 获取当前问卷答案
List<ReviewDetailsResult> carResults = reviewDetailsResultService.findByTaskId(carReviewTask.getId());
// 车型审查
setCarDataStatistics(carStandardTree,carResults,response);
return response;
}
private void setSystemDataStatistics(List<ReviewStandard> standards, List<ReviewDetailsResult> results,DataStatisticsResponse response) {
Map<Long, ReviewDetailsResult> resultMap = results.stream().collect(Collectors.toMap(ReviewDetailsResult::getReviewDetailsId, Function.identity(), (v1, v2) -> v1));
response.setSystemStandards(DataStatisticsUtils.calculateStandards(standards));
response.setSystemStandardsPassNum(DataStatisticsUtils.calculateStandardsPass(standards, resultMap));
response.setSystemStandardsNoPassNum(DataStatisticsUtils.calculateStandardsNoPass(standards, resultMap));
response.setSystemStandardsUnderNum(response.getSystemStandards() -response.getSystemStandardsPassNum() - response.getSystemStandardsNoPassNum());
BigDecimal standardPass = new BigDecimal(response.getSystemStandardsPassNum() / (double) response.getSystemStandards());
response.setSystemStandardsPass(standardPass.setScale(3,BigDecimal.ROUND_UP).doubleValue() * 100);
response.setSystemDetails(DataStatisticsUtils.calculateDetails(standards));
response.setSystemDetailsPassNum(DataStatisticsUtils.calculateDetailsPass(standards, resultMap));
response.setSystemDetailsNoPassNum(DataStatisticsUtils.calculateDetailsNoPass(standards, resultMap));
response.setSystemDetailsUnderNum(response.getSystemDetails() - response.getSystemDetailsPassNum() - response.getSystemDetailsNoPassNum());
BigDecimal detailsPass = new BigDecimal(response.getSystemDetailsPassNum() / (double) response.getSystemDetails());
response.setSystemDetailsPass(detailsPass.setScale(3,BigDecimal.ROUND_UP).doubleValue() * 100);
}
private void setCarDataStatistics(List<ReviewStandard> standards, List<ReviewDetailsResult> results,DataStatisticsResponse response) {
Map<Long, ReviewDetailsResult> resultMap = results.stream().collect(Collectors.toMap(ReviewDetailsResult::getReviewDetailsId, Function.identity(), (v1, v2) -> v1));
response.setCarStandards(DataStatisticsUtils.calculateStandards(standards));
response.setCarStandardsPassNum(DataStatisticsUtils.calculateStandardsPass(standards, resultMap));
response.setCarStandardsNoPassNum(DataStatisticsUtils.calculateStandardsNoPass(standards, resultMap));
response.setCarStandardsUnderNum(response.getCarStandards() -response.getCarStandardsPassNum() - response.getCarStandardsNoPassNum());
BigDecimal standardPass = new BigDecimal(response.getCarStandardsPassNum() / (double) response.getCarStandards());
response.setCarStandardsPass(standardPass.setScale(3,BigDecimal.ROUND_UP).doubleValue() * 100);
response.setCarDetails(DataStatisticsUtils.calculateDetails(standards));
response.setCarDetailsPassNum(DataStatisticsUtils.calculateDetailsPass(standards, resultMap));
response.setCarDetailsNoPassNum(DataStatisticsUtils.calculateDetailsNoPass(standards, resultMap));
response.setCarDetailsUnderNum(response.getCarDetails() - response.getCarDetailsPassNum() - response.getCarDetailsNoPassNum());
BigDecimal detailsPass = new BigDecimal(response.getCarDetailsPassNum() / (double) response.getCarDetails());
response.setCarDetailsPass(detailsPass.setScale(3,BigDecimal.ROUND_UP).doubleValue() * 100);
}
public List<TaskUserRelation> setAuditors ( Long id) { public List<TaskUserRelation> setAuditors ( Long id) {
// 小组成员 // 小组成员
......
...@@ -20,6 +20,9 @@ public class TestScenarioServiceImpl extends ServiceImpl<TestScenarioMapper, Tes ...@@ -20,6 +20,9 @@ public class TestScenarioServiceImpl extends ServiceImpl<TestScenarioMapper, Tes
@Override @Override
public List<TestScenario> selectTestScenarioList(TestScenarioRequest testScenarioRequest){ public List<TestScenario> selectTestScenarioList(TestScenarioRequest testScenarioRequest){
if(testScenarioRequest.getTestScenario() != null && (testScenarioRequest.getTestScenario().contains("%") ||testScenarioRequest.getTestScenario().contains("_") )){
testScenarioRequest.setTestScenario(testScenarioRequest.getTestScenario().toString().replaceAll("%","/%").replaceAll("_","/_"));
}
return testScenarioMapper.selectTestScenarioList(testScenarioRequest); return testScenarioMapper.selectTestScenarioList(testScenarioRequest);
} }
} }
...@@ -29,6 +29,9 @@ public class TestTypeServiceImpl extends ServiceImpl<TestTypeMapper, TestType> i ...@@ -29,6 +29,9 @@ public class TestTypeServiceImpl extends ServiceImpl<TestTypeMapper, TestType> i
@Override @Override
public List<TestType> selectTestTypeList(TestTypeRequest testTypeRequest) public List<TestType> selectTestTypeList(TestTypeRequest testTypeRequest)
{ {
if(testTypeRequest.getTestType() != null && (testTypeRequest.getTestType().contains("%") ||testTypeRequest.getTestType().contains("_") )){
testTypeRequest.setTestType(testTypeRequest.getTestType().toString().replaceAll("%","/%").replaceAll("_","/_"));
}
return testTypeMapper.selectTestTypeList(testTypeRequest); return testTypeMapper.selectTestTypeList(testTypeRequest);
} }
} }
...@@ -31,6 +31,9 @@ public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestU ...@@ -31,6 +31,9 @@ public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestU
*/ */
@Override @Override
public List<TestUseCase> selectseCaseList(TestUserCaseRequest testUserCaseRequest){ public List<TestUseCase> selectseCaseList(TestUserCaseRequest testUserCaseRequest){
if(testUserCaseRequest.getSearchKeywords() != null && (testUserCaseRequest.getSearchKeywords().contains("%") ||testUserCaseRequest.getSearchKeywords().contains("_") )){
testUserCaseRequest.setSearchKeywords(testUserCaseRequest.getSearchKeywords().toString().replaceAll("%","/%").replaceAll("_","/_"));
}
return testUseCaseMapper.selectseCaseList(testUserCaseRequest); return testUseCaseMapper.selectseCaseList(testUserCaseRequest);
} }
......
...@@ -13,6 +13,7 @@ import com.ruoyi.service.TaskSampleRelationService; ...@@ -13,6 +13,7 @@ import com.ruoyi.service.TaskSampleRelationService;
import com.ruoyi.service.TaskService; import com.ruoyi.service.TaskService;
import com.ruoyi.service.TaskUserRelationService; import com.ruoyi.service.TaskUserRelationService;
import com.ruoyi.web.request.*; import com.ruoyi.web.request.*;
import com.ruoyi.web.response.DataStatisticsResponse;
import com.ruoyi.web.response.TaskFindResponse; import com.ruoyi.web.response.TaskFindResponse;
import com.ruoyi.web.response.TaskGetInfoResponse; import com.ruoyi.web.response.TaskGetInfoResponse;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -57,7 +58,7 @@ public class TaskController extends BaseController { ...@@ -57,7 +58,7 @@ public class TaskController extends BaseController {
@Log(title = "总任务", businessType = BusinessType.INSERT) @Log(title = "总任务", businessType = BusinessType.INSERT)
@RequestMapping(method = RequestMethod.POST, value = "/add") @RequestMapping(method = RequestMethod.POST, value = "/add")
public R<String> createTask(@Validated @RequestBody TaskCreateRequest request) { public R<String> createTask(@Validated @RequestBody TaskCreateRequest request) {
taskService.createTask(request); taskService.createTask(request,getUserId());
return R.ok(); return R.ok();
} }
...@@ -148,6 +149,16 @@ public class TaskController extends BaseController { ...@@ -148,6 +149,16 @@ public class TaskController extends BaseController {
return R.ok(); return R.ok();
} }
@ApiOperation("编辑暂存任务")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@Log(title = "编辑暂存任务", businessType = BusinessType.UPDATE)
@RequestMapping(method = RequestMethod.POST, value = "/editTemporaryStorage")
public R<String> editTemporaryStorage(@Validated @RequestBody TaskEditRequest request) {
taskService.editTemporaryStorageTask(request);
return R.ok();
}
@ApiOperation("删除任务") @ApiOperation("删除任务")
@Trace @Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")}) @Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
...@@ -169,4 +180,14 @@ public class TaskController extends BaseController { ...@@ -169,4 +180,14 @@ public class TaskController extends BaseController {
} }
@ApiOperation("查看任务数据统计")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/dataStatistics")
public R<DataStatisticsResponse> dataStatistics(@Validated @RequestBody TaskGetInfoRequest request) {
DataStatisticsResponse response = taskService.dataStatistics(request);
return R.ok(response);
}
} }
package com.ruoyi.web.response;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel(value = "DataStatisticsResponse", description = "任务数据统计")
@Data
public class DataStatisticsResponse {
@ApiModelProperty("体系用例审查通过率")
private Double systemDetailsPass;
@ApiModelProperty("体系审查细则")
private Integer systemDetails;
@ApiModelProperty("体系审查细则通过")
private Integer systemDetailsPassNum;
@ApiModelProperty("体系审查细则未通过")
private Integer systemDetailsNoPassNum;
@ApiModelProperty("体系细则审查中")
private Integer systemDetailsUnderNum;
@ApiModelProperty("体系标准审查通过率")
private Double systemStandardsPass;
@ApiModelProperty("体系标准条款")
private Integer systemStandards;
@ApiModelProperty("体系标准条款通过")
private Integer systemStandardsPassNum;
@ApiModelProperty("体系标准条款未通过")
private Integer systemStandardsNoPassNum;
@ApiModelProperty("体系标准审查中")
private Integer systemStandardsUnderNum;
@ApiModelProperty(" 车型审查用例审查通过率")
private Double carDetailsPass;
@ApiModelProperty(" 车型审查审查细则")
private Integer carDetails;
@ApiModelProperty(" 车型审查审查细则通过")
private Integer carDetailsPassNum;
@ApiModelProperty(" 车型审查审查细则未通过")
private Integer carDetailsNoPassNum;
@ApiModelProperty(" 车型审查细则审查中")
private Integer carDetailsUnderNum;
@ApiModelProperty(" 车型审查标准审查通过率")
private Double carStandardsPass;
@ApiModelProperty(" 车型审查标准条款")
private Integer carStandards;
@ApiModelProperty(" 车型审查标准条款通过")
private Integer carStandardsPassNum;
@ApiModelProperty(" 车型审查标准条款未通过")
private Integer carStandardsNoPassNum;
@ApiModelProperty(" 车型审查标准审查中")
private Integer carStandardsUnderNum;
@ApiModelProperty(" 车型试验用例审查通过率")
private Double testDetailsPass;
@ApiModelProperty(" 车型试验审查细则")
private Integer testDetails;
@ApiModelProperty(" 车型试验审查细则通过")
private Integer testDetailsPassNum;
@ApiModelProperty(" 车型试验审查细则未通过")
private Integer testDetailsNoPassNum;
@ApiModelProperty(" 车型试验细则审查中")
private Integer testDetailsUnderNum;
@ApiModelProperty(" 车型试验标准审查通过率")
private Double testStandardsPass;
@ApiModelProperty(" 车型试验标准条款")
private Integer testStandards;
@ApiModelProperty(" 车型试验标准条款通过")
private Integer testStandardsPassNum;
@ApiModelProperty(" 车型试验标准条款未通过")
private Integer testStandardsNoPassNum;
@ApiModelProperty(" 车型试验标准审查中")
private Integer testStandardsUnderNum;
}
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
SELECT SELECT
relation.sample_id, relation.sample_id,
relation.task_id, relation.task_id,
task.NAME As taskName task.task_no As taskNo
FROM FROM
t_task_sample_relation relation t_task_sample_relation relation
LEFT JOIN t_task task ON task.id = relation.task_id LEFT JOIN t_task task ON task.id = relation.task_id
......
...@@ -21,7 +21,7 @@ server: ...@@ -21,7 +21,7 @@ server:
port: 22032 port: 22032
servlet: servlet:
# 应用的访问路径 # 应用的访问路径
context-path: /prod-api context-path: /
tomcat: tomcat:
# tomcat的URI编码 # tomcat的URI编码
uri-encoding: UTF-8 uri-encoding: UTF-8
......
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