pqc查询机型编号新增
This commit is contained in:
parent
cb941c0438
commit
89a171e461
|
|
@ -107,7 +107,7 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void savePqcModelBindings(Long userId, List<String> modelNos) {
|
||||
private void savePqcModelBindings(Long inspectorId, List<String> modelNos) {
|
||||
List<String> normalizedModelNos = normalizeModelNos(modelNos);
|
||||
if (!normalizedModelNos.isEmpty()) {
|
||||
List<String> existingModelNos = pqcInspectionRuleService.lambdaQuery()
|
||||
|
|
@ -127,7 +127,7 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
}
|
||||
|
||||
pqcInspectionRuleService.lambdaUpdate()
|
||||
.eq(QmsPqcInspectionRule::getInspectorId, userId)
|
||||
.eq(QmsPqcInspectionRule::getInspectorId, inspectorId)
|
||||
.set(QmsPqcInspectionRule::getInspectorId, null)
|
||||
.update();
|
||||
|
||||
|
|
@ -137,19 +137,19 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
|
||||
pqcInspectionRuleService.lambdaUpdate()
|
||||
.in(QmsPqcInspectionRule::getModelNo, normalizedModelNos)
|
||||
.set(QmsPqcInspectionRule::getInspectorId, userId)
|
||||
.set(QmsPqcInspectionRule::getInspectorId, inspectorId)
|
||||
.set(QmsPqcInspectionRule::getUpdateBy, UserUtil.getUserId())
|
||||
.set(QmsPqcInspectionRule::getUpdateName, UserUtil.getUserName())
|
||||
.set(QmsPqcInspectionRule::getUpdateTime, LocalDateTime.now())
|
||||
.update();
|
||||
}
|
||||
|
||||
private List<QmsQualityInspectorPqcModelVO> getPqcModelsByUserId(Long userId) {
|
||||
if (userId == null) {
|
||||
private List<QmsQualityInspectorPqcModelVO> getPqcModelsByInspectorId(Long inspectorId) {
|
||||
if (inspectorId == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return pqcInspectionRuleService.lambdaQuery()
|
||||
.eq(QmsPqcInspectionRule::getInspectorId, userId)
|
||||
.eq(QmsPqcInspectionRule::getInspectorId, inspectorId)
|
||||
.orderByAsc(QmsPqcInspectionRule::getModelNo)
|
||||
.list()
|
||||
.stream()
|
||||
|
|
@ -168,26 +168,30 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
if (CollectionUtils.isEmpty(records)) {
|
||||
return;
|
||||
}
|
||||
List<Long> userIds = records.stream()
|
||||
List<Long> inspectorIds = records.stream()
|
||||
.filter(vo -> Objects.equals(vo.getInspectionType(), 2))
|
||||
.map(QmsQualityInspectorVO::getUserId)
|
||||
.map(QmsQualityInspectorVO::getId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
if (userIds.isEmpty()) {
|
||||
if (inspectorIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<Long, List<String>> modelNoMap = pqcInspectionRuleService.lambdaQuery()
|
||||
.in(QmsPqcInspectionRule::getInspectorId, userIds)
|
||||
.in(QmsPqcInspectionRule::getInspectorId, inspectorIds)
|
||||
.list()
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
QmsPqcInspectionRule::getInspectorId,
|
||||
Collectors.mapping(QmsPqcInspectionRule::getModelNo, Collectors.toList())
|
||||
Collectors.mapping(QmsPqcInspectionRule::getModelNo,
|
||||
Collectors.collectingAndThen(Collectors.toList(), modelNos -> modelNos.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList())))
|
||||
));
|
||||
records.forEach(vo -> {
|
||||
if (Objects.equals(vo.getInspectionType(), 2)) {
|
||||
vo.setPqcModelNos(modelNoMap.getOrDefault(vo.getUserId(), Collections.emptyList()));
|
||||
vo.setPqcModelNos(modelNoMap.getOrDefault(vo.getId(), Collections.emptyList()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -336,7 +340,7 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
.setUpdateTime(now);
|
||||
save(inspector);
|
||||
|
||||
savePqcModelBindings(request.getUserId(), request.getModelNos());
|
||||
savePqcModelBindings(inspector.getId(), request.getModelNos());
|
||||
}
|
||||
|
||||
// ========================= 删除 =========================
|
||||
|
|
@ -362,7 +366,7 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
.remove();
|
||||
if (Objects.equals(inspector.getInspectionType(), 2)) {
|
||||
pqcInspectionRuleService.lambdaUpdate()
|
||||
.eq(QmsPqcInspectionRule::getInspectorId, inspector.getUserId())
|
||||
.eq(QmsPqcInspectionRule::getInspectorId, inspector.getId())
|
||||
.set(QmsPqcInspectionRule::getInspectorId, null)
|
||||
.update();
|
||||
}
|
||||
|
|
@ -484,7 +488,7 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
@Override
|
||||
public void updatePqc(QmsQualityInspectorPqcUpdateQO request) {
|
||||
QmsQualityInspector inspector = getPqcInspector(request.getId());
|
||||
savePqcModelBindings(inspector.getUserId(), request.getModelNos());
|
||||
savePqcModelBindings(inspector.getId(), request.getModelNos());
|
||||
lambdaUpdate()
|
||||
.eq(QmsQualityInspector::getId, request.getId())
|
||||
.set(QmsQualityInspector::getUpdateBy, UserUtil.getUserName())
|
||||
|
|
@ -567,7 +571,7 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
}
|
||||
detail.setMaterials(Collections.emptyList());
|
||||
detail.setCategories(Collections.emptyList());
|
||||
detail.setPqcModels(getPqcModelsByUserId(inspector.getUserId()));
|
||||
detail.setPqcModels(getPqcModelsByInspectorId(inspector.getId()));
|
||||
return detail;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM qms_pqc_inspection_rule pir
|
||||
WHERE pir.inspector_id = qi.user_id
|
||||
WHERE pir.inspector_id = qi.id
|
||||
AND pir.model_no ilike concat('%', #{request.pqcModelNo}, '%')
|
||||
)
|
||||
</if>
|
||||
|
|
|
|||
Loading…
Reference in New Issue