Compare commits
2 Commits
57e6046dc6
...
005be7233a
Author | SHA1 | Date | |
---|---|---|---|
005be7233a | |||
6c7aed9e16 |
@ -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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询出库计划管理列表
|
||||
*/
|
||||
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user