From fa5f8d68cc248bb93a149516999850c618090d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Thu, 9 Jul 2026 16:00:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E5=AE=A2=E6=88=B7=E9=A2=84=E7=BA=A6?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E5=88=86=E9=85=8D=E5=BA=93=E5=AD=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/factory/RemoteWmsFallbackFactory.java | 2 +- ...vationStockOutOrderApplicationService.java | 12 +++-- .../StockOutOrderApplicationService.java | 50 +++++++++---------- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteWmsFallbackFactory.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteWmsFallbackFactory.java index 19b01814a..e187b6c4a 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteWmsFallbackFactory.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteWmsFallbackFactory.java @@ -85,7 +85,7 @@ public class RemoteWmsFallbackFactory implements FallbackFactory 库存,扣全部库存 - detail.setMaterialInventoryId(materialInventory.getMaterialInventoryId()); - detail.setStorageLocationId(materialInventory.getStorageLocationId()); - detail.setStorageLocationName(materialInventory.getStorageLocationName()); - detail.setStorageLocationCode(materialInventory.getStorageLocationCode()); - detail.setStorageSectionId(materialInventory.getStorageSectionId()); - detail.setStorageName(materialInventory.getStorageName()); - detail.setStorageCode(materialInventory.getStorageCode()); - detail.setInventoryQuantity(materialInventory.getInventoryQuantity()); - detail.setAllocationQuantity(deductQuantity); - materialDetailList2.add(detail); - // 更新剩余计划数量 - remainingQuantity = remainingQuantity.subtract(deductQuantity); + // 当前物料的可用库存 + BigDecimal availableStock = materialInventory.getAllocationQuantity(); + // 如果当前物料没有库存,跳过 + if (availableStock == null || availableStock.compareTo(BigDecimal.ZERO) <= 0) { + continue; } + if (availableStock.compareTo(remainingQuantity) < 0) { + throw new RuntimeException( + String.format("可用库存不足,计划数量:%s,当前可用库存:%s", + remainingQuantity, availableStock) + ); + } +// detail.setMaterialInventoryId(materialInventory.getMaterialInventoryId()); + detail.setStorageLocationId(materialInventory.getStorageLocationId()); + detail.setStorageLocationName(materialInventory.getStorageLocationName()); + detail.setStorageLocationCode(materialInventory.getStorageLocationCode()); + detail.setStorageSectionId(materialInventory.getStorageSectionId()); + detail.setStorageName(materialInventory.getStorageName()); + detail.setStorageCode(materialInventory.getStorageCode()); + detail.setInventoryQuantity(materialInventory.getInventoryQuantity()); + detail.setAllocationQuantity(remainingQuantity); + materialDetailList2.add(detail); } stockOutOrderD.setMaterialDetailList(materialDetailList2); StockOutOrderDO assembleStockOutOrderDO = assembleParamByOutOrder(stockOutOrderD);