初步完成整刀入库机制

This commit is contained in:
刘名喜 2024-12-17 11:47:36 +08:00
parent 5358dcca31
commit c6d436526d
2 changed files with 46 additions and 18 deletions

View File

@ -1,27 +1,24 @@
package com.ktg.mes.wm.controller; 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.annotation.Log;
import com.ktg.common.core.controller.BaseController; import com.ktg.common.core.controller.BaseController;
import com.ktg.common.core.domain.AjaxResult; 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.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 * 入库计划Controller
@ -34,6 +31,8 @@ import com.ktg.common.core.page.TableDataInfo;
@RequiredArgsConstructor @RequiredArgsConstructor
public class WmsInPlanController extends BaseController { public class WmsInPlanController extends BaseController {
private final IWmsInPlanService wmsInPlanService; private final IWmsInPlanService wmsInPlanService;
private final IWmStorageLocationService wmStorageLocationService;
private final MdItemMapper mdItemMapper;
private final IAP0AEService iAP0AEService; private final IAP0AEService iAP0AEService;
/** /**
@ -89,6 +88,22 @@ public class WmsInPlanController extends BaseController {
@Log(title = "入库计划", businessType = BusinessType.INSERT) @Log(title = "入库计划", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody WmsInPlan wmsInPlan) { 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)); return toAjax(wmsInPlanService.insertWmsInPlan(wmsInPlan));
} }

View File

@ -159,6 +159,11 @@ public class WmsInPlan extends BaseEntity {
*/ */
private String planTypeCode; private String planTypeCode;
/**
* 库区编码
*/
private String locationCode;
/** /**
* 入库计划明细信息 * 入库计划明细信息
*/ */
@ -364,6 +369,14 @@ public class WmsInPlan extends BaseEntity {
this.wmsInPlanDetailsList = wmsInPlanDetailsList; this.wmsInPlanDetailsList = wmsInPlanDetailsList;
} }
public String getLocationCode() {
return locationCode;
}
public void setLocationCode(String locationCode) {
this.locationCode = locationCode;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)