Compare commits

..

2 Commits

Author SHA1 Message Date
005be7233a feat(出库): 新增根据订单号出库接口-开放 2025-01-04 08:52:44 +08:00
6c7aed9e16 doc: 格式化 2025-01-04 08:51:46 +08:00
3 changed files with 98 additions and 7 deletions

View File

@ -7,12 +7,14 @@ import com.ktg.common.core.controller.BaseController;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.common.core.page.TableDataInfo;
import com.ktg.common.enums.BusinessType;
import com.ktg.common.utils.StringUtils;
import com.ktg.common.utils.poi.ExcelUtil;
import com.ktg.generator.util.MultiModuleCodeGenerator;
import com.ktg.mes.md.domain.AP0AE;
import com.ktg.mes.md.domain.WmsOutPlan;
import com.ktg.mes.md.domain.WmsOutPlanDetailEntity;
import com.ktg.mes.md.domain.*;
import com.ktg.mes.md.domain.dto.WmsOutboundOrderDto;
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.md.service.IWmsOutPlanService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
@ -20,6 +22,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.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -34,6 +38,8 @@ import java.util.List;
@RequiredArgsConstructor
public class WmsOutPlanController extends BaseController {
private final IWmsOutPlanService wmsOutPlanService;
private final IWmsBusinessTypeService wmsBusinessTypeService;
private final IMdItemService mdItemService;
/**
* 查询出库计划管理列表
@ -54,6 +60,64 @@ public class WmsOutPlanController extends BaseController {
return toAjax(wmsOutPlanService.insertWmsOutPlanAndRun(wmsOutPlan));
}
/**
* @param wmsOutboundOrderDto
* @return
*/
@PostMapping("/open/order/add")
public AjaxResult openOrderAdd(@RequestBody @Valid WmsOutboundOrderDto wmsOutboundOrderDto) {
// 查询业务类型
WmsBusinessType wmsBusinessType = wmsBusinessTypeService.selectWmsBusinessTypeByCode(wmsOutboundOrderDto.getTypeCode());
if (wmsBusinessType == null) {
return AjaxResult.error("出库类型编码错误:" + wmsOutboundOrderDto.getTypeCode());
}
// 查询物料信息
MdItem mdItem = mdItemService.selectMdItemByCode(wmsOutboundOrderDto.getMaterialCode());
if (mdItem == null) {
return AjaxResult.error("物料编码错误:" + wmsOutboundOrderDto.getMaterialCode());
}
// 创建出库计划
WmsOutPlan wmsOutPlan = new WmsOutPlan();
wmsOutPlan.setPlanCode(MultiModuleCodeGenerator.generateTaskCode("CKP"));
wmsOutPlan.setWmsBusinessTypeId(wmsBusinessType.getTypeId());
wmsOutPlan.setWmsBusinessType(wmsBusinessType);
wmsOutPlan.setPlanType("SCZB");
wmsOutPlan.setPlanState("0");
// 创建出库计划明细
ArrayList<WmsOutPlanDetail> wmsOutPlanDetails = getWmsOutPlanDetails(wmsOutboundOrderDto, mdItem);
wmsOutPlan.setWmsOutPlanDetailList(wmsOutPlanDetails);
// 插入出库计划并执行
try {
int i = wmsOutPlanService.insertWmsOutPlanAndRun(wmsOutPlan);
if (i > 0) {
return AjaxResult.success("出库任务创建成功");
} else {
return AjaxResult.error("出库任务创建失败,原因:数据库插入失败");
}
} catch (Exception e) {
return AjaxResult.error("出库任务创建失败,原因:" + e.getMessage());
}
}
private static ArrayList<WmsOutPlanDetail> getWmsOutPlanDetails(WmsOutboundOrderDto wmsOutboundOrderDto, MdItem mdItem) {
WmsOutPlanDetail wmsOutPlanDetail = new WmsOutPlanDetail();
wmsOutPlanDetail.setMdItemId(mdItem.getItemId());
wmsOutPlanDetail.setMdItemName(mdItem.getItemName());
wmsOutPlanDetail.setMdItemCode(mdItem.getItemCode());
wmsOutPlanDetail.setMdItemUnit(mdItem.getUnitName());
wmsOutPlanDetail.setPlannedQuantity(wmsOutboundOrderDto.getQuantity());
wmsOutPlanDetail.setRealQuantity(wmsOutboundOrderDto.getQuantity());
wmsOutPlanDetail.setDetailBatchNum(wmsOutboundOrderDto.getOrderId());
wmsOutPlanDetail.setDetailState("0");
ArrayList<WmsOutPlanDetail> wmsOutPlanDetails = new ArrayList<>();
wmsOutPlanDetails.add(wmsOutPlanDetail);
return wmsOutPlanDetails;
}
/**
* 查询出库计划管理列表
*/

View File

@ -0,0 +1,27 @@
package com.ktg.mes.md.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 WmsOutboundOrderDto {
// 订单号
@NotBlank(message = "订单号不能为空")
private String orderId;
// 物料编码
@NotBlank(message = "物料编码不能为空")
private String materialCode;
// 出库类型编码
@NotBlank(message = "出库类型编码不能为空")
private String typeCode;
// 出库数量
@NotNull(message = "出库数量不能为空")
@Min(value = 1, message = "数量必须大于等于 1")
private int quantity;
}

View File

@ -241,7 +241,7 @@ public class WmsInTaskController extends BaseController {
baseKnifeService.updateBaseKnife(baseKnife);
// 判断物料是否有绑定了订单
if (baseKnife.getPlanSheet() != null){
if (baseKnife.getPlanSheet() != null) {
// 获取台账锁定实体并将状态设置为已完成
BaseKnifeLocked baseKnifeLockedWrapper = new BaseKnifeLocked();
baseKnifeLockedWrapper.setStatus(0);
@ -251,7 +251,7 @@ public class WmsInTaskController extends BaseController {
// 获取实体并修改状态
BaseKnifeLocked baseKnifeLocked;
if (!baseKnifeLockedList.isEmpty()){
if (!baseKnifeLockedList.isEmpty()) {
baseKnifeLocked = baseKnifeLockedList.get(0);
baseKnifeLocked.setStatus(1);
baseKnifeLockedMapper.updateBaseKnifeLocked(baseKnifeLocked);
@ -260,7 +260,7 @@ public class WmsInTaskController extends BaseController {
// 再次查询物料是否有预订订单
baseKnifeLockedWrapper.setPlanSheet(null);
baseKnifeLockedList = baseKnifeLockedMapper.selectBaseKnifeLockedList(baseKnifeLockedWrapper);
if (!baseKnifeLockedList.isEmpty()){
if (!baseKnifeLockedList.isEmpty()) {
baseKnifeLocked = baseKnifeLockedList.get(0);
baseKnife.setPlanSheet(baseKnifeLocked.getPlanSheet());
baseKnife.setIsLocked(1);
@ -548,7 +548,7 @@ public class WmsInTaskController extends BaseController {
.build();
// 发送请求
try(Response response = client.newCall(request).execute()) {
try (Response response = client.newCall(request).execute()) {
if (!response.isSuccessful())
throw new IOException("Unexpected code " + response);