From b8f9156200ae3d4517df5a94aa715e8c17db8422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Sat, 28 Feb 2026 15:06:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=85=8D=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E6=94=B9;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../persistence/OutMaterialDetailImpl.java | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/outMaterialDetail/repository/persistence/OutMaterialDetailImpl.java b/mhd_wms/src/main/java/com/mhd/wms/domain/outMaterialDetail/repository/persistence/OutMaterialDetailImpl.java index 0a15078d0..1ac6cec61 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/outMaterialDetail/repository/persistence/OutMaterialDetailImpl.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/outMaterialDetail/repository/persistence/OutMaterialDetailImpl.java @@ -490,6 +490,93 @@ public class OutMaterialDetailImpl extends ServiceImpl outMaterialDetails = outMaterialDetailMapper.selectList(new QueryWrapper().lambda().eq(OutMaterialDetail::getParentUniqueId, uniqueId).eq(OutMaterialDetail::getOutOrderNumber, outOrderNumber1)); + if (!CollectionUtils.isEmpty(outMaterialDetails)) { + childrenxgkc(outMaterialDetails,outOrderNumber,loginUser); + } + } + } + + public synchronized void childrenxgkc(List outMaterialDetailList,String outOrderNumber,LoginUser loginUser) { + StockOutOrder stockOutOrder = stockOutOrderMapper.selectOne(new QueryWrapper().lambda().eq(StockOutOrder::getOutOrderNumber, outOrderNumber)); + for (OutMaterialDetail outMaterialDetail : outMaterialDetailList) { + BigDecimal nowAllocationQuantity = outMaterialDetail.getNowAllocationQuantity(); + if (nowAllocationQuantity == null && nowAllocationQuantity.compareTo(BigDecimal.ZERO) <= 0) { + continue; + } + Long materialInventoryId = outMaterialDetail.getMaterialInventoryId(); + + //分配数量为本次分配数量 + BigDecimal allocationQuantity = outMaterialDetail.getNowAllocationQuantity(); + if (ObjectUtils.isEmpty(allocationQuantity)) { + allocationQuantity = BigDecimal.ZERO; + } + MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId); + if (materialInventoryPO != null) { + //更新库存数量 + //可用数量 + BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity(); + //冻结数量 + BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity(); + //分配后可用数量 + BigDecimal newAllocationQuantity = oldAllocationQuantity.subtract(allocationQuantity); + //分配后冻结数量 + BigDecimal newFreezeQuantity = oldFreezeQuantity.add(allocationQuantity); + materialInventoryPO.setAllocationQuantity(newAllocationQuantity); + materialInventoryPO.setFreezeQuantity(newFreezeQuantity); + MaterialInventory materialInventory = new MaterialInventory(); + BeanUtils.copyProperties(materialInventoryPO, materialInventory); + materialInventoryMapper.updateById(materialInventory); + + //库存调整记录 + InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord(); + inventoryAdjustmentRecord.setAdjustAfterStatusCode("he_ge"); + inventoryAdjustmentRecord.setAdjustBeforeStatusCode("he_ge"); + inventoryAdjustmentRecord.setAdjustAfterStatusName("合格"); + inventoryAdjustmentRecord.setAdjustBeforeStatusName("合格"); + inventoryAdjustmentRecord.setAdjustType(1L); + inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId()); + inventoryAdjustmentRecord.setMaterialCode(outMaterialDetail.getMaterialNo()); + inventoryAdjustmentRecord.setMaterialName(outMaterialDetail.getCommodityName()); + inventoryAdjustmentRecord.setBarCode(outMaterialDetail.getBarCode()); + inventoryAdjustmentRecord.setMaterialBaseInfoId(outMaterialDetail.getMaterialBaseInfoId()); + inventoryAdjustmentRecord.setOrganizationId(stockOutOrder.getOrganizationId()); + inventoryAdjustmentRecord.setOrganizationName(stockOutOrder.getOrganizationName()); + inventoryAdjustmentRecord.setTopOrganizationId(stockOutOrder.getTopOrganizationId()); + inventoryAdjustmentRecord.setWarehouseCode(stockOutOrder.getWarehouseCode()); + inventoryAdjustmentRecord.setWarehouseName(stockOutOrder.getWarehouseName()); + inventoryAdjustmentRecord.setWarehouseId(stockOutOrder.getWarehouseId()); + inventoryAdjustmentRecord.setStorageCode(materialInventoryPO.getStorageCode()); + inventoryAdjustmentRecord.setStorageName(materialInventoryPO.getStorageName()); + inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId()); + inventoryAdjustmentRecord.setStorageLocationCode(materialInventoryPO.getStorageLocationCode()); + inventoryAdjustmentRecord.setStorageLocationName(materialInventoryPO.getStorageLocationName()); + inventoryAdjustmentRecord.setMaterialInventoryId(materialInventoryPO.getMaterialInventoryId()); + inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId()); + inventoryAdjustmentRecord.setShipperId(stockOutOrder.getShipperId()); + inventoryAdjustmentRecord.setShipperName(stockOutOrder.getShipperName()); + inventoryAdjustmentRecord.setStorageSectionId(materialInventoryPO.getStorageSectionId()); + inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId()); + inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid()); + inventoryAdjustmentRecord.setCreateByName(loginUser.getUsername()); + inventoryAdjustmentRecord.setCreateTime(new Date()); + inventoryAdjustmentRecord.setAllocationAfterQuantity(newAllocationQuantity); + inventoryAdjustmentRecord.setAllocationBeforeQuantity(oldAllocationQuantity); + inventoryAdjustmentRecord.setFreezeBeforeQuantity(oldFreezeQuantity); + inventoryAdjustmentRecord.setFreezeAfterQuantity(newFreezeQuantity); + inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventoryPO.getInventoryQuantity()); + inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventoryPO.getInventoryQuantity()); + inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid()); + inventoryAdjustmentRecord.setCreateByName(loginUser.getUsername()); + inventoryAdjustmentRecord.setCreateTime(new Date()); + inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord); + } + Long uniqueId = outMaterialDetail.getUniqueId(); + String outOrderNumber1 = outMaterialDetail.getOutOrderNumber(); + List outMaterialDetails = outMaterialDetailMapper.selectList(new QueryWrapper().lambda().eq(OutMaterialDetail::getParentUniqueId, uniqueId).eq(OutMaterialDetail::getOutOrderNumber, outOrderNumber1)); + } }