From f5d3b2e766c0c1e01d0b2ca301fd4365e62c4f50 Mon Sep 17 00:00:00 2001 From: yf001217 <834502597@qq.com> Date: Thu, 28 May 2026 15:23:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=A7=84=E8=8C=83=EF=BC=88QM?= =?UTF-8?q?S=EF=BC=89=EF=BC=9A=E7=BB=9F=E4=B8=80=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=99=A8=E4=B8=8E=E6=9C=8D=E5=8A=A1=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 优化QMS任务记录代码的导入顺序及换行符。 - 确保控制器与服务文件符合项目风格规范。 --- .../QmsPqcTaskRecordController.java | 10 + .../QmsPqcTaskRecordControllerService.java | 211 ++++++++++++++++++ .../vo/QmsPqcTaskRecordPointProgressVO.java | 86 +++++++ 3 files changed, 307 insertions(+) create mode 100644 nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/vo/QmsPqcTaskRecordPointProgressVO.java diff --git a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/controller/QmsPqcTaskRecordController.java b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/controller/QmsPqcTaskRecordController.java index ebb4cabe..82687dda 100644 --- a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/controller/QmsPqcTaskRecordController.java +++ b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/controller/QmsPqcTaskRecordController.java @@ -13,6 +13,8 @@ import jakarta.validation.Valid; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.util.List; + /** * PQC任务 * @@ -66,6 +68,14 @@ public class QmsPqcTaskRecordController { return ApiResult.success(pqcTaskRecordService.getReviewDetail(taskId)); } + /** + * 查询PQC检查点进度 + */ + @GetMapping("/point/progress") + public ApiResult getPointProgress(@RequestParam Long taskId) { + return ApiResult.success(pqcTaskRecordService.getPointProgress(taskId)); + } + /** * 暂存 */ diff --git a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/QmsPqcTaskRecordControllerService.java b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/QmsPqcTaskRecordControllerService.java index 534ff373..d1eeb64c 100644 --- a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/QmsPqcTaskRecordControllerService.java +++ b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/QmsPqcTaskRecordControllerService.java @@ -610,6 +610,94 @@ public class QmsPqcTaskRecordControllerService { return vo; } + /** + * 查询PQC检查点进度 + */ + public QmsPqcTaskRecordPointProgressVO getPointProgress(Long taskId) { + QmsPqcTaskRecord currentTask = pqcTaskRecordService.getById(taskId); + VUtil.trueThrowBusinessError(currentTask == null).throwMessage("任务不存在"); + + String no = currentTask.getNo(); + String modelNo = currentTask.getModelNo(); + + QmsPqcInspectionRule latestRule = pqcInspectionRuleService.lambdaQuery() + .eq(QmsPqcInspectionRule::getModelNo, modelNo) + .eq(QmsPqcInspectionRule::getIsDisabled, true) + .orderByDesc(QmsPqcInspectionRule::getRuleVersion) + .last("LIMIT 1") + .one(); + + LinkedHashMap stepMap = new LinkedHashMap<>(); + Integer latestRuleVersion = latestRule != null ? latestRule.getRuleVersion() : null; + if (latestRule != null) { + List latestPoints = pqcInspectionPointService.lambdaQuery() + .eq(QmsPqcInspectionPoint::getPqcRuleId, latestRule.getId()) + .orderByAsc(QmsPqcInspectionPoint::getStepDicItemId) + .orderByAsc(QmsPqcInspectionPoint::getId) + .list(); + for (QmsPqcInspectionPoint point : latestPoints) { + StepProgressAccumulator stepAccumulator = stepMap.computeIfAbsent(buildStepKey(point), + k -> StepProgressAccumulator.fromPoint(point)); + stepAccumulator.putIfAbsent(buildPointKey(point), + PointProgressAccumulator.fromLatestPoint(point, latestRuleVersion)); + } + } + + List taskRecords = pqcTaskRecordService.lambdaQuery() + .eq(QmsPqcTaskRecord::getNo, no) + .eq(QmsPqcTaskRecord::getModelNo, modelNo) + .isNotNull(QmsPqcTaskRecord::getInspectionPointId) + .orderByAsc(QmsPqcTaskRecord::getCreateTime) + .list(); + + if (!taskRecords.isEmpty()) { + Set pointIds = taskRecords.stream() + .map(QmsPqcTaskRecord::getInspectionPointId) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + + Map pointMap = new HashMap<>(); + if (!pointIds.isEmpty()) { + pointMap = pqcInspectionPointService.listByIds(pointIds).stream() + .collect(Collectors.toMap(QmsPqcInspectionPoint::getId, point -> point)); + } + + Set ruleIds = pointMap.values().stream() + .map(QmsPqcInspectionPoint::getPqcRuleId) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + + Map ruleVersionMap = new HashMap<>(); + if (!ruleIds.isEmpty()) { + ruleVersionMap = pqcInspectionRuleService.listByIds(ruleIds).stream() + .collect(Collectors.toMap(QmsPqcInspectionRule::getId, QmsPqcInspectionRule::getRuleVersion)); + } + + for (QmsPqcTaskRecord record : taskRecords) { + QmsPqcInspectionPoint point = pointMap.get(record.getInspectionPointId()); + if (point == null) { + continue; + } + + Integer recordRuleVersion = ruleVersionMap.get(point.getPqcRuleId()); + StepProgressAccumulator stepAccumulator = stepMap.computeIfAbsent(buildStepKey(point), + k -> StepProgressAccumulator.fromPoint(point)); + String key = buildPointKey(point); + PointProgressAccumulator accumulator = stepAccumulator.computeIfAbsent(key, + k -> PointProgressAccumulator.fromTaskPoint(point)); + accumulator.mergeRecord(point, recordRuleVersion, record.getStatus()); + } + } + + QmsPqcTaskRecordPointProgressVO result = new QmsPqcTaskRecordPointProgressVO(); + result.setNo(no); + result.setModelNo(modelNo); + result.setSteps(stepMap.values().stream() + .map(StepProgressAccumulator::toVO) + .collect(Collectors.toList())); + return result; + } + /** * 解析文件列表 */ @@ -1012,6 +1100,129 @@ public class QmsPqcTaskRecordControllerService { } } + /** + * 生成检查点合并键 + */ + private String buildStepKey(QmsPqcInspectionPoint point) { + String stepName = StrUtil.blankToDefault(point.getStepName(), ""); + String stepDicItemId = point.getStepDicItemId() == null ? "" : point.getStepDicItemId().toString(); + return stepDicItemId + "|" + stepName; + } + + private String buildPointKey(QmsPqcInspectionPoint point) { + String pointCode = StrUtil.blankToDefault(point.getInspectionPointCode(), ""); + String pointName = StrUtil.blankToDefault(point.getInspectionPointName(), ""); + return buildStepKey(point) + "|" + pointCode + "|" + pointName; + } + + private static String formatRuleVersion(Collection versions, Integer fallbackVersion) { + if (versions != null && !versions.isEmpty()) { + String versionText = versions.stream() + .filter(Objects::nonNull) + .distinct() + .sorted() + .map(version -> "V" + version) + .collect(Collectors.joining("/")); + if (StrUtil.isNotBlank(versionText)) { + return versionText; + } + } + return fallbackVersion == null ? null : "V" + fallbackVersion; + } + + /** + * 检查点进度聚合器 + */ + private static class PointProgressAccumulator { + private String stepName; + private Long stepDicItemId; + private String inspectionPointName; + private String inspectionPointCode; + private Long inspectionPointId; + private boolean completed; + private int inspectionCount; + private final Set versions = new LinkedHashSet<>(); + private Integer fallbackVersion; + + private static PointProgressAccumulator fromLatestPoint(QmsPqcInspectionPoint point, Integer latestRuleVersion) { + PointProgressAccumulator accumulator = new PointProgressAccumulator(); + accumulator.stepName = point.getStepName(); + accumulator.stepDicItemId = point.getStepDicItemId(); + accumulator.inspectionPointName = point.getInspectionPointName(); + accumulator.inspectionPointCode = point.getInspectionPointCode(); + accumulator.inspectionPointId = point.getId(); + accumulator.fallbackVersion = latestRuleVersion; + return accumulator; + } + + private static PointProgressAccumulator fromTaskPoint(QmsPqcInspectionPoint point) { + PointProgressAccumulator accumulator = new PointProgressAccumulator(); + accumulator.stepName = point.getStepName(); + accumulator.stepDicItemId = point.getStepDicItemId(); + accumulator.inspectionPointName = point.getInspectionPointName(); + accumulator.inspectionPointCode = point.getInspectionPointCode(); + accumulator.inspectionPointId = point.getId(); + return accumulator; + } + + private void mergeRecord(QmsPqcInspectionPoint point, Integer recordRuleVersion, Short status) { + inspectionCount++; + if (status != null && status == 3) { + completed = true; + } + if (recordRuleVersion != null) { + versions.add(recordRuleVersion); + } + } + + private QmsPqcTaskRecordPointProgressVO toVO() { + QmsPqcTaskRecordPointProgressVO vo = new QmsPqcTaskRecordPointProgressVO(); + vo.setStepName(stepName); + vo.setStepDicItemId(stepDicItemId); + vo.setInspectionPointName(inspectionPointName); + vo.setInspectionPointCode(inspectionPointCode); + vo.setInspectionPointId(inspectionPointId); + vo.setCompleted(completed); + vo.setInspectionCount(inspectionCount); + vo.setRuleVersion(formatRuleVersion(versions, fallbackVersion)); + return vo; + } + } + + /** + * 步装进度聚合器 + */ + private static class StepProgressAccumulator { + private String stepName; + private Long stepDicItemId; + private final LinkedHashMap points = new LinkedHashMap<>(); + + private static StepProgressAccumulator fromPoint(QmsPqcInspectionPoint point) { + StepProgressAccumulator accumulator = new StepProgressAccumulator(); + accumulator.stepName = point.getStepName(); + accumulator.stepDicItemId = point.getStepDicItemId(); + return accumulator; + } + + private PointProgressAccumulator computeIfAbsent(String key, java.util.function.Supplier supplier) { + return points.computeIfAbsent(key, k -> supplier.get()); + } + + private void putIfAbsent(String key, PointProgressAccumulator accumulator) { + points.putIfAbsent(key, accumulator); + } + + private QmsPqcTaskRecordPointProgressVO.StepVO toVO() { + QmsPqcTaskRecordPointProgressVO.StepVO vo = new QmsPqcTaskRecordPointProgressVO.StepVO(); + vo.setStepName(stepName); + vo.setStepDicItemId(stepDicItemId); + vo.setPoints(points.values().stream() + .map(PointProgressAccumulator::toVO) + .collect(Collectors.toList())); + return vo; + } + } + /** * 提交结果类 */ diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/vo/QmsPqcTaskRecordPointProgressVO.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/vo/QmsPqcTaskRecordPointProgressVO.java new file mode 100644 index 00000000..2f09a38e --- /dev/null +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/vo/QmsPqcTaskRecordPointProgressVO.java @@ -0,0 +1,86 @@ +package com.nflg.wms.common.pojo.vo; + +import lombok.Data; + +import java.util.List; + +/** + * PQC任务检查点进度返回对象 + */ +@Data +public class QmsPqcTaskRecordPointProgressVO { + + /** + * 机台编号 + */ + private String no; + + /** + * 机型编号 + */ + private String modelNo; + + /** + * 步装列表 + */ + private List steps; + + /** + * 步装进度 + */ + @Data + public static class StepVO { + + /** + * 步装名称 + */ + private String stepName; + + /** + * 步装字典ID + */ + private Long stepDicItemId; + + /** + * 检查点列表 + */ + private List points; + } + + /** + * 检查点进度 + */ + @Data + public static class PointVO { + + /** + * 检查点名称 + */ + private String inspectionPointName; + + /** + * 检查点编号 + */ + private String inspectionPointCode; + + /** + * 检查点流水号 + */ + private Long inspectionPointId; + + /** + * 是否完成,true=已完成,false=未完成 + */ + private Boolean completed; + + /** + * 检测次数 + */ + private Integer inspectionCount; + + /** + * 检测版本,示例:V1/V2/V3 + */ + private String ruleVersion; + } +}