feat(入库计划): 增加执行入库计划;增加根据订单生成入库计划

This commit is contained in:
Kelvin 2025-01-05 16:28:22 +08:00
parent ea7d61a6f4
commit a2f5177f2c
5 changed files with 179 additions and 210 deletions

View File

@ -2,7 +2,9 @@ package com.ktg.mes.wm.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; 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.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -82,6 +84,13 @@ public class WmsInPlanController extends BaseController {
return toAjax(wmsInPlanService.insertWmsInPlan(wmsInPlan)); 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("入库任务创建成功");
}
/** /**
* 修改入库计划 * 修改入库计划
*/ */

View File

@ -3,6 +3,8 @@ package com.ktg.mes.wm.domain;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.ktg.common.annotation.Excel; import com.ktg.common.annotation.Excel;
@ -14,6 +16,8 @@ import com.ktg.common.core.domain.BaseEntity;
* @author yinjinlu * @author yinjinlu
* @date 2024-10-31 * @date 2024-10-31
*/ */
@Getter
@Setter
public class WmsInPlan extends BaseEntity { public class WmsInPlan extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -159,211 +163,17 @@ public class WmsInPlan extends BaseEntity {
*/ */
private String planTypeCode; private String planTypeCode;
/**
* 库区编码
*/
private String locationCode;
/** /**
* 入库计划明细信息 * 入库计划明细信息
*/ */
private List<WmsInPlanDetails> wmsInPlanDetailsList; private List<WmsInPlanDetails> 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<WmsInPlanDetails> getWmsInPlanDetailsList() {
return wmsInPlanDetailsList;
}
public void setWmsInPlanDetailsList(List<WmsInPlanDetails> wmsInPlanDetailsList) {
this.wmsInPlanDetailsList = wmsInPlanDetailsList;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

View File

@ -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;
}

View File

@ -2,6 +2,7 @@ package com.ktg.mes.wm.service;
import java.util.List; import java.util.List;
import com.ktg.mes.wm.domain.WmsInPlan; import com.ktg.mes.wm.domain.WmsInPlan;
import com.ktg.mes.wm.domain.dto.WmsInboundOrderDto;
/** /**
* 入库计划Service接口 * 入库计划Service接口
@ -67,4 +68,23 @@ public interface IWmsInPlanService
* @return 是否重复 * @return 是否重复
*/ */
public Boolean isDuplicatePlanCode(String planCode); 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);
} }

View File

@ -5,23 +5,26 @@ import com.ktg.common.utils.StringUtils;
import com.ktg.generator.util.MultiModuleCodeGenerator; import com.ktg.generator.util.MultiModuleCodeGenerator;
import com.ktg.mes.md.domain.BaseKnife; import com.ktg.mes.md.domain.BaseKnife;
import com.ktg.mes.md.domain.MdItem; 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.IMdItemService;
import com.ktg.mes.md.service.impl.BaseKnifeServiceImpl; import com.ktg.mes.md.service.impl.BaseKnifeServiceImpl;
import com.ktg.mes.wm.domain.WmStorageArea; import com.ktg.mes.md.service.impl.WmsBusinessTypeServiceImpl;
import com.ktg.mes.wm.domain.WmsInPlan; import com.ktg.mes.wm.domain.*;
import com.ktg.mes.wm.domain.WmsInPlanDetailEntity; import com.ktg.mes.wm.domain.dto.WmsInboundOrderDto;
import com.ktg.mes.wm.domain.WmsInPlanDetails;
import com.ktg.mes.wm.mapper.UcmCtBaseMapper; import com.ktg.mes.wm.mapper.UcmCtBaseMapper;
import com.ktg.mes.wm.mapper.WmStorageAreaMapper; import com.ktg.mes.wm.mapper.WmStorageAreaMapper;
import com.ktg.mes.wm.mapper.WmsInPlanDetailEntityMapper; import com.ktg.mes.wm.mapper.WmsInPlanDetailEntityMapper;
import com.ktg.mes.wm.mapper.WmsInPlanMapper; import com.ktg.mes.wm.mapper.WmsInPlanMapper;
import com.ktg.mes.wm.service.IWmsInPlanService; import com.ktg.mes.wm.service.IWmsInPlanService;
import com.ktg.mes.wm.service.IWmsInTaskService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.*;
import java.util.List; import java.util.concurrent.atomic.AtomicInteger;
/** /**
* 入库计划Service业务层处理 * 入库计划Service业务层处理
@ -32,13 +35,14 @@ import java.util.List;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class WmsInPlanServiceImpl implements IWmsInPlanService { public class WmsInPlanServiceImpl implements IWmsInPlanService {
private final IWmsInTaskService wmsInTaskService;
private final IMdItemService mdItemService;
private final IBaseKnifeService baseKnifeService;
private final WmsInPlanMapper wmsInPlanMapper; private final WmsInPlanMapper wmsInPlanMapper;
private final WmsInPlanDetailEntityMapper wmsInPlanDetailEntityMapper; private final WmsInPlanDetailEntityMapper wmsInPlanDetailEntityMapper;
private final UcmCtBaseMapper ucmCtBaseMapper;
private final BaseKnifeServiceImpl baseKnifeService;
private final IMdItemService mdItemService;
private final WmStorageAreaServiceImpl wmStorageAreaService; private final WmStorageAreaServiceImpl wmStorageAreaService;
private final WmStorageAreaMapper wmStorageAreaMapper; private final WmStorageAreaMapper wmStorageAreaMapper;
private final WmsBusinessTypeMapper wmsBusinessTypeMapper;
/** /**
* 查询入库计划 * 查询入库计划
@ -190,7 +194,7 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService {
// 查询库位信息 // 查询库位信息
WmStorageArea wmStorageArea = wmStorageAreaService.selectWmStorageAreaByAreaId(wmsInPlanDetails.getCellId()); WmStorageArea wmStorageArea = wmStorageAreaService.selectWmStorageAreaByAreaId(wmsInPlanDetails.getCellId());
if (StringUtils.isNotNull(wmsInPlanDetailEntityList)) { if (!Objects.isNull(wmsInPlanDetailEntityList)) {
ArrayList<WmsInPlanDetailEntity> list = new ArrayList<>(); ArrayList<WmsInPlanDetailEntity> list = new ArrayList<>();
for (WmsInPlanDetailEntity wmsInPlanDetailEntity : wmsInPlanDetailEntityList) { for (WmsInPlanDetailEntity wmsInPlanDetailEntity : wmsInPlanDetailEntityList) {
if (wmsInPlanDetailEntity.getKnifeId() == null) { if (wmsInPlanDetailEntity.getKnifeId() == null) {
@ -240,4 +244,105 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService {
public Boolean isDuplicatePlanCode(String planCode) { public Boolean isDuplicatePlanCode(String planCode) {
return wmsInPlanMapper.isDuplicatePlanCode(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);
}
} }