From 82fbc4ea415ac1da89b2572b541e9c0c1c9cf757 Mon Sep 17 00:00:00 2001 From: gaoqr <13665037151@163.com> Date: Wed, 22 Jul 2026 15:20:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=9C=AA=E6=8E=92=E8=B4=B4?= =?UTF-8?q?=E7=9A=AE=E6=9D=BF=E4=BB=B6=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9F=A5=E8=AF=A2=E5=85=A5=E5=8F=82=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/UnplannedVeneerPlateDataReqVO.java | 4 ++ .../veneer/VeneerDimensionRangeValid.java | 31 ++++++++++++ .../veneer/VeneerDimensionRangeValidator.java | 50 +++++++++++++++++++ .../mapper/veneer/VeneerManageMapper.xml | 2 +- .../src/main/resources/message_cht.properties | 3 ++ .../src/main/resources/message_en.properties | 3 ++ .../src/main/resources/message_zh.properties | 3 ++ 7 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/validation/veneer/VeneerDimensionRangeValid.java create mode 100644 cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/validation/veneer/VeneerDimensionRangeValidator.java diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/veneer/vo/UnplannedVeneerPlateDataReqVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/veneer/vo/UnplannedVeneerPlateDataReqVO.java index 0169c9197..a133b5929 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/veneer/vo/UnplannedVeneerPlateDataReqVO.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/veneer/vo/UnplannedVeneerPlateDataReqVO.java @@ -1,5 +1,6 @@ package com.cf.imes.module.executor.controller.admin.veneer.vo; +import com.cf.imes.module.executor.validation.veneer.VeneerDimensionRangeValid; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.hibernate.validator.constraints.Length; @@ -50,11 +51,14 @@ public class UnplannedVeneerPlateDataReqVO { private String plateName; @Schema(description = "长度范围(mm),依次为最小值、最大值") + @VeneerDimensionRangeValid(message = "{veneer.unplanned.plate.query.length.range.invalid}") private BigDecimal[] length; @Schema(description = "宽度范围(mm),依次为最小值、最大值") + @VeneerDimensionRangeValid(message = "{veneer.unplanned.plate.query.width.range.invalid}") private BigDecimal[] width; @Schema(description = "厚度范围(mm),依次为最小值、最大值") + @VeneerDimensionRangeValid(message = "{veneer.unplanned.plate.query.thickness.range.invalid}") private BigDecimal[] thickness; } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/validation/veneer/VeneerDimensionRangeValid.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/validation/veneer/VeneerDimensionRangeValid.java new file mode 100644 index 000000000..bb462cf31 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/validation/veneer/VeneerDimensionRangeValid.java @@ -0,0 +1,31 @@ +package com.cf.imes.module.executor.validation.veneer; + +import jakarta.validation.Constraint; +import jakarta.validation.Payload; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 贴皮板件尺寸查询区间校验注解。 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Constraint(validatedBy = VeneerDimensionRangeValidator.class) +public @interface VeneerDimensionRangeValid { + + /** + * 校验失败提示。 + * + * @return 国际化消息模板 + */ + String message(); + + Class[] groups() default {}; + + Class[] payload() default {}; +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/validation/veneer/VeneerDimensionRangeValidator.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/validation/veneer/VeneerDimensionRangeValidator.java new file mode 100644 index 000000000..c3016d166 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/validation/veneer/VeneerDimensionRangeValidator.java @@ -0,0 +1,50 @@ +package com.cf.imes.module.executor.validation.veneer; + +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; + +import java.math.BigDecimal; + +/** + * 贴皮板件尺寸查询区间校验器。 + */ +public class VeneerDimensionRangeValidator + implements ConstraintValidator { + + /** + * 单个尺寸允许的最大整数位数。 + */ + private static final int MAX_INTEGER_DIGITS = 5; + + /** + * 单个尺寸允许的最大小数位数。 + */ + private static final int MAX_FRACTION_DIGITS = 3; + + @Override + public boolean isValid(BigDecimal[] range, ConstraintValidatorContext context) { + if (range == null) { + return true; + } + if (range.length != 2 || !isValidDimension(range[0]) || !isValidDimension(range[1])) { + return false; + } + return range[0].compareTo(range[1]) <= 0; + } + + /** + * 校验尺寸值非负,且整数、小数位数均未超过限制。 + * + * @param value 待校验尺寸值 + * @return 是否合法 + */ + private boolean isValidDimension(BigDecimal value) { + if (value == null || value.signum() < 0) { + return false; + } + String[] parts = value.toPlainString().split("\\.", -1); + int integerLength = parts[0].length(); + int fractionLength = parts.length == 2 ? parts[1].length() : 0; + return integerLength <= MAX_INTEGER_DIGITS && fractionLength <= MAX_FRACTION_DIGITS; + } +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/veneer/VeneerManageMapper.xml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/veneer/VeneerManageMapper.xml index 0499ea559..972a6eba9 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/veneer/VeneerManageMapper.xml +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/veneer/VeneerManageMapper.xml @@ -482,7 +482,7 @@ AND opv.plate_name LIKE CONCAT('%', #{req.plateName}, '%') - AND opv.plate_height BETWEEN #{req.length[0]} AND #{req.length[1]} + AND opv.plate_length BETWEEN #{req.length[0]} AND #{req.length[1]} AND opv.plate_width BETWEEN #{req.width[0]} AND #{req.width[1]} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/message_cht.properties b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/message_cht.properties index 1e5b4150c..2471fe57e 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/message_cht.properties +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/message_cht.properties @@ -43,6 +43,9 @@ veneer.unplanned.plate.query.sourceVeneerNo.length.max=貼皮商品編號不能 veneer.unplanned.plate.query.material.length.max=貼皮材質不能超過64個字元 veneer.unplanned.plate.query.color.length.max=貼皮顏色不能超過32個字元 veneer.unplanned.plate.query.plateName.length.max=板名稱不能超過64個字元 +veneer.unplanned.plate.query.length.range.invalid=長度範圍必須包含兩個非負數,整數最多5位、小數最多3位,且最小值不能大於最大值 +veneer.unplanned.plate.query.width.range.invalid=寬度範圍必須包含兩個非負數,整數最多5位、小數最多3位,且最小值不能大於最大值 +veneer.unplanned.plate.query.thickness.range.invalid=厚度範圍必須包含兩個非負數,整數最多5位、小數最多3位,且最小值不能大於最大值 veneer.defect.save.id.not.null=貼皮ID不能為空 veneer.classification.name.save.name.not.null=分類名稱不能為空 veneer.classification.name.save.name.length.max=分類名稱不能超過64個字元 diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/message_en.properties b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/message_en.properties index 472e6bbb7..682585bf2 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/message_en.properties +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/message_en.properties @@ -43,6 +43,9 @@ veneer.unplanned.plate.query.sourceVeneerNo.length.max=veneer product number can veneer.unplanned.plate.query.material.length.max=veneer material cannot exceed 64 characters veneer.unplanned.plate.query.color.length.max=veneer color cannot exceed 32 characters veneer.unplanned.plate.query.plateName.length.max=plate name cannot exceed 64 characters +veneer.unplanned.plate.query.length.range.invalid=length range must contain two non-negative numbers with at most 5 integer digits and 3 decimal places, and the minimum cannot exceed the maximum +veneer.unplanned.plate.query.width.range.invalid=width range must contain two non-negative numbers with at most 5 integer digits and 3 decimal places, and the minimum cannot exceed the maximum +veneer.unplanned.plate.query.thickness.range.invalid=thickness range must contain two non-negative numbers with at most 5 integer digits and 3 decimal places, and the minimum cannot exceed the maximum veneer.defect.save.id.not.null=veneer id cannot be empty veneer.classification.name.save.name.not.null=classification name cannot be empty veneer.classification.name.save.name.length.max=classification name length cannot exceed 64 characters diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/message_zh.properties b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/message_zh.properties index b47b4086e..2ca4781f7 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/message_zh.properties +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/message_zh.properties @@ -43,6 +43,9 @@ veneer.unplanned.plate.query.sourceVeneerNo.length.max=贴皮商品编号不能 veneer.unplanned.plate.query.material.length.max=贴皮材质不能超过64个字符 veneer.unplanned.plate.query.color.length.max=贴皮颜色不能超过32个字符 veneer.unplanned.plate.query.plateName.length.max=板名称不能超过64个字符 +veneer.unplanned.plate.query.length.range.invalid=长度范围必须包含两个非负数,整数最多5位、小数最多3位,且最小值不能大于最大值 +veneer.unplanned.plate.query.width.range.invalid=宽度范围必须包含两个非负数,整数最多5位、小数最多3位,且最小值不能大于最大值 +veneer.unplanned.plate.query.thickness.range.invalid=厚度范围必须包含两个非负数,整数最多5位、小数最多3位,且最小值不能大于最大值 veneer.defect.save.id.not.null=贴皮ID不能为空 veneer.classification.name.save.name.not.null=分类名称不能为空 veneer.classification.name.save.name.length.max=分类名称长度不能超过64