diff --git a/ruoyi-modules/ruoyi-wms/src/main/java/org/dromara/wms/mapper/WmsInventoryDetailsMapper.java b/ruoyi-modules/ruoyi-wms/src/main/java/org/dromara/wms/mapper/WmsInventoryDetailsMapper.java index 9fa57f05..4290fb75 100644 --- a/ruoyi-modules/ruoyi-wms/src/main/java/org/dromara/wms/mapper/WmsInventoryDetailsMapper.java +++ b/ruoyi-modules/ruoyi-wms/src/main/java/org/dromara/wms/mapper/WmsInventoryDetailsMapper.java @@ -18,7 +18,11 @@ import org.springframework.stereotype.Repository; @Repository public interface WmsInventoryDetailsMapper extends BaseMapperPlus { - int updataDetailsByInventoryId(WmsInventoryDetails inventoryDetails); + int updataDetailsByInventoryId(@Param("inventoryDetailsId") Long inventoryDetailsId, + @Param("outStockAmount") Double outStockAmount, + @Param("nowDate") Date nowDate, + @Param("userId") Long userId, + @Param("delFlag") String delFlag); int workAddUpdateInventory(WmsInventoryDetails inventoryDetails); diff --git a/ruoyi-modules/ruoyi-wms/src/main/java/org/dromara/wms/service/IWmsInventoryDetailsService.java b/ruoyi-modules/ruoyi-wms/src/main/java/org/dromara/wms/service/IWmsInventoryDetailsService.java index 441c1721..9341d835 100644 --- a/ruoyi-modules/ruoyi-wms/src/main/java/org/dromara/wms/service/IWmsInventoryDetailsService.java +++ b/ruoyi-modules/ruoyi-wms/src/main/java/org/dromara/wms/service/IWmsInventoryDetailsService.java @@ -72,11 +72,12 @@ public interface IWmsInventoryDetailsService { WmsInventoryDetails queryInventory(WmsInventoryDetailsBo inventory); - Double workUpdateInventory(Long inventoryDetailsId, Double disposalQty); WmsInventoryDetails selectDetailsById(Long sampleLedgerId); Boolean workAddUpdateInventory(WmsInventoryDetails inventoryDetails); Boolean inStoreAddInventoryAmount(Long warehouseId, Long projectId, String batchNumber, Long materialId, Double unitPrice, String unitName, Double inStockAmount,String changeType); + + Boolean outStoreLossInventoryAmount(Long inventoryId, Double outStockAmount, Long warehouseId, String batchNumber, Long materielId, String changeType); } diff --git a/ruoyi-modules/ruoyi-wms/src/main/java/org/dromara/wms/service/impl/WmsInventoryDetailsServiceImpl.java b/ruoyi-modules/ruoyi-wms/src/main/java/org/dromara/wms/service/impl/WmsInventoryDetailsServiceImpl.java index 49cb13e2..4adb564d 100644 --- a/ruoyi-modules/ruoyi-wms/src/main/java/org/dromara/wms/service/impl/WmsInventoryDetailsServiceImpl.java +++ b/ruoyi-modules/ruoyi-wms/src/main/java/org/dromara/wms/service/impl/WmsInventoryDetailsServiceImpl.java @@ -162,25 +162,6 @@ public class WmsInventoryDetailsServiceImpl implements IWmsInventoryDetailsServi return baseMapper.deleteByIds(ids) > 0; } - @Override - public Double workUpdateInventory(Long inventoryDetailsId, Double disposalQty) { - - WmsInventoryDetails inventory = baseMapper.selectById(inventoryDetailsId); - Double inventoryAmount = inventory.getInventoryAmount(); - double lossQty = inventoryAmount - disposalQty; - if (lossQty < 0) { - throw new IllegalArgumentException("库存数量不足"); - } - - inventory.setInventoryAmount(lossQty); - if (lossQty == 0.0) { - inventory.setDelFlag("1"); - } - inventory.setUpdateBy(LoginHelper.getUserId()); - inventory.setUpdateTime(DateUtils.getNowDate()); - baseMapper.updataDetailsByInventoryId(inventory); - return inventoryAmount; - } @Override public WmsInventoryDetails selectDetailsById(Long sampleLedgerId) { @@ -223,7 +204,7 @@ public class WmsInventoryDetailsServiceImpl implements IWmsInventoryDetailsServi Double inventoryTableAmount = 0.0; if (queryInventory != null) { inventoryTableAmount = queryInventory.getInventoryAmount(); - baseMapper.updateTableById(queryInventory.getInventoryDetailsId(), inStockAmount, DateUtils.getNowDate(), LoginHelper.getUserId()); // 更新库存数量 + baseMapper.updateTableById(queryInventory.getInventoryDetailsId(), inStockAmount, DateUtils.getNowDate(), LoginHelper.getUserId()); // update增加库存数量 } else { inventory.setUnitName(unitName); inventory.setInventoryAmount(inStockAmount); @@ -263,4 +244,28 @@ public class WmsInventoryDetailsServiceImpl implements IWmsInventoryDetailsServi return baseMapper.selectOne(lqw); } + + @Override + public Boolean outStoreLossInventoryAmount(Long inventoryId, Double outStockAmount, Long warehouseId, + String batchNumber, Long materielId, String changeType) { + WmsInventoryDetails inventory = baseMapper.selectById(inventoryId); + Double inventoryAmount = inventory.getInventoryAmount(); + double lossQty = inventoryAmount - outStockAmount; + if (lossQty < 0) { + throw new IllegalArgumentException("库存数量不足"); + } + + baseMapper.updataDetailsByInventoryId(inventoryId, outStockAmount, DateUtils.getNowDate(), LoginHelper.getUserId(), lossQty == 0.0 ? "1" : "0"); + //库存变动 + WmsInventoryLedger wmsInventoryLedger = new WmsInventoryLedger(); + wmsInventoryLedger.setWarehouseId(warehouseId); + wmsInventoryLedger.setBatchNumber(batchNumber); + wmsInventoryLedger.setMaterielId(materielId); + wmsInventoryLedger.setChangeType(changeType);//变动类型 + wmsInventoryLedger.setLedgerState("0"); + wmsInventoryLedger.setChangeAmount(outStockAmount); + wmsInventoryLedger.setInventoryAmount(inventoryAmount); + wmsInventoryLedgerMapper.insert(wmsInventoryLedger); + return true; + } } diff --git a/ruoyi-modules/ruoyi-wms/src/main/java/org/dromara/wms/service/impl/WmsOutStockBillServiceImpl.java b/ruoyi-modules/ruoyi-wms/src/main/java/org/dromara/wms/service/impl/WmsOutStockBillServiceImpl.java index 7ad63f50..d1ae4210 100644 --- a/ruoyi-modules/ruoyi-wms/src/main/java/org/dromara/wms/service/impl/WmsOutStockBillServiceImpl.java +++ b/ruoyi-modules/ruoyi-wms/src/main/java/org/dromara/wms/service/impl/WmsOutStockBillServiceImpl.java @@ -22,6 +22,7 @@ import org.dromara.wms.mapper.WmsInventoryDetailsMapper; import org.dromara.wms.mapper.WmsInventoryLedgerMapper; import org.dromara.wms.mapper.WmsOutStockBillMapper; import org.dromara.wms.mapper.WmsOutStockDetailsMapper; +import org.dromara.wms.service.IWmsInventoryDetailsService; import org.dromara.wms.service.IWmsOutStockBillService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -44,8 +45,7 @@ public class WmsOutStockBillServiceImpl implements IWmsOutStockBillService { private final WmsOutStockBillMapper baseMapper; private final WmsOutStockDetailsMapper wmsOutStockDetailsMapper; - private final WmsInventoryDetailsMapper wmsInventoryDetailsMapper; - private final WmsInventoryLedgerMapper wmsInventoryLedgerMapper; + private final IWmsInventoryDetailsService inventoryDetailsService; @DubboReference private RemoteCodeRuleService remoteCodeRuleService; @@ -123,35 +123,12 @@ public class WmsOutStockBillServiceImpl implements IWmsOutStockBillService { item.setOutStockBillId(outStockBillId); // 从出库明细中获取库存ID Long inventoryId = item.getInventoryDetailsId(); - WmsInventoryDetails inventory = wmsInventoryDetailsMapper.selectById(inventoryId); - Double inventoryAmount = inventory.getInventoryAmount(); - double lossQty = inventoryAmount - item.getOutStockAmount(); - if (lossQty < 0) { - throw new IllegalArgumentException("库存数量不足"); - } - - inventory.setInventoryAmount(lossQty); - if (lossQty == 0.0){ - inventory.setDelFlag("1"); - } - inventory.setUpdateBy( LoginHelper.getUserId()); - inventory.setUpdateTime(DateUtils.getNowDate()); - wmsInventoryDetailsMapper.updataDetailsByInventoryId(inventory); - //库存变动 - WmsInventoryLedger wmsInventoryLedger = new WmsInventoryLedger(); - wmsInventoryLedger.setWarehouseId(item.getWarehouseId()); - wmsInventoryLedger.setBatchNumber(item.getBatchNumber()); - wmsInventoryLedger.setMaterielId(item.getMaterielId()); - wmsInventoryLedger.setChangeType("3");//变动类型 - wmsInventoryLedger.setLedgerState("0"); - wmsInventoryLedger.setChangeAmount(item.getOutStockAmount()); - wmsInventoryLedger.setInventoryAmount(inventoryAmount); - wmsInventoryLedgers.add(wmsInventoryLedger); + inventoryDetailsService.outStoreLossInventoryAmount(inventoryId, + item.getOutStockAmount(),item.getWarehouseId(),item.getBatchNumber(),item.getMaterielId(),"3"); }); //插入出库明细 wmsOutStockDetailsMapper.insert(outStockDetailsList); - //插入库存变动 - wmsInventoryLedgerMapper.insert(wmsInventoryLedgers); + } return flag; } diff --git a/ruoyi-modules/ruoyi-wms/src/main/resources/mapper/wms/WmsInventoryDetailsMapper.xml b/ruoyi-modules/ruoyi-wms/src/main/resources/mapper/wms/WmsInventoryDetailsMapper.xml index 401eccac..2219e497 100644 --- a/ruoyi-modules/ruoyi-wms/src/main/resources/mapper/wms/WmsInventoryDetailsMapper.xml +++ b/ruoyi-modules/ruoyi-wms/src/main/resources/mapper/wms/WmsInventoryDetailsMapper.xml @@ -7,15 +7,13 @@ - + update wms_inventory_details - - inventory_amount = #{inventoryAmount}, - del_flag = #{delFlag}, - update_by = #{updateBy}, - update_time = #{updateTime}, - - where inventory_details_id = #{inventoryDetailsId} + set inventory_amount = inventory_amount - #{outStockAmount}, + del_flag = #{delFlag}, + update_by = #{userId}, + update_time = #{nowDate} + where inventory_details_id = #{inventoryDetailsId}