feat(wms): 新增钢卷信息校验功能
- 在 IWmsReceivePlanService 中添加 validateCoil 方法接口 - 在 WmsReceivePlanController 中新增 /validateCoil 接口 - 在 WmsReceivePlanServiceImpl 中实现钢卷信息校验逻辑 - 创建 CoilValidationBo 用于接收校验参数 - 创建 CoilValidationVo 用于返回校验结果 - 实现钢卷信息与数据库数据的字段对比功能 - 添加对原材料、产品和仓库数据的查询验证 - 支持多种字段类型的比较并返回差异信息
This commit is contained in:
@@ -18,7 +18,9 @@ import com.klp.common.core.validate.EditGroup;
|
||||
import com.klp.common.enums.BusinessType;
|
||||
import com.klp.common.utils.poi.ExcelUtil;
|
||||
import com.klp.domain.vo.WmsReceivePlanVo;
|
||||
import com.klp.domain.vo.CoilValidationVo;
|
||||
import com.klp.domain.bo.WmsReceivePlanBo;
|
||||
import com.klp.domain.bo.CoilValidationBo;
|
||||
import com.klp.service.IWmsReceivePlanService;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
|
||||
@@ -96,4 +98,15 @@ public class WmsReceivePlanController extends BaseController {
|
||||
@PathVariable Long[] receiveIds) {
|
||||
return toAjax(iWmsReceivePlanService.deleteWithValidByIds(Arrays.asList(receiveIds), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 钢卷信息校验
|
||||
*
|
||||
* @param bo 钢卷校验对象
|
||||
*/
|
||||
@Log(title = "钢卷信息校验", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/validateCoil")
|
||||
public R<CoilValidationVo> validateCoil(@Validated @RequestBody CoilValidationBo bo) {
|
||||
return R.ok(iWmsReceivePlanService.validateCoil(bo));
|
||||
}
|
||||
}
|
||||
|
||||
113
klp-wms/src/main/java/com/klp/domain/bo/CoilValidationBo.java
Normal file
113
klp-wms/src/main/java/com/klp/domain/bo/CoilValidationBo.java
Normal file
@@ -0,0 +1,113 @@
|
||||
package com.klp.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 钢卷校验业务对象
|
||||
*
|
||||
* @author klp
|
||||
* @date 2026-05-10
|
||||
*/
|
||||
@Data
|
||||
public class CoilValidationBo {
|
||||
|
||||
/**
|
||||
* 材质类型
|
||||
*/
|
||||
private String materialType;
|
||||
|
||||
/**
|
||||
* 入场卷号 (必填)
|
||||
*/
|
||||
@NotBlank(message = "入场卷号不能为空")
|
||||
private String enterCoilNo;
|
||||
|
||||
/**
|
||||
* 当前卷号
|
||||
*/
|
||||
private String currentCoilNo;
|
||||
|
||||
/**
|
||||
* 物料ID
|
||||
*/
|
||||
private Long itemId;
|
||||
|
||||
/**
|
||||
* 物料类型
|
||||
*/
|
||||
private String itemType;
|
||||
|
||||
/**
|
||||
* 仓库ID
|
||||
*/
|
||||
private String warehouseId;
|
||||
|
||||
/**
|
||||
* 净重
|
||||
*/
|
||||
private String netWeight;
|
||||
|
||||
/**
|
||||
* 毛重
|
||||
*/
|
||||
private String grossWeight;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 数据类型
|
||||
*/
|
||||
private Integer dataType;
|
||||
|
||||
/**
|
||||
* 切边要求
|
||||
*/
|
||||
private String trimmingRequirement;
|
||||
|
||||
/**
|
||||
* 原料材质
|
||||
*/
|
||||
private String packingStatus;
|
||||
|
||||
/**
|
||||
* 包装要求
|
||||
*/
|
||||
private String packagingRequirement;
|
||||
|
||||
/**
|
||||
* 计划ID
|
||||
*/
|
||||
private String planId;
|
||||
|
||||
/**
|
||||
* 长度
|
||||
*/
|
||||
private BigDecimal length;
|
||||
|
||||
/**
|
||||
* 等级
|
||||
*/
|
||||
private String temperGrade;
|
||||
|
||||
/**
|
||||
* 涂层类型
|
||||
*/
|
||||
private String coatingType;
|
||||
|
||||
/**
|
||||
* 供应商卷号
|
||||
*/
|
||||
private String supplierCoilNo;
|
||||
|
||||
/**
|
||||
* 班组
|
||||
*/
|
||||
private String team;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.klp.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 钢卷校验结果视图对象
|
||||
*
|
||||
* @author klp
|
||||
* @date 2026-05-10
|
||||
*/
|
||||
@Data
|
||||
public class CoilValidationVo {
|
||||
|
||||
/**
|
||||
* 是否找到匹配的钢卷
|
||||
*/
|
||||
private Boolean found;
|
||||
|
||||
/**
|
||||
* 校验消息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 字段差异信息 (字段名 -> 差异信息)
|
||||
*/
|
||||
private Map<String, String> differences;
|
||||
|
||||
/**
|
||||
* 数据库中的钢卷信息
|
||||
*/
|
||||
private WmsReceivePlanVo dbData;
|
||||
|
||||
}
|
||||
@@ -2,7 +2,9 @@ package com.klp.service;
|
||||
|
||||
import com.klp.domain.WmsReceivePlan;
|
||||
import com.klp.domain.vo.WmsReceivePlanVo;
|
||||
import com.klp.domain.vo.CoilValidationVo;
|
||||
import com.klp.domain.bo.WmsReceivePlanBo;
|
||||
import com.klp.domain.bo.CoilValidationBo;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
|
||||
@@ -46,4 +48,9 @@ public interface IWmsReceivePlanService {
|
||||
* 校验并批量删除应收货物计划信息
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 钢卷信息校验
|
||||
*/
|
||||
CoilValidationVo validateCoil(CoilValidationBo bo);
|
||||
}
|
||||
|
||||
@@ -7,17 +7,25 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.klp.common.utils.StringUtils;
|
||||
import com.klp.domain.vo.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.klp.domain.bo.WmsReceivePlanBo;
|
||||
import com.klp.domain.vo.WmsReceivePlanVo;
|
||||
import com.klp.domain.bo.CoilValidationBo;
|
||||
import com.klp.domain.WmsReceivePlan;
|
||||
import com.klp.domain.WmsRawMaterial;
|
||||
import com.klp.domain.WmsProduct;
|
||||
import com.klp.domain.WmsWarehouse;
|
||||
import com.klp.mapper.WmsReceivePlanMapper;
|
||||
import com.klp.service.IWmsReceivePlanService;
|
||||
import com.klp.service.IWmsRawMaterialService;
|
||||
import com.klp.service.IWmsProductService;
|
||||
import com.klp.service.IWmsWarehouseService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 应收货物计划Service业务层处理
|
||||
@@ -30,6 +38,9 @@ import java.util.Collection;
|
||||
public class WmsReceivePlanServiceImpl implements IWmsReceivePlanService {
|
||||
|
||||
private final WmsReceivePlanMapper baseMapper;
|
||||
private final IWmsRawMaterialService rawMaterialService;
|
||||
private final IWmsProductService productService;
|
||||
private final IWmsWarehouseService warehouseService;
|
||||
|
||||
/**
|
||||
* 查询应收货物计划
|
||||
@@ -124,4 +135,119 @@ public class WmsReceivePlanServiceImpl implements IWmsReceivePlanService {
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 钢卷信息校验
|
||||
*/
|
||||
@Override
|
||||
public CoilValidationVo validateCoil(CoilValidationBo bo) {
|
||||
CoilValidationVo result = new CoilValidationVo();
|
||||
|
||||
// 根据入场卷号查询数据库中的钢卷信息
|
||||
LambdaQueryWrapper<WmsReceivePlan> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.eq(WmsReceivePlan::getLotNo, bo.getEnterCoilNo());
|
||||
WmsReceivePlanVo dbData = baseMapper.selectVoOne(queryWrapper);
|
||||
|
||||
if (dbData == null) {
|
||||
// 查询不到对应的钢卷
|
||||
result.setFound(false);
|
||||
result.setMessage("当前收货的钢卷不在计划收货钢卷内");
|
||||
return result;
|
||||
}
|
||||
|
||||
// 找到了钢卷,进行字段对比
|
||||
result.setFound(true);
|
||||
result.setDbData(dbData);
|
||||
result.setMessage("钢卷信息校验完成");
|
||||
|
||||
Map<String, String> differences = new HashMap<>();
|
||||
|
||||
// 1. 根据 itemId 和 itemType 查询对应的标准数据
|
||||
String standardMaterialType = null;
|
||||
String standardSpec = null;
|
||||
String standardManufacturer = null;
|
||||
String standardSurfaceTreatment = null;
|
||||
String standardZincCoating = null;
|
||||
|
||||
if ("raw_material".equals(bo.getItemType()) && bo.getItemId() != null) {
|
||||
// 查询原材料表
|
||||
WmsRawMaterialVo rawMaterial = rawMaterialService.queryById(bo.getItemId());
|
||||
if (rawMaterial != null) {
|
||||
standardMaterialType = rawMaterial.getMaterial();
|
||||
standardSpec = rawMaterial.getSpecification();
|
||||
standardManufacturer = rawMaterial.getManufacturer();
|
||||
standardSurfaceTreatment = rawMaterial.getSurfaceTreatmentDesc();
|
||||
standardZincCoating = rawMaterial.getZincLayer();
|
||||
}
|
||||
} else if ("product".equals(bo.getItemType()) && bo.getItemId() != null) {
|
||||
// 查询产品表
|
||||
WmsProductVo product = productService.queryById(bo.getItemId());
|
||||
if (product != null) {
|
||||
standardMaterialType = product.getMaterial();
|
||||
standardSpec = product.getSpecification();
|
||||
standardManufacturer = product.getManufacturer();
|
||||
standardSurfaceTreatment = product.getSurfaceTreatmentDesc();
|
||||
standardZincCoating = product.getZincLayer();
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 根据 warehouseId 查询仓库名称
|
||||
String standardWarehouseArea = null;
|
||||
if (bo.getWarehouseId() != null) {
|
||||
try {
|
||||
Long warehouseLongId = Long.parseLong(bo.getWarehouseId());
|
||||
WmsWarehouseVo warehouse = warehouseService.queryById(warehouseLongId);
|
||||
if (warehouse != null) {
|
||||
standardWarehouseArea = warehouse.getWarehouseName();
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
// ID格式错误,忽略
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 进行字段对比
|
||||
// 对比标准数据(从原材料或产品表获取的6个字段)
|
||||
compareField("名称", standardMaterialType, dbData.getGoodsName(), differences);
|
||||
compareField("规格", standardSpec, dbData.getSpec(), differences);
|
||||
compareField("材质", standardMaterialType, dbData.getMaterialType(), differences);
|
||||
compareField("生产厂家", standardManufacturer, dbData.getManufacturer(), differences);
|
||||
compareField("表面处理工艺", standardSurfaceTreatment, dbData.getSurfaceTreatment(), differences);
|
||||
compareField("锌层", standardZincCoating, dbData.getZincCoating(), differences);
|
||||
|
||||
// 对比前端传入的其他字段
|
||||
compareField("成品卷号", bo.getCurrentCoilNo(), dbData.getProductLotNo(), differences);
|
||||
compareField("厂家原卷号", bo.getSupplierCoilNo(), dbData.getSupplierLotNo(), differences);
|
||||
compareField("类型", bo.getMaterialType(), dbData.getGoodsType(), differences);
|
||||
compareField("班组", bo.getTeam(), dbData.getTeamGroup(), differences);
|
||||
compareField("调制度", bo.getTemperGrade(), dbData.getTemperRolling(), differences);
|
||||
compareField("镀层种类", bo.getCoatingType(), dbData.getCoatingType(), differences);
|
||||
compareField("逻辑库区", standardWarehouseArea, dbData.getWarehouseArea(), differences);
|
||||
compareField("计划ID", bo.getPlanId(), dbData.getPlanId() != null ? dbData.getPlanId().toString() : null, differences);
|
||||
compareField("长度", bo.getLength() != null ? bo.getLength().toString() : null,
|
||||
dbData.getLength() != null ? dbData.getLength().toString() : null, differences);
|
||||
|
||||
// 对比重量(需要转换类型)
|
||||
compareField("重量", bo.getNetWeight(), dbData.getWeight() != null ? dbData.getWeight().toString() : null, differences);
|
||||
|
||||
// 如果有差异,设置差异信息
|
||||
if (!differences.isEmpty()) {
|
||||
result.setDifferences(differences);
|
||||
result.setMessage("钢卷信息存在差异");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 比较字段值
|
||||
*/
|
||||
private void compareField(String fieldName, String frontValue, String dbValue, Map<String, String> differences) {
|
||||
if (frontValue != null && !frontValue.trim().isEmpty()) {
|
||||
if (dbValue == null || !frontValue.trim().equals(dbValue.trim())) {
|
||||
differences.put(fieldName, String.format("前端值: %s, 数据库值: %s",
|
||||
frontValue != null ? frontValue : "空",
|
||||
dbValue != null ? dbValue : "空"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user