From 733156372945f6e80a6b49ef2520be16500bca1e Mon Sep 17 00:00:00 2001 From: JR <3573153686@qq.com> Date: Wed, 30 Jul 2025 10:49:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=87=87=E8=B4=AD=E5=88=A0=E4=B8=BB?= =?UTF-8?q?=E8=A1=A8=E5=90=8C=E6=97=B6=E5=88=A0=E6=98=8E=E7=BB=86=EF=BC=8C?= =?UTF-8?q?=E6=8E=A8=E8=8D=90=E8=AE=A1=E7=AE=97=E5=9C=A8=E9=80=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/WmsPurchasePlanServiceImpl.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/klp-wms/src/main/java/com/klp/service/impl/WmsPurchasePlanServiceImpl.java b/klp-wms/src/main/java/com/klp/service/impl/WmsPurchasePlanServiceImpl.java index f07c0fbe..7004e090 100644 --- a/klp-wms/src/main/java/com/klp/service/impl/WmsPurchasePlanServiceImpl.java +++ b/klp-wms/src/main/java/com/klp/service/impl/WmsPurchasePlanServiceImpl.java @@ -81,7 +81,8 @@ public class WmsPurchasePlanServiceImpl implements IWmsPurchasePlanService { List bomList = wmsProductBomService.listByProductId(detail.getProductId()); for (WmsProductBom bom : bomList) { BigDecimal needQty = bom.getQuantity().multiply(detail.getQuantity()); - WmsPurchasePlanDetailVo vo = materialMap.getOrDefault(bom.getRawMaterialId(), new WmsPurchasePlanDetailVo()); + WmsPurchasePlanDetailVo vo = + materialMap.getOrDefault(bom.getRawMaterialId(), new WmsPurchasePlanDetailVo()); vo.setRawMaterialId(bom.getRawMaterialId()); vo.setQuantity(vo.getQuantity() == null ? needQty : vo.getQuantity().add(needQty)); vo.setUnit(bom.getUnit()); @@ -98,19 +99,20 @@ public class WmsPurchasePlanServiceImpl implements IWmsPurchasePlanService { vo.setDemand(vo.getQuantity()); BigDecimal stockQty = wmsStockService.getStockByItemId(vo.getRawMaterialId()); // 库存量 + if(stockQty == null){ + stockQty = BigDecimal.ZERO; + } vo.setInventory(stockQty); // 在途量 BigDecimal onTheWayQty = BigDecimal.ZERO; - BigDecimal byRawMaterialIdAndOnTheWay = wmsPurchasePlanDetailMapper.getByRawMaterialIdAndOnTheWay(vo.getRawMaterialId()); + BigDecimal byRawMaterialIdAndOnTheWay = + wmsPurchasePlanDetailMapper.getByRawMaterialIdAndOnTheWay(vo.getRawMaterialId()); if (byRawMaterialIdAndOnTheWay != null) { onTheWayQty = byRawMaterialIdAndOnTheWay; } vo.setOnTheWay(onTheWayQty); - // 要是物料不是产品 - BigDecimal recommendQty = BigDecimal.ZERO; - if (stockQty != null) { - recommendQty = vo.getQuantity().subtract(stockQty); - } + // 计算推荐采购量 + BigDecimal recommendQty = vo.getQuantity().subtract(onTheWayQty).subtract(stockQty); vo.setQuantity(recommendQty.compareTo(BigDecimal.ZERO) > 0 ? recommendQty : BigDecimal.ZERO); } // 4. 组装主VO @@ -196,9 +198,11 @@ public class WmsPurchasePlanServiceImpl implements IWmsPurchasePlanService { */ @Override public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { - if(isValid){ - //TODO 做一些业务上的校验,判断是否需要校验 - } + // 逻辑删除采购明细 + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.in(WmsPurchasePlanDetail::getPlanId, ids); + wmsPurchasePlanDetailMapper.delete(lqw); + // 逻辑删除采购计划主表 return baseMapper.deleteBatchIds(ids) > 0; } }