板材、余料字段检验

This commit is contained in:
lym
2024-10-15 15:55:15 +08:00
parent 5090ce1807
commit 8b6232edbb
17 changed files with 269 additions and 15 deletions
@@ -24,7 +24,7 @@ public class ErrorCodeConstants {
// ========== 生产单 TODO 补充编号 ==========
public static final ErrorCode ORDER_NOT_EXISTS = new ErrorCode(1_001_109_000, "生产单不存在");
public static final ErrorCode ORDER_NOT_CANCEL = new ErrorCode(1_001_109_000, "生产单已生产,无法作废");
public static final ErrorCode ORDER_NOT_CANCEL = new ErrorCode(1_001_109_000, "生产单以进入生产状态,无法作废");
public static final ErrorCode ORDER_PLAN_ERROR = new ErrorCode(1_001_109_001, "选中删除对象有已开料板件,请联系管理员修改开料状态后再删除!");
public static final ErrorCode ORDER_ERROR = new ErrorCode(1_001_109_002, "当前生产单柜体,房间已全部删除!");
@@ -1000,7 +1000,7 @@ public class ApiTypeRealize {
Map<String, String> map = new HashMap<>();
for (int i = 1; i < 6; i++) {
if (block.getString("Remark" + i) != null && !block.getString("Remark" + i).isEmpty()) {
map.put("remark" + i, block.getString("remark" + i));
map.put("Remark" + i, block.getString("Remark" + i));
}
}
return map;
@@ -244,12 +244,12 @@
bdy.room_id,
bdy.room_name
from order_plate op
left join order_goods ogs on op.goods_id = ogs.id
left join order_item its on op.id = its.plate_id
left join order_body bdy on bdy.id = its.body_id
where op.order_id = #{orderId}
and op.organ_id = #{organId}
left join order_goods ogs on op.organ_id = ogs.organ_id and op.order_id = ogs.order_id and op.goods_id = ogs.id
left join order_item its on op.organ_id = its.organ_id and op.order_id = its.order_id and op.id = its.plate_id
left join order_body bdy on its.organ_id = bdy.organ_id and its.order_id = bdy.order_id and its.body_id = bdy.id
where op.organ_id = #{organId}
and op.deleted = #{deleted}
and op.order_id = #{orderId}
</select>
<select id="selectPlateGoodsListSummary" resultType="com.cf.imes.module.executor.controller.admin.plate.vo.PlateGoodsRespVO">
@@ -271,9 +271,9 @@
bdy.room_id,
bdy.room_name
from order_plate op
left join order_goods ogs on op.goods_id = ogs.id
left join order_item its on op.id = its.plate_id
left join order_body bdy on bdy.id = its.body_id
left join order_goods ogs on op.organ_id = ogs.organ_id and op.order_id = ogs.order_id and op.goods_id = ogs.id
left join order_item its on op.organ_id = its.organ_id and op.order_id = its.order_id and op.id = its.plate_id
left join order_body bdy on its.organ_id = bdy.organ_id and its.order_id = bdy.order_id and its.body_id = bdy.id
where op.order_id = #{orderId}
and op.organ_id = #{organId}
and op.deleted = #{deleted}
@@ -1,10 +1,15 @@
package com.cf.imes.module.manage.controller.admin.plate.vo.plate;
import com.alibaba.excel.annotation.ExcelProperty;
import com.cf.imes.module.manage.validation.length.ValidLength;
import com.cf.imes.module.manage.validation.texture.ValidBoolean;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@Schema(description = "管理后台 - 板材信息表 plate_{N}新增/修改 Request VO")
@Data
@@ -15,42 +20,52 @@ public class PlateSaveReqVO {
@Schema(description = "客户的商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotEmpty(message = "客户的商品编号不能为空")
@Size(max = 30, message = "客户的商品编号长度不能超过32个字符")
private String goodsId;
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
@NotEmpty(message = "商品名称不能为空")
@Size(max = 64, message = "商品名称长度不能超过64个字符")
private String goodsName;
@Schema(description = "材质:颗粒板、欧松板、多层板、生态板、禾香板、密度板、实木、铝蜂窝板、铝塑板", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "材质:颗粒板、欧松板、多层板、生态板、禾香板、密度板、实木、铝蜂窝板、铝塑板不能为空")
@Size(max = 64, message = "商品材料长度不能超过64个字符")
private String material;
@Schema(description = "颜色", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "颜色不能为空")
@Size(max = 32, message = "商品颜色长度不能超过32个字符")
private String color;
@Schema(description = "纹理", requiredMode = Schema.RequiredMode.REQUIRED)
@ValidBoolean
private Boolean texture;
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "宽度不能为空")
@ValidLength()
private Double width;
@Schema(description = "高度", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "高度不能为空")
@ValidLength()
private Double height;
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "厚度不能为空")
@ValidLength()
private Double thickness;
// @Schema(description = "价格", example = "3380")
// private Double price;
@Schema(description = "品牌")
@Size(max = 64, message = "商品品牌长度不能超过64个字符")
private String brand;
@Schema(description = "规格")
@Size(max = 64, message = "商品规格长度不能超过64个字符")
private String spec;
@Schema(description = "备注", example = "随便")
@@ -1,10 +1,15 @@
package com.cf.imes.module.manage.controller.admin.plate.vo.remain;
import com.cf.imes.module.manage.validation.common.ValidCommonStatus;
import com.cf.imes.module.manage.validation.length.ValidLength;
import com.cf.imes.module.manage.validation.placeStyle.ValidPlaceStyle;
import com.cf.imes.module.manage.validation.type.ValidTypeField;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.cf.imes.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@@ -29,28 +34,34 @@ public class RemainPlatePageReqVO extends PageParam {
private Long initPlanId;
@Schema(description = "余料板状态,0未使用,1使用中", example = "0")
@ValidCommonStatus
private Integer status;
@Schema(description = "是否为开料添加,0否,1是", example = "0")
private Boolean isCutting;
@Schema(description = "使用类型,0核销,1排单,2补板", example = "0")
@ValidTypeField
private Integer useType;
@Schema(description = "商品 ID", example = "7425")
@Size(max = 32, message = "商品ID长度不能超过32个字符")
private String goodsId;
@Schema(description = "商品名", example = "晨丰")
@Size(max = 255, message = "商品名长度不能超过255个字符")
private String name;
@Schema(description = "材料")
@Size(max = 50, message = "材料长度不能超过50个字符")
private String material;
@Schema(description = "颜色")
@Size(max = 50, message = "颜色长度不能超过50个字符")
private String color;
@Schema(description = "纹理")
private String texture;
private Boolean texture;
@Schema(description = "宽度")
private BigDecimal[] width;
@@ -62,18 +73,22 @@ public class RemainPlatePageReqVO extends PageParam {
private BigDecimal thickness;
@Schema(description = "品牌")
@Size(max = 50, message = "品牌长度不能超过50个字符")
private String brand;
@Schema(description = "放置样式,0正面,1正面右转,2正面后转,3正面左转,4反面,5反面右转,6反面后转,7反面左转")
@ValidPlaceStyle
private Integer placeStyle;
@Schema(description = "仓库名")
@Size(max = 64, message = "品牌长度不能超过64个字符")
private String store;
@Schema(description = "数量", example = "18318")
private Integer count;
@Schema(description = "备注", example = "随便")
@Size(max = 255, message = "品牌长度不能超过255个字符")
private String remark;
@Schema(description = "轮廊数据,Json 串")
@@ -1,10 +1,14 @@
package com.cf.imes.module.manage.controller.admin.plate.vo.remain;
import com.alibaba.excel.annotation.ExcelProperty;
import com.cf.imes.module.manage.validation.common.ValidCommonStatus;
import com.cf.imes.module.manage.validation.length.ValidLength;
import com.cf.imes.module.manage.validation.placeStyle.ValidPlaceStyle;
import com.cf.imes.module.manage.validation.type.ValidTypeField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 生产单余料板表 order_remain_plate_{N}新增/修改 Request VO")
@@ -23,7 +27,8 @@ public class RemainPlateSaveReqVO {
@Schema(description = "初始排单 ID")
private Long initPlanId;
@Schema(description = "余料板状态,0未使用,1使用中,2已使用", example = "1")
@Schema(description = "余料板状态,0未使用,1已使用", example = "1")
@ValidCommonStatus
private Integer status;
@Schema(description = "是否为开料添加,0否,1是", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@@ -31,45 +36,55 @@ public class RemainPlateSaveReqVO {
private Boolean isCutting;
@Schema(description = "使用类型,0核销,1排单,2补板", example = "0")
@ValidTypeField
private Integer useType;
@Schema(description = "商品 ID", example = "7425")
@Size(max = 32, message = "商品ID长度不能超过32个字符")
private String goodsId;
@Schema(description = "商品名", example = "晨丰")
@Size(max = 255, message = "商品名长度不能超过255个字符")
private String name;
@Schema(description = "材料", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "材料不能为空")
@Size(max = 50, message = "材料长度不能超过50个字符")
private String material;
@Schema(description = "颜色", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "颜色不能为空")
@Size(max = 50, message = "颜色长度不能超过50个字符")
private String color;
@Schema(description = "纹理 有 无", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "纹理不能为空")
private String texture;
private Boolean texture;
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "宽度不能为空")
@ValidLength
private BigDecimal width;
@Schema(description = "长度", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "长度不能为空")
@ValidLength
private BigDecimal length;
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "厚度不能为空")
@ValidLength
private BigDecimal thickness;
@Schema(description = "品牌")
@Size(max = 50, message = "品牌长度不能超过50个字符")
private String brand;
@Schema(description = "放置样式,0正面,1正面右转,2正面后转,3正面左转,4反面,5反面右转,6反面后转,7反面左转")
@ValidPlaceStyle
private Integer placeStyle;
@Schema(description = "仓库名")
@Size(max = 64, message = "品牌长度不能超过64个字符")
private String store;
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "18318")
@@ -77,6 +92,7 @@ public class RemainPlateSaveReqVO {
private Integer count;
@Schema(description = "备注", example = "随便")
@Size(max = 255, message = "品牌长度不能超过255个字符")
private String remark;
@Schema(description = "轮廊数据,Json 串", requiredMode = Schema.RequiredMode.REQUIRED, example = "18318")
@@ -1,5 +1,7 @@
package com.cf.imes.module.manage.controller.admin.plate.vo.remain;
import com.cf.imes.module.manage.validation.common.ValidCommonStatus;
import com.cf.imes.module.manage.validation.type.ValidTypeField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -13,9 +15,11 @@ public class RemainPlateUptReqVO {
private Set<Long> ids;
@Schema(description = "余料板状态,0未使用,1使用中", example = "1")
@ValidCommonStatus
private Integer status;
@Schema(description = "使用类型,1核销,2排单,3补板", example = "0")
@ValidTypeField
private Integer useType;
@Schema(description = "排单 ID", example = "6628")
@@ -0,0 +1,15 @@
package com.cf.imes.module.manage.validation.common;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
/**
* 状态校验
*/
public class CommonStatusValidator implements ConstraintValidator<ValidCommonStatus, Integer> {
@Override
public boolean isValid(Integer value, ConstraintValidatorContext context) {
return value != null && (value == 0 || value == 1);
}
}
@@ -0,0 +1,20 @@
package com.cf.imes.module.manage.validation.common;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
/**
* 状态校验注解
*/
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = CommonStatusValidator.class)
@Documented
public @interface ValidCommonStatus {
String message() default "状态值必须为 0:未使用、1:已使用 ";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
@@ -0,0 +1,23 @@
package com.cf.imes.module.manage.validation.length;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
/**
* 数字长度校验器注解
*/
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = WidthLengthValidator.class)
@Documented
public @interface ValidLength {
String message() default "数值长度不符合";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
int maxDigits() default 8; // 最大总位数
int maxFractionalDigits() default 3; // 小数点后的最大位数
}
@@ -0,0 +1,36 @@
package com.cf.imes.module.manage.validation.length;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
/**
* 数字长度校验器
*/
public class WidthLengthValidator implements ConstraintValidator<ValidLength, Double> {
private int maxDigits;
private int maxFractionalDigits;
@Override
public void initialize(ValidLength constraintAnnotation) {
this.maxDigits = constraintAnnotation.maxDigits();
this.maxFractionalDigits = constraintAnnotation.maxFractionalDigits();
}
@Override
public boolean isValid(Double value, ConstraintValidatorContext context) {
if (value == null) {
return true; // 允许 null 值
}
String valueAsString = Double.toString(value);
int decimalPointIndex = valueAsString.indexOf('.');
// 计算整数部分和小数部分的位数
int integerPartLength = decimalPointIndex == -1 ? valueAsString.length() : decimalPointIndex;
int fractionalPartLength = decimalPointIndex == -1 ? 0 : valueAsString.length() - decimalPointIndex - 1;
int totalDigits = integerPartLength + fractionalPartLength;
return totalDigits <= maxDigits && fractionalPartLength <= maxFractionalDigits;
}
}
@@ -0,0 +1,16 @@
package com.cf.imes.module.manage.validation.placeStyle;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
/**
* 放置样式校验
*/
public class PlaceStyleValidator implements ConstraintValidator<ValidPlaceStyle, Integer> {
@Override
public boolean isValid(Integer value, ConstraintValidatorContext context) {
return value != null && (value == 0 || value == 1 || value == 2 || value == 3
|| value == 4 || value == 5 || value == 6 || value == 7);
}
}
@@ -0,0 +1,24 @@
package com.cf.imes.module.manage.validation.placeStyle;
import com.cf.imes.module.manage.validation.texture.BooleanTypeValidator;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
/**
* 放置样式校验注解
*/
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = PlaceStyleValidator.class)
@Documented
public @interface ValidPlaceStyle {
String message() default " 放置样式不合法,0正面,1正面右转,2正面后转,3正面左转,4反面,5反面右转,6反面后转,7反面左转";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
@@ -0,0 +1,15 @@
package com.cf.imes.module.manage.validation.texture;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
/**
* 纹理校验
*/
public class BooleanTypeValidator implements ConstraintValidator<ValidBoolean, Object> {
@Override
public boolean isValid(Object value, ConstraintValidatorContext context) {
return value instanceof Boolean;
}
}
@@ -0,0 +1,20 @@
package com.cf.imes.module.manage.validation.texture;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
/**
* 纹理校验注解
*/
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = BooleanTypeValidator.class)
@Documented
public @interface ValidBoolean {
String message() default "纹理不合法,1:有、0:无";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
@@ -0,0 +1,15 @@
package com.cf.imes.module.manage.validation.type;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
/**
* 使用类型校验
*/
public class TypeFieldValidator implements ConstraintValidator<ValidTypeField, Integer> {
@Override
public boolean isValid(Integer value, ConstraintValidatorContext context) {
return value != null && (value == 0 || value == 1 || value == 2);
}
}
@@ -0,0 +1,20 @@
package com.cf.imes.module.manage.validation.type;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
/**
* 使用类型校验注解
*/
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = TypeFieldValidator.class)
@Documented
public @interface ValidTypeField {
String message() default "状态值必须为 0:核销、1:排单 或 2:补板";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}