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()); + }); + } + } }