From 8c564739af07fb7eda13e879af9f3a5a928980b2 Mon Sep 17 00:00:00 2001 From: funny <834502597@qq.com> Date: Thu, 7 May 2026 07:56:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(qms):=20=E4=BC=98=E5=8C=96=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E9=A1=B9=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E5=8F=8A?= =?UTF-8?q?=E7=B1=BB=E5=88=AB=E7=AD=9B=E9=80=89=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改QmsInspectionItemAddQO注释,明确检测项名称和编号由后端自动生成无需传入 - 在QmsInspectionItemServiceImpl中新增根据物料类别生成检测项编号和名称的逻辑 - 实现构建物料类别全路径名称的辅助方法 - 实现收集指定物料类别及其所有子孙类别ID集合的方法 - 查询时支持根据类别及其所有子孙类别ID过滤 - 修正QmsPdiTaskRecordController中请求参数名称由taskId改为id --- .../QmsPdiTaskRecordController.java | 4 +- .../pojo/qo/QmsInspectionItemAddQO.java | 6 +- .../impl/QmsInspectionItemServiceImpl.java | 66 ++++++++++++++++++- 3 files changed, 67 insertions(+), 9 deletions(-) diff --git a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/controller/QmsPdiTaskRecordController.java b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/controller/QmsPdiTaskRecordController.java index f89797e8..b3523f6f 100644 --- a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/controller/QmsPdiTaskRecordController.java +++ b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/controller/QmsPdiTaskRecordController.java @@ -88,7 +88,7 @@ public class QmsPdiTaskRecordController extends BaseController { */ @GetMapping("summary") public ApiResult summary( - @NotNull(message = "任务ID不能为空") @RequestParam Long taskId) { - return ApiResult.success(taskRecordControllerService.summary(taskId)); + @NotNull(message = "任务ID不能为空") @RequestParam Long id) { + return ApiResult.success(taskRecordControllerService.summary(id)); } } diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsInspectionItemAddQO.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsInspectionItemAddQO.java index a598466d..ccfc1764 100644 --- a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsInspectionItemAddQO.java +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/QmsInspectionItemAddQO.java @@ -27,15 +27,13 @@ public class QmsInspectionItemAddQO { private Integer detectionType; /** - * 检测项名称(必传) + * 检测项名称(后端根据物料类别全路径自动生成,无需传入) */ - @NotBlank(message = "检测项名称不能为空") private String inspectionItemName; /** - * 检测项编号(必传) + * 检测项编号(后端自动生成:CATD_ + 类别码,无需传入) */ - @NotBlank(message = "检测项编号不能为空") private String inspectionNo; /** diff --git a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/QmsInspectionItemServiceImpl.java b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/QmsInspectionItemServiceImpl.java index cf02ccec..b845b6b6 100644 --- a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/QmsInspectionItemServiceImpl.java +++ b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/service/impl/QmsInspectionItemServiceImpl.java @@ -30,6 +30,8 @@ import org.springframework.transaction.annotation.Transactional; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; @@ -56,12 +58,20 @@ public class QmsInspectionItemServiceImpl extends ServiceImpl categoryIds = null; + if (Objects.nonNull(qo.getMaterialTypeId())) { + categoryIds = collectDescendantIds(qo.getMaterialTypeId()); + } + + List finalCategoryIds = categoryIds; IPage page = lambdaQuery() - .eq(Objects.nonNull(qo.getMaterialTypeId()), QmsInspectionItem::getMaterialTypeId, qo.getMaterialTypeId()) + .in(finalCategoryIds != null && !finalCategoryIds.isEmpty(), QmsInspectionItem::getMaterialTypeId, finalCategoryIds) .like(StrUtil.isNotBlank(qo.getInspectionItemName()), QmsInspectionItem::getInspectionItemName, qo.getInspectionItemName()) .ge(Objects.nonNull(start), QmsInspectionItem::getCreateTime, Objects.nonNull(start) ? start.atStartOfDay() : null) .le(Objects.nonNull(end), QmsInspectionItem::getCreateTime, Objects.nonNull(end) ? end.atTime(LocalTime.MAX) : null) @@ -327,4 +344,47 @@ public class QmsInspectionItemServiceImpl extends ServiceImpl names = new ArrayList<>(); + Long currentId = categoryId; + while (currentId != null) { + QmsQcMaterialCategory cat = materialCategoryService.getById(currentId); + if (cat == null) break; + names.add(cat.getCategoryName()); + currentId = cat.getParentCategoryRowId(); + } + Collections.reverse(names); + return String.join("/", names); + } + + /** + * 收集指定类别及其所有子孙类别的ID集合 + */ + private List collectDescendantIds(Long categoryId) { + List all = materialCategoryService.list(); + // 构建 parentId -> children 映射 + Map> childrenMap = all.stream() + .filter(c -> c.getParentCategoryRowId() != null && c.getParentCategoryRowId() > 0) + .collect(Collectors.groupingBy(QmsQcMaterialCategory::getParentCategoryRowId)); + + List result = new ArrayList<>(); + // BFS 收集所有后代 + java.util.Deque queue = new java.util.ArrayDeque<>(); + queue.add(categoryId); + while (!queue.isEmpty()) { + Long current = queue.poll(); + result.add(current); + List children = childrenMap.get(current); + if (children != null) { + for (QmsQcMaterialCategory child : children) { + queue.add(child.getId()); + } + } + } + return result; + } }