From a2f5177f2cff45cff4cae76c38cdda35265f0c6f Mon Sep 17 00:00:00 2001 From: Kelvin Date: Sun, 5 Jan 2025 16:28:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=85=A5=E5=BA=93=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=A7=E8=A1=8C=E5=85=A5=E5=BA=93=E8=AE=A1?= =?UTF-8?q?=E5=88=92=EF=BC=9B=E5=A2=9E=E5=8A=A0=E6=A0=B9=E6=8D=AE=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E7=94=9F=E6=88=90=E5=85=A5=E5=BA=93=E8=AE=A1=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wm/controller/WmsInPlanController.java | 9 + .../java/com/ktg/mes/wm/domain/WmsInPlan.java | 210 +----------------- .../mes/wm/domain/dto/WmsInboundOrderDto.java | 25 +++ .../ktg/mes/wm/service/IWmsInPlanService.java | 20 ++ .../wm/service/impl/WmsInPlanServiceImpl.java | 125 ++++++++++- 5 files changed, 179 insertions(+), 210 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 4c5daa3..14ab7d9 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 @@ -2,7 +2,9 @@ package com.ktg.mes.wm.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import com.ktg.mes.wm.domain.dto.WmsInboundOrderDto; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -82,6 +84,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/WmsInPlan.java b/ktg-mes/src/main/java/com/ktg/mes/wm/domain/WmsInPlan.java index c25e501..ff22801 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 @@ -3,6 +3,8 @@ package com.ktg.mes.wm.domain; import java.util.Date; import java.util.List; +import lombok.Getter; +import lombok.Setter; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ktg.common.annotation.Excel; @@ -14,6 +16,8 @@ import com.ktg.common.core.domain.BaseEntity; * @author yinjinlu * @date 2024-10-31 */ +@Getter +@Setter public class WmsInPlan extends BaseEntity { private static final long serialVersionUID = 1L; @@ -159,211 +163,17 @@ public class WmsInPlan extends BaseEntity { */ private String planTypeCode; + /** + * 库区编码 + */ + private String locationCode; + + /** * 入库计划明细信息 */ private List wmsInPlanDetailsList; - public void setPlanId(Long planId) { - this.planId = planId; - } - - public Long getPlanId() { - return planId; - } - - public void setState(String state) { - this.state = state; - } - - public String getState() { - return state; - } - - public void setSourceType(String sourceType) { - this.sourceType = sourceType; - } - - public String getSourceType() { - return sourceType; - } - - public void setWareId(String wareId) { - this.wareId = wareId; - } - - public String getWareId() { - return wareId; - } - - public void setCellCode(String cellCode) { - this.cellCode = cellCode; - } - - public String getCellCode() { - return cellCode; - } - - public void setWorkOrderCode(String workOrderCode) { - this.workOrderCode = workOrderCode; - } - - public String getWorkOrderCode() { - return workOrderCode; - } - - public void setExpectDate(Date expectDate) { - this.expectDate = expectDate; - } - - public Date getExpectDate() { - return expectDate; - } - - public void setPublishName(String publishName) { - this.publishName = publishName; - } - - public String getPublishName() { - return publishName; - } - - public void setPublishTime(String publishTime) { - this.publishTime = publishTime; - } - - public String getPublishTime() { - return publishTime; - } - - public void setCloserId(String closerId) { - this.closerId = closerId; - } - - public String getCloserId() { - return closerId; - } - - public void setCloseTime(String closeTime) { - this.closeTime = closeTime; - } - - public String getCloseTime() { - return closeTime; - } - - public void setRelBillCode(String relBillCode) { - this.relBillCode = relBillCode; - } - - public String getRelBillCode() { - return relBillCode; - } - - public void setCustomerId(String customerId) { - this.customerId = customerId; - } - - public String getCustomerId() { - return customerId; - } - - public void setPoCode(String poCode) { - this.poCode = poCode; - } - - public String getPoCode() { - return poCode; - } - - public void setDepartmentId(String departmentId) { - this.departmentId = departmentId; - } - - public String getDepartmentId() { - return departmentId; - } - - public void setContractNo(String contractNo) { - this.contractNo = contractNo; - } - - public String getContractNo() { - return contractNo; - } - - public void setSupplierId(String supplierId) { - this.supplierId = supplierId; - } - - public String getSupplierId() { - return supplierId; - } - - public void setBusinessTypeId(String businessTypeId) { - this.businessTypeId = businessTypeId; - } - - public String getBusinessTypeId() { - return businessTypeId; - } - - public void setSrcOutTaskId(String srcOutTaskId) { - this.srcOutTaskId = srcOutTaskId; - } - - public String getSrcOutTaskId() { - return srcOutTaskId; - } - - public void setIsActive(String isActive) { - this.isActive = isActive; - } - - public String getIsActive() { - return isActive; - } - - public void setIsDelete(String isDelete) { - this.isDelete = isDelete; - } - - public String getIsDelete() { - return isDelete; - } - - public void setPlanCode(String planCode) { - this.planCode = planCode; - } - - public String getPlanCode() { - return planCode; - } - - public void setPlanTypeId(Long planTypeId) { - this.planTypeId = planTypeId; - } - - public Long getPlanTypeId() { - return planTypeId; - } - - public String getPlanTypeCode() { - return planTypeCode; - } - - public void setPlanTypeCode(String planTypeCode) { - this.planTypeCode = planTypeCode; - } - - public List getWmsInPlanDetailsList() { - return wmsInPlanDetailsList; - } - - public void setWmsInPlanDetailsList(List wmsInPlanDetailsList) { - this.wmsInPlanDetailsList = wmsInPlanDetailsList; - } - @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) 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..b46a53a --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/domain/dto/WmsInboundOrderDto.java @@ -0,0 +1,25 @@ +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; + @NotBlank(message = "RFID不能为空") + private String rfid; + // 入库类型编码 + @NotBlank(message = "入库类型编码不能为空") + private String typeCode; +} 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 4798bcd..e3e9821 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接口 @@ -67,4 +68,23 @@ public interface IWmsInPlanService * @return 是否重复 */ public Boolean isDuplicatePlanCode(String planCode); + + /** + * 执行入库计划 + * + * @param planId 入库计划ID + */ + public void issueWmsInPlan(Long planId); + + /** + * 创建并执行入库计划 + * @param wmsInPlan 入库计划 + */ + public void insertAndIssueWmsInPlan(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 efb0d39..1e4b797 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 @@ -5,23 +5,26 @@ import com.ktg.common.utils.StringUtils; 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.WmsBusinessTypeMapper; +import com.ktg.mes.md.service.IBaseKnifeService; import com.ktg.mes.md.service.IMdItemService; import com.ktg.mes.md.service.impl.BaseKnifeServiceImpl; -import com.ktg.mes.wm.domain.WmStorageArea; -import com.ktg.mes.wm.domain.WmsInPlan; -import com.ktg.mes.wm.domain.WmsInPlanDetailEntity; -import com.ktg.mes.wm.domain.WmsInPlanDetails; +import com.ktg.mes.md.service.impl.WmsBusinessTypeServiceImpl; +import com.ktg.mes.wm.domain.*; +import com.ktg.mes.wm.domain.dto.WmsInboundOrderDto; import com.ktg.mes.wm.mapper.UcmCtBaseMapper; import com.ktg.mes.wm.mapper.WmStorageAreaMapper; import com.ktg.mes.wm.mapper.WmsInPlanDetailEntityMapper; import com.ktg.mes.wm.mapper.WmsInPlanMapper; import com.ktg.mes.wm.service.IWmsInPlanService; +import com.ktg.mes.wm.service.IWmsInTaskService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; -import java.util.List; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; /** * 入库计划Service业务层处理 @@ -32,13 +35,14 @@ import java.util.List; @Service @RequiredArgsConstructor public class WmsInPlanServiceImpl implements IWmsInPlanService { + private final IWmsInTaskService wmsInTaskService; + private final IMdItemService mdItemService; + private final IBaseKnifeService baseKnifeService; private final WmsInPlanMapper wmsInPlanMapper; private final WmsInPlanDetailEntityMapper wmsInPlanDetailEntityMapper; - private final UcmCtBaseMapper ucmCtBaseMapper; - private final BaseKnifeServiceImpl baseKnifeService; - private final IMdItemService mdItemService; private final WmStorageAreaServiceImpl wmStorageAreaService; private final WmStorageAreaMapper wmStorageAreaMapper; + private final WmsBusinessTypeMapper wmsBusinessTypeMapper; /** * 查询入库计划 @@ -190,7 +194,7 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService { // 查询库位信息 WmStorageArea wmStorageArea = wmStorageAreaService.selectWmStorageAreaByAreaId(wmsInPlanDetails.getCellId()); - if (StringUtils.isNotNull(wmsInPlanDetailEntityList)) { + if (!Objects.isNull(wmsInPlanDetailEntityList)) { ArrayList list = new ArrayList<>(); for (WmsInPlanDetailEntity wmsInPlanDetailEntity : wmsInPlanDetailEntityList) { if (wmsInPlanDetailEntity.getKnifeId() == null) { @@ -240,4 +244,105 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService { public Boolean isDuplicatePlanCode(String planCode) { return wmsInPlanMapper.isDuplicatePlanCode(planCode); } + + /** + * 执行入库计划 + * + * @param planId 入库计划ID + */ + @Override + @Transactional + public void issueWmsInPlan(Long planId) { + WmsInPlan wmsInPlan = selectWmsInPlanByPlanId(planId); + WmsInTask wmsInTask = new WmsInTask(); + + AtomicInteger atomicInteger = new AtomicInteger(); + wmsInPlan.getWmsInPlanDetailsList().forEach(detail -> { + int index = atomicInteger.getAndIncrement(); + + wmsInTask.setPlanInId(wmsInPlan.getPlanId()); + wmsInTask.setPlanInCode(wmsInPlan.getPlanCode()); + wmsInTask.setTaskInQuantity(Integer.parseInt(detail.getQuantity())); + wmsInTask.setActualInQuantity(Integer.parseInt(detail.getQuantityIn())); + wmsInTask.setCellTgt(detail.getCellId()); + wmsInTask.setCellOrig(new Date().toString() + index); + wmsInTask.setRemark(detail.getRemark()); + wmsInTask.setBatch(detail.getBatch()); + wmsInTask.setMaterialId(detail.getMaterialId()); + + MdItem mdItem = mdItemService.selectMdItemById(Long.parseLong(wmsInTask.getMaterialId())); + wmsInTask.setMaterialCode(mdItem.getItemCode()); + wmsInTask.setPlanTypeCode(wmsInPlan.getPlanTypeCode()); + wmsInTask.setPlanInStatus("0"); + wmsInTask.setDetailInId(detail.getDetailsId()); + + wmsInTaskService.insertWmsInTask(wmsInTask); + }); + + wmsInPlan.setState("1"); + wmsInPlanMapper.updateWmsInPlan(wmsInPlan); + } + + /** + * 创建并执行入库计划 + * + * @param wmsInPlan 入库计划 + */ + @Transactional + @Override + public void insertAndIssueWmsInPlan(WmsInPlan wmsInPlan) { + this.insertWmsInPlan(wmsInPlan); + this.issueWmsInPlan(wmsInPlan.getPlanId()); + } + + @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()); + + //-- 入库计划详情 + WmsInPlanDetails wmsInPlanDetail = new WmsInPlanDetails(); + // 状态-待执行 + wmsInPlanDetail.setPlanInStatus("0"); + // 数量 + wmsInPlanDetail.setQuantity("1"); + wmsInPlanDetail.setQuantityIn("1"); + wmsInPlanDetail.setMaterialId(mdItem.getItemId().toString()); + wmsInPlan.setWmsInPlanDetailsList(Collections.singletonList(wmsInPlanDetail)); + // 创建入库计划详情实例 + WmsInPlanDetailEntity wmsInPlanDetailEntity = new WmsInPlanDetailEntity(); + // 工具回库 + if (StringUtils.equals(wmsInboundOrderDto.getTypeCode(), "GJHK")) { + BaseKnife baseKnife = baseKnifeService.selectBaseKnifeByRfid(wmsInboundOrderDto.getRfid()); + if (baseKnife == null) { + throw new RuntimeException("RFID错误:" + wmsInboundOrderDto.getRfid()); + } + wmsInPlanDetailEntity.setKnifeId(baseKnife.getBaseKnifeId()); + // 采购入库 + } else if (StringUtils.equals(wmsInboundOrderDto.getTypeCode(), "DPRK")) { + + } + wmsInPlanDetailEntity.setRfid(wmsInboundOrderDto.getRfid()); + wmsInPlanDetail.setWmsInPlanDetailEntityList(Collections.singletonList(wmsInPlanDetailEntity)); + + this.insertAndIssueWmsInPlan(wmsInPlan); + } }