From c6d436526d6e90fa2511bc11f79a9c10cc6adf11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=90=8D=E5=96=9C?= Date: Tue, 17 Dec 2024 11:47:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E5=AE=8C=E6=88=90=E6=95=B4?= =?UTF-8?q?=E5=88=80=E5=85=A5=E5=BA=93=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wm/controller/WmsInPlanController.java | 51 ++++++++++++------- .../java/com/ktg/mes/wm/domain/WmsInPlan.java | 13 +++++ 2 files changed, 46 insertions(+), 18 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 517c0b6..d407446 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 @@ -1,27 +1,24 @@ package com.ktg.mes.wm.controller; -import java.util.List; -import javax.servlet.http.HttpServletResponse; - -import com.ktg.mes.md.service.IAP0AEService; -import lombok.RequiredArgsConstructor; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import com.ktg.common.annotation.Log; import com.ktg.common.core.controller.BaseController; import com.ktg.common.core.domain.AjaxResult; -import com.ktg.common.enums.BusinessType; -import com.ktg.mes.wm.domain.WmsInPlan; -import com.ktg.mes.wm.service.IWmsInPlanService; -import com.ktg.common.utils.poi.ExcelUtil; import com.ktg.common.core.page.TableDataInfo; +import com.ktg.common.enums.BusinessType; +import com.ktg.common.utils.poi.ExcelUtil; +import com.ktg.mes.md.domain.MdItem; +import com.ktg.mes.md.mapper.MdItemMapper; +import com.ktg.mes.md.service.IAP0AEService; +import com.ktg.mes.wm.domain.WmStorageArea; +import com.ktg.mes.wm.domain.WmsInPlan; +import com.ktg.mes.wm.service.IWmStorageLocationService; +import com.ktg.mes.wm.service.IWmsInPlanService; +import lombok.RequiredArgsConstructor; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** * 入库计划Controller @@ -34,6 +31,8 @@ import com.ktg.common.core.page.TableDataInfo; @RequiredArgsConstructor public class WmsInPlanController extends BaseController { private final IWmsInPlanService wmsInPlanService; + private final IWmStorageLocationService wmStorageLocationService; + private final MdItemMapper mdItemMapper; private final IAP0AEService iAP0AEService; /** @@ -89,6 +88,22 @@ 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()); + }); + } + return toAjax(wmsInPlanService.insertWmsInPlan(wmsInPlan)); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/domain/WmsInPlan.java b/ktg-mes/src/main/java/com/ktg/mes/wm/domain/WmsInPlan.java index c25e501..69a6ac1 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/domain/WmsInPlan.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/domain/WmsInPlan.java @@ -159,6 +159,11 @@ public class WmsInPlan extends BaseEntity { */ private String planTypeCode; + /** + * 库区编码 + */ + private String locationCode; + /** * 入库计划明细信息 */ @@ -364,6 +369,14 @@ public class WmsInPlan extends BaseEntity { this.wmsInPlanDetailsList = wmsInPlanDetailsList; } + public String getLocationCode() { + return locationCode; + } + + public void setLocationCode(String locationCode) { + this.locationCode = locationCode; + } + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)