diff --git a/src/main/java/com/xujie/modules/part/service/Impl/PartAdvancedCopyService.java b/src/main/java/com/xujie/modules/part/service/Impl/PartAdvancedCopyService.java index 9105e66..16b8d69 100644 --- a/src/main/java/com/xujie/modules/part/service/Impl/PartAdvancedCopyService.java +++ b/src/main/java/com/xujie/modules/part/service/Impl/PartAdvancedCopyService.java @@ -163,10 +163,7 @@ public class PartAdvancedCopyService { || StringUtils.isBlank(request.getBasePartNo())) { throw new RuntimeException("工厂、源物料和目标基准料号不能为空(请前端传site)"); } - if (request.getPartSuffix().contains("-")) { - throw new RuntimeException("物料后缀不能包含 '-' 符号"); - } - // 空后缀不拼接 '-';新基准号无需与源物料相同。 + // 后缀允许包含 '-',按原值拼接;空后缀不追加连字符,新基准号无需与源物料相同 - rqrq。 String targetPartNo = request.getBasePartNo() + (StringUtils.isBlank(request.getPartSuffix()) ? "" : "-" + request.getPartSuffix()); if (targetPartNo.length() > 30) { diff --git a/src/main/java/com/xujie/modules/part/service/Impl/PartServiceImpl.java b/src/main/java/com/xujie/modules/part/service/Impl/PartServiceImpl.java index 170cd89..65e2cde 100644 --- a/src/main/java/com/xujie/modules/part/service/Impl/PartServiceImpl.java +++ b/src/main/java/com/xujie/modules/part/service/Impl/PartServiceImpl.java @@ -529,17 +529,19 @@ public class PartServiceImpl extends ServiceImpl implements IP model.setItem(StringUtils.trimToEmpty(model.getItem()).toUpperCase()); } - /** 基准料号必填,后缀可空;空后缀直接使用基准料号,供新增及原有复制共用 - rqrq */ + /** 基准料号必填,后缀可空且允许包含 '-';生成的完整编码最多30位,供新增及原有复制共用 - rqrq */ private String buildPartNo(String basePartNo, String partSuffix) { String normalizedBase = StringUtils.trimToEmpty(basePartNo).toUpperCase(); String normalizedSuffix = StringUtils.trimToEmpty(partSuffix).toUpperCase(); if (StringUtils.isBlank(normalizedBase)) { throw new RuntimeException("基准料号不能为空!"); } - if (normalizedSuffix.contains("-")) { - throw new RuntimeException("物料后缀不能包含 '-' 符号!"); + // 保留后缀内的连字符;空后缀直接使用基准料号,统一校验 part.part_no 的30位长度 - rqrq。 + String partNo = StringUtils.isBlank(normalizedSuffix) ? normalizedBase : normalizedBase + "-" + normalizedSuffix; + if (partNo.length() > 30) { + throw new RuntimeException("产品编码不能超过30个字符"); } - return StringUtils.isBlank(normalizedSuffix) ? normalizedBase : normalizedBase + "-" + normalizedSuffix; + return partNo; } private String extractBasePartNo(String partNo) {