From 7f32271adc60586550041734d9def74f86d8b05a 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, 2 Apr 2026 13:59:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=BA=93=E5=AD=98=E5=92=8C?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=96=B9=E6=B3=95=E9=9B=86=E5=90=88;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HandoverTaskOrderDomainService.java | 218 +++++----- ...nventoryAdjustmentRecordDomainService.java | 94 +++-- .../facade/IMaterialInventoryService.java | 4 +- .../persistence/MaterialInventoryImpl.java | 120 ++++-- .../todo/MaterialInventoryParamDO.java | 4 + .../persistence/OutMaterialDetailImpl.java | 386 ++++++++++-------- .../service/StockShelfOrderDomainService.java | 349 ++++++---------- 7 files changed, 610 insertions(+), 565 deletions(-) diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/handoverTaskOrder/service/HandoverTaskOrderDomainService.java b/mhd_wms/src/main/java/com/mhd/wms/domain/handoverTaskOrder/service/HandoverTaskOrderDomainService.java index 01024d5ed..c44055b89 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/handoverTaskOrder/service/HandoverTaskOrderDomainService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/handoverTaskOrder/service/HandoverTaskOrderDomainService.java @@ -20,7 +20,9 @@ import com.mhd.wms.domain.inventoryAdjustmentRecord.repository.mapper.InventoryA import com.mhd.wms.domain.materialBarCode.repository.facade.IMaterialBarCodeService; import com.mhd.wms.domain.materialBarCode.repository.po.MaterialBarCodePO; import com.mhd.wms.domain.materialInventory.entity.MaterialInventory; +import com.mhd.wms.domain.materialInventory.repository.facade.IMaterialInventoryService; import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper; +import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryParamDO; import com.mhd.wms.domain.outMaterialDetail.entity.OutMaterialDetail; import com.mhd.wms.domain.outMaterialDetail.repository.mapper.OutMaterialDetailMapper; import com.mhd.wms.domain.pickingMaterialDetail.repository.mapper.PickingMaterialDetailMapper; @@ -70,6 +72,8 @@ public class HandoverTaskOrderDomainService { private PickingMaterialDetailMapper pickingMaterialDetailMapper; @Autowired private IMaterialBarCodeService materialBarCodeService; + @Autowired + private IMaterialInventoryService materialInventoryService; /** @@ -330,110 +334,120 @@ public class HandoverTaskOrderDomainService { MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId); if (materialInventoryPO != null) { + MaterialInventoryParamDO materialInventoryParamDO = new MaterialInventoryParamDO(); //更新库存数量 - //库存数量 - BigDecimal oldInventoryQuantity = materialInventoryPO.getInventoryQuantity(); - oldInventoryQuantity = oldInventoryQuantity != null ? oldInventoryQuantity : BigDecimal.ZERO; - //可用数量 - BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity(); - oldAllocationQuantity = oldAllocationQuantity != null ? oldAllocationQuantity : BigDecimal.ZERO; - //冻结数量(出库交接不变动冻结数量) - BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity(); - oldFreezeQuantity = oldFreezeQuantity != null ? oldFreezeQuantity : BigDecimal.ZERO; - //扣减后库存数量 - BigDecimal newInventoryQuantity = oldInventoryQuantity.subtract(checkQuantity); - //扣减后可用数量 - BigDecimal newAllocationQuantity = oldAllocationQuantity.subtract(checkQuantity); - BigDecimal newFreezeQuantity = oldFreezeQuantity; - - - - BigDecimal oldArea = materialInventoryPO.getArea(); - BigDecimal oldVolume = materialInventoryPO.getVolume(); - BigDecimal oldGrossWeight = materialInventoryPO.getGrossWeight(); - BigDecimal oldNetWeight = materialInventoryPO.getNetWeight(); - - // 初始化旧数据,避免空指针 - oldArea = oldArea != null ? oldArea : BigDecimal.ZERO; - oldVolume = oldVolume != null ? oldVolume : BigDecimal.ZERO; - oldGrossWeight = oldGrossWeight != null ? oldGrossWeight : BigDecimal.ZERO; - oldNetWeight = oldNetWeight != null ? oldNetWeight : BigDecimal.ZERO; - - BigDecimal newArea = oldArea.subtract(checkArea); - BigDecimal newVolume = oldVolume.subtract(checkVolume); - BigDecimal newGrossWeight = oldGrossWeight.subtract(checkGrossWeight); - BigDecimal newNetWeight = oldNetWeight.subtract(checkNetWeight); - - materialInventoryPO.setInventoryQuantity(newInventoryQuantity); - materialInventoryPO.setAllocationQuantity(materialInventoryPO.getAllocationQuantity()); - materialInventoryPO.setFreezeQuantity(materialInventoryPO.getFreezeQuantity().subtract(outMaterialDetail.getCheckQuantity()) ); - materialInventoryPO.setArea(newArea); - materialInventoryPO.setVolume(newVolume); - materialInventoryPO.setGrossWeight(newGrossWeight); - materialInventoryPO.setNetWeight(newNetWeight); - MaterialInventory materialInventory = new MaterialInventory(); - BeanUtils.copyProperties(materialInventoryPO, materialInventory); - materialInventoryMapper.updateById(materialInventory); - +// //库存数量 +// BigDecimal oldInventoryQuantity = materialInventoryPO.getInventoryQuantity(); +// oldInventoryQuantity = oldInventoryQuantity != null ? oldInventoryQuantity : BigDecimal.ZERO; +// //可用数量 +// BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity(); +// oldAllocationQuantity = oldAllocationQuantity != null ? oldAllocationQuantity : BigDecimal.ZERO; +// //冻结数量(出库交接不变动冻结数量) +// BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity(); +// oldFreezeQuantity = oldFreezeQuantity != null ? oldFreezeQuantity : BigDecimal.ZERO; +// //扣减后库存数量 +// BigDecimal newInventoryQuantity = oldInventoryQuantity.subtract(checkQuantity); +// //扣减后可用数量 +// BigDecimal newAllocationQuantity = oldAllocationQuantity.subtract(checkQuantity); +// BigDecimal newFreezeQuantity = oldFreezeQuantity; +// +// +// +// BigDecimal oldArea = materialInventoryPO.getArea(); +// BigDecimal oldVolume = materialInventoryPO.getVolume(); +// BigDecimal oldGrossWeight = materialInventoryPO.getGrossWeight(); +// BigDecimal oldNetWeight = materialInventoryPO.getNetWeight(); +// +// // 初始化旧数据,避免空指针 +// oldArea = oldArea != null ? oldArea : BigDecimal.ZERO; +// oldVolume = oldVolume != null ? oldVolume : BigDecimal.ZERO; +// oldGrossWeight = oldGrossWeight != null ? oldGrossWeight : BigDecimal.ZERO; +// oldNetWeight = oldNetWeight != null ? oldNetWeight : BigDecimal.ZERO; +// +// BigDecimal newArea = oldArea.subtract(checkArea); +// BigDecimal newVolume = oldVolume.subtract(checkVolume); +// BigDecimal newGrossWeight = oldGrossWeight.subtract(checkGrossWeight); +// BigDecimal newNetWeight = oldNetWeight.subtract(checkNetWeight); +// +// materialInventoryPO.setInventoryQuantity(newInventoryQuantity); +// materialInventoryPO.setAllocationQuantity(materialInventoryPO.getAllocationQuantity()); +// materialInventoryPO.setFreezeQuantity(materialInventoryPO.getFreezeQuantity().subtract(outMaterialDetail.getCheckQuantity()) ); +// materialInventoryPO.setArea(newArea); +// materialInventoryPO.setVolume(newVolume); +// materialInventoryPO.setGrossWeight(newGrossWeight); +// materialInventoryPO.setNetWeight(newNetWeight); +// MaterialInventory materialInventory = new MaterialInventory(); +// BeanUtils.copyProperties(materialInventoryPO, materialInventory); + //materialInventoryMapper.updateById(materialInventory); + materialInventoryParamDO.setArea(checkArea); + materialInventoryParamDO.setVolume(checkVolume); + materialInventoryParamDO.setGrossWeight(checkGrossWeight); + materialInventoryParamDO.setNetWeight(checkNetWeight); + materialInventoryParamDO.setQuantity(checkQuantity); + materialInventoryParamDO.setMaterialInventoryId(materialInventoryPO.getMaterialInventoryId()); + materialInventoryParamDO.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId()); + materialInventoryParamDO.setType("4"); + materialInventoryService.kctzjl(materialInventoryParamDO,"出库",loginUser); + materialInventoryService.xgkc(materialInventoryParamDO); //库存调整记录 - InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord(); - inventoryAdjustmentRecord.setAdjustAction("出库"); - inventoryAdjustmentRecord.setRelateNo(orderNumber); - inventoryAdjustmentRecord.setAdjustAfterStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode()); - inventoryAdjustmentRecord.setAdjustBeforeStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode()); - inventoryAdjustmentRecord.setAdjustAfterStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName()); - inventoryAdjustmentRecord.setAdjustBeforeStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName()); -// inventoryAdjustmentRecord.setAdjustBeforeStatusCode("he_ge"); -// inventoryAdjustmentRecord.setAdjustBeforeStatusName("合格"); - inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId()); - inventoryAdjustmentRecord.setMaterialCode(outMaterialDetail.getMaterialNo()); - inventoryAdjustmentRecord.setMaterialName(outMaterialDetail.getCommodityName()); - inventoryAdjustmentRecord.setBarCode(outMaterialDetail.getBarCode()); - if (inventoryAdjustmentRecord.getBarCode() == null || inventoryAdjustmentRecord.getBarCode().isEmpty()){ - getBarCode(materialInventoryPO, inventoryAdjustmentRecord); - } - inventoryAdjustmentRecord.setMaterialBaseInfoId(outMaterialDetail.getMaterialBaseInfoId()); - inventoryAdjustmentRecord.setAdjustType(1L); - 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()); - UserPo userPo = loginUser.getUserPo(); - if (userPo != null) inventoryAdjustmentRecord.setCreateByName(userPo.getUserName()); - inventoryAdjustmentRecord.setCreateTime(new Date()); - inventoryAdjustmentRecord.setAllocationBeforeQuantity(oldAllocationQuantity); - inventoryAdjustmentRecord.setAllocationAfterQuantity(oldAllocationQuantity); - inventoryAdjustmentRecord.setFreezeBeforeQuantity(oldFreezeQuantity); - inventoryAdjustmentRecord.setFreezeAfterQuantity(newFreezeQuantity.subtract(outMaterialDetail.getCheckQuantity()));//调整后 冻结-出库 - inventoryAdjustmentRecord.setInventoryBeforeQuantity(oldInventoryQuantity); - inventoryAdjustmentRecord.setInventoryAfterQuantity(newInventoryQuantity); - // 调整前:库存数量(净重、毛重、体积、面积) - inventoryAdjustmentRecord.setNetWeight(oldNetWeight); - inventoryAdjustmentRecord.setGrossWeight(oldGrossWeight); - inventoryAdjustmentRecord.setVolume(oldVolume); - inventoryAdjustmentRecord.setArea(oldArea); - // 调整后:库存数量 - 复核时填写的数量 - inventoryAdjustmentRecord.setAdjustedNetWeight(newNetWeight); - inventoryAdjustmentRecord.setAdjustedGrossWeight(newGrossWeight); - inventoryAdjustmentRecord.setAdjustedVolume(newVolume); - inventoryAdjustmentRecord.setAdjustedArea(newArea); - - inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord); +// InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord(); +// inventoryAdjustmentRecord.setAdjustAction("出库"); +// inventoryAdjustmentRecord.setRelateNo(orderNumber); +// inventoryAdjustmentRecord.setAdjustAfterStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode()); +// inventoryAdjustmentRecord.setAdjustBeforeStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode()); +// inventoryAdjustmentRecord.setAdjustAfterStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName()); +// inventoryAdjustmentRecord.setAdjustBeforeStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName()); +//// inventoryAdjustmentRecord.setAdjustBeforeStatusCode("he_ge"); +//// inventoryAdjustmentRecord.setAdjustBeforeStatusName("合格"); +// inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId()); +// inventoryAdjustmentRecord.setMaterialCode(outMaterialDetail.getMaterialNo()); +// inventoryAdjustmentRecord.setMaterialName(outMaterialDetail.getCommodityName()); +// inventoryAdjustmentRecord.setBarCode(outMaterialDetail.getBarCode()); +// if (inventoryAdjustmentRecord.getBarCode() == null || inventoryAdjustmentRecord.getBarCode().isEmpty()){ +// getBarCode(materialInventoryPO, inventoryAdjustmentRecord); +// } +// inventoryAdjustmentRecord.setMaterialBaseInfoId(outMaterialDetail.getMaterialBaseInfoId()); +// inventoryAdjustmentRecord.setAdjustType(1L); +// 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()); +// UserPo userPo = loginUser.getUserPo(); +// if (userPo != null) inventoryAdjustmentRecord.setCreateByName(userPo.getUserName()); +// inventoryAdjustmentRecord.setCreateTime(new Date()); +// inventoryAdjustmentRecord.setAllocationBeforeQuantity(oldAllocationQuantity); +// inventoryAdjustmentRecord.setAllocationAfterQuantity(oldAllocationQuantity); +// inventoryAdjustmentRecord.setFreezeBeforeQuantity(oldFreezeQuantity); +// inventoryAdjustmentRecord.setFreezeAfterQuantity(newFreezeQuantity.subtract(outMaterialDetail.getCheckQuantity()));//调整后 冻结-出库 +// inventoryAdjustmentRecord.setInventoryBeforeQuantity(oldInventoryQuantity); +// inventoryAdjustmentRecord.setInventoryAfterQuantity(newInventoryQuantity); +// // 调整前:库存数量(净重、毛重、体积、面积) +// inventoryAdjustmentRecord.setNetWeight(oldNetWeight); +// inventoryAdjustmentRecord.setGrossWeight(oldGrossWeight); +// inventoryAdjustmentRecord.setVolume(oldVolume); +// inventoryAdjustmentRecord.setArea(oldArea); +// // 调整后:库存数量 - 复核时填写的数量 +// inventoryAdjustmentRecord.setAdjustedNetWeight(newNetWeight); +// inventoryAdjustmentRecord.setAdjustedGrossWeight(newGrossWeight); +// inventoryAdjustmentRecord.setAdjustedVolume(newVolume); +// inventoryAdjustmentRecord.setAdjustedArea(newArea); +// +// inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord); } } } @@ -524,4 +538,4 @@ public class HandoverTaskOrderDomainService { -} +} \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/inventoryAdjustmentRecord/service/InventoryAdjustmentRecordDomainService.java b/mhd_wms/src/main/java/com/mhd/wms/domain/inventoryAdjustmentRecord/service/InventoryAdjustmentRecordDomainService.java index 2c4020e41..016834474 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/inventoryAdjustmentRecord/service/InventoryAdjustmentRecordDomainService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/inventoryAdjustmentRecord/service/InventoryAdjustmentRecordDomainService.java @@ -15,6 +15,7 @@ import com.mhd.wms.domain.materialBaseInfo.entity.MaterialBaseInfo; import com.mhd.wms.domain.materialBaseInfo.repository.facade.IMaterialBaseInfoService; import com.mhd.wms.domain.materialInventory.entity.MaterialInventory; import com.mhd.wms.domain.materialInventory.repository.facade.IMaterialInventoryService; +import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryParamDO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -276,45 +277,62 @@ public class InventoryAdjustmentRecordDomainService { */ @Transactional public Boolean inventoryFrozenForAll(InventoryAdjustmentRecordDO inventoryAdjustmentRecordDO) { - InventoryAdjustmentRecordDO inventoryAdjustmentRecord = new InventoryAdjustmentRecordDO(); - LoginUser loginUser = SecurityUtils.getLoginUser(); - inventoryAdjustmentRecord.setAdjustAction("库存冻结"); - inventoryAdjustmentRecord.setOrganizationId(loginUser.getUserPo().getOrganizationId()); - inventoryAdjustmentRecord.setOrganizationName(loginUser.getUserPo().getOrganizationName()); - inventoryAdjustmentRecord.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId()); - inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid()); - inventoryAdjustmentRecord.setCreateByName(loginUser.getUsername()); - inventoryAdjustmentRecord.setCreateTime(new Date()); - MaterialInventory materialInventory = materialInventoryService.getById(inventoryAdjustmentRecordDO.getMaterialInventoryId()); - inventoryAdjustmentRecord.setAdjustType(3L); - if (ObjectUtil.isNotNull(materialInventory)) { - BeanUtils.copyProperties(materialInventory, inventoryAdjustmentRecord); - inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventory.getInventoryQuantity()); - inventoryAdjustmentRecord.setAllocationBeforeQuantity(materialInventory.getAllocationQuantity()); - inventoryAdjustmentRecord.setFreezeBeforeQuantity(materialInventory.getFreezeQuantity()); - MaterialBaseInfo materialBaseInfo = materialBaseInfoService.getOne(new QueryWrapper().lambda() - .eq(MaterialBaseInfo::getMaterialBaseInfoId,materialInventory.getMaterialBaseInfoId()).eq(BaseVOEntity::getDelFlag,1)); - if (ObjectUtil.isNotNull(materialBaseInfo)) { - inventoryAdjustmentRecord.setMaterialCode(materialBaseInfo.getMaterialCode()); - inventoryAdjustmentRecord.setMaterialName(materialBaseInfo.getMaterialName()); - inventoryAdjustmentRecord.setBarCode(materialBaseInfo.getBarCode()); - inventoryAdjustmentRecord.setShipperId(materialBaseInfo.getShipperId()); - inventoryAdjustmentRecord.setShipperName(materialBaseInfo.getShipperName()); - } - //可用数量减,冻结数量加 - materialInventory.setAllocationQuantity(materialInventory.getInventoryQuantity().subtract(inventoryAdjustmentRecordDO.getAdjustQuantity())); - materialInventory.setFreezeQuantity(inventoryAdjustmentRecordDO.getAdjustQuantity()); - if (materialInventory.getAllocationQuantity().compareTo(BigDecimal.ZERO) < 0) { - throw new ServiceException("冻结可用数量不能小于0"); - } - inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity()); - inventoryAdjustmentRecord.setAllocationAfterQuantity(materialInventory.getAllocationQuantity()); - inventoryAdjustmentRecord.setFreezeAfterQuantity(materialInventory.getFreezeQuantity()); - } else { - throw new ServiceException("根据物料库存id查询不到物料库存信息!"); + //InventoryAdjustmentRecordDO inventoryAdjustmentRecord = new InventoryAdjustmentRecordDO(); + try { + LoginUser loginUser = SecurityUtils.getLoginUser(); + BigDecimal adjustQuantity = inventoryAdjustmentRecordDO.getAdjustQuantity(); + MaterialInventoryParamDO materialInventoryParamDO = new MaterialInventoryParamDO(); + materialInventoryParamDO.setMaterialInventoryId(inventoryAdjustmentRecordDO.getMaterialInventoryId()); + materialInventoryParamDO.setQuantity(adjustQuantity); + materialInventoryParamDO.setType("7"); + materialInventoryService.kctzjl(materialInventoryParamDO,"库存冻结",loginUser); + materialInventoryService.xgkc(materialInventoryParamDO); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; } - materialInventoryService.updateById(materialInventory); - return inventoryAdjustmentRecordService.insert(inventoryAdjustmentRecord); + + + + +// inventoryAdjustmentRecord.setAdjustAction("库存冻结"); +// inventoryAdjustmentRecord.setOrganizationId(loginUser.getUserPo().getOrganizationId()); +// inventoryAdjustmentRecord.setOrganizationName(loginUser.getUserPo().getOrganizationName()); +// inventoryAdjustmentRecord.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId()); +// inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid()); +// inventoryAdjustmentRecord.setCreateByName(loginUser.getUsername()); +// inventoryAdjustmentRecord.setCreateTime(new Date()); +// MaterialInventory materialInventory = materialInventoryService.getById(inventoryAdjustmentRecordDO.getMaterialInventoryId()); +// inventoryAdjustmentRecord.setAdjustType(3L); +// if (ObjectUtil.isNotNull(materialInventory)) { +// BeanUtils.copyProperties(materialInventory, inventoryAdjustmentRecord); +// inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventory.getInventoryQuantity()); +// inventoryAdjustmentRecord.setAllocationBeforeQuantity(materialInventory.getAllocationQuantity()); +// inventoryAdjustmentRecord.setFreezeBeforeQuantity(materialInventory.getFreezeQuantity()); +// MaterialBaseInfo materialBaseInfo = materialBaseInfoService.getOne(new QueryWrapper().lambda() +// .eq(MaterialBaseInfo::getMaterialBaseInfoId,materialInventory.getMaterialBaseInfoId()).eq(BaseVOEntity::getDelFlag,1)); +// if (ObjectUtil.isNotNull(materialBaseInfo)) { +// inventoryAdjustmentRecord.setMaterialCode(materialBaseInfo.getMaterialCode()); +// inventoryAdjustmentRecord.setMaterialName(materialBaseInfo.getMaterialName()); +// inventoryAdjustmentRecord.setBarCode(materialBaseInfo.getBarCode()); +// inventoryAdjustmentRecord.setShipperId(materialBaseInfo.getShipperId()); +// inventoryAdjustmentRecord.setShipperName(materialBaseInfo.getShipperName()); +// } +// //可用数量减,冻结数量加 +// materialInventory.setAllocationQuantity(materialInventory.getInventoryQuantity().subtract(inventoryAdjustmentRecordDO.getAdjustQuantity())); +// materialInventory.setFreezeQuantity(inventoryAdjustmentRecordDO.getAdjustQuantity()); +// if (materialInventory.getAllocationQuantity().compareTo(BigDecimal.ZERO) < 0) { +// throw new ServiceException("冻结可用数量不能小于0"); +// } +// inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity()); +// inventoryAdjustmentRecord.setAllocationAfterQuantity(materialInventory.getAllocationQuantity()); +// inventoryAdjustmentRecord.setFreezeAfterQuantity(materialInventory.getFreezeQuantity()); +// } else { +// throw new ServiceException("根据物料库存id查询不到物料库存信息!"); +// } +// materialInventoryService.updateById(materialInventory); +// return inventoryAdjustmentRecordService.insert(inventoryAdjustmentRecord); } /** diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/facade/IMaterialInventoryService.java b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/facade/IMaterialInventoryService.java index 01e0da2d7..a3000dca6 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/facade/IMaterialInventoryService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/facade/IMaterialInventoryService.java @@ -113,7 +113,5 @@ public interface IMaterialInventoryService extends IService * */ public void xgkc(MaterialInventoryParamDO materialInventoryParamDO); - public void kctzjl(MaterialInventory materialInventory, String orderNumber, LoginUser loginUser, - BigDecimal oldArea, BigDecimal oldGrossWeight, BigDecimal oldNetWeight, BigDecimal oldVolume - ,BigDecimal oldInventoryQuantity, BigDecimal oldAllocationQuantity, BigDecimal oldFreezeQuantity,String adjustAction); + public void kctzjl(MaterialInventoryParamDO materialInventoryParamDO,String adjustAction,LoginUser loginUser); } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/persistence/MaterialInventoryImpl.java b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/persistence/MaterialInventoryImpl.java index ddc7651b5..0fbf3d60b 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/persistence/MaterialInventoryImpl.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/persistence/MaterialInventoryImpl.java @@ -560,17 +560,18 @@ public class MaterialInventoryImpl extends ServiceImpl().lambda() + .eq(MaterialInventory::getMaterialInventoryId, materialInventoryId)); Long materialBaseInfoId = materialInventory.getMaterialBaseInfoId(); MaterialBaseInfo materialBaseInfo = materialBaseInfoService.getOne(new QueryWrapper().lambda() .eq(MaterialBaseInfo::getMaterialBaseInfoId, materialBaseInfoId).eq(BaseVOEntity::getDelFlag,1)); InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord(); inventoryAdjustmentRecord.setAdjustAction(adjustAction); - inventoryAdjustmentRecord.setRelateNo(orderNumber); + inventoryAdjustmentRecord.setRelateNo(materialInventoryParamDO.getInOrderNumber()); inventoryAdjustmentRecord.setAdjustAfterStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode()); inventoryAdjustmentRecord.setAdjustBeforeStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode()); inventoryAdjustmentRecord.setAdjustAfterStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName()); @@ -588,6 +589,9 @@ public class MaterialInventoryImpl extends ServiceImpl children = outMaterialDetail.getChildren(); @@ -887,66 +909,74 @@ public class OutMaterialDetailImpl extends ServiceImpl barCodeList = materialBarCodeService.getInfoByMaterialBaseInfoIds(shelfMaterialDetail.getMaterialBaseInfoId()); - if (barCodeList != null && !barCodeList.isEmpty()) { - // 优先选择单位代码为EA的条码,若不存在则取第一条 - MaterialBarCodePO eaBarCode = barCodeList.stream() - .filter(po -> "EA".equals(po.getUnitCode())) - .findFirst() - .orElse(barCodeList.get(0)); - if (eaBarCode != null && StringUtils.isNotBlank(eaBarCode.getBarCode())) { - shelfBarCode = eaBarCode.getBarCode(); - } - } - } catch (Exception e) { - log.warn("根据物料基础信息ID获取条码失败,materialBaseInfoId={},错误:{}", shelfMaterialDetail.getMaterialBaseInfoId(), e.getMessage()); - } - } - inventoryAdjustmentRecord.setBarCode(shelfBarCode); - inventoryAdjustmentRecord.setMaterialBaseInfoId(shelfMaterialDetail.getMaterialBaseInfoId()); - inventoryAdjustmentRecord.setOrganizationId(stockReceiptOrderDO.getOrganizationId()); - inventoryAdjustmentRecord.setOrganizationName(stockReceiptOrderDO.getOrganizationName()); - inventoryAdjustmentRecord.setTopOrganizationId(stockReceiptOrderDO.getTopOrganizationId()); - inventoryAdjustmentRecord.setWarehouseCode(stockReceiptOrderDO.getWarehouseCode()); - inventoryAdjustmentRecord.setWarehouseName(stockReceiptOrderDO.getWarehouseName()); - inventoryAdjustmentRecord.setWarehouseId(stockReceiptOrderDO.getWarehouseId()); - inventoryAdjustmentRecord.setStorageCode(materialInventory.getStorageCode()); - inventoryAdjustmentRecord.setStorageName(materialInventory.getStorageName()); - inventoryAdjustmentRecord.setStorageLocationId(materialInventory.getStorageLocationId()); - inventoryAdjustmentRecord.setStorageLocationCode(materialInventory.getStorageLocationCode()); - inventoryAdjustmentRecord.setStorageLocationName(materialInventory.getStorageLocationName()); - inventoryAdjustmentRecord.setMaterialInventoryId(materialInventory.getMaterialInventoryId()); - inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventory.getMaterialBaseInfoId()); - inventoryAdjustmentRecord.setShipperId(stockReceiptOrderDO.getShipperId()); - inventoryAdjustmentRecord.setShipperName(stockReceiptOrderDO.getShipperName()); - inventoryAdjustmentRecord.setStorageSectionId(materialInventory.getStorageSectionId()); - inventoryAdjustmentRecord.setStorageLocationId(materialInventory.getStorageLocationId()); - inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid()); - UserPo userPo = loginUser.getUserPo(); - if (userPo != null) inventoryAdjustmentRecord.setCreateByName(userPo.getUserName()); - inventoryAdjustmentRecord.setCreateTime(new Date()); - inventoryAdjustmentRecord.setAllocationAfterQuantity(materialInventory.getAllocationQuantity()); - inventoryAdjustmentRecord.setAllocationBeforeQuantity(BigDecimal.ZERO); - inventoryAdjustmentRecord.setFreezeBeforeQuantity(BigDecimal.ZERO); - inventoryAdjustmentRecord.setFreezeAfterQuantity(BigDecimal.ZERO); - inventoryAdjustmentRecord.setInventoryBeforeQuantity(BigDecimal.ZERO); - inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity()); - inventoryAdjustmentRecord.setNetWeight(BigDecimal.ZERO ); - inventoryAdjustmentRecord.setGrossWeight(BigDecimal.ZERO); - inventoryAdjustmentRecord.setVolume(BigDecimal.ZERO); - inventoryAdjustmentRecord.setArea(BigDecimal.ZERO); - inventoryAdjustmentRecord.setAdjustedNetWeight(materialInventory.getNetWeight() == null ? BigDecimal.ZERO : materialInventory.getNetWeight()); - inventoryAdjustmentRecord.setAdjustedGrossWeight(materialInventory.getGrossWeight() == null ? BigDecimal.ZERO : materialInventory.getGrossWeight()); - inventoryAdjustmentRecord.setAdjustedVolume(materialInventory.getVolume() == null ? BigDecimal.ZERO : materialInventory.getVolume()); - inventoryAdjustmentRecord.setAdjustedArea(materialInventory.getArea() == null ? BigDecimal.ZERO : materialInventory.getArea()); - inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord); + materialInventoryService.kctzjl(inventoryParamDO,"入库", loginUser); + materialInventoryService.xgkc(inventoryParamDO); } else if (materialInventoryPOS.size() == 1) { - MaterialInventory materialInventory = new MaterialInventory(); - materialInventory.setInOrderNumber(stockReceiptOrderDO.getInOrderNumber()); - materialInventory.setLotNumber(shelfMaterialDetail.getLotNumber()); + MaterialInventoryParamDO inventoryParamDO = new MaterialInventoryParamDO(); BigDecimal shelvesQuantity = shelfMaterialDetail.getShelvesQuantity(); shelvesQuantity = shelvesQuantity != null ? shelvesQuantity : BigDecimal.ZERO; MaterialInventoryPO materialInventoryPO = materialInventoryPOS.get(0); - + BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity(); BigDecimal oldInventoryQuantity = materialInventoryPO.getInventoryQuantity(); oldInventoryQuantity = oldInventoryQuantity != null ? oldInventoryQuantity : BigDecimal.ZERO; BigDecimal newInventoryQuantity = oldInventoryQuantity.add(shelvesQuantity); @@ -848,110 +828,41 @@ public class StockShelfOrderDomainService { BigDecimal oldArea = materialInventoryPO.getArea(); oldArea = oldArea != null ? oldArea : BigDecimal.ZERO; BigDecimal totalArea = shelfMaterialDetail.getTotalArea(); + totalArea = totalArea != null ? totalArea : BigDecimal.ZERO; BigDecimal newArea = oldArea.add(totalArea); BigDecimal oldVolume = materialInventoryPO.getVolume(); oldVolume = oldVolume != null ? oldVolume : BigDecimal.ZERO; BigDecimal totalVolume = shelfMaterialDetail.getTotalVolume(); + totalVolume = totalVolume != null ? totalVolume : BigDecimal.ZERO; BigDecimal newVolume = oldVolume.add(totalVolume); BigDecimal oldGrossWeight = materialInventoryPO.getGrossWeight(); oldGrossWeight = oldGrossWeight != null ? oldGrossWeight : BigDecimal.ZERO; BigDecimal totalGrossWeight = shelfMaterialDetail.getTotalGrossWeight(); + totalGrossWeight = totalGrossWeight != null ? totalGrossWeight : BigDecimal.ZERO; BigDecimal newGrossWeight = oldGrossWeight.add(totalGrossWeight); BigDecimal oldNetWeight = materialInventoryPO.getNetWeight(); oldNetWeight = oldNetWeight != null ? oldNetWeight : BigDecimal.ZERO; BigDecimal totalNetWeight = shelfMaterialDetail.getTotalNetWeight(); + totalNetWeight = totalNetWeight != null ? totalNetWeight : BigDecimal.ZERO; BigDecimal newNetWeight = oldNetWeight.add(totalNetWeight); - materialInventoryPO.setInventoryQuantity(newInventoryQuantity); - materialInventoryPO.setAllocationQuantity(newAllocationQuantity); - materialInventoryPO.setArea(newArea); - materialInventoryPO.setVolume(newVolume); - materialInventoryPO.setGrossWeight(newGrossWeight); - materialInventoryPO.setNetWeight(newNetWeight); - BeanUtils.copyProperties(materialInventoryPO, materialInventory); - materialInventory.setUpdateBy(loginUser.getUserid()); - materialInventory.setUpdateByName(loginUser.getUsername()); - materialInventory.setUpdateTime(new Date()); - // 如果库存记录没有 barCode,则补充写入 - if (StringUtils.isBlank(materialInventoryPO.getBarCode())) { - String updateBarCode = shelfMaterialDetail.getBarCode(); - if (StringUtils.isBlank(updateBarCode) && shelfMaterialDetail.getMaterialBaseInfoId() != null) { - try { - List barCodeList = materialBarCodeService.getInfoByMaterialBaseInfoIds(shelfMaterialDetail.getMaterialBaseInfoId()); - if (barCodeList != null && !barCodeList.isEmpty()) { - MaterialBarCodePO eaBarCode = barCodeList.stream() - .filter(po -> "EA".equals(po.getUnitCode())) - .findFirst().orElse(barCodeList.get(0)); - if (eaBarCode != null && StringUtils.isNotBlank(eaBarCode.getBarCode())) { - updateBarCode = eaBarCode.getBarCode(); - } - } - } catch (Exception e) { - log.warn("获取条码失败,materialBaseInfoId={},错误:{}", shelfMaterialDetail.getMaterialBaseInfoId(), e.getMessage()); - } - } - materialInventory.setBarCode(updateBarCode); - } - materialInventoryMapper.updateById(materialInventory); - - - InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord(); - inventoryAdjustmentRecord.setInOrderNumber(stockReceiptOrderDO.getInOrderNumber()); - inventoryAdjustmentRecord.setLotNumber(shelfMaterialDetail.getLotNumber()); - inventoryAdjustmentRecord.setAdjustAction("入库"); - inventoryAdjustmentRecord.setRelateNo(stockReceiptOrderDO.getInOrderNumber()); - inventoryAdjustmentRecord.setAdjustAfterStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode()); - inventoryAdjustmentRecord.setAdjustBeforeStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode()); - inventoryAdjustmentRecord.setAdjustAfterStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName()); - inventoryAdjustmentRecord.setAdjustBeforeStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName()); - inventoryAdjustmentRecord.setAdjustType(1L); - inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventory.getMaterialBaseInfoId()); - inventoryAdjustmentRecord.setMaterialCode(shelfMaterialDetail.getMaterialCode()); - inventoryAdjustmentRecord.setMaterialName(shelfMaterialDetail.getMaterialName()); - inventoryAdjustmentRecord.setBarCode(shelfMaterialDetail.getBarCode()); - inventoryAdjustmentRecord.setMaterialBaseInfoId(shelfMaterialDetail.getMaterialBaseInfoId()); - inventoryAdjustmentRecord.setOrganizationId(stockReceiptOrderDO.getOrganizationId()); - inventoryAdjustmentRecord.setOrganizationName(stockReceiptOrderDO.getOrganizationName()); - inventoryAdjustmentRecord.setTopOrganizationId(stockReceiptOrderDO.getTopOrganizationId()); - inventoryAdjustmentRecord.setWarehouseCode(stockReceiptOrderDO.getWarehouseCode()); - inventoryAdjustmentRecord.setWarehouseName(stockReceiptOrderDO.getWarehouseName()); - inventoryAdjustmentRecord.setWarehouseId(stockReceiptOrderDO.getWarehouseId()); - inventoryAdjustmentRecord.setStorageCode(materialInventory.getStorageCode()); - inventoryAdjustmentRecord.setStorageName(materialInventory.getStorageName()); - inventoryAdjustmentRecord.setStorageLocationId(materialInventory.getStorageLocationId()); - inventoryAdjustmentRecord.setStorageLocationCode(materialInventory.getStorageLocationCode()); - inventoryAdjustmentRecord.setStorageLocationName(materialInventory.getStorageLocationName()); - inventoryAdjustmentRecord.setMaterialInventoryId(materialInventory.getMaterialInventoryId()); - inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventory.getMaterialBaseInfoId()); - inventoryAdjustmentRecord.setShipperId(stockReceiptOrderDO.getShipperId()); - inventoryAdjustmentRecord.setShipperName(stockReceiptOrderDO.getShipperName()); - inventoryAdjustmentRecord.setStorageSectionId(materialInventory.getStorageSectionId()); - inventoryAdjustmentRecord.setStorageLocationId(materialInventory.getStorageLocationId()); - inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid()); - UserPo userPo = loginUser.getUserPo(); - if (userPo != null) inventoryAdjustmentRecord.setCreateByName(userPo.getUserName()); - inventoryAdjustmentRecord.setCreateTime(new Date()); - inventoryAdjustmentRecord.setAllocationAfterQuantity(newAllocationQuantity); - inventoryAdjustmentRecord.setAllocationBeforeQuantity(oldAllocationQuantity); - inventoryAdjustmentRecord.setFreezeBeforeQuantity(materialInventory.getFreezeQuantity()); - inventoryAdjustmentRecord.setFreezeAfterQuantity(materialInventory.getFreezeQuantity()); - inventoryAdjustmentRecord.setInventoryBeforeQuantity(oldInventoryQuantity); - inventoryAdjustmentRecord.setInventoryAfterQuantity(newInventoryQuantity); - inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid()); - inventoryAdjustmentRecord.setCreateTime(new Date()); - inventoryAdjustmentRecord.setNetWeight(BigDecimal.ZERO ); - inventoryAdjustmentRecord.setGrossWeight(BigDecimal.ZERO); - inventoryAdjustmentRecord.setVolume(BigDecimal.ZERO); - inventoryAdjustmentRecord.setArea(BigDecimal.ZERO); - inventoryAdjustmentRecord.setAdjustedNetWeight(materialInventory.getNetWeight() == null ? BigDecimal.ZERO : materialInventory.getNetWeight()); - inventoryAdjustmentRecord.setAdjustedGrossWeight(materialInventory.getGrossWeight() == null ? BigDecimal.ZERO : materialInventory.getGrossWeight()); - inventoryAdjustmentRecord.setAdjustedVolume(materialInventory.getVolume() == null ? BigDecimal.ZERO : materialInventory.getVolume()); - inventoryAdjustmentRecord.setAdjustedArea(materialInventory.getArea() == null ? BigDecimal.ZERO : materialInventory.getArea()); - inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord); + inventoryParamDO.setArea(totalArea); + inventoryParamDO.setVolume(totalVolume); + inventoryParamDO.setNetWeight(totalNetWeight); + inventoryParamDO.setGrossWeight(totalGrossWeight); + inventoryParamDO.setMaterialInventoryId(materialInventoryPO.getMaterialInventoryId()); + inventoryParamDO.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId()); + inventoryParamDO.setInOrderNumber(stockReceiptOrderDO.getInOrderNumber()); + inventoryParamDO.setLotNumber(shelfMaterialDetail.getLotNumber()); + inventoryParamDO.setQuantity(shelfMaterialDetail.getShelvesQuantity()); + inventoryParamDO.setType("1"); + //库存调整记录 + materialInventoryService.kctzjl(inventoryParamDO, "入库", loginUser); + materialInventoryService.xgkc(inventoryParamDO); } } }