From 76252a3479a182c83a45e804ff38eec77b98ebd6 Mon Sep 17 00:00:00 2001 From: Kelvin Date: Sat, 4 Jan 2025 15:39:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=85=A5=E5=BA=93=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E8=AE=A2=E5=8D=95=E7=94=9F=E6=88=90=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E8=AE=A1=E5=88=92=E5=B9=B6=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wm/controller/WmsInPlanController.java | 17 ++++- .../mes/wm/domain/dto/WmsInboundOrderDto.java | 32 +++++++++ .../ktg/mes/wm/service/IWmsInPlanService.java | 7 ++ .../wm/service/impl/WmsInPlanServiceImpl.java | 70 ++++++++++++++++++- 4 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 ktg-mes/src/main/java/com/ktg/mes/wm/domain/dto/WmsInboundOrderDto.java 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 9fe45ed..27232f3 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 @@ -7,10 +7,15 @@ 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.domain.WmsBusinessType; import com.ktg.mes.md.mapper.MdItemMapper; import com.ktg.mes.md.service.IAP0AEService; +import com.ktg.mes.md.service.IMdItemService; +import com.ktg.mes.md.service.IWmsBusinessTypeService; import com.ktg.mes.wm.domain.WmStorageArea; import com.ktg.mes.wm.domain.WmsInPlan; +import com.ktg.mes.wm.domain.WmsInPlanDetail; +import com.ktg.mes.wm.domain.dto.WmsInboundOrderDto; import com.ktg.mes.wm.service.IWmStorageLocationService; import com.ktg.mes.wm.service.IWmsInPlanService; import lombok.RequiredArgsConstructor; @@ -18,6 +23,8 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.util.Collections; import java.util.List; /** @@ -33,7 +40,8 @@ public class WmsInPlanController extends BaseController { private final IWmsInPlanService wmsInPlanService; private final IWmStorageLocationService wmStorageLocationService; private final MdItemMapper mdItemMapper; - private final IAP0AEService iAP0AEService; + private final IWmsBusinessTypeService wmsBusinessTypeService; + private final IMdItemService mdItemService; /** * 查询入库计划列表 @@ -92,6 +100,13 @@ public class WmsInPlanController extends BaseController { return toAjax(wmsInPlanService.insertWmsInPlan(wmsInPlan)); } + @Log(title = "入库计划", businessType = BusinessType.INSERT) + @PostMapping("/open/order/add") + public AjaxResult openOrderAdd(@RequestBody @Valid WmsInboundOrderDto wmsInboundOrderDto) { + wmsInPlanService.insertOrderWmsInPlan(wmsInboundOrderDto); + return AjaxResult.success("入库任务创建成功"); + } + /** * 修改入库计划 */ diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/domain/dto/WmsInboundOrderDto.java b/ktg-mes/src/main/java/com/ktg/mes/wm/domain/dto/WmsInboundOrderDto.java new file mode 100644 index 0000000..8ca4f6c --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/domain/dto/WmsInboundOrderDto.java @@ -0,0 +1,32 @@ +package com.ktg.mes.wm.domain.dto; + +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +// 根据订单入库 +@Getter +@Setter +public class WmsInboundOrderDto { + // 订单号 + @NotBlank(message = "订单号不能为空") + private String orderId; + // 物料编码 + @NotBlank(message = "物料编码不能为空") + private String materialCode; + private String rfid; + // 出库类型编码 + @NotBlank(message = "入库类型编码不能为空") + private String typeCode; + // 出库数量 + @NotNull(message = "入库数量不能为空") + @Min(value = 1, message = "数量必须大于等于 1") + private Integer quantity; + + // 消耗寿命 + @Min(value = 0, message = "消耗寿命值必须大于等于 0") + private Integer consumesLife; +} 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 359bc63..2014c75 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 @@ -2,6 +2,7 @@ package com.ktg.mes.wm.service; import java.util.List; import com.ktg.mes.wm.domain.WmsInPlan; +import com.ktg.mes.wm.domain.dto.WmsInboundOrderDto; /** * 入库计划Service接口 @@ -88,4 +89,10 @@ public interface IWmsInPlanService * @param wmsInPlan 入库计划 */ public void autoCell(WmsInPlan wmsInPlan); + + /** + * 根据订单创建入库计划 + * @param wmsInboundOrderDto 入库计划参数 + */ + public void insertOrderWmsInPlan(WmsInboundOrderDto wmsInboundOrderDto); } 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 9930abc..4fd0ac4 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 @@ -4,16 +4,23 @@ import java.util.Collections; import java.util.Date; import java.util.List; +import com.ktg.common.core.domain.AjaxResult; import com.ktg.common.utils.DateUtils; import com.ktg.generator.util.MultiModuleCodeGenerator; +import com.ktg.mes.md.domain.BaseKnife; import com.ktg.mes.md.domain.MdItem; +import com.ktg.mes.md.domain.WmsBusinessType; import com.ktg.mes.md.mapper.AP0AEMapper; +import com.ktg.mes.md.mapper.WmsBusinessTypeMapper; +import com.ktg.mes.md.service.IBaseKnifeService; import com.ktg.mes.md.service.IMdItemService; import com.ktg.mes.stl.domain.InventoryAdjustment; import com.ktg.mes.stl.mapper.InventoryAdjustmentMapper; import com.ktg.mes.wm.domain.*; +import com.ktg.mes.wm.domain.dto.WmsInboundOrderDto; import com.ktg.mes.wm.mapper.WmsInPlanDetailEntityMapper; import com.ktg.mes.wm.service.IWmStorageAreaService; +import com.ktg.mes.wm.service.IWmStorageLocationService; import com.ktg.mes.wm.service.IWmsInTaskService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -40,8 +47,10 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService { private final IWmStorageAreaService wmStorageAreaService; private final IWmsInTaskService wmsInTaskService; private final IMdItemService mdItemService; - private final AP0AEMapper ap0AEMapper; private final InventoryAdjustmentMapper inventoryAdjustmentMapper; + private final IWmStorageLocationService wmStorageLocationService; + private final WmsBusinessTypeMapper wmsBusinessTypeMapper; + private final IBaseKnifeService baseKnifeService; /** * 查询入库计划 @@ -337,4 +346,63 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService { }); } } + + @Transactional + @Override + public void insertOrderWmsInPlan(WmsInboundOrderDto wmsInboundOrderDto) { + // 查询业务类型 + WmsBusinessType wmsBusinessType = wmsBusinessTypeMapper.selectWmsBusinessTypeByCode(wmsInboundOrderDto.getTypeCode()); + if (wmsBusinessType == null) { + throw new RuntimeException("出库类型编码错误: " + wmsInboundOrderDto.getTypeCode()); + } + // 查询物料信息 + MdItem mdItem = mdItemService.selectMdItemByCode(wmsInboundOrderDto.getMaterialCode()); + if (mdItem == null) { + throw new RuntimeException("物料编码错误: " + wmsInboundOrderDto.getMaterialCode()); + } + + // 创建入库计划 + WmsInPlan wmsInPlan = new WmsInPlan(); + wmsInPlan.setState("0"); + // 业务类型 生产准备 + wmsInPlan.setSourceType("SGLR"); + wmsInPlan.setPlanTypeCode(wmsBusinessType.getCode()); + wmsInPlan.setPlanTypeId(wmsBusinessType.getTypeId()); + wmsInPlan.setRemark("订单号: " + wmsInboundOrderDto.getOrderId()); + + //-- 入库计划详情 + WmsInPlanDetail wmsInPlanDetail = new WmsInPlanDetail(); + // 状态-待执行 + wmsInPlanDetail.setPlanInStatus("0"); + // 数量 + wmsInPlanDetail.setQuantity(wmsInboundOrderDto.getQuantity().toString()); + wmsInPlanDetail.setQuantityIn(wmsInboundOrderDto.getQuantity().toString()); + wmsInPlanDetail.setMaterialId(mdItem.getItemId().toString()); + wmsInPlan.setWmsInPlanDetailsList(Collections.singletonList(wmsInPlanDetail)); + // 整刀回库 + if (StringUtils.equals(wmsInboundOrderDto.getTypeCode(), "ZDHK")) { + // 如果是整刀回库,入库数量限制为 1 + if (wmsInboundOrderDto.getQuantity() != 1) { + throw new RuntimeException("整刀回库数量必须等于 1"); + } + BaseKnife baseKnife = baseKnifeService.selectBaseKnifeByRfid(wmsInboundOrderDto.getRfid()); + if (baseKnife == null) { + throw new RuntimeException("RFID错误:" + wmsInboundOrderDto.getRfid()); + } + // 指定为刀具库库区 + wmsInPlan.setLocationCode("L055"); + // 创建入库计划详情实例 + WmsInPlanDetailEntity wmsInPlanDetailEntity = new WmsInPlanDetailEntity(); + wmsInPlanDetailEntity.setKnifeId(baseKnife.getBaseKnifeId()); + wmsInPlanDetailEntity.setRfid(wmsInboundOrderDto.getRfid()); + wmsInPlanDetailEntity.setConsumeLife(wmsInboundOrderDto.getConsumesLife()); + wmsInPlanDetail.setWmsInPlanDetailEntityList(Collections.singletonList(wmsInPlanDetailEntity)); + } else if (StringUtils.equals(wmsInboundOrderDto.getTypeCode(), "DPRK")) { + + } + + // 自动分配库位 + this.autoCell(wmsInPlan); + this.insertAndIssueWmsInPlan(wmsInPlan); + } }