fix: 木箱类型

This commit is contained in:
2026-08-17 19:56:20 +08:00
parent 6e9bbce2fe
commit 18490ba4a0
17 changed files with 339 additions and 41 deletions

View File

@@ -23,6 +23,22 @@ public class BoxTypeRespVO {
@ExcelProperty("木箱描述")
private String boxName;
@Schema(description = "木箱长度")
@ExcelProperty("木箱长度")
private Integer boxLength;
@Schema(description = "木箱宽度")
@ExcelProperty("木箱宽度")
private Integer boxWidth;
@Schema(description = "木箱高度")
@ExcelProperty("木箱高度")
private Integer boxHigh;
@Schema(description = "最大子卷数", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("最大子卷数")
private Integer maxNum;
@Schema(description = "捆扎模版")
@ExcelProperty("捆扎模版")
private String lashNum;

View File

@@ -1,10 +1,19 @@
package cn.code.nl.module.lms.controller.admin.boxtype.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import jakarta.validation.constraints.*;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.exc.InputCoercionException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.*;
@Schema(description = "管理后台 - 木箱类型新增/修改 Request VO")
@Data
@@ -17,6 +26,21 @@ public class BoxTypeSaveReqVO {
@Schema(description = "木箱描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
private String boxName;
@Schema(description = "木箱长度")
private Integer boxLength;
@Schema(description = "木箱宽度")
private Integer boxWidth;
@Schema(description = "木箱高度")
private Integer boxHigh;
@Schema(description = "最大子卷数", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "最大子卷数不能为空")
@Min(value = 1, message = "最大子卷数不能小于1")
@JsonDeserialize(using = StrictIntegerDeserializer.class)
private Integer maxNum;
@Schema(description = "捆扎模版")
private String lashNum;
@@ -42,4 +66,22 @@ public class BoxTypeSaveReqVO {
@NotNull(message = "干燥剂数量不能为空")
private Integer desiccantNum;
}
/**
* 严格限制 JSON 数字必须为整数,避免小数被 Jackson 截断。
*/
private static class StrictIntegerDeserializer extends JsonDeserializer<Integer> {
@Override
public Integer deserialize(JsonParser parser, DeserializationContext context) throws IOException {
if (!parser.hasToken(JsonToken.VALUE_NUMBER_INT)) {
throw InvalidFormatException.from(parser, "最大子卷数必须为整数", parser.getText(), Integer.class);
}
try {
return parser.getIntValue();
} catch (InputCoercionException exception) {
throw InvalidFormatException.from(parser, "最大子卷数超出整数范围", parser.getText(), Integer.class);
}
}
}
}

View File

@@ -24,7 +24,7 @@ public class SubPackageRelationPageReqVO extends PageParam {
private String saleOrderName;
@Schema(description = "客户编号", example = "王五")
private String customerName;
private String customerCode;
@Schema(description = "产品编码", example = "李四")
private String productName;

View File

@@ -25,10 +25,6 @@ public class SubPackageRelationRespVO {
@ExcelProperty("箱内子卷数量")
private Integer qualityInBox;
@Schema(description = "erp木箱号")
@ExcelProperty("erp木箱号")
private String extBoxSn;
@Schema(description = "木箱自身重量")
@ExcelProperty("木箱自身重量")
private BigDecimal boxWeight;
@@ -47,11 +43,11 @@ public class SubPackageRelationRespVO {
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("客户编号")
private String customerName;
private String customerCode;
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
@ExcelProperty("客户名称")
private String customerDescription;
private String customerName;
@Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
@ExcelProperty("产品编码")

View File

@@ -34,11 +34,11 @@ public class SubPackageRelationSaveReqVO {
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "客户编号不能为空")
private String customerName;
private String customerCode;
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
@NotEmpty(message = "客户名称不能为空")
private String customerDescription;
private String customerName;
@Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
@NotEmpty(message = "产品编码不能为空")

View File

@@ -35,6 +35,22 @@ public class BoxTypeDO {
* 木箱描述
*/
private String boxName;
/**
* 木箱长度
*/
private Integer boxLength;
/**
* 木箱宽度
*/
private Integer boxWidth;
/**
* 木箱高度
*/
private Integer boxHigh;
/**
* 最大子卷数
*/
private Integer maxNum;
/**
* 捆扎模版
*/

View File

@@ -59,11 +59,11 @@ public class SubPackageRelationDO extends BaseDO {
/**
* 客户编号
*/
private String customerName;
private String customerCode;
/**
* 客户名称
*/
private String customerDescription;
private String customerName;
/**
* 产品编码
*/

View File

@@ -26,4 +26,8 @@ public interface BoxTypeMapper extends BaseMapperX<BoxTypeDO> {
.orderByDesc(BoxTypeDO::getId));
}
default BoxTypeDO selectByBoxType(String boxType) {
return selectOne(BoxTypeDO::getBoxType, boxType);
}
}

View File

@@ -22,7 +22,7 @@ public interface SubPackageRelationMapper extends BaseMapperX<SubPackageRelation
.eqIfPresent(SubPackageRelationDO::getPackageBoxSn, reqVO.getPackageBoxSn())
.eqIfPresent(SubPackageRelationDO::getBoxType, reqVO.getBoxType())
.likeIfPresent(SubPackageRelationDO::getSaleOrderName, reqVO.getSaleOrderName())
.likeIfPresent(SubPackageRelationDO::getCustomerName, reqVO.getCustomerName())
.likeIfPresent(SubPackageRelationDO::getCustomerCode, reqVO.getCustomerCode())
.likeIfPresent(SubPackageRelationDO::getProductName, reqVO.getProductName())
.eqIfPresent(SubPackageRelationDO::getDateOfFgInbound, reqVO.getDateOfFgInbound())
.likeIfPresent(SubPackageRelationDO::getContainerName, reqVO.getContainerName())

View File

@@ -34,6 +34,8 @@ public class BoxTypeServiceImpl implements BoxTypeService {
@Override
public Long createBoxType(BoxTypeSaveReqVO createReqVO) {
// 校验唯一性
validateBoxTypeUnique(createReqVO.getBoxType());
// 插入
BoxTypeDO boxType = BeanUtils.toBean(createReqVO, BoxTypeDO.class);
boxTypeMapper.insert(boxType);
@@ -42,6 +44,12 @@ public class BoxTypeServiceImpl implements BoxTypeService {
return boxType.getId();
}
private void validateBoxTypeUnique(String boxType) {
if (boxTypeMapper.selectByBoxType(boxType) != null) {
throw exception(BOX_TYPE_EXISTS);
}
}
@Override
public void updateBoxType(BoxTypeSaveReqVO updateReqVO) {
// 校验存在