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

This commit is contained in:
Kelvin 2025-01-04 15:39:02 +08:00
parent 3b5dcf7bbf
commit 76252a3479
4 changed files with 124 additions and 2 deletions

View File

@ -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("入库任务创建成功");
}
/**
* 修改入库计划
*/

View File

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

View File

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

View File

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