diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/repository/persistence/ExecutionStockInOrderImpl.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/repository/persistence/ExecutionStockInOrderImpl.java index d12764de6..c92312bea 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/repository/persistence/ExecutionStockInOrderImpl.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/repository/persistence/ExecutionStockInOrderImpl.java @@ -259,26 +259,6 @@ public class ExecutionStockInOrderImpl extends ServiceImpl 0) { - String warehouseName = reservationStockInOrderMapper.getWarehouseName(warehouseId); - List wrongWarehouseMaterials = new ArrayList<>(); - for (ProductDetail productDetail : productDetailList) { - MaterialBaseInfoPO materialBaseInfoPO = stockInOrderMapper.getByCode(productDetail.getProductCode()); - if (materialBaseInfoPO == null) { - continue; - } - int count = reservationStockInOrderMapper.countInventoryByWarehouse(materialBaseInfoPO.getMaterialBaseInfoId(), warehouseId); - if (count <= 0) { - wrongWarehouseMaterials.add(productDetail.getProductCode()); - } - } - if (!wrongWarehouseMaterials.isEmpty()) { - throw new Exception("物料[" + String.join("、", wrongWarehouseMaterials) + "]在当前仓库[" - + (warehouseName == null ? warehouseId : warehouseName) + "]没有库存记录,无法从该仓库出库,请确认导入仓库是否正确"); - } - } - ExecutionStockOutOrderDO reservationStockOutOrderDO = new ExecutionStockOutOrderDO(); reservationStockOutOrderDO.setOutOrderNumber(OrderSequence.getOrderCode("CK")); reservationStockOutOrderDO.setShipperId((Long) shipperIds.get(0).get("shipperId")); diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/mapper/ReservationStockInOrderMapper.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/mapper/ReservationStockInOrderMapper.java index 95c8d9bc2..6749cbfc2 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/mapper/ReservationStockInOrderMapper.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/mapper/ReservationStockInOrderMapper.java @@ -37,12 +37,6 @@ public interface ReservationStockInOrderMapper extends BaseMapper getkcId(@Param("id") Long id,@Param("q") BigDecimal q, @Param("warehouseId") Long warehouseId); - /** - * 出库导入校验:物料在指定仓库是否存在库存记录(存在即视为归属该仓库,不限数量) - * @return 库存记录数 - */ - public int countInventoryByWarehouse(@Param("id") Long id, @Param("warehouseId") Long warehouseId); - public MaterialWarehouseControlPO getInfoByMaterialBaseInfoIds(@Param("id") Long id); public MaterialGoodsRulePO getGoodsInfoByMaterialBaseInfoIds(@Param("id") Long id); diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/persistence/ReservationStockInOrderImpl.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/persistence/ReservationStockInOrderImpl.java index 44e1cf151..9d7774ba5 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/persistence/ReservationStockInOrderImpl.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/persistence/ReservationStockInOrderImpl.java @@ -309,24 +309,9 @@ public class ReservationStockInOrderImpl extends ServiceImpl 0) { - String warehouseName = stockInOrderMapper.getWarehouseName(warehouseId); - List wrongWarehouseMaterials = new ArrayList<>(); - for (MaterialBaseInfoPO materialBaseInfoPO : materialCache.values()) { - int count = stockInOrderMapper.countInventoryByWarehouse(materialBaseInfoPO.getMaterialBaseInfoId(), warehouseId); - if (count <= 0) { - wrongWarehouseMaterials.add(materialBaseInfoPO.getMaterialCode()); - } - } - if (!wrongWarehouseMaterials.isEmpty()) { - throw new Exception("物料[" + String.join("、", wrongWarehouseMaterials) + "]在当前仓库[" - + (warehouseName == null ? warehouseId : warehouseName) + "]没有库存记录,无法从该仓库出库,请确认导入仓库是否正确"); - } - } - // ====== 后续处理(编号均已存在):货主归属校验、建单落库 ====== + // 物料档案全仓共享、不属于任何仓库;仓库约束在下方"分配批次"环节生效: + // getkcId 按 warehouseId 过滤,分不到当前仓库的批次即报"批次库存数量少于出库数量",不会取到其他仓库的库存 for (MaterialBaseInfoPO materialBaseInfoPO : materialCache.values()) { if (materialBaseInfoPO.getShipperId() != null && processedShipperIds.add(materialBaseInfoPO.getShipperId())) { Map shipper = new HashMap<>(); @@ -347,6 +332,28 @@ public class ReservationStockInOrderImpl extends ServiceImpl insufficientMaterials = new HashSet<>(); + for (ProductDetail productDetail : productDetailList) { + MaterialBaseInfoPO materialBaseInfoPO = materialCache.get(productDetail.getProductCode()); + if (materialBaseInfoPO == null) { + continue; // 存在性已在前面统一校验 + } + BigDecimal requireQty = new BigDecimal(productDetail.getPieceCount()).setScale(2, BigDecimal.ROUND_HALF_UP); + List inventoryList = stockInOrderMapper.getkcId( + materialBaseInfoPO.getMaterialBaseInfoId(), requireQty, warehouseId); + if (inventoryList == null || inventoryList.isEmpty()) { + insufficientMaterials.add(productDetail.getProductCode()); + } + } + if (!insufficientMaterials.isEmpty()) { + throw new Exception("物料[" + String.join("、", insufficientMaterials) + "]" + + (warehouseId != null && warehouseId > 0 ? "在当前仓库" : "") + "批次库存数量少于出库数量!"); + } + } + ReservationStockOutOrderDO reservationStockOutOrderDO = new ReservationStockOutOrderDO(); // 生成出库业务单号 String orderNumber = reservationStockOutOrderApplicationService.generateReserveOrderNumber(); @@ -415,6 +422,15 @@ public class ReservationStockInOrderImpl extends ServiceImpl 0) { + if (warehouseCode == null || warehouseCode.trim().isEmpty()) { + warehouseCode = stockInOrderMapper.getWarehouseCode(invWarehouseId); + } + if (warehouseName == null || warehouseName.trim().isEmpty()) { + warehouseName = stockInOrderMapper.getWarehouseName(invWarehouseId); + } + } String inOrderNumber = reservationMaterialInventoryPO.getInOrderNumber(); BigDecimal inventoryQuantity = reservationMaterialInventoryPO.getInventoryQuantity(); String unit = reservationMaterialInventoryPO.getUnit(); diff --git a/mhd_oms/src/main/resources/mapper/reservationStockInOrder/ReservationStockInOrderMapper.xml b/mhd_oms/src/main/resources/mapper/reservationStockInOrder/ReservationStockInOrderMapper.xml index f2d601503..bc72a3926 100644 --- a/mhd_oms/src/main/resources/mapper/reservationStockInOrder/ReservationStockInOrderMapper.xml +++ b/mhd_oms/src/main/resources/mapper/reservationStockInOrder/ReservationStockInOrderMapper.xml @@ -559,11 +559,8 @@ and WAREHOUSE_ID = #{warehouseId} - - -