From cc98aef022d76974eda6919899f037eab83241b5 Mon Sep 17 00:00:00 2001 From: yf001217 <834502597@qq.com> Date: Thu, 11 Jun 2026 14:07:10 +0800 Subject: [PATCH] =?UTF-8?q?pdi=E6=9F=A5=E8=AF=A2=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E9=A1=B9=E6=96=B9=E6=B3=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...qcInspectionRuleControllerServiceImpl.java | 58 +++++++++++++++++-- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/impl/QmsPqcInspectionRuleControllerServiceImpl.java b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/impl/QmsPqcInspectionRuleControllerServiceImpl.java index cbef6467..02abee93 100644 --- a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/impl/QmsPqcInspectionRuleControllerServiceImpl.java +++ b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/impl/QmsPqcInspectionRuleControllerServiceImpl.java @@ -819,7 +819,6 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti .one(); Long targetRuleId; - boolean isNewRule = false; if (Objects.isNull(highestRule)) { // 该机型无规则,新建 @@ -834,14 +833,12 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti newRule.setCreateTime(now); ruleService.save(newRule); targetRuleId = newRule.getId(); - isNewRule = true; } else if (highestRule.getAuditStatus() != null && highestRule.getAuditStatus() == 1) { // 最高版本已审核,fork新版本 if (checkDraftExists(modelNo, null)) { throw new NflgException(STATE.BusinessError, "机型" + modelNo + "已存在未审核的版本,请先完成审核后再导入"); } targetRuleId = forkNewVersion(highestRule); - isNewRule = true; } else { // 最高版本未审核,直接在其上修改 targetRuleId = highestRule.getId(); @@ -875,9 +872,8 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti appendImportPointsAndItems(targetRuleId, pointGroups, stepDicItems, operator, operatorId, now); } - if (isNewRule) { - ensurePlaceholderPointsForMissingSteps(targetRuleId, stepDicItems, operator, operatorId, now); - } + removeRedundantPlaceholderPoints(targetRuleId); + ensurePlaceholderPointsForMissingSteps(targetRuleId, stepDicItems, operator, operatorId, now); } } @@ -1235,6 +1231,56 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti return maxVersion + 1; } + private void removeRedundantPlaceholderPoints(Long ruleId) { + List points = pointService.lambdaQuery() + .eq(QmsPqcInspectionPoint::getPqcRuleId, ruleId) + .list(); + if (CollectionUtil.isEmpty(points)) { + return; + } + + List realStepIds = points.stream() + .filter(point -> point.getStepDicItemId() != null) + .filter(point -> StrUtil.isNotBlank(point.getInspectionPointCode()) + || StrUtil.isNotBlank(point.getInspectionPointName())) + .map(QmsPqcInspectionPoint::getStepDicItemId) + .distinct() + .collect(Collectors.toList()); + if (CollectionUtil.isEmpty(realStepIds)) { + return; + } + + List placeholderPointIds = points.stream() + .filter(point -> point.getStepDicItemId() != null) + .filter(point -> realStepIds.contains(point.getStepDicItemId())) + .filter(point -> StrUtil.isBlank(point.getInspectionPointCode())) + .filter(point -> StrUtil.isBlank(point.getInspectionPointName())) + .map(QmsPqcInspectionPoint::getId) + .collect(Collectors.toList()); + if (CollectionUtil.isEmpty(placeholderPointIds)) { + return; + } + + List pointIdsWithItems = itemsService.lambdaQuery() + .in(QmsPqcInspectionPointItems::getInspectionCodeId, placeholderPointIds) + .list() + .stream() + .map(QmsPqcInspectionPointItems::getInspectionCodeId) + .distinct() + .collect(Collectors.toList()); + placeholderPointIds = placeholderPointIds.stream() + .filter(pointId -> !pointIdsWithItems.contains(pointId)) + .collect(Collectors.toList()); + if (CollectionUtil.isEmpty(placeholderPointIds)) { + return; + } + + itemsService.lambdaUpdate() + .in(QmsPqcInspectionPointItems::getInspectionCodeId, placeholderPointIds) + .remove(); + pointService.removeByIds(placeholderPointIds); + } + private void ensurePlaceholderPointsForMissingSteps(Long ruleId, List stepDicItems, String operator,