From 7a38091468c3bba6fb9054fabf31af567e2ac91d Mon Sep 17 00:00:00 2001 From: Joshi <3040996759@qq.com> Date: Wed, 14 Jan 2026 17:34:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(wms):=20=E6=89=A9=E5=B1=95=E9=92=A2?= =?UTF-8?q?=E5=8D=B7=E5=BE=85=E5=A4=84=E7=90=86=E5=8A=A8=E4=BD=9C=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=8A=9F=E8=83=BD=E5=B9=B6=E5=AE=8C=E5=96=84=E5=88=86?= =?UTF-8?q?=E5=8D=B7=E5=90=88=E5=8D=B7=E4=B8=9A=E5=8A=A1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在WmsCoilPendingActionMapper.xml中新增仓库名称、规格、材质、生产厂家等物料信息字段查询 - 为WmsCoilPendingActionVo添加specification、material、manufacturer等物料属性字段 - 完善分卷合卷业务逻辑,增加对历史卷的分卷限制验证 - 新增validateOriginalCoilsForMerge方法用于合卷前验证原始钢卷数据状态 - 优化实际库区ID更新条件,当状态为1时也清除实际库区绑定 - 移除分卷新卷继承母卷实际库区ID的逻辑 - 增强合卷操作前的原始钢卷数据校验机制 --- .../klp/domain/vo/WmsCoilPendingActionVo.java | 39 ++++++++++++++++ .../impl/WmsMaterialCoilServiceImpl.java | 44 +++++++++++++++++-- .../mapper/klp/WmsCoilPendingActionMapper.xml | 33 +++++++++++++- 3 files changed, 111 insertions(+), 5 deletions(-) diff --git a/klp-wms/src/main/java/com/klp/domain/vo/WmsCoilPendingActionVo.java b/klp-wms/src/main/java/com/klp/domain/vo/WmsCoilPendingActionVo.java index 5e7c8dfe..7ed75456 100644 --- a/klp-wms/src/main/java/com/klp/domain/vo/WmsCoilPendingActionVo.java +++ b/klp-wms/src/main/java/com/klp/domain/vo/WmsCoilPendingActionVo.java @@ -163,5 +163,44 @@ public class WmsCoilPendingActionVo extends BaseEntity implements Serializable { private String operatorByName; + /** + * 规格(原料/产品通用) + */ + private String specification; + + /** + * 材质(原料/产品通用) + */ + private String material; + + /** + * 生产厂家(原料/产品通用) + */ + private String manufacturer; + + /** + * 表面处理说明(原料/产品通用) + */ + private String surfaceTreatmentDesc; + + /** + * 锌层(原料/产品通用) + */ + private String zincLayer; + + /** + * 物品名称(原料名称/产品名称) + */ + private String itemName; + + /** + * 物品编码(原料编码/产品编码) + */ + private String itemCode; + + private String actualWarehouseName; + + + } diff --git a/klp-wms/src/main/java/com/klp/service/impl/WmsMaterialCoilServiceImpl.java b/klp-wms/src/main/java/com/klp/service/impl/WmsMaterialCoilServiceImpl.java index a5376a71..1ee85295 100644 --- a/klp-wms/src/main/java/com/klp/service/impl/WmsMaterialCoilServiceImpl.java +++ b/klp-wms/src/main/java/com/klp/service/impl/WmsMaterialCoilServiceImpl.java @@ -919,7 +919,7 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService { baseMapper.update(null, updateWrapper); } // 如果实际库区id为-1或状态为1,则清空钢卷上的实际库区绑定 - if ((bo.getActualWarehouseId() != null && bo.getActualWarehouseId().equals(-1L)) + if ((bo.getActualWarehouseId() != null && bo.getActualWarehouseId().equals(-1L)) || (bo.getStatus() != null && bo.getStatus().equals(1))) { clearActualWarehouseBinding(oldCoil.getActualWarehouseId(), bo.getCoilId()); } @@ -1131,6 +1131,10 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService { throw new RuntimeException("原钢卷不存在"); } } + // oldCoil 如果是历史卷也就是date_type=0 的时候就不能分卷 + if (oldCoil != null && oldCoil.getDataType() == 0) { + throw new RuntimeException("原钢卷已分卷,不能再分卷"); + } // 判断是分卷还是合卷 boolean isSplit = false; @@ -1218,9 +1222,6 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService { if (newCoil.getWarehouseId() == null) { newCoil.setWarehouseId(oldCoil.getWarehouseId()); } - if (newCoil.getActualWarehouseId() == null){ - newCoil.setActualWarehouseId(oldCoil.getActualWarehouseId()); - } // 在子卷的 parent_coil_nos 字段中记录母卷号 newCoil.setParentCoilNos(oldCoil.getCurrentCoilNo()); @@ -1242,6 +1243,8 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService { } else if (isMerge) { // 合卷:将bo作为合卷后的新钢卷,newCoils中的对象作为参与合卷的原始钢卷 // 1. 将参与合卷的原始钢卷的二维码标记为失效,并将钢卷标记为历史数据 + //在合卷之前需要判断前端传来的bo.getNewCoils()中的所有原始钢卷的coilId是否已经是历史卷 + validateOriginalCoilsForMerge(bo.getNewCoils()); for (WmsMaterialCoilBo originalCoilBo : bo.getNewCoils()) { if (originalCoilBo.getCoilId() != null) { WmsMaterialCoil originalCoil = baseMapper.selectById(originalCoilBo.getCoilId()); @@ -1326,6 +1329,39 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService { return true; } + /** + * 验证参与合卷的原始钢卷是否都是当前数据(而非历史数据) + * @param originalCoils 参与合卷的原始钢卷列表 + */ + private void validateOriginalCoilsForMerge(List originalCoils) { + if (CollectionUtils.isEmpty(originalCoils)) { + return; + } + + // 收集所有需要验证的coilId + List coilIds = originalCoils.stream() + .map(WmsMaterialCoilBo::getCoilId) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + + if (CollectionUtils.isEmpty(coilIds)) { + return; + } + + // 批量查询钢卷数据,避免N+1查询问题 + List originalCoilsData = baseMapper.selectBatchIds(coilIds); + + // 检查是否有历史数据 + List historyCoils = originalCoilsData.stream() + .filter(coil -> coil.getDataType() != null && coil.getDataType() == 0) // dataType=0表示历史数据 + .map(coil -> ": " + coil.getCurrentCoilNo()) + .collect(Collectors.toList()); + + if (!historyCoils.isEmpty()) { + String errorDetails = String.join(", ", historyCoils); + throw new RuntimeException("合卷操作需要所有原始钢卷为当前数据,以下卷号已被合卷" + errorDetails); + } + } /** * 为分卷生成新二维码(每个子钢卷一个) diff --git a/klp-wms/src/main/resources/mapper/klp/WmsCoilPendingActionMapper.xml b/klp-wms/src/main/resources/mapper/klp/WmsCoilPendingActionMapper.xml index 13c72e82..4ba01082 100644 --- a/klp-wms/src/main/resources/mapper/klp/WmsCoilPendingActionMapper.xml +++ b/klp-wms/src/main/resources/mapper/klp/WmsCoilPendingActionMapper.xml @@ -50,9 +50,40 @@ wmc.enter_coil_no as enterCoilNo, wmc.supplier_coil_no as supplierCoilNo, wmc.item_id as itemId, - wmc.item_type as itemType + wmc.item_type as itemType, + w.warehouse_name AS warehouseName, + aw.actual_warehouse_name AS actualWarehouseName, + CASE WHEN wmc.item_type = 'raw_material' THEN rm.specification + WHEN wmc.item_type = 'product' THEN p.specification + ELSE NULL END AS specification, + CASE WHEN wmc.item_type = 'raw_material' THEN rm.material + WHEN wmc.item_type = 'product' THEN p.material + ELSE NULL END AS material, + CASE WHEN wmc.item_type = 'raw_material' THEN rm.manufacturer + WHEN wmc.item_type = 'product' THEN p.manufacturer + ELSE NULL END AS manufacturer, + CASE WHEN wmc.item_type = 'raw_material' THEN rm.surface_treatment_desc + WHEN wmc.item_type = 'product' THEN p.surface_treatment_desc + ELSE NULL END AS surfaceTreatmentDesc, + CASE WHEN wmc.item_type = 'raw_material' THEN rm.zinc_layer + WHEN wmc.item_type = 'product' THEN p.zinc_layer + ELSE NULL END AS zincLayer, + CASE + WHEN wmc.item_type = 'raw_material' THEN rm.raw_material_name + WHEN wmc.item_type = 'product' THEN p.product_name + ELSE NULL + END as itemName, + CASE + WHEN wmc.item_type = 'raw_material' THEN rm.raw_material_code + WHEN wmc.item_type = 'product' THEN p.product_code + ELSE NULL + END as itemCode from wms_coil_pending_action wcpa inner join wms_material_coil wmc ON wcpa.coil_id = wmc.coil_id AND wmc.del_flag = 0 + LEFT JOIN wms_warehouse w ON wmc.warehouse_id = w.warehouse_id + LEFT JOIN wms_actual_warehouse aw ON wmc.actual_warehouse_id = aw.actual_warehouse_id + LEFT JOIN wms_raw_material rm ON wmc.item_type = 'raw_material' AND wmc.item_id = rm.raw_material_id + LEFT JOIN wms_product p ON wmc.item_type = 'product' AND wmc.item_id = p.product_id ${ew.customSqlSegment}