2026-05-10 13:52:43 +08:00
|
|
|
|
package com.klp.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
|
import com.klp.common.core.page.TableDataInfo;
|
|
|
|
|
|
import com.klp.common.core.domain.PageQuery;
|
|
|
|
|
|
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;
|
2026-05-10 14:55:20 +08:00
|
|
|
|
import com.klp.domain.vo.*;
|
2026-05-10 13:52:43 +08:00
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.klp.domain.bo.WmsReceivePlanBo;
|
2026-05-10 14:55:20 +08:00
|
|
|
|
import com.klp.domain.bo.CoilValidationBo;
|
2026-05-10 13:52:43 +08:00
|
|
|
|
import com.klp.domain.WmsReceivePlan;
|
2026-05-10 14:55:20 +08:00
|
|
|
|
import com.klp.domain.WmsRawMaterial;
|
|
|
|
|
|
import com.klp.domain.WmsProduct;
|
|
|
|
|
|
import com.klp.domain.WmsWarehouse;
|
2026-05-10 13:52:43 +08:00
|
|
|
|
import com.klp.mapper.WmsReceivePlanMapper;
|
|
|
|
|
|
import com.klp.service.IWmsReceivePlanService;
|
2026-05-10 14:55:20 +08:00
|
|
|
|
import com.klp.service.IWmsRawMaterialService;
|
|
|
|
|
|
import com.klp.service.IWmsProductService;
|
|
|
|
|
|
import com.klp.service.IWmsWarehouseService;
|
2026-05-10 13:52:43 +08:00
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
import java.util.Collection;
|
2026-05-10 14:55:20 +08:00
|
|
|
|
import java.util.HashMap;
|
2026-05-10 13:52:43 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 应收货物计划Service业务层处理
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author klp
|
|
|
|
|
|
* @date 2026-05-10
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
|
@Service
|
|
|
|
|
|
public class WmsReceivePlanServiceImpl implements IWmsReceivePlanService {
|
|
|
|
|
|
|
|
|
|
|
|
private final WmsReceivePlanMapper baseMapper;
|
2026-05-10 14:55:20 +08:00
|
|
|
|
private final IWmsRawMaterialService rawMaterialService;
|
|
|
|
|
|
private final IWmsProductService productService;
|
|
|
|
|
|
private final IWmsWarehouseService warehouseService;
|
2026-05-10 13:52:43 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询应收货物计划
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public WmsReceivePlanVo queryById(Long receiveId){
|
|
|
|
|
|
return baseMapper.selectVoById(receiveId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询应收货物计划列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public TableDataInfo<WmsReceivePlanVo> queryPageList(WmsReceivePlanBo bo, PageQuery pageQuery) {
|
|
|
|
|
|
LambdaQueryWrapper<WmsReceivePlan> lqw = buildQueryWrapper(bo);
|
|
|
|
|
|
Page<WmsReceivePlanVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
|
|
|
return TableDataInfo.build(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询应收货物计划列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<WmsReceivePlanVo> queryList(WmsReceivePlanBo bo) {
|
|
|
|
|
|
LambdaQueryWrapper<WmsReceivePlan> lqw = buildQueryWrapper(bo);
|
|
|
|
|
|
return baseMapper.selectVoList(lqw);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private LambdaQueryWrapper<WmsReceivePlan> buildQueryWrapper(WmsReceivePlanBo bo) {
|
|
|
|
|
|
Map<String, Object> params = bo.getParams();
|
|
|
|
|
|
LambdaQueryWrapper<WmsReceivePlan> lqw = Wrappers.lambdaQuery();
|
|
|
|
|
|
lqw.eq(bo.getPlanId() != null, WmsReceivePlan::getPlanId, bo.getPlanId());
|
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getWarehouseArea()), WmsReceivePlan::getWarehouseArea, bo.getWarehouseArea());
|
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getLotNo()), WmsReceivePlan::getLotNo, bo.getLotNo());
|
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getSupplierLotNo()), WmsReceivePlan::getSupplierLotNo, bo.getSupplierLotNo());
|
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getProductLotNo()), WmsReceivePlan::getProductLotNo, bo.getProductLotNo());
|
|
|
|
|
|
lqw.eq(bo.getProductionDate() != null, WmsReceivePlan::getProductionDate, bo.getProductionDate());
|
|
|
|
|
|
lqw.eq(bo.getWeight() != null, WmsReceivePlan::getWeight, bo.getWeight());
|
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getReceiveStatus()), WmsReceivePlan::getReceiveStatus, bo.getReceiveStatus());
|
|
|
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getGoodsName()), WmsReceivePlan::getGoodsName, bo.getGoodsName());
|
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getSpec()), WmsReceivePlan::getSpec, bo.getSpec());
|
|
|
|
|
|
lqw.eq(bo.getLength() != null, WmsReceivePlan::getLength, bo.getLength());
|
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getMaterialType()), WmsReceivePlan::getMaterialType, bo.getMaterialType());
|
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getManufacturer()), WmsReceivePlan::getManufacturer, bo.getManufacturer());
|
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getSurfaceTreatment()), WmsReceivePlan::getSurfaceTreatment, bo.getSurfaceTreatment());
|
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getZincCoating()), WmsReceivePlan::getZincCoating, bo.getZincCoating());
|
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getTeamGroup()), WmsReceivePlan::getTeamGroup, bo.getTeamGroup());
|
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getTemperRolling()), WmsReceivePlan::getTemperRolling, bo.getTemperRolling());
|
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getCoatingType()), WmsReceivePlan::getCoatingType, bo.getCoatingType());
|
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getGoodsType()), WmsReceivePlan::getGoodsType, bo.getGoodsType());
|
|
|
|
|
|
return lqw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 新增应收货物计划
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public Long insertByBo(WmsReceivePlanBo bo) {
|
|
|
|
|
|
WmsReceivePlan add = BeanUtil.toBean(bo, WmsReceivePlan.class);
|
|
|
|
|
|
validEntityBeforeSave(add);
|
|
|
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
|
|
|
if (flag) {
|
|
|
|
|
|
bo.setReceiveId(add.getReceiveId());
|
|
|
|
|
|
}
|
|
|
|
|
|
return add.getReceiveId();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 修改应收货物计划
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public Boolean updateByBo(WmsReceivePlanBo bo) {
|
|
|
|
|
|
WmsReceivePlan update = BeanUtil.toBean(bo, WmsReceivePlan.class);
|
|
|
|
|
|
validEntityBeforeSave(update);
|
|
|
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 保存前的数据校验
|
|
|
|
|
|
*/
|
|
|
|
|
|
private void validEntityBeforeSave(WmsReceivePlan entity){
|
|
|
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 批量删除应收货物计划
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
|
|
|
if(isValid){
|
|
|
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
|
|
|
}
|
|
|
|
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
|
|
|
|
|
}
|
2026-05-10 14:55:20 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 钢卷信息校验
|
|
|
|
|
|
*/
|
|
|
|
|
|
@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 : "空"));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-05-10 13:52:43 +08:00
|
|
|
|
}
|