diff --git a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/pojo/qo/PqcInspectionRuleAddQO.java b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/pojo/qo/PqcInspectionRuleAddQO.java index ac0b6cc8..14406d1b 100644 --- a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/pojo/qo/PqcInspectionRuleAddQO.java +++ b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/pojo/qo/PqcInspectionRuleAddQO.java @@ -76,7 +76,7 @@ public class PqcInspectionRuleAddQO { private String inspectionContent; /** - * 检查类型:0=工序检查,1=关键物料拍照,2=关键物料采集(多选) + * 检查类型:0=工序检查,1=关键物料拍照,2=全部 */ private List inspectionType; diff --git a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/pojo/qo/PqcInspectionRuleEditQO.java b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/pojo/qo/PqcInspectionRuleEditQO.java index c3b27293..3c4325f0 100644 --- a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/pojo/qo/PqcInspectionRuleEditQO.java +++ b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/pojo/qo/PqcInspectionRuleEditQO.java @@ -86,7 +86,7 @@ public class PqcInspectionRuleEditQO { private String inspectionContent; /** - * 检查类型:多选 + * 检查类型:0=工序检查,1=关键物料拍照,2=全部 */ private List inspectionType; diff --git a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/pojo/vo/PqcInspectionPointItemVO.java b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/pojo/vo/PqcInspectionPointItemVO.java index 9d880cf2..45802fb7 100644 --- a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/pojo/vo/PqcInspectionPointItemVO.java +++ b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/pojo/vo/PqcInspectionPointItemVO.java @@ -34,7 +34,7 @@ public class PqcInspectionPointItemVO { private String inspectionContent; /** - * 检查类型:0=工序检查,1=关键物料拍照,2=关键物料采集(多选,返回数组) + * 检查类型:0=工序检查,1=关键物料拍照,2=全部(返回数组) */ private List inspectionType; 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 8504e08d..821a856f 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 @@ -122,21 +122,20 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti Integer level = item.getInspectionLevel(); // 第1类:关键物料拍照类 - // 包含:inspectionType = 0(所有)+ inspectionType = 2(所有) - if (type == 0 || type == 2) { + // 包含:inspectionType = 1(关键物料拍照)+ inspectionType = 2(全部) + if (Objects.equals(type, 1) || Objects.equals(type, 2)) { materialItems.add(vo); } - // 第2类和第3类:工序检查(按类型和星级分) - // 包含:inspectionType = 1 或 2 - if (type == 1 || type == 2) { - if (level == 1 || level == 2) { - // 星级1或2 → 自检复核类 - selfReviewItems.add(vo); - } else if (level == 3) { - // 星级3 → QC检测类 - qcItems.add(vo); - } + // 第2类:自检只看1/2星的工序检查或全部 + if ((Objects.equals(type, 0) || Objects.equals(type, 2)) + && (Objects.equals(level, 1) || Objects.equals(level, 2))) { + selfReviewItems.add(vo); + } + + // 第3类:3星不区分检测/采集,全部由复核人员处理 + if (Objects.equals(level, 3)) { + qcItems.add(vo); } } @@ -223,8 +222,8 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti List itemVOs = items.stream() .map(item -> { PqcInspectionPointItemVO itemVO = BeanUtil.copyProperties(item, PqcInspectionPointItemVO.class); - // 将位标志转换回List - itemVO.setInspectionType(bitmaskToList(item.getInspectionType())); + // 将检查类型转换回List + itemVO.setInspectionType(inspectionTypeToList(item.getInspectionType())); return itemVO; }) .collect(Collectors.toList()); @@ -600,7 +599,7 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti item.setInspectionCodeId(point.getId()); item.setSort(sort++); item.setInspectionContent(itemQO.getInspectionContent()); - item.setInspectionType(listToBitmask(itemQO.getInspectionType())); + item.setInspectionType(normalizeInspectionType(itemQO.getInspectionType())); item.setInspectionMethods(itemQO.getInspectionMethods()); item.setInspectionImgUrl(itemQO.getInspectionImgUrl()); item.setInspectionLevel(itemQO.getInspectionLevel()); @@ -657,7 +656,7 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti item.setInspectionCodeId(point.getId()); item.setSort(itemQO.getSort() != null ? itemQO.getSort() : sort++); item.setInspectionContent(itemQO.getInspectionContent()); - item.setInspectionType(listToBitmask(itemQO.getInspectionType())); + item.setInspectionType(normalizeInspectionType(itemQO.getInspectionType())); item.setInspectionMethods(itemQO.getInspectionMethods()); item.setInspectionImgUrl(itemQO.getInspectionImgUrl()); item.setInspectionLevel(itemQO.getInspectionLevel()); @@ -670,37 +669,33 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti } } - // ========================= inspectionType 位标志转换 ========================= + // ========================= inspectionType 转换 ========================= /** - * 将List转换为位标志Integer - * 0=工序检查 → bit 0 → 1 - * 1=关键物料拍照 → bit 1 → 2 - * 2=关键物料采集 → bit 2 → 4 + * 前端兼容数组传参,最终保存为枚举:0=工序检查,1=关键物料拍照,2=全部 */ - private Integer listToBitmask(List types) { + private Integer normalizeInspectionType(List types) { if (types == null || types.isEmpty()) { return 0; } - int result = 0; - for (Integer type : types) { - result |= (1 << type); + if (types.contains(2) || (types.contains(0) && types.contains(1))) { + return 2; } - return result; + Integer type = types.get(0); + if (Objects.equals(type, 0) || Objects.equals(type, 1)) { + return type; + } + throw new NflgException(STATE.BusinessError, "检查类型只能为0工序检查、1关键物料拍照、2全部"); } /** - * 将位标志Integer转换为List + * 将检查类型枚举转换为List */ - private List bitmaskToList(Integer bitmask) { - if (bitmask == null || bitmask == 0) { + private List inspectionTypeToList(Integer inspectionType) { + if (inspectionType == null) { return Collections.emptyList(); } - List result = new ArrayList<>(); - if ((bitmask & 1) != 0) result.add(0); - if ((bitmask & 2) != 0) result.add(1); - if ((bitmask & 4) != 0) result.add(2); - return result; + return List.of(inspectionType); } // ========================= 导入 ========================= @@ -1029,37 +1024,47 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti } /** - * 解析检查项类别文本 → 位标志Integer - * 工序检查→1, 关键物料采集拍照→2, 全部→3 + * 解析检查项类别文本:工序检查→0, 关键物料拍照→1, 全部→2 */ private Integer parseInspectionTypeText(String text) { - if (StrUtil.isBlank(text)) return 0; + if (StrUtil.isBlank(text)) { + return 0; + } switch (text.trim()) { - case "工序检查": return 1; - case "关键物料采集拍照": return 2; - case "全部": return 3; + case "工序检查": + return 0; + case "关键物料拍照": + case "关键物料采集拍照": + return 1; + case "全部": + return 2; default: - // 尝试数字解析 - try { return Integer.parseInt(text.trim()); } catch (NumberFormatException e) { - throw new NflgException(STATE.BusinessError, "检查项类别\"" + text + "\"无法识别,请输入:工序检查/关键物料采集拍照/全部"); + try { + Integer type = Integer.parseInt(text.trim()); + if (Objects.equals(type, 0) || Objects.equals(type, 1) || Objects.equals(type, 2)) { + return type; + } + throw new NumberFormatException(); + } catch (NumberFormatException e) { + throw new NflgException(STATE.BusinessError, "检查项类别\"" + text + "\"无法识别,请输入:工序检查/关键物料拍照/全部"); } } } /** - * 位标志Integer → 检查项类别文本 + * 检查类型枚举 → 检查项类别文本 */ - private String inspectionTypeToText(Integer bitmask) { - if (bitmask == null || bitmask == 0) return ""; - if (bitmask == 1) return "工序检查"; - if (bitmask == 2) return "关键物料采集拍照"; - if (bitmask == 3) return "全部"; - // 其他位标志组合(如4=关键物料采集)也做处理 - if (bitmask == 4) return "关键物料采集"; - List types = bitmaskToList(bitmask); - return types.stream().map(t -> { - switch (t) { case 0: return "工序检查"; case 1: return "关键物料采集拍照"; case 2: return "关键物料采集"; default: return ""; } - }).collect(Collectors.joining("+")); + private String inspectionTypeToText(Integer inspectionType) { + if (Objects.equals(inspectionType, 0)) { + return "工序检查"; + } + if (Objects.equals(inspectionType, 1)) { + return "关键物料拍照"; + } + if (Objects.equals(inspectionType, 2)) { + return "全部"; + } + return ""; } /** diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/dto/PqcInspectionRuleExportDTO.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/dto/PqcInspectionRuleExportDTO.java index 012cae69..7a9b0151 100644 --- a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/dto/PqcInspectionRuleExportDTO.java +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/dto/PqcInspectionRuleExportDTO.java @@ -44,7 +44,7 @@ public class PqcInspectionRuleExportDTO { private String inspectionContent; /** - * 检查项类别(工序检查/关键物料采集拍照/全部) + * 检查项类别(工序检查/关键物料拍照/全部) */ @ExcelColumn("检查项类别") private String inspectionTypeText; @@ -91,4 +91,4 @@ public class PqcInspectionRuleExportDTO { */ @ExcelColumn("审核状态") private String auditStatusText; -} \ No newline at end of file +} diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/dto/PqcInspectionRuleImportDTO.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/dto/PqcInspectionRuleImportDTO.java index db9eefa3..a54fe2a7 100644 --- a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/dto/PqcInspectionRuleImportDTO.java +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/dto/PqcInspectionRuleImportDTO.java @@ -43,7 +43,7 @@ public class PqcInspectionRuleImportDTO { private String inspectionContent; /** - * 检查项类别(必填):工序检查/关键物料采集拍照/全部 + * 检查项类别(必填):工序检查/关键物料拍照/全部 */ @ExcelColumn("检查项类别*") private String inspectionTypeText; @@ -77,4 +77,4 @@ public class PqcInspectionRuleImportDTO { */ @ExcelColumn("错误信息") private String error; -} \ No newline at end of file +} diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/vo/QmsPqcInspectionPointItemsGroupedVO.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/vo/QmsPqcInspectionPointItemsGroupedVO.java index 8a4e8aea..8fbf7445 100644 --- a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/vo/QmsPqcInspectionPointItemsGroupedVO.java +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/vo/QmsPqcInspectionPointItemsGroupedVO.java @@ -12,19 +12,19 @@ public class QmsPqcInspectionPointItemsGroupedVO { /** * 第1类:关键物料拍照类 - * 包含:inspectionType = 0(所有)+ inspectionType = 2(所有) + * 包含:inspectionType = 1(关键物料拍照)+ inspectionType = 2(全部) */ private List materialItems; /** * 第2类:工序检查-自检复核类 - * 包含:inspectionType = 1且星级=1或2 + inspectionType = 2且星级=1或2 + * 包含:inspectionType = 0且星级=1或2 + inspectionType = 2且星级=1或2 */ private List selfReviewItems; /** * 第3类:工序检查-QC检测类 - * 包含:inspectionType = 1且星级=3 + inspectionType = 2且星级=3 + * 包含:星级=3,不区分检查类型 */ private List qcItems; } diff --git a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/entity/QmsPqcInspectionPointItems.java b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/entity/QmsPqcInspectionPointItems.java index a282b9f3..b55abb0c 100644 --- a/nflg-wms-repository/src/main/java/com/nflg/wms/repository/entity/QmsPqcInspectionPointItems.java +++ b/nflg-wms-repository/src/main/java/com/nflg/wms/repository/entity/QmsPqcInspectionPointItems.java @@ -47,7 +47,7 @@ public class QmsPqcInspectionPointItems implements Serializable { private String inspectionContent; /** - * 检查类型(位标志,支持多选):bit0=工序检查(1), bit1=关键物料拍照(2), bit2=关键物料采集(4) + * 检查类型:0=工序检查,1=关键物料拍照,2=全部 */ private Integer inspectionType;