From 7a518435b4e53c71b6592f97d4c77c971ffa3070 Mon Sep 17 00:00:00 2001 From: Kelvin Date: Sat, 4 Jan 2025 11:33:23 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E5=85=A5=E5=BA=93=E8=AE=A1=E5=88=92):?= =?UTF-8?q?=20=E5=B0=81=E8=A3=85=E8=87=AA=E5=8A=A8=E5=88=86=E9=85=8D?= =?UTF-8?q?=E5=BA=93=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wm/controller/WmsInPlanController.java | 17 +---------- .../ktg/mes/wm/service/IWmsInPlanService.java | 6 ++++ .../wm/service/impl/WmsInPlanServiceImpl.java | 29 +++++++++++++++++++ 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/controller/WmsInPlanController.java b/ktg-mes/src/main/java/com/ktg/mes/wm/controller/WmsInPlanController.java index d407446..9fe45ed 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/controller/WmsInPlanController.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/controller/WmsInPlanController.java @@ -88,22 +88,7 @@ public class WmsInPlanController extends BaseController { @Log(title = "入库计划", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody WmsInPlan wmsInPlan) { - // 校验是否指定了库区 - if (wmsInPlan.getLocationCode() != null && !wmsInPlan.getLocationCode().isEmpty()) { - wmsInPlan.getWmsInPlanDetailsList().forEach(wmsInPlanDetails -> { - // 获得物料ID - MdItem mdItemById = mdItemMapper.selectMdItemById(Long.parseLong(wmsInPlanDetails.getMaterialId())); - if (mdItemById == null) throw new RuntimeException("操作失败,该物料不存在"); - - // 根据限定条件自动获取库位 - WmStorageArea wmStorageArea = wmStorageLocationService.queryOneAreaByLocationCode(wmsInPlan.getLocationCode(), mdItemById.getAttr3() == 1); - if (wmStorageArea == null) throw new RuntimeException("操作失败,缺少空闲库位"); - - // 设定库位 - wmsInPlanDetails.setCellId(wmStorageArea.getAreaId()); - }); - } - + wmsInPlanService.autoCell(wmsInPlan); return toAjax(wmsInPlanService.insertWmsInPlan(wmsInPlan)); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmsInPlanService.java b/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmsInPlanService.java index 74cbafb..359bc63 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmsInPlanService.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmsInPlanService.java @@ -82,4 +82,10 @@ public interface IWmsInPlanService * @param wmsInPlan 入库计划 */ public void insertAndIssueWmsInPlan(WmsInPlan wmsInPlan); + + /** + * 分配库位 + * @param wmsInPlan 入库计划 + */ + public void autoCell(WmsInPlan wmsInPlan); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsInPlanServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsInPlanServiceImpl.java index 6c50e14..9930abc 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsInPlanServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsInPlanServiceImpl.java @@ -302,10 +302,39 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService { wmsInPlanMapper.updateWmsInPlan(wmsInPlan); } + /** + * 创建并执行入库计划 + * + * @param wmsInPlan 入库计划 + */ @Transactional @Override public void insertAndIssueWmsInPlan(WmsInPlan wmsInPlan) { this.insertWmsInPlan(wmsInPlan); this.issueWmsInPlan(wmsInPlan.getPlanId()); } + + /** + * 自动分配库位 + * + * @param wmsInPlan 入库计划 + */ + @Override + public void autoCell(WmsInPlan wmsInPlan) { + // 校验是否指定了库区 + if (StringUtils.isNotEmpty(wmsInPlan.getLocationCode())) { + wmsInPlan.getWmsInPlanDetailsList().forEach(wmsInPlanDetails -> { + // 获得物料ID + MdItem mdItemById = mdItemService.selectMdItemById(Long.parseLong(wmsInPlanDetails.getMaterialId())); + if (mdItemById == null) throw new RuntimeException("操作失败,该物料不存在"); + + // 根据限定条件自动获取库位 + WmStorageArea wmStorageArea = wmStorageLocationService.queryOneAreaByLocationCode(wmsInPlan.getLocationCode(), mdItemById.getAttr3() == 1); + if (wmStorageArea == null) throw new RuntimeException("操作失败,缺少空闲库位"); + + // 设定库位 + wmsInPlanDetails.setCellId(wmStorageArea.getAreaId()); + }); + } + } }