|
|
|
|
@ -63,6 +63,11 @@ public class QmsSamplingPlanControllerService {
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void add(@Valid QmsSamplingPlanAddQO request) {
|
|
|
|
|
VUtil.trueThrowBusinessError(samplingPlanService.lambdaQuery()
|
|
|
|
|
.eq(QmsSamplingPlan::getPlanName, request.getPlanName())
|
|
|
|
|
.exists()
|
|
|
|
|
).throwMessage("方案名称已存在");
|
|
|
|
|
|
|
|
|
|
String operator = UserUtil.getUserName();
|
|
|
|
|
Long operatorId = UserUtil.getUserId();
|
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
@ -147,7 +152,7 @@ public class QmsSamplingPlanControllerService {
|
|
|
|
|
// 通过AQL优先值获取AQL优先值ID
|
|
|
|
|
Long aqlPriorityValueId = aqlPriorityValueIdMap.get(qo.getAqlPriorityValue());
|
|
|
|
|
VUtil.trueThrowBusinessError(aqlPriorityValueId == null).throwMessage("字码矩阵维护中的AQL优先值[" + qo.getAqlPriorityValue() + "]在AQL优先值列表中不存在");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QmsCodeLetterMatrix entity = new QmsCodeLetterMatrix()
|
|
|
|
|
.setSamplingPlanId(planId)
|
|
|
|
|
.setInspectionType(qo.getInspectionType())
|
|
|
|
|
@ -168,7 +173,7 @@ public class QmsSamplingPlanControllerService {
|
|
|
|
|
// 通过字码内容获取字码ID
|
|
|
|
|
Long codeLetterId = codeLetterIdMap.get(qo.getCodeLetter());
|
|
|
|
|
VUtil.trueThrowBusinessError(codeLetterId == null).throwMessage("抽样方案检验中的字码[" + qo.getCodeLetter() + "]在字码列表中不存在");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QmsSamplingPlanInspection entity = new QmsSamplingPlanInspection()
|
|
|
|
|
.setSamplingPlanId(planId)
|
|
|
|
|
.setRangeStart(qo.getRangeStart())
|
|
|
|
|
@ -187,13 +192,19 @@ public class QmsSamplingPlanControllerService {
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void edit(@Valid QmsSamplingPlanEditQO request) {
|
|
|
|
|
Long planId = request.getId();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VUtil.trueThrowBusinessError(samplingPlanService.lambdaQuery()
|
|
|
|
|
.eq(QmsSamplingPlan::getPlanName, request.getPlanName())
|
|
|
|
|
.ne(QmsSamplingPlan::getId, planId)
|
|
|
|
|
.exists()
|
|
|
|
|
).throwMessage("方案名称已存在");
|
|
|
|
|
|
|
|
|
|
// 0. 验证抽样方案是否存在
|
|
|
|
|
QmsSamplingPlan existPlan = samplingPlanService.getById(planId);
|
|
|
|
|
VUtil.trueThrowBusinessError(ObjectUtil.isNull(existPlan)).throwMessage("抽样方案不存在");
|
|
|
|
|
// 已发布状态不能编辑
|
|
|
|
|
VUtil.trueThrowBusinessError(existPlan.getPublishStatus() == 1).throwMessage("已发布的抽样方案不能编辑");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String operator = UserUtil.getUserName();
|
|
|
|
|
Long operatorId = UserUtil.getUserId();
|
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
@ -283,7 +294,7 @@ public class QmsSamplingPlanControllerService {
|
|
|
|
|
// 通过AQL优先值获取AQL优先值ID
|
|
|
|
|
Long aqlPriorityValueId = aqlPriorityValueIdMap.get(qo.getAqlPriorityValue());
|
|
|
|
|
VUtil.trueThrowBusinessError(aqlPriorityValueId == null).throwMessage("字码矩阵维护中的AQL优先值[" + qo.getAqlPriorityValue() + "]在AQL优先值列表中不存在");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QmsCodeLetterMatrix entity = new QmsCodeLetterMatrix()
|
|
|
|
|
.setSamplingPlanId(planId)
|
|
|
|
|
.setInspectionType(qo.getInspectionType())
|
|
|
|
|
@ -307,7 +318,7 @@ public class QmsSamplingPlanControllerService {
|
|
|
|
|
// 通过字码内容获取字码ID
|
|
|
|
|
Long codeLetterId = codeLetterIdMap.get(qo.getCodeLetter());
|
|
|
|
|
VUtil.trueThrowBusinessError(codeLetterId == null).throwMessage("抽样方案检验中的字码[" + qo.getCodeLetter() + "]在字码列表中不存在");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QmsSamplingPlanInspection entity = new QmsSamplingPlanInspection()
|
|
|
|
|
.setSamplingPlanId(planId)
|
|
|
|
|
.setRangeStart(qo.getRangeStart())
|
|
|
|
|
@ -363,7 +374,7 @@ public class QmsSamplingPlanControllerService {
|
|
|
|
|
VUtil.trueThrowBusinessError(ObjectUtil.isNull(existPlan)).throwMessage("抽样方案不存在");
|
|
|
|
|
// 已发布状态不能删除
|
|
|
|
|
VUtil.trueThrowBusinessError(existPlan.getPublishStatus() == 1).throwMessage("已发布的抽样方案不能删除");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1. 删除关联的子表数据
|
|
|
|
|
aqlPriorityValueService.lambdaUpdate()
|
|
|
|
|
.eq(QmsAqlPriorityValue::getSamplingPlanId, id)
|
|
|
|
|
@ -380,7 +391,7 @@ public class QmsSamplingPlanControllerService {
|
|
|
|
|
samplingPlanInspectionService.lambdaUpdate()
|
|
|
|
|
.eq(QmsSamplingPlanInspection::getSamplingPlanId, id)
|
|
|
|
|
.remove();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 删除主表数据
|
|
|
|
|
samplingPlanService.removeById(id);
|
|
|
|
|
}
|
|
|
|
|
@ -390,21 +401,22 @@ public class QmsSamplingPlanControllerService {
|
|
|
|
|
*/
|
|
|
|
|
public PageData<QmsSamplingPlanVO> search(QmsSamplingPlanSearchQO request) {
|
|
|
|
|
Page<QmsSamplingPlan> page = new Page<>(request.getPage(), request.getPageSize());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var query = samplingPlanService.lambdaQuery()
|
|
|
|
|
.like(StrUtil.isNotBlank(request.getPlanCode()), QmsSamplingPlan::getPlanCode, request.getPlanCode())
|
|
|
|
|
.like(StrUtil.isNotBlank(request.getPlanName()), QmsSamplingPlan::getPlanName, request.getPlanName())
|
|
|
|
|
.eq(request.getPublishStatus() != null, QmsSamplingPlan::getPublishStatus, request.getPublishStatus())
|
|
|
|
|
.ge(request.getStartDate() != null, QmsSamplingPlan::getCreateTime, request.getStartDate())
|
|
|
|
|
.le(request.getEndDate() != null, QmsSamplingPlan::getCreateTime, request.getEndDate())
|
|
|
|
|
.like(StrUtil.isNotBlank(request.getPlanCode()), QmsSamplingPlan::getPlanCode, request.getPlanCode())
|
|
|
|
|
.like(StrUtil.isNotBlank(request.getPlanName()), QmsSamplingPlan::getPlanName, request.getPlanName())
|
|
|
|
|
.orderByAsc(QmsSamplingPlan::getPublishStatus)
|
|
|
|
|
.orderByDesc(QmsSamplingPlan::getId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IPage<QmsSamplingPlan> result = query.page(page);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<QmsSamplingPlanVO> voList = result.getRecords().stream()
|
|
|
|
|
.map(plan -> BeanUtil.copyProperties(plan, QmsSamplingPlanVO.class))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PageData<QmsSamplingPlanVO> pageData = new PageData<>();
|
|
|
|
|
pageData.setPage((int) result.getCurrent());
|
|
|
|
|
pageData.setPageSize((int) result.getSize());
|
|
|
|
|
@ -435,9 +447,9 @@ public class QmsSamplingPlanControllerService {
|
|
|
|
|
// 1. 查询主表
|
|
|
|
|
QmsSamplingPlan plan = samplingPlanService.getById(id);
|
|
|
|
|
VUtil.trueThrowBusinessError(ObjectUtil.isNull(plan)).throwMessage("抽样方案不存在");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QmsSamplingPlanDetailVO detail = BeanUtil.copyProperties(plan, QmsSamplingPlanDetailVO.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 查询AQL优先值预定义
|
|
|
|
|
List<QmsAqlPriorityValue> aqlPriorityValues = aqlPriorityValueService.lambdaQuery()
|
|
|
|
|
.eq(QmsAqlPriorityValue::getSamplingPlanId, id)
|
|
|
|
|
@ -447,7 +459,7 @@ public class QmsSamplingPlanControllerService {
|
|
|
|
|
.map(v -> BeanUtil.copyProperties(v, QmsSamplingPlanDetailVO.AqlPriorityValueVO.class))
|
|
|
|
|
.collect(Collectors.toList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 查询抽样严格性转移规则
|
|
|
|
|
List<QmsSamplingStrictnessTransferRule> transferRules = strictnessTransferRuleService.lambdaQuery()
|
|
|
|
|
.eq(QmsSamplingStrictnessTransferRule::getSamplingPlanId, id)
|
|
|
|
|
@ -457,7 +469,7 @@ public class QmsSamplingPlanControllerService {
|
|
|
|
|
.map(r -> BeanUtil.copyProperties(r, QmsSamplingPlanDetailVO.StrictnessTransferRuleVO.class))
|
|
|
|
|
.collect(Collectors.toList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 4. 查询字码
|
|
|
|
|
List<QmsCodeLetter> codeLetters = codeLetterService.lambdaQuery()
|
|
|
|
|
.eq(QmsCodeLetter::getSamplingPlanId, id)
|
|
|
|
|
@ -469,11 +481,11 @@ public class QmsSamplingPlanControllerService {
|
|
|
|
|
.map(c -> BeanUtil.copyProperties(c, QmsSamplingPlanDetailVO.CodeLetterVO.class))
|
|
|
|
|
.collect(Collectors.toList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 5. 查询AQL优先值Map
|
|
|
|
|
Map<Long, java.math.BigDecimal> aqlPriorityValueMap = aqlPriorityValues.stream()
|
|
|
|
|
.collect(Collectors.toMap(QmsAqlPriorityValue::getId, QmsAqlPriorityValue::getPriorityValue));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 6. 查询字码矩阵维护
|
|
|
|
|
List<QmsCodeLetterMatrix> codeLetterMatrices = codeLetterMatrixService.lambdaQuery()
|
|
|
|
|
.eq(QmsCodeLetterMatrix::getSamplingPlanId, id)
|
|
|
|
|
@ -488,7 +500,7 @@ public class QmsSamplingPlanControllerService {
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 7. 查询抽样方案检验
|
|
|
|
|
List<QmsSamplingPlanInspection> inspections = samplingPlanInspectionService.lambdaQuery()
|
|
|
|
|
.eq(QmsSamplingPlanInspection::getSamplingPlanId, id)
|
|
|
|
|
@ -502,7 +514,7 @@ public class QmsSamplingPlanControllerService {
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return detail;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|