Merge branch 'test'
This commit is contained in:
@@ -17,6 +17,8 @@ import org.nl.wms.ext_manage.service.WmsToZDWmdService;
|
||||
import org.nl.wms.ext_manage.service.dto.FeedingRecordPushDto;
|
||||
import org.nl.wms.ext_manage.service.dto.MesTaskParams;
|
||||
import org.nl.wms.ext_manage.service.dto.ZDInventory;
|
||||
import org.nl.wms.pm_manage.demand.service.IPmDemandPlatingService;
|
||||
import org.nl.wms.ext_manage.service.dto.*;
|
||||
import org.nl.wms.pm_manage.demand.service.IPmDemandService;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandParam;
|
||||
import org.nl.wms.pm_manage.pmreturn.service.IPmReturnService;
|
||||
@@ -57,6 +59,8 @@ public class MesToWmsController {
|
||||
|
||||
@Autowired
|
||||
private IPmDemandService iPmDemandService;
|
||||
@Autowired
|
||||
private IPmDemandPlatingService iPmDemandPlatingService;
|
||||
|
||||
@Autowired
|
||||
private IStInventoryService iStInventoryService;
|
||||
@@ -97,11 +101,59 @@ public class MesToWmsController {
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("api/mes/confirmWorkOrder")
|
||||
@SaIgnore
|
||||
@Log("喷涂产线确认工单")
|
||||
public ResponseEntity confirmWorkOrder(@RequestBody LoadMatDto param){
|
||||
mesToWmsService.confirmWorkOrder(param);
|
||||
return ResponseData.build();
|
||||
}
|
||||
@PostMapping("api/mes/platingInbound")
|
||||
@SaIgnore
|
||||
@Log("喷涂入库")
|
||||
public ResponseEntity platingInbound(@Valid @RequestBody PlatingInboundDto param){
|
||||
mesToWmsService.platingInbound(param);
|
||||
return ResponseData.build();
|
||||
}
|
||||
@PostMapping("api/mes/platingOffline")
|
||||
@SaIgnore
|
||||
@Log("喷涂下线")
|
||||
public ResponseEntity platingOffline(@Valid @RequestBody PlatingOfflineDto param){
|
||||
mesToWmsService.platingOffline(param);
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("api/mes/assemblyOffline")
|
||||
@SaIgnore
|
||||
@Log("部装下线")
|
||||
public ResponseEntity assemblyOffline(@Valid @RequestBody AssemblyOfflineDto assemblyOfflineDto){
|
||||
mesToWmsService.assemblyOffline(assemblyOfflineDto);
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("api/mes/loadMat")
|
||||
@SaIgnore
|
||||
@Log("装配上料")
|
||||
public ResponseEntity loadMat(@Valid @RequestBody LoadMatDto loadMatDto){
|
||||
mesToWmsService.loadMat(loadMatDto);
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("app/restful/api/v3/wms/mesRequisitionSync")
|
||||
@SaIgnore
|
||||
@Log("需求单同步")
|
||||
public ResponseEntity mesRequisitionSync(@RequestBody List<@Valid PmDemandParam> params) {
|
||||
iPmDemandService.batchCreate(params);
|
||||
public ResponseEntity mesRequisitionSync(@RequestBody List<PmDemandParam> params) {
|
||||
ArrayList<PmDemandParam> pmDemandParams = new ArrayList<>();
|
||||
ArrayList<PmDemandParam> pmDemandPlatingParams = new ArrayList<>();
|
||||
for (PmDemandParam param : params) {
|
||||
if (Boolean.TRUE.equals(param.getIsSprayPart())){
|
||||
pmDemandPlatingParams.add(param);
|
||||
}else {
|
||||
pmDemandParams.add(param);
|
||||
}
|
||||
}
|
||||
iPmDemandService.batchCreate(pmDemandParams);
|
||||
iPmDemandPlatingService.batchCreate(pmDemandPlatingParams);
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
package org.nl.wms.ext_manage.service;
|
||||
|
||||
import org.nl.wms.ext_manage.service.dto.MesTaskParams;
|
||||
import org.nl.wms.ext_manage.service.dto.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
public interface MesToWmsService {
|
||||
void task(MesTaskParams mesTaskParams);
|
||||
|
||||
void confirmWorkOrder(LoadMatDto param);
|
||||
|
||||
void assemblyOffline(AssemblyOfflineDto assemblyOfflineDto);
|
||||
|
||||
void loadMat(LoadMatDto loadMatDto);
|
||||
|
||||
void platingOffline(PlatingOfflineDto param);
|
||||
|
||||
void platingInbound(@Valid PlatingInboundDto param);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package org.nl.wms.ext_manage.service.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class AssemblyOfflineDto {
|
||||
/**
|
||||
* 产线编码
|
||||
*/
|
||||
@NotBlank(message = "产线编码不能为空")
|
||||
@JsonProperty("LineCode")
|
||||
private String lineCode;
|
||||
|
||||
/**
|
||||
* 下料位置
|
||||
*/
|
||||
@NotBlank(message = "下料位置不能为空")
|
||||
@JsonProperty("UnloadPort")
|
||||
private String unloadPort;
|
||||
|
||||
/**
|
||||
* 工单编码
|
||||
*/
|
||||
@NotBlank(message = "工单编码不能为空")
|
||||
@JsonProperty("OrderCode")
|
||||
private String orderCode;
|
||||
|
||||
/**
|
||||
* 下料数量
|
||||
*/
|
||||
@JsonProperty("UnloadQty")
|
||||
private BigDecimal unloadQty;
|
||||
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
@NotBlank(message = "物料编码不能为空")
|
||||
@JsonProperty("MaterialCode")
|
||||
private String materialCode;
|
||||
|
||||
/**
|
||||
* 物料名称
|
||||
*/
|
||||
@NotBlank(message = "物料名称不能为空")
|
||||
@JsonProperty("MaterialName")
|
||||
private String materialName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonProperty("CreatedOn")
|
||||
private String createdOn;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.nl.wms.ext_manage.service.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class LoadMatDto {
|
||||
/**
|
||||
* 产线编码
|
||||
*/
|
||||
@NotBlank(message = "产线编码不能为空")
|
||||
@JsonProperty("LineCode")
|
||||
private String lineCode;
|
||||
|
||||
/**
|
||||
* 上料位置
|
||||
*/
|
||||
@NotBlank(message = "上料位置不能为空")
|
||||
@JsonProperty("PortCode")
|
||||
private String portCode;
|
||||
|
||||
/**
|
||||
* 工单编码
|
||||
*/
|
||||
@NotBlank(message = "工单编码不能为空")
|
||||
@JsonProperty("OrderCode")
|
||||
private String orderCode;
|
||||
|
||||
/**
|
||||
* 上料数量
|
||||
*/
|
||||
@JsonProperty("LoadQty")
|
||||
private BigDecimal loadQty;
|
||||
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
@NotBlank(message = "物料编码不能为空")
|
||||
@JsonProperty("MaterialCode")
|
||||
private String materialCode;
|
||||
|
||||
/**
|
||||
* 物料名称
|
||||
*/
|
||||
@NotBlank(message = "物料名称不能为空")
|
||||
@JsonProperty("MaterialName")
|
||||
private String materialName;
|
||||
/**
|
||||
* 跟踪号
|
||||
*/
|
||||
@NotBlank(message = "物料名称不能为空")
|
||||
@JsonProperty("TrackNo")
|
||||
private String trackNo;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.nl.wms.ext_manage.service.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class PlatingInboundDto {
|
||||
|
||||
/**
|
||||
* 工单编码
|
||||
*/
|
||||
@NotBlank(message = "工单编码不能为空")
|
||||
@JsonProperty("OrderCode")
|
||||
private String orderCode;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@JsonProperty("Qty")
|
||||
private BigDecimal qty;
|
||||
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
@NotBlank(message = "物料编码不能为空")
|
||||
@JsonProperty("MaterialCode")
|
||||
private String materialCode;
|
||||
|
||||
/**
|
||||
* 物料名称
|
||||
*/
|
||||
@NotBlank(message = "物料名称不能为空")
|
||||
@JsonProperty("MaterialName")
|
||||
private String materialName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package org.nl.wms.ext_manage.service.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class PlatingOfflineDto {
|
||||
/**
|
||||
* 产线编码
|
||||
*/
|
||||
@NotBlank(message = "产线编码不能为空")
|
||||
@JsonProperty("LineCode")
|
||||
private String lineCode;
|
||||
|
||||
/**
|
||||
* 下料位置
|
||||
*/
|
||||
@NotBlank(message = "下料位置不能为空")
|
||||
@JsonProperty("UnloadPort")
|
||||
private String unloadPort;
|
||||
|
||||
/**
|
||||
* 工单编码
|
||||
*/
|
||||
@NotBlank(message = "工单编码不能为空")
|
||||
@JsonProperty("OrderCode")
|
||||
private String orderCode;
|
||||
|
||||
/**
|
||||
* 下料数量
|
||||
*/
|
||||
@JsonProperty("UnloadQty")
|
||||
private BigDecimal unloadQty;
|
||||
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
@NotBlank(message = "物料编码不能为空")
|
||||
@JsonProperty("MaterialCode")
|
||||
private String materialCode;
|
||||
|
||||
/**
|
||||
* 物料名称
|
||||
*/
|
||||
@NotBlank(message = "物料名称不能为空")
|
||||
@JsonProperty("MaterialName")
|
||||
private String materialName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonProperty("CreatedOn")
|
||||
private String createdOn;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.base.ResponseData;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.pda_manage.ios_manage.purchase.service.InboundPdaService;
|
||||
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.*;
|
||||
import org.nl.wms.pda_manage.ios_manage.purchase.service.vo.PurchaseMatInfoVo;
|
||||
@@ -16,6 +17,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@@ -53,12 +55,26 @@ public class InboundPdaController {
|
||||
|
||||
|
||||
@PostMapping("/groupPlate")
|
||||
@Log("PDA提交组盘")
|
||||
@Log("PDA收货组盘")
|
||||
@SaIgnore
|
||||
public ResponseEntity submitGroupPlate(@RequestBody PdaGroupPlateDto dto) {
|
||||
JSONObject result = inboundPdaService.submitGroupPlate(dto);
|
||||
return ResponseData.build(result);
|
||||
}
|
||||
@PostMapping("/manualGroupPlate")
|
||||
@Log("PDA手工组盘")
|
||||
@SaIgnore
|
||||
public ResponseEntity manualGroupPlate(@RequestBody @Valid ManualGroupPlateDto dto) {
|
||||
inboundPdaService.manualGroupPlate(dto);
|
||||
return ResponseData.build();
|
||||
}
|
||||
@GetMapping("/getMatByCode")
|
||||
@Log("PDA根据编码获取物料信息")
|
||||
@SaIgnore
|
||||
public ResponseEntity getMatByCode(String code) {
|
||||
MdMeMaterialbase material = inboundPdaService.getMatByCode(code);
|
||||
return ResponseData.build(material);
|
||||
}
|
||||
@PostMapping("/groupPlateInbound")
|
||||
@Log("PDA提交AGV组盘入库")
|
||||
@SaIgnore
|
||||
@@ -69,7 +85,7 @@ public class InboundPdaController {
|
||||
@PostMapping("/manualInbound")
|
||||
@Log("PDA提交手工入库")
|
||||
@SaIgnore
|
||||
public ResponseEntity submitManualInbound(@RequestBody ManualInboundDto dto) {
|
||||
public ResponseEntity submitManualInbound(@RequestBody @Valid ManualInboundDto dto) {
|
||||
inboundPdaService.submitManualInbound(dto);
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.nl.wms.pda_manage.ios_manage.purchase.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.*;
|
||||
import org.nl.wms.pda_manage.ios_manage.purchase.service.vo.PurchaseMatInfoVo;
|
||||
|
||||
@@ -25,4 +26,8 @@ public interface InboundPdaService {
|
||||
List<PurchaseMatInfoVo> getInfoByReturnBill(String code);
|
||||
|
||||
void returnInbound(ReturnInboundDto returnInboundDto);
|
||||
|
||||
void manualGroupPlate(ManualGroupPlateDto dto);
|
||||
|
||||
MdMeMaterialbase getMatByCode(String code);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.nl.wms.pda_manage.ios_manage.purchase.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ManualGroupPlateDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotBlank(message = "载具号不能为空")
|
||||
private String vehicle_code;
|
||||
@NotBlank(message = "库位号不能为空")
|
||||
private String location_code;
|
||||
private List<ManualGroupPlateDtlDto> items;
|
||||
|
||||
@Data
|
||||
public static class ManualGroupPlateDtlDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String material_code;
|
||||
private String material_name;
|
||||
private BigDecimal qty;
|
||||
private String order_code;
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,12 @@ package org.nl.wms.pda_manage.ios_manage.purchase.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Data
|
||||
public class ManualInboundDto {
|
||||
@NotBlank(message = "载具号不能为空")
|
||||
private String vehicle_code;
|
||||
@NotBlank(message = "库位号不能为空")
|
||||
private String struct_code;
|
||||
}
|
||||
|
||||
@@ -4,14 +4,18 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.basedata_manage.enums.BaseDataEnum;
|
||||
import org.nl.wms.basedata_manage.service.*;
|
||||
import org.nl.wms.basedata_manage.service.dao.*;
|
||||
import org.nl.wms.pda_manage.ios_manage.purchase.service.InboundPdaService;
|
||||
@@ -26,16 +30,24 @@ import org.nl.wms.pm_manage.purchase.service.dao.Purchasemst;
|
||||
import org.nl.wms.pm_manage.purchase.service.enums.PurchaseBillStatus;
|
||||
import org.nl.wms.warehouse_manage.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.IInBillService;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInv;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInvDis;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInvDtl;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvDisMapper;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvDtlMapper;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvMapper;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dto.IOStorInvDisDto;
|
||||
import org.nl.wms.warehouse_manage.inventory.IStInventoryService;
|
||||
import org.nl.wms.warehouse_manage.inventory.core.enums.InventoryChangeType;
|
||||
import org.nl.wms.warehouse_manage.inventory.core.param.impl.AddInvParam;
|
||||
import org.nl.wms.warehouse_manage.inventory.core.param.impl.InFinishParam;
|
||||
import org.nl.wms.warehouse_manage.service.IMdPbGroupplateService;
|
||||
import org.nl.wms.warehouse_manage.service.dao.GroupPlate;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.dao.PmStockReturn;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.enums.StockReturnStatusEnum;
|
||||
import org.nl.wms.welding_manage.service.work_order.IWorkOrderService;
|
||||
import org.nl.wms.welding_manage.service.work_order.dao.WorkOrderDao;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -43,6 +55,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
|
||||
import static org.nl.wms.warehouse_manage.enums.IOSEnum.GROUP_PLATE_STATUS;
|
||||
@@ -71,13 +84,15 @@ public class InboundPdaServiceImpl implements InboundPdaService {
|
||||
|
||||
@Resource
|
||||
private IStructattrService iStructattrService;
|
||||
|
||||
@Autowired
|
||||
private IBsrealStorattrService storattrService;
|
||||
/**
|
||||
* 基础物料服务
|
||||
*/
|
||||
@Autowired
|
||||
private IMdMeMaterialbaseService iMdMeMaterialbaseService;
|
||||
|
||||
@Autowired
|
||||
private IWorkOrderService workOrderService;
|
||||
/**
|
||||
* 计量单位服务
|
||||
*/
|
||||
@@ -103,10 +118,12 @@ public class InboundPdaServiceImpl implements InboundPdaService {
|
||||
*/
|
||||
@Autowired
|
||||
private IOStorInvDtlMapper ioStorInvDtlMapper;
|
||||
|
||||
@Autowired
|
||||
private IOStorInvMapper ioStorInvMapper;
|
||||
@Resource
|
||||
private IOStorInvDisMapper ioStorInvDisMapper;
|
||||
|
||||
@Autowired
|
||||
private IPmStockReturnService iPmStockReturnService;
|
||||
|
||||
|
||||
|
||||
@@ -708,6 +725,158 @@ public class InboundPdaServiceImpl implements InboundPdaService {
|
||||
iRawAssistIStorService.disFinish(ioStorInvDis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手工组盘
|
||||
* @param dto
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public void manualGroupPlate(ManualGroupPlateDto dto) {
|
||||
if (dto.getItems().isEmpty()){
|
||||
throw new BadRequestException("组盘物料为空");
|
||||
}
|
||||
Structattr structattr = iStructattrService.getByCode(dto.getLocation_code());
|
||||
BsrealStorattr storattrIn = storattrService.findByCode(structattr.getStor_code());
|
||||
if (!StringUtils.isEmpty(structattr.getStoragevehicle_code())){
|
||||
if (!Objects.equals(structattr.getStoragevehicle_code(), dto.getVehicle_code())){
|
||||
throw new BadRequestException("当前库位已存在其他载具" + structattr.getStoragevehicle_code());
|
||||
}
|
||||
}else {
|
||||
structattr.setStoragevehicle_code(dto.getVehicle_code());
|
||||
iStructattrService.update(structattr);
|
||||
}
|
||||
final String now = DateUtil.now();
|
||||
int seq = 1;
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
final List<IOStorInvDtl> ioStorInvDtls = new ArrayList<>();
|
||||
final List<IOStorInvDis> iOStorInvDiss = new ArrayList<>();
|
||||
List<AddInvParam> addInvParams = new ArrayList<>();
|
||||
List<InFinishParam> inFinishParams = new ArrayList<>();
|
||||
|
||||
//生成入库单
|
||||
IOStorInv ioStorInvIn = new IOStorInv();
|
||||
ioStorInvIn.setIostorinv_id(IdUtil.getStringId());
|
||||
ioStorInvIn.setBill_code(CodeUtil.getNewCode("IN_STORE_CODE"));
|
||||
ioStorInvIn.setIo_type(IOSEnum.IO_TYPE.code("入库"));
|
||||
ioStorInvIn.setBill_type(IOSEnum.BILL_TYPE.code("生产入库"));
|
||||
ioStorInvIn.setBiz_date(DateUtil.today());
|
||||
ioStorInvIn.setStor_code(storattrIn.getStor_code());
|
||||
ioStorInvIn.setStor_name(storattrIn.getStor_name());
|
||||
ioStorInvIn.setStor_id(storattrIn.getStor_id());
|
||||
ioStorInvIn.setDetail_count(1);
|
||||
ioStorInvIn.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
|
||||
ioStorInvIn.setCreate_mode(IOSEnum.CREATE_MODE.code("终端产生"));
|
||||
ioStorInvIn.setInput_optid(currentUserId);
|
||||
ioStorInvIn.setInput_optname(nickName);
|
||||
ioStorInvIn.setInput_time(now);
|
||||
ioStorInvIn.setIs_delete(BaseDataEnum.IS_YES_NOT.code("否"));
|
||||
ioStorInvIn.setIs_upload(BaseDataEnum.IS_YES_NOT.code("是"));
|
||||
dto.getItems().forEach(item -> {
|
||||
BigDecimal qty = item.getQty();
|
||||
WorkOrderDao workOrder = workOrderService.getWorkOrder(item.getOrder_code());
|
||||
MdMeMaterialbase material = iMdMeMaterialbaseService.getByCode(item.getMaterial_code());
|
||||
|
||||
final IOStorInvDtl ioStorInvDtl = new IOStorInvDtl();
|
||||
ioStorInvDtl.setIostorinv_id(ioStorInvIn.getIostorinv_id());
|
||||
ioStorInvDtl.setIostorinvdtl_id(IdUtil.getStringId());
|
||||
ioStorInvDtl.setSeq_no(String.valueOf(seq));
|
||||
ioStorInvDtl.setMaterial_code(material.getMaterial_code());
|
||||
ioStorInvDtl.setMaterial_id(material.getMaterial_id());
|
||||
ioStorInvDtl.setQty_unit_id(material.getQty_unit_id());
|
||||
ioStorInvDtl.setQty_unit_name(material.getQty_unit_name());
|
||||
ioStorInvDtl.setPcsn("1");
|
||||
ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
|
||||
ioStorInvDtl.setAssign_qty(qty);
|
||||
ioStorInvDtl.setPlan_qty(qty);
|
||||
ioStorInvDtl.setUnassign_qty(BigDecimal.ZERO);
|
||||
ioStorInvDtl.setSource_bill_code(workOrder.getOrder_code());
|
||||
ioStorInvDtl.setSource_bill_type("work_order");
|
||||
ioStorInvDtls.add(ioStorInvDtl);
|
||||
// 分配
|
||||
final IOStorInvDis ioStorInvDis = new IOStorInvDis();
|
||||
ioStorInvDis.setIostorinvdis_id(IdUtil.getStringId());
|
||||
ioStorInvDis.setIostorinv_id(ioStorInvIn.getIostorinv_id()); // 修正变量名
|
||||
ioStorInvDis.setIostorinvdtl_id(ioStorInvDtl.getIostorinvdtl_id()); // 从对象获取,而不是从 JSON
|
||||
ioStorInvDis.setSeq_no("1"); // 直接用 int,不需要 String
|
||||
ioStorInvDis.setMaterial_id(material.getMaterial_id());
|
||||
ioStorInvDis.setMaterial_code(material.getMaterial_code()); // 直接使用变量
|
||||
ioStorInvDis.setSect_code(workOrder.getDefault_warehouse_code());
|
||||
ioStorInvDis.setStruct_code(structattr.getStruct_code());
|
||||
ioStorInvDis.setPcsn("1");
|
||||
ioStorInvDis.setStoragevehicle_code(structattr.getStoragevehicle_code());
|
||||
ioStorInvDis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("完成"));
|
||||
ioStorInvDis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("是"));
|
||||
ioStorInvDis.setQty_unit_id(material.getQty_unit_id());
|
||||
ioStorInvDis.setQty_unit_name(material.getQty_unit_name());
|
||||
ioStorInvDis.setPlan_qty(qty); // 直接使用 qty 变量
|
||||
ioStorInvDis.setReal_qty(qty);
|
||||
iOStorInvDiss.add(ioStorInvDis);
|
||||
AddInvParam addParam = new AddInvParam();
|
||||
addParam.setPcsn("1");
|
||||
addParam.setMaterialCode(material.getMaterial_code());
|
||||
addParam.setStoragevehicleCode(dto.getVehicle_code());
|
||||
addParam.setUnitName(material.getQty_unit_name());
|
||||
addParam.setUnitId(material.getQty_unit_id());
|
||||
addParam.setExtCode(workOrder.getOrder_code());
|
||||
addParam.setQty(qty);
|
||||
addInvParams.add(addParam);
|
||||
|
||||
InFinishParam inFinishParam = new InFinishParam();
|
||||
inFinishParam.setPcsn("1");
|
||||
inFinishParam.setMaterialCode(material.getMaterial_code());
|
||||
inFinishParam.setStoragevehicleCode(dto.getVehicle_code());
|
||||
inFinishParam.setUnitName(material.getQty_unit_name());
|
||||
inFinishParam.setUnitId(material.getQty_unit_id());
|
||||
inFinishParam.setQty(qty);
|
||||
inFinishParam.setSectCode(structattr.getSect_code());
|
||||
inFinishParam.setStructCode(structattr.getStruct_code());
|
||||
inFinishParams.add(inFinishParam);
|
||||
//保存生产入库回传单定时回传
|
||||
JSONObject callbackInData = new JSONObject();
|
||||
callbackInData.put("method", "DealSCRKBill");
|
||||
callbackInData.put("type", "MES");
|
||||
// 组装data节点
|
||||
JSONObject dataIn = new JSONObject();
|
||||
dataIn.put("orgno", workOrder.getOrg_code());//库存组织
|
||||
dataIn.put("billno", workOrder.getOrder_code()); // 单据编号
|
||||
dataIn.put("biztype", "390");
|
||||
dataIn.put("invscheme", "001");
|
||||
dataIn.put("transtype", "024");
|
||||
dataIn.put("biztime", LocalDate.now());
|
||||
JSONArray entrysIn = new JSONArray();
|
||||
JSONObject entry = new JSONObject();
|
||||
entry.put("srcbillno", workOrder.getOrder_code());
|
||||
entry.put("srcbillid", workOrder.getOrder_id()); // 数量
|
||||
entry.put("srcbillentryid", workOrder.getOrder_id());
|
||||
entry.put("qty", item.getQty());
|
||||
entry.put("materialno", item.getMaterial_code());
|
||||
entrysIn.add(entry);
|
||||
dataIn.put("entrys", entrysIn);
|
||||
callbackInData.put("data", dataIn);
|
||||
PmStockReturn stockReturnIn = new PmStockReturn();
|
||||
stockReturnIn.setRequest_Id(workOrder.getOrder_code());
|
||||
stockReturnIn.setRequest_type(IOSEnum.BILL_TYPE.code("生产入库"));
|
||||
stockReturnIn.setStatus(StockReturnStatusEnum.TODO.getCode()); // 0-处理中
|
||||
stockReturnIn.setCreate_time(now);
|
||||
stockReturnIn.setRequest_data(callbackInData.toString());
|
||||
iPmStockReturnService.save(stockReturnIn);
|
||||
});
|
||||
ioStorInvMapper.insert(ioStorInvIn);
|
||||
ioStorInvDtlMapper.batchInsert(ioStorInvDtls);
|
||||
ioStorInvDisMapper.batchSave(iOStorInvDiss);
|
||||
iStInventoryService.changeInventory(InventoryChangeType.ADD_INV, addInvParams);
|
||||
iStInventoryService.changeInventory(InventoryChangeType.IN_FINISH, inFinishParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MdMeMaterialbase getMatByCode(String code) {
|
||||
if (StringUtils.isEmpty(code)){
|
||||
throw new BadRequestException("输入物料编码为空");
|
||||
}
|
||||
return iMdMeMaterialbaseService.getByCode(code);
|
||||
}
|
||||
|
||||
private Map<String,Object> parseCode(String code){
|
||||
String[] parts = code.split("#", -1);
|
||||
log.info("采购单入库条码解析结果:{}", Arrays.toString(parts));
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package org.nl.wms.pm_manage.demand.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import org.nl.common.base.ResponseData;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.pm_manage.demand.service.IPmDemandPlatingService;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.*;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/pmDemandPlating")
|
||||
@SaIgnore
|
||||
public class PmDemandPlatingController {
|
||||
|
||||
@Resource
|
||||
private IPmDemandPlatingService pmDemandService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询需求单")
|
||||
public ResponseEntity<Object> queryAll(PmDemandQuery query, PageQuery page) {
|
||||
return ResponseData.build(pmDemandService.queryPage(query, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增需求单")
|
||||
public ResponseEntity<Object> create(@Valid @RequestBody PmDemandParam param) {
|
||||
pmDemandService.create(param);
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改需求单")
|
||||
public ResponseEntity<Object> update(@Valid @RequestBody PmDemandDto param) {
|
||||
pmDemandService.update(param);
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除需求单")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
|
||||
List<String> idList = Arrays.asList(ids);
|
||||
pmDemandService.deleteByIds(idList);
|
||||
return ResponseData.build();
|
||||
}
|
||||
@GetMapping("/queryInventory")
|
||||
@Log("根据需求单查询所有库存信息")
|
||||
public ResponseEntity<List<DemandInventryDto>> queryInventory(String skuCode) {
|
||||
return ResponseData.build(pmDemandService.queryInventory(skuCode), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/allocate")
|
||||
@Log("库存分配")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<Object> allocateInventory(@RequestBody PmDemandDto demand) {
|
||||
pmDemandService.allocateInventory(demand.getId(), demand.getInventoryDis());
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("/batchAllocate")
|
||||
@Log("批量分配仓库")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<Object> batchAllocate(@RequestBody BatchAllocateParam param) {
|
||||
pmDemandService.batchAllocateInventory(param.getIds(), param.getInventoryDis());
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("/push")
|
||||
@Log("需求单下发")
|
||||
public ResponseEntity<Object> push(@RequestBody List<PmDemandDto> pmDemandDtos) {
|
||||
pmDemandService.pushDemand(pmDemandDtos);
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PutMapping("/issueReturnBill")
|
||||
@Log("强制回传EAS")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<Object> issueReturnBill(@RequestBody Set<String> ids) {
|
||||
pmDemandService.issueReturnBill(ids);
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("/autoAllcation")
|
||||
@Log("自动分配需求单")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<Object> autoAllcation(@RequestBody Set<String> ids) {
|
||||
pmDemandService.autoAllcation(ids);
|
||||
return ResponseData.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.nl.wms.pm_manage.demand.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.pm_manage.demand.service.dao.PmDemandPlating;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.DemandInventryDto;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandDto;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandParam;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandQuery;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface IPmDemandPlatingService extends IService<PmDemandPlating> {
|
||||
|
||||
Page<PmDemandDto> queryPage(PmDemandQuery query, PageQuery pageQuery);
|
||||
|
||||
void create(PmDemandParam param);
|
||||
void batchCreate(List<PmDemandParam> param);
|
||||
|
||||
void update(PmDemandDto param);
|
||||
|
||||
void deleteByIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据需求单查询库存信息
|
||||
* @param skuCode
|
||||
* @return
|
||||
*/
|
||||
List<DemandInventryDto> queryInventory(String skuCode);
|
||||
|
||||
/**
|
||||
* 库存分配
|
||||
* @param id
|
||||
* @param inventoryDis
|
||||
*/
|
||||
void allocateInventory(String id, String inventoryDis);
|
||||
|
||||
/**
|
||||
* 批量分配仓库
|
||||
* @param ids 需求单ID列表
|
||||
* @param inventoryDis 分配仓库JSON
|
||||
*/
|
||||
void batchAllocateInventory(List<String> ids, String inventoryDis);
|
||||
|
||||
/**
|
||||
* 推送需求单
|
||||
* 1.需求单分配出库仓库
|
||||
* 2。如果分配给中鼎则直接将需求单推送给中鼎WMS,如果有这边出库则在WMS上生成出库单,有操作人点击自动分配,分配库存
|
||||
* 3。一个物料可能存在多个仓库,如果是平库则不生成AGV任务,如果是高架库则分配完自动生成AGV任务
|
||||
* 4。当前
|
||||
* @param pmDemandDto
|
||||
*/
|
||||
void pushDemand(List<PmDemandDto> pmDemandDto);
|
||||
void issueReturnBill(Set<String> ids);
|
||||
void autoAllcation(Set<String> ids);
|
||||
}
|
||||
@@ -70,6 +70,7 @@ public class PmDemand extends Model<PmDemand> {
|
||||
|
||||
private String lk_container;
|
||||
private String max_load;
|
||||
private String warehouse_code;
|
||||
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package org.nl.wms.pm_manage.demand.service.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("pm_demand_plating")
|
||||
public class PmDemandPlating extends Model<PmDemandPlating> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private String id;
|
||||
|
||||
private String creator;
|
||||
|
||||
@TableField("create_time")
|
||||
private String create_time;
|
||||
|
||||
private Integer priority;
|
||||
|
||||
private String status;
|
||||
private String seq_no;
|
||||
|
||||
@TableField("work_order")
|
||||
private String work_order;
|
||||
|
||||
@TableField("sku_code")
|
||||
private String sku_code;
|
||||
|
||||
@TableField("sku_name")
|
||||
private String sku_name;
|
||||
|
||||
private BigDecimal qty;
|
||||
private BigDecimal assign_qty;
|
||||
|
||||
private String unit;
|
||||
|
||||
@TableField("target_area")
|
||||
private String target_area;
|
||||
|
||||
@TableField("target_house_code")
|
||||
private String target_house_code;
|
||||
|
||||
@TableField("carrier_type")
|
||||
private String carrier_type;
|
||||
|
||||
@TableField("production_line")
|
||||
private String production_line;
|
||||
|
||||
@TableField("is_deleted")
|
||||
private Integer is_deleted;
|
||||
|
||||
private String sn;
|
||||
|
||||
@TableField("create_at")
|
||||
private String create_at;
|
||||
|
||||
@TableField("inventory_dis")
|
||||
private String inventory_dis;
|
||||
|
||||
private String lk_container;
|
||||
private String max_load;
|
||||
private String warehouse_code;
|
||||
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.nl.wms.pm_manage.demand.service.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.nl.wms.pm_manage.demand.service.dao.PmDemandPlating;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandDto;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PmDemandPlatingMapper extends BaseMapper<PmDemandPlating> {
|
||||
|
||||
List<PmDemandDto> queryPage(@Param("query") PmDemandQuery query);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.wms.pm_manage.demand.service.dao.mapper.PmDemandPlatingMapper">
|
||||
|
||||
<resultMap id="DemandDtoMap" type="org.nl.wms.pm_manage.demand.service.dto.PmDemandDto">
|
||||
<result property="id" column="id"/>
|
||||
<result property="creator" column="creator"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="priority" column="priority"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="seqNo" column="seq_no"/>
|
||||
<result property="workOrder" column="work_order"/>
|
||||
<result property="skuCode" column="sku_code"/>
|
||||
<result property="skuName" column="sku_name"/>
|
||||
<result property="qty" column="qty"/>
|
||||
<result property="assignQty" column="assign_qty"/>
|
||||
<result property="unit" column="unit"/>
|
||||
<result property="targetArea" column="target_area"/>
|
||||
<result property="targetHouseCode" column="target_house_code"/>
|
||||
<result property="carrierType" column="carrier_type"/>
|
||||
<result property="isDeleted" column="is_deleted"/>
|
||||
<result property="productionLine" column="production_line"/>
|
||||
<result property="sn" column="sn"/>
|
||||
<result property="createAt" column="create_at"/>
|
||||
<result property="inventoryDis" column="inventory_dis"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="queryPage" resultMap="DemandDtoMap">
|
||||
select d.*,g.qty pkInv
|
||||
from pm_demand_plating d
|
||||
left join md_pb_groupplate g on d.sku_code = g.material_code and g.storagevehicle_code = 'VTP0006'
|
||||
where 1 = 1
|
||||
<if test="query.status == 90">
|
||||
and is_deleted = 1
|
||||
</if>
|
||||
<if test="query.status != 90">
|
||||
and is_deleted = 0
|
||||
</if>
|
||||
<if test="query.id != null and query.id != ''">
|
||||
and d.id = #{query.id}
|
||||
</if>
|
||||
<if test="query.creator != null and query.creator != ''">
|
||||
and d.creator like concat('%', #{query.creator}, '%')
|
||||
</if>
|
||||
<if test="query.status != null">
|
||||
and d.status = #{query.status}
|
||||
</if>
|
||||
<if test="query.workOrder != null and query.workOrder != ''">
|
||||
and d.work_order like concat('%', #{query.workOrder}, '%')
|
||||
</if>
|
||||
<if test="query.skuCode != null and query.skuCode != ''">
|
||||
and (d.sku_code like concat('%', #{query.skuCode}, '%') or d.sku_name like concat('%', #{query.skuCode}, '%'))
|
||||
</if>
|
||||
<if test="query.productionLine != null and query.productionLine != ''">
|
||||
and d.production_line like concat('%', #{query.productionLine}, '%')
|
||||
</if>
|
||||
<if test="query.targetArea != null and query.targetArea != ''">
|
||||
and d.target_area like concat('%', #{query.targetArea}, '%')
|
||||
</if>
|
||||
<if test="query.startTime != null and query.startTime != ''">
|
||||
and d.create_time >= #{query.startTime}
|
||||
</if>
|
||||
<if test="query.endTime != null and query.endTime != ''">
|
||||
and d.create_time <= #{query.endTime}
|
||||
</if>
|
||||
order by d.seq_no asc,d.priority desc, d.create_time desc
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.wms.pm_manage.demand.service.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
@@ -14,53 +15,77 @@ import java.math.BigDecimal;
|
||||
*/
|
||||
@Data
|
||||
public class PmDemandParam {
|
||||
|
||||
@NotBlank(message = "单据唯一ID不能为空")
|
||||
@JsonProperty("Id")
|
||||
private String id;
|
||||
|
||||
@NotBlank(message = "操作人不能为空")
|
||||
@JsonProperty("Creator")
|
||||
private String creator;
|
||||
|
||||
@NotBlank(message = "需求日期不能为空")
|
||||
@JsonProperty("CreateTime")
|
||||
private String createTime;
|
||||
|
||||
@NotNull(message = "优先级不能为空")
|
||||
@JsonProperty("Priority")
|
||||
private Integer priority;
|
||||
|
||||
@JsonProperty("Status")
|
||||
private String status;
|
||||
|
||||
@JsonProperty("SeqNo")
|
||||
private String seqNo;
|
||||
|
||||
@NotBlank(message = "工单编号不能为空")
|
||||
@JsonProperty("WorkOrder")
|
||||
private String workOrder;
|
||||
|
||||
@NotBlank(message = "物料编码不能为空")
|
||||
@JsonProperty("SkuCode")
|
||||
private String skuCode;
|
||||
|
||||
@NotBlank(message = "物料名称不能为空")
|
||||
@JsonProperty("SkuName")
|
||||
private String skuName;
|
||||
|
||||
@NotNull(message = "数量不能为空")
|
||||
@DecimalMin(value = "0", inclusive = false, message = "数量必须大于0")
|
||||
@JsonProperty("Qty")
|
||||
private BigDecimal qty;
|
||||
|
||||
@JsonProperty("SsignQty")
|
||||
private BigDecimal ssignQty;
|
||||
|
||||
@NotBlank(message = "单位不能为空")
|
||||
@JsonProperty("Unit")
|
||||
private String unit;
|
||||
|
||||
@NotBlank(message = "目标库存地点不能为空")
|
||||
@JsonProperty("TargetArea")
|
||||
private String targetArea;
|
||||
|
||||
@NotBlank(message = "产线不能为空")
|
||||
@JsonProperty("ProductionLine")
|
||||
private String productionLine;
|
||||
|
||||
@NotBlank(message = "目标库存地点不能为空")
|
||||
@JsonProperty("TargetHouseCode")
|
||||
private String targetHouseCode;
|
||||
|
||||
@NotBlank(message = "载具类型为空")
|
||||
@JsonProperty("CarrierType")
|
||||
private String carrierType;
|
||||
|
||||
@JsonProperty("MaxLoad")
|
||||
private String maxLoad;
|
||||
|
||||
@JsonProperty("WarehouseCode")
|
||||
private String warehouseCode;
|
||||
|
||||
@JsonProperty("SN")
|
||||
private String sn;
|
||||
@JsonProperty("IsSprayPart")
|
||||
private Boolean isSprayPart;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,501 @@
|
||||
package org.nl.wms.pm_manage.demand.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
|
||||
import org.nl.wms.basedata_manage.service.IStructattrService;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.basedata_manage.service.dao.Structattr;
|
||||
import org.nl.wms.ext_manage.api.MesApi;
|
||||
import org.nl.wms.ext_manage.enums.EXTConstant;
|
||||
import org.nl.wms.ext_manage.service.WmsToZDWmdService;
|
||||
import org.nl.wms.ext_manage.service.dto.ZDInventory;
|
||||
import org.nl.wms.pm_manage.demand.service.IPmDemandPlatingService;
|
||||
import org.nl.wms.pm_manage.demand.service.dao.PmDemandPlating;
|
||||
import org.nl.wms.pm_manage.demand.service.dao.mapper.PmDemandPlatingMapper;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.DemandInventryDto;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandDto;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandParam;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandQuery;
|
||||
import org.nl.wms.pm_manage.demand.service.enums.DemandStatus;
|
||||
import org.nl.wms.sch_manage.service.ISchBaseRegionService;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseRegion;
|
||||
import org.nl.wms.system_manage.service.param.ISysParamService;
|
||||
import org.nl.wms.system_manage.service.param.dao.Param;
|
||||
import org.nl.wms.warehouse_manage.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.IOutBillService;
|
||||
import org.nl.wms.warehouse_manage.inventory.IStInventoryService;
|
||||
import org.nl.wms.warehouse_manage.inventory.core.enums.InventoryChangeType;
|
||||
import org.nl.wms.warehouse_manage.inventory.core.param.impl.AddInvParam;
|
||||
import org.nl.wms.warehouse_manage.inventory.core.param.impl.InFinishParam;
|
||||
import org.nl.wms.warehouse_manage.inventory.dto.StInventoryDto;
|
||||
import org.nl.wms.warehouse_manage.inventory.dto.StInventoryQuery;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.dao.PmStockReturn;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.enums.StockReturnStatusEnum;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.nl.common.domain.query.PageQuery.trimStringFields;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class PmDemandPlatingServiceImpl extends ServiceImpl<PmDemandPlatingMapper, PmDemandPlating> implements IPmDemandPlatingService {
|
||||
@Autowired
|
||||
private IStInventoryService iStInventoryService;
|
||||
@Autowired
|
||||
private WmsToZDWmdService wmsToZDWmdService;
|
||||
@Autowired
|
||||
private IOutBillService iOutBillService;
|
||||
@Autowired
|
||||
private IMdMeMaterialbaseService iMdMeMaterialbaseService;
|
||||
@Autowired
|
||||
private ISysParamService iSysParamService;
|
||||
@Autowired
|
||||
private ISchBaseRegionService iSchBaseRegionService;
|
||||
|
||||
@Autowired
|
||||
private IStructattrService iStructattrService;
|
||||
|
||||
@Autowired
|
||||
private IPmStockReturnService iPmStockReturnService;
|
||||
@Autowired
|
||||
private MesApi mesApi;
|
||||
|
||||
@Override
|
||||
public Page<PmDemandDto> queryPage(PmDemandQuery query, PageQuery pageQuery) {
|
||||
trimStringFields(query);
|
||||
com.github.pagehelper.Page<Object> page = PageHelper.startPage(pageQuery.getPage() + 1, pageQuery.getSize());
|
||||
page.setOrderBy("priority desc, create_time desc");
|
||||
List<PmDemandDto> records = this.baseMapper.queryPage(query);
|
||||
Page<PmDemandDto> dtoPage = new Page<>(page.getPageNum(), page.getPageSize(), page.getTotal());
|
||||
dtoPage.setRecords(records);
|
||||
return dtoPage;
|
||||
}
|
||||
@Override
|
||||
public void create(PmDemandParam param) {
|
||||
PmDemandPlating demand = new PmDemandPlating();
|
||||
demand.setId(param.getId());
|
||||
demand.setCreator(param.getCreator());
|
||||
demand.setCreate_time(param.getCreateTime());
|
||||
demand.setPriority(param.getPriority());
|
||||
demand.setStatus(param.getStatus());
|
||||
demand.setSeq_no(param.getSeqNo());
|
||||
demand.setWork_order(param.getWorkOrder());
|
||||
demand.setSku_code(param.getSkuCode());
|
||||
demand.setSku_name(param.getSkuName());
|
||||
demand.setQty(param.getQty());
|
||||
demand.setUnit(param.getUnit());
|
||||
demand.setTarget_area(param.getTargetArea());
|
||||
demand.setTarget_house_code(param.getTargetHouseCode());
|
||||
demand.setCarrier_type(param.getCarrierType());
|
||||
demand.setProduction_line(param.getProductionLine());
|
||||
demand.setSn(param.getSn());
|
||||
demand.setIs_deleted(0);
|
||||
demand.setCreate_at(DateUtil.now());
|
||||
demand.setMax_load(param.getMaxLoad());
|
||||
demand.setStatus("01");
|
||||
demand.setInventory_dis("6.005");
|
||||
this.save(demand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchCreate(List<PmDemandParam> param) {
|
||||
final List<String> orders = param.stream()
|
||||
.filter(item-> !Objects.equals(item.getStatus(), "1"))
|
||||
.map(PmDemandParam::getWorkOrder).collect(Collectors.toList());
|
||||
if (!orders.isEmpty()){
|
||||
final int count = this.count(new LambdaQueryWrapper<PmDemandPlating>()
|
||||
.in(PmDemandPlating::getWork_order, orders)
|
||||
.eq(PmDemandPlating::getIs_deleted,0));
|
||||
if (count>0){
|
||||
throw new BadRequestException("MES推送需求单失败,需求单已存在");
|
||||
}
|
||||
}
|
||||
for (PmDemandParam pmDemandParam : param) {
|
||||
if (StringUtils.isEmpty(pmDemandParam.getTargetHouseCode())){
|
||||
throw new BadRequestException("目标库位为空!");
|
||||
}
|
||||
if (Objects.equals(pmDemandParam.getStatus(), "1")){
|
||||
pmDemandParam.setStatus(DemandStatus.CANCEL.getValue());
|
||||
PmDemandPlating demand = new PmDemandPlating();
|
||||
demand.setId(pmDemandParam.getId());
|
||||
demand.setCreator(pmDemandParam.getCreator());
|
||||
demand.setCreate_time(pmDemandParam.getCreateTime());
|
||||
demand.setPriority(pmDemandParam.getPriority());
|
||||
demand.setStatus(pmDemandParam.getStatus());
|
||||
demand.setSeq_no(pmDemandParam.getSeqNo());
|
||||
demand.setWork_order(pmDemandParam.getWorkOrder());
|
||||
demand.setSku_code(pmDemandParam.getSkuCode());
|
||||
demand.setSku_name(pmDemandParam.getSkuName());
|
||||
demand.setQty(pmDemandParam.getQty());
|
||||
demand.setUnit(pmDemandParam.getUnit());
|
||||
demand.setTarget_area(pmDemandParam.getTargetArea());
|
||||
demand.setProduction_line(pmDemandParam.getProductionLine());
|
||||
demand.setSn(pmDemandParam.getSn());
|
||||
demand.setMax_load(pmDemandParam.getMaxLoad());
|
||||
demand.setStatus("01");
|
||||
demand.setInventory_dis("6.005");
|
||||
this.updateById(demand);
|
||||
}else{
|
||||
this.create(pmDemandParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void update(PmDemandDto param) {
|
||||
PmDemandPlating dbDemand = this.getById(param.getId());
|
||||
if (dbDemand == null) {
|
||||
throw new BadRequestException("需求单不存在");
|
||||
}
|
||||
PmDemandPlating demand = new PmDemandPlating();
|
||||
demand.setId(param.getId());
|
||||
demand.setCreator(param.getCreator());
|
||||
demand.setCreate_time(param.getCreateTime());
|
||||
demand.setPriority(param.getPriority());
|
||||
demand.setStatus(param.getStatus());
|
||||
demand.setWork_order(param.getWorkOrder());
|
||||
demand.setSku_code(param.getSkuCode());
|
||||
demand.setSku_name(param.getSkuName());
|
||||
demand.setQty(param.getQty());
|
||||
demand.setAssign_qty(param.getAssignQty());
|
||||
demand.setUnit(param.getUnit());
|
||||
demand.setTarget_area(param.getTargetArea());
|
||||
demand.setProduction_line(param.getProductionLine());
|
||||
demand.setSn(param.getSn());
|
||||
demand.setCreate_at(dbDemand.getCreate_at());
|
||||
this.updateById(demand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(List<String> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
final List<PmDemandPlating> pmDemands = this.listByIds(ids);
|
||||
for (PmDemandPlating pmDemand : pmDemands) {
|
||||
if (!pmDemand.getStatus().equals(DemandStatus.CREATE.getValue())
|
||||
&& !pmDemand.getStatus().equals(DemandStatus.DIS.getValue())){
|
||||
throw new BadRequestException("删除失败,已经执行的需求单无法删除");
|
||||
}
|
||||
}
|
||||
for (String id : ids) {
|
||||
mesApi.delMesDemand(id);
|
||||
this.update(new LambdaUpdateWrapper<PmDemandPlating>()
|
||||
.eq(PmDemandPlating::getId,id)
|
||||
.set(PmDemandPlating::getStatus, DemandStatus.CANCEL.getValue())
|
||||
.set(PmDemandPlating::getIs_deleted,1));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void allocateInventory(String id, String inventoryDis) {
|
||||
PmDemandPlating demand = this.getById(id);
|
||||
if (demand == null) {
|
||||
throw new BadRequestException("需求单不存在");
|
||||
}
|
||||
if (Objects.equals(demand.getStatus(), DemandStatus.FINISH.getValue())){
|
||||
throw new BadRequestException("单据已完成不允许分配");
|
||||
}
|
||||
demand.setInventory_dis(inventoryDis);
|
||||
demand.setStatus(DemandStatus.DIS.getValue());
|
||||
this.updateById(demand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchAllocateInventory(List<String> ids, String inventoryDis) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
throw new BadRequestException("请选择需求单");
|
||||
}
|
||||
List<PmDemandPlating> demands = this.listByIds(ids);
|
||||
if (CollectionUtils.isEmpty(demands)) {
|
||||
throw new BadRequestException("需求单不存在");
|
||||
}
|
||||
for (PmDemandPlating demand : demands) {
|
||||
if (!"0".equals(demand.getStatus())) {
|
||||
throw new BadRequestException("仅支持对生成状态的需求单进行批量分配");
|
||||
}
|
||||
}
|
||||
this.update(new LambdaUpdateWrapper<PmDemandPlating>()
|
||||
.set(PmDemandPlating::getInventory_dis, inventoryDis)
|
||||
.set(PmDemandPlating::getStatus, DemandStatus.DIS.getValue())
|
||||
.in(PmDemandPlating::getId, ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DemandInventryDto> queryInventory(String skuCode) {
|
||||
List<DemandInventryDto> resultList = new ArrayList<>();
|
||||
List<StInventoryDto> inventoryDtos = iStInventoryService.queryInventory(StInventoryQuery.builder().materialCode(skuCode).build());
|
||||
if (!CollectionUtils.isEmpty(inventoryDtos)) {
|
||||
for (StInventoryDto dto : inventoryDtos) {
|
||||
DemandInventryDto demandDto = new DemandInventryDto();
|
||||
demandDto.setSkuCode(dto.getMaterialCode());
|
||||
demandDto.setQty(dto.getQty());
|
||||
demandDto.setHouseCode(dto.getStorCode());
|
||||
demandDto.setHouseName(dto.getStorName());
|
||||
resultList.add(demandDto);
|
||||
}
|
||||
}else {
|
||||
DemandInventryDto demandDto = new DemandInventryDto();
|
||||
demandDto.setSkuCode(skuCode);
|
||||
demandDto.setQty(BigDecimal.ZERO);
|
||||
demandDto.setHouseCode("6.011");
|
||||
demandDto.setHouseName("'五期装配原材料平库'");
|
||||
}
|
||||
ResponseEntity<List<ZDInventory>> responseEntity = wmsToZDWmdService.queryInventory(skuCode);
|
||||
List<ZDInventory> zdInventorys = responseEntity.getBody();
|
||||
if (!CollectionUtils.isEmpty(zdInventorys)) {
|
||||
for (ZDInventory item : zdInventorys) {
|
||||
DemandInventryDto demandDto = new DemandInventryDto();
|
||||
demandDto.setSkuCode(item.getSkuCode());
|
||||
demandDto.setSkuName(null);
|
||||
demandDto.setQty(item.getQty());
|
||||
//中鼎库存有映射
|
||||
String houseMapping = WmsToZDWmdService.ZD_LOS_MAPPING.get(item.getHouseCode());
|
||||
if (StringUtils.isEmpty(houseMapping)){
|
||||
throw new BadRequestException("分配失败,当前中鼎仓库编码未配置映射");
|
||||
}
|
||||
demandDto.setHouseCode(houseMapping);
|
||||
demandDto.setHouseName("五期原材料立库6.002");
|
||||
resultList.add(demandDto);
|
||||
}
|
||||
}else {
|
||||
DemandInventryDto demandDto = new DemandInventryDto();
|
||||
demandDto.setSkuCode(skuCode);
|
||||
demandDto.setSkuName(null);
|
||||
demandDto.setQty(BigDecimal.ZERO);
|
||||
demandDto.setHouseCode("6.002");
|
||||
demandDto.setHouseName("五期原材料立库6.002");
|
||||
resultList.add(demandDto);
|
||||
}
|
||||
return resultList.stream().filter(i-> !i.getHouseName().contains("线边库")).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void pushDemand(List<PmDemandDto> pmDemandDtos) {
|
||||
if (CollectionUtils.isEmpty(pmDemandDtos)){
|
||||
throw new BadRequestException("下推失败,请求数据不能为空");
|
||||
}
|
||||
if (pmDemandDtos.stream().anyMatch(i -> !Objects.equals(i.getStatus(), "01"))){
|
||||
throw new BadRequestException("单据不为已分配状态不能下推");
|
||||
}
|
||||
// 一次性分成两组
|
||||
Param zdStorParam = iSysParamService.findByCode(EXTConstant.ZD_STOR_SET);
|
||||
List ZD_STOR_SET;
|
||||
if (zdStorParam!=null){
|
||||
ZD_STOR_SET = JSONObject.parseObject(zdStorParam.getValue(), List.class);
|
||||
} else {
|
||||
ZD_STOR_SET = new ArrayList<>();
|
||||
}
|
||||
Map<Boolean, List<PmDemandDto>> partitioned = pmDemandDtos.stream()
|
||||
.collect(Collectors.partitioningBy(a -> ZD_STOR_SET
|
||||
.contains(a.getInventoryDis())));
|
||||
List<PmDemandDto> zdDemands = partitioned.get(true);
|
||||
List<PmDemandDto> otherDemands = partitioned.get(false);
|
||||
if (!CollectionUtils.isEmpty(otherDemands)) {
|
||||
JSONObject billParam = convertDemandsToBillParam(otherDemands);
|
||||
iOutBillService.saveBill(billParam);
|
||||
this.update(new LambdaUpdateWrapper<PmDemandPlating>()
|
||||
.set(PmDemandPlating::getStatus,DemandStatus.SEND.getValue())
|
||||
.in(PmDemandPlating::getId,otherDemands.stream()
|
||||
.map(PmDemandDto::getId).collect(Collectors.toList())));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(zdDemands)) {
|
||||
Map<String, List<PmDemandDto>> groupByWorkOrder = zdDemands.stream()
|
||||
.collect(Collectors.groupingBy(PmDemandDto::getWorkOrder));
|
||||
//判断是否存在其他工单的数据是则保存
|
||||
for (String workOrder : groupByWorkOrder.keySet()) {
|
||||
final List<PmDemandDto> demandDtos = groupByWorkOrder.get(workOrder);
|
||||
final int orderCount = this.count(new LambdaQueryWrapper<PmDemandPlating>()
|
||||
.eq(PmDemandPlating::getWork_order, workOrder)
|
||||
.in(PmDemandPlating::getInventory_dis, ZD_STOR_SET)
|
||||
.ne(PmDemandPlating::getIs_deleted, 1));
|
||||
if (orderCount > demandDtos.size()){
|
||||
throw new BadRequestException("工单"+workOrder+"下推中鼎失败,存在未勾选的单子");
|
||||
}
|
||||
List<PmDemandDto> zd = new ArrayList<>();
|
||||
List<AddInvParam> addInvParams = new ArrayList<>();
|
||||
List<InFinishParam> inFinishParams = new ArrayList<>();
|
||||
for (PmDemandDto zdDemand : demandDtos) {
|
||||
Structattr structattr = iStructattrService.getOne(new LambdaQueryWrapper<Structattr>()
|
||||
.eq(Structattr::getSect_code, zdDemand.getTargetHouseCode())
|
||||
.isNotNull(Structattr::getStoragevehicle_code)
|
||||
.last("limit 1"));
|
||||
AddInvParam addInvParam = new AddInvParam();
|
||||
addInvParam.setMaterialCode(zdDemand.getSkuCode());
|
||||
addInvParam.setUnitId("1");
|
||||
addInvParam.setUnitName(zdDemand.getUnit());
|
||||
addInvParam.setPcsn("1");
|
||||
addInvParam.setStoragevehicleCode(structattr.getStoragevehicle_code());
|
||||
addInvParam.setQty(zdDemand.getQty());
|
||||
addInvParam.setStorCode(structattr.getStor_code());
|
||||
addInvParam.setSectCode(structattr.getSect_code());
|
||||
addInvParam.setStructCode(structattr.getStruct_code());
|
||||
addInvParam.setRemark("中鼎需求单变动");
|
||||
addInvParams.add(addInvParam);
|
||||
InFinishParam inFinishParam = new InFinishParam();
|
||||
BeanUtils.copyProperties(addInvParam,inFinishParam);
|
||||
inFinishParams.add(inFinishParam);
|
||||
zd.add(zdDemand);
|
||||
}
|
||||
wmsToZDWmdService.syncDemandOrder(zd);
|
||||
try {
|
||||
iStInventoryService.changeInventory(InventoryChangeType.ADD_INV, addInvParams);
|
||||
iStInventoryService.changeInventory(InventoryChangeType.IN_FINISH, inFinishParams);
|
||||
this.update(new LambdaUpdateWrapper<PmDemandPlating>()
|
||||
.set(PmDemandPlating::getStatus,DemandStatus.FINISH.getValue())
|
||||
.in(PmDemandPlating::getId,demandDtos.stream()
|
||||
.map(PmDemandDto::getId).collect(Collectors.toList())));
|
||||
}catch (Exception ex){
|
||||
log.error("回传中鼎成功,WMS库存变动失败"+ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private JSONObject convertDemandsToBillParam(List<PmDemandDto> demands) {
|
||||
if (CollectionUtils.isEmpty(demands)) {
|
||||
throw new BadRequestException("需求单数据为空");
|
||||
}
|
||||
|
||||
PmDemandDto firstDemand = demands.get(0);
|
||||
|
||||
JSONObject billParam = new JSONObject();
|
||||
billParam.put("stor_code", firstDemand.getInventoryDis());
|
||||
billParam.put("biz_date", DateUtil.today());
|
||||
billParam.put("bill_type", IOSEnum.BILL_TYPE.code("库存调拨"));
|
||||
billParam.put("remark", "需求单下推生成");
|
||||
|
||||
List<JSONObject> tableData = new ArrayList<>();
|
||||
//查询物料id;
|
||||
final List<MdMeMaterialbase> materialbases = iMdMeMaterialbaseService
|
||||
.list(new LambdaQueryWrapper<MdMeMaterialbase>()
|
||||
.in(MdMeMaterialbase::getMaterial_code,
|
||||
demands.stream().map(PmDemandDto::getSkuCode).collect(Collectors.toList()))
|
||||
.select(MdMeMaterialbase::getQty_unit_id,MdMeMaterialbase::getMaterial_id, MdMeMaterialbase::getMaterial_code));
|
||||
Map<String, MdMeMaterialbase> codeToIdMap = materialbases.stream()
|
||||
.collect(Collectors.toMap(
|
||||
MdMeMaterialbase::getMaterial_code, Function.identity()));
|
||||
for (PmDemandDto demand : demands) {
|
||||
JSONObject detailRow = new JSONObject();
|
||||
detailRow.put("material_code", demand.getSkuCode());
|
||||
MdMeMaterialbase materialbase = codeToIdMap.get(demand.getSkuCode());
|
||||
if (materialbase == null){
|
||||
throw new BadRequestException("下推失败,"+demand.getSkuCode()+"在WMS中不存在");
|
||||
}
|
||||
detailRow.put("material_id", materialbase.getMaterial_id());
|
||||
detailRow.put("qty_unit_name", demand.getUnit());
|
||||
detailRow.put("qty_unit_id", codeToIdMap.get(demand.getSkuCode()).getQty_unit_id());
|
||||
detailRow.put("qty", demand.getQty());
|
||||
detailRow.put("source_bill_code", demand.getId());
|
||||
//走调拨回传
|
||||
detailRow.put("callback_strategy", "DealLLDBBillPmDeamndPlatingCallBack");
|
||||
detailRow.put("source_bill_type", "需求单");
|
||||
detailRow.put("source_billdtl_id", demand.getId());
|
||||
detailRow.put("source_bill_table", "pm_demand");
|
||||
detailRow.put("remark", "关联工单:" + demand.getWorkOrder());
|
||||
detailRow.put("load_port", demand.getTargetArea());
|
||||
detailRow.put("vehicle_type", demand.getCarrierType());
|
||||
tableData.add(detailRow);
|
||||
}
|
||||
billParam.put("tableData", tableData);
|
||||
return billParam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void issueReturnBill(Set<String> ids) {
|
||||
final List<PmDemandPlating> pmDemands = this.listByIds(ids);
|
||||
if (ObjectUtil.isEmpty(pmDemands)) {
|
||||
throw new BadRequestException("未找到选中的单据");
|
||||
}
|
||||
JSONObject callbackData = new JSONObject();
|
||||
callbackData.put("method", "DealLLDBBill");
|
||||
callbackData.put("type", "WMS");
|
||||
final String uuidBill = UUID.randomUUID().toString();
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("issueStorageOrgUnitNo", "01.09.14"); // 业务状态,可根据实际业务逻辑设置
|
||||
data.put("bizTypeNo", "331"); // 业务日期
|
||||
data.put("receiptStorageOrgUnitNo", "01.09.14"); // 创建人编号,从当前登录用户获取
|
||||
data.put("billNo", uuidBill); // 使用工单编号作为MES单号
|
||||
// 组装明细列表
|
||||
JSONArray entrys = new JSONArray();
|
||||
for (PmDemandPlating pmDemand : pmDemands) {
|
||||
final SchBaseRegion region = iSchBaseRegionService.getOne(new LambdaQueryWrapper<SchBaseRegion>()
|
||||
.eq(SchBaseRegion::getRegion_code, pmDemand.getProduction_line())
|
||||
.select(SchBaseRegion::getPoint_type_explain));
|
||||
if (region==null){
|
||||
throw new BadRequestException("当前产线未配置对应仓库编码getPoint_type_explain");
|
||||
}
|
||||
cn.hutool.json.JSONObject entry = new cn.hutool.json.JSONObject();
|
||||
entry.put("unitNo", "PCS"); // 序号
|
||||
entry.put("qty", pmDemand.getQty()); // 数量
|
||||
entry.put("materialNo", pmDemand.getSku_code()); // 来源单据标识
|
||||
entry.put("issueWarehouseNo", pmDemand.getInventory_dis());
|
||||
entry.put("receiptWarehouseNo", region.getPoint_type_explain());
|
||||
entrys.add(entry);
|
||||
}
|
||||
data.put("entrys", entrys);
|
||||
callbackData.put("data", data);
|
||||
PmStockReturn stockReturn = new PmStockReturn();
|
||||
stockReturn.setRequest_Id(uuidBill);
|
||||
stockReturn.setRequest_type(IOSEnum.BILL_TYPE.code("库存调拨"));
|
||||
stockReturn.setStatus(StockReturnStatusEnum.TODO.getCode()); // 0-处理中
|
||||
stockReturn.setCreate_time(DateUtil.now());
|
||||
stockReturn.setRequest_data(callbackData.toString());
|
||||
iPmStockReturnService.save(stockReturn);
|
||||
this.update(new LambdaUpdateWrapper<PmDemandPlating>()
|
||||
.set(PmDemandPlating::getStatus,DemandStatus.FINISH.getValue())
|
||||
.in(PmDemandPlating::getId,ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autoAllcation(Set<String> ids) {
|
||||
final List<PmDemandPlating> pmDemands = this.listByIds(ids);
|
||||
final List<PmDemandPlating> needAllcation = new ArrayList<>();
|
||||
for (PmDemandPlating pmDemand : pmDemands) {
|
||||
if (!pmDemand.getStatus().equals(DemandStatus.CREATE.getValue())){
|
||||
throw new BadRequestException("当前单子"+pmDemand.getWork_order()+"不是生成状态无法勾选");
|
||||
}
|
||||
final List<DemandInventryDto> demandInventryDtos = this.queryInventory(pmDemand.getSku_code());
|
||||
final Map<String, DemandInventryDto> inventryDtoMap = demandInventryDtos.stream().collect(Collectors.toMap(DemandInventryDto::getHouseCode, Function.identity()));
|
||||
final DemandInventryDto demandInventryDto = inventryDtoMap.get("6.002");
|
||||
final DemandInventryDto pInventryDto = inventryDtoMap.get("6.011");
|
||||
if (demandInventryDto !=null && demandInventryDto.getQty()!=null && demandInventryDto.getQty().compareTo(pmDemand.getQty())>=0){
|
||||
pmDemand.setInventory_dis("6.002");
|
||||
pmDemand.setStatus(DemandStatus.DIS.getValue());
|
||||
needAllcation.add(pmDemand);
|
||||
}else if (pInventryDto !=null && pInventryDto.getQty()!=null && pInventryDto.getQty().compareTo(pmDemand.getQty())>=0){
|
||||
pmDemand.setInventory_dis("6.011");
|
||||
pmDemand.setStatus(DemandStatus.DIS.getValue());
|
||||
}else {
|
||||
pmDemand.setInventory_dis("库存不足请手动分配");
|
||||
}
|
||||
needAllcation.add(pmDemand);
|
||||
}
|
||||
this.updateBatchById(needAllcation);
|
||||
}
|
||||
}
|
||||
@@ -322,13 +322,14 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
.map(PmDemandDto::getWorkOrder)
|
||||
.distinct()
|
||||
.collect(Collectors.toList()))
|
||||
.ne(PmDemand::getStatus, DemandStatus.FINISH.getValue())
|
||||
.ne(PmDemand::getIs_deleted, 1));
|
||||
if (pmDemandDtos.size() < allWorkDemand.size()) {
|
||||
// 统计 allWorkDemand 中每个工单的数量
|
||||
Map<String, Long> sourceCountMap = allWorkDemand.stream()
|
||||
.collect(Collectors.groupingBy(PmDemand::getWork_order, Collectors.counting()));
|
||||
|
||||
// 统计 pmDemandDtos 中每个工单的数量
|
||||
// 统计 pmDemandDtos 中每个工单的数量
|
||||
Map<String, Long> targetCountMap = pmDemandDtos.stream()
|
||||
.collect(Collectors.groupingBy(PmDemandDto::getWorkOrder, Collectors.counting()));
|
||||
|
||||
@@ -339,7 +340,7 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
return !entry.getValue().equals(targetCount);
|
||||
})
|
||||
.map(Map.Entry::getKey)
|
||||
.collect(Collectors.joining(",\n"));
|
||||
.collect(Collectors.joining(","));
|
||||
throw new BadRequestException("存在未勾选完全的工单" + collect);
|
||||
}
|
||||
// 一次性分成两组
|
||||
|
||||
@@ -19,6 +19,7 @@ public class AddInvParam implements InventoryParam {
|
||||
private String unitName;
|
||||
private String unitId;
|
||||
private String remark;
|
||||
private String loadPort;
|
||||
|
||||
@Override
|
||||
public AddInvParam validation() {
|
||||
|
||||
@@ -61,7 +61,8 @@ public class StInventoryServiceImpl implements IStInventoryService {
|
||||
for (AddInvParam invParam : addInvParams) {
|
||||
LambdaQueryWrapper<GroupPlate> query = new QueryWrapper<GroupPlate>().lambda()
|
||||
.eq(GroupPlate::getStoragevehicle_code, invParam.getStoragevehicleCode())
|
||||
.eq(GroupPlate::getMaterial_code, invParam.getMaterialCode());
|
||||
.eq(GroupPlate::getMaterial_code, invParam.getMaterialCode())
|
||||
.eq(GroupPlate::getStatus, GROUP_PLATE_STATUS.code("入库"));
|
||||
if (!StringUtils.isEmpty(invParam.getPcsn())){
|
||||
query.eq(GroupPlate::getPcsn,invParam.getPcsn());
|
||||
}
|
||||
@@ -78,6 +79,7 @@ public class StInventoryServiceImpl implements IStInventoryService {
|
||||
.status(GROUP_PLATE_STATUS.code("入库"))
|
||||
.ext_code(invParam.getExtCode())
|
||||
.ext_type(invParam.getExtType())
|
||||
.load_port(invParam.getLoadPort())
|
||||
.create_id(SecurityUtils.getCurrentUserId())
|
||||
.create_name(SecurityUtils.getCurrentNickName())
|
||||
.create_time(DateUtil.now())
|
||||
|
||||
@@ -543,8 +543,8 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
||||
String reportParam = receiveOutReturn.getReportParam();
|
||||
WorkReportParam workReportParam = JSONObject.parseObject(reportParam, WorkReportParam.class);
|
||||
|
||||
mesReportService.workReportReturn(workReportParam);
|
||||
this.removeById(receiveOutReturn.getId());
|
||||
mesReportService.workReportReturn(workReportParam);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
package org.nl.wms.warehouse_manage.stockReturn.strategy.core.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.wms.basedata_manage.service.IStructattrService;
|
||||
import org.nl.wms.basedata_manage.service.dao.Structattr;
|
||||
import org.nl.wms.ext_manage.api.MesApi;
|
||||
import org.nl.wms.pm_manage.demand.service.IPmDemandPlatingService;
|
||||
import org.nl.wms.pm_manage.demand.service.dao.PmDemandPlating;
|
||||
import org.nl.wms.pm_manage.demand.service.enums.DemandStatus;
|
||||
import org.nl.wms.sch_manage.service.ISchBaseRegionService;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseRegion;
|
||||
import org.nl.wms.warehouse_manage.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInvDtl;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvDisMapper;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dto.IOStorInvDisDto;
|
||||
import org.nl.wms.warehouse_manage.inventory.IStInventoryService;
|
||||
import org.nl.wms.warehouse_manage.inventory.core.enums.InventoryChangeType;
|
||||
import org.nl.wms.warehouse_manage.inventory.core.param.impl.AddInvParam;
|
||||
import org.nl.wms.warehouse_manage.inventory.core.param.impl.InFinishParam;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.dao.PmStockReturn;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.enums.StockReturnStatusEnum;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.strategy.core.CallbackStrategy;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 需求单库存调拨回传
|
||||
*/
|
||||
@Service(value = "DealLLDBBillPmDeamndPlatingCallBack")
|
||||
@Slf4j
|
||||
public class DealLLDBBillPmDeamndPlatingCallBack implements CallbackStrategy {
|
||||
|
||||
@Autowired
|
||||
private IPmDemandPlatingService iPmDemandService;
|
||||
@Autowired
|
||||
private IPmStockReturnService iPmStockReturnService;
|
||||
@Resource
|
||||
private IOStorInvDisMapper ioStorInvDisMapper;
|
||||
@Autowired
|
||||
private ISchBaseRegionService iSchBaseRegionService;
|
||||
@Autowired
|
||||
private IStructattrService iStructattrService;
|
||||
@Autowired
|
||||
private IStInventoryService iStInventoryService;
|
||||
@Autowired
|
||||
private MesApi mesApi;
|
||||
|
||||
@Override
|
||||
public void buildCallback(IOStorInvDtl param) {
|
||||
final String orderCode = param.getSource_bill_code();
|
||||
PmDemandPlating one = iPmDemandService.getOne(new LambdaQueryWrapper<PmDemandPlating>().eq(PmDemandPlating::getId, orderCode));
|
||||
if (one == null){
|
||||
throw new BadRequestException("需求单不存在");
|
||||
}
|
||||
final SchBaseRegion region = iSchBaseRegionService.getOne(new LambdaQueryWrapper<SchBaseRegion>()
|
||||
.eq(SchBaseRegion::getRegion_code, one.getProduction_line())
|
||||
.select(SchBaseRegion::getPoint_type_explain));
|
||||
if (region==null){
|
||||
throw new BadRequestException("当前产线未配置对应仓库编码getPoint_type_explain");
|
||||
}
|
||||
//更新库存,查询托盘
|
||||
final Structattr targetAttr = iStructattrService.getOne(new LambdaQueryWrapper<Structattr>()
|
||||
.eq(Structattr::getSect_code, region.getPoint_type_explain()));
|
||||
if (targetAttr ==null ||StringUtils.isEmpty(targetAttr.getStoragevehicle_code())){
|
||||
throw new BadRequestException("调拨失败,当前调拨目标区域缺少仓库熟悉"+targetAttr.getStruct_code());
|
||||
}
|
||||
List<AddInvParam> addInvParams = new ArrayList<>();
|
||||
AddInvParam addParam = new AddInvParam();
|
||||
addParam.setPcsn(StringUtils.isEmpty(param.getPcsn())?"1":param.getPcsn());
|
||||
addParam.setMaterialCode(param.getMaterial_code());
|
||||
addParam.setStoragevehicleCode(targetAttr.getStoragevehicle_code());
|
||||
addParam.setStructCode(targetAttr.getStruct_code());
|
||||
addParam.setSectCode(targetAttr.getSect_code());
|
||||
addParam.setStorCode(targetAttr.getStor_code());
|
||||
addParam.setUnitName(param.getQty_unit_name());
|
||||
addParam.setUnitId(param.getQty_unit_id());
|
||||
addParam.setQty(param.getAssign_qty());
|
||||
addInvParams.add(addParam);
|
||||
iStInventoryService.changeInventory(InventoryChangeType.ADD_INV, addInvParams);
|
||||
final List<InFinishParam> inFinishParams = new ArrayList<>();
|
||||
InFinishParam inFinishParam = new InFinishParam();
|
||||
BeanUtils.copyProperties(addParam,inFinishParam);
|
||||
inFinishParam.setRemark("需求单库存调拨");
|
||||
inFinishParams.add(inFinishParam);
|
||||
iStInventoryService.changeInventory(InventoryChangeType.IN_FINISH, inFinishParams);
|
||||
if (one.getStatus().equals(DemandStatus.FINISH.getValue())){
|
||||
return;
|
||||
}
|
||||
one.setAssign_qty(param.getAssign_qty());
|
||||
if (one.getAssign_qty().intValue()>=one.getQty().intValue()){
|
||||
one.setStatus(DemandStatus.FINISH.getValue());
|
||||
final String now = DateUtil.now();
|
||||
JSONObject callbackData = new JSONObject();
|
||||
callbackData.put("method", "DealLLDBBill");
|
||||
callbackData.put("type", "WMS");
|
||||
// 组装data节点
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("issueStorageOrgUnitNo", "01.09.14"); // 业务状态,可根据实际业务逻辑设置
|
||||
data.put("bizTypeNo", "331"); // 业务日期
|
||||
data.put("receiptStorageOrgUnitNo", "01.09.14"); // 创建人编号,从当前登录用户获取
|
||||
data.put("billNo", param.getIostorinvdtl_id()+"#"+param.getSeq_no()); // 使用工单编号作为MES单号
|
||||
// 组装明细列表
|
||||
JSONArray entrys = new JSONArray();
|
||||
final List<IOStorInvDisDto> disSet = ioStorInvDisMapper.queryOutBillDisDtl(MapOf.of("iostorinvdtl_id", param.getIostorinvdtl_id()));
|
||||
for (IOStorInvDisDto ioStorInvDisDto : disSet) {
|
||||
JSONObject entry = new JSONObject();
|
||||
entry.put("unitNo", "PCS"); // 序号
|
||||
entry.put("qty", ioStorInvDisDto.getPlan_qty()); // 数量
|
||||
entry.put("materialNo", ioStorInvDisDto.getMaterial_code()); // 来源单据标识
|
||||
entry.put("issueWarehouseNo", ioStorInvDisDto.getSect_code());
|
||||
entry.put("receiptWarehouseNo", region.getPoint_type_explain());
|
||||
entrys.add(entry);
|
||||
}
|
||||
data.put("entrys", entrys);
|
||||
callbackData.put("data", data);
|
||||
PmStockReturn stockReturn = new PmStockReturn();
|
||||
stockReturn.setRequest_Id(param.getIostorinv_id());
|
||||
stockReturn.setRequest_type(IOSEnum.BILL_TYPE.code("库存调拨"));
|
||||
stockReturn.setStatus(StockReturnStatusEnum.TODO.getCode()); // 0-处理中
|
||||
stockReturn.setCreate_time(now);
|
||||
stockReturn.setRequest_data(callbackData.toString());
|
||||
//回传MES
|
||||
try {
|
||||
mesApi.pmDemandCallback(Arrays.asList(new MesApi.PmDemandCall(
|
||||
one.getId()
|
||||
,one.getId()
|
||||
,now,one.getTarget_area()
|
||||
,1
|
||||
,disSet.get(0).getStoragevehicle_code(),
|
||||
param.getAssign_qty().toString())));
|
||||
}catch (Exception ex){
|
||||
log.error("DealLLDBBillPmDeamndCallBack#pmDemandCallback error:{}",ex.getMessage());
|
||||
}
|
||||
iPmStockReturnService.save(stockReturn);
|
||||
}
|
||||
this.iPmDemandService.updateById(one);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,8 @@ public class WorkOrderDto implements Serializable {
|
||||
@JsonProperty("Id")
|
||||
private String id;
|
||||
|
||||
@JsonProperty("WorkOrderSnList")
|
||||
private List<String> workOrderSnList;
|
||||
// @JsonProperty("WorkOrderSnList")
|
||||
// private String workOrderSnList;
|
||||
|
||||
private String workOrderSnListString;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.wms.welding_manage.service.work_order.IWorkOrderService;
|
||||
import org.nl.wms.welding_manage.service.work_order.dao.WorkOrderBomDao;
|
||||
import org.nl.wms.welding_manage.service.work_order.dao.WorkOrderDao;
|
||||
@@ -13,12 +14,10 @@ import org.nl.wms.welding_manage.service.work_order.dto.WorkOrderDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -58,14 +57,6 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
||||
record.setPortList(portDtoList);
|
||||
}
|
||||
|
||||
String snListString = record.getWorkOrderSnListString();
|
||||
if (!StringUtils.isEmpty(snListString)){
|
||||
List<String> snList = Arrays.stream(snListString.split(","))
|
||||
.map(String::trim)
|
||||
.filter(s -> !s.isEmpty())
|
||||
.collect(Collectors.toList());
|
||||
record.setWorkOrderSnList(snList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +74,9 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
||||
workOrderMapper.deleteById(workOrderDao.getId());
|
||||
workOrderMapper.deleteByOrderCode(workOrderDao.getOrder_code());
|
||||
}
|
||||
if (StringUtils.isEmpty(dto.getId())){
|
||||
dto.setId(IdUtil.getStringId());
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
@@ -90,10 +84,6 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
||||
String nowStr = now.format(dateTimeFormatter).toString();
|
||||
dto.setCreateTime(nowStr);
|
||||
|
||||
List<String> workOrderSnList = dto.getWorkOrderSnList();
|
||||
if (workOrderSnList != null && !workOrderSnList.isEmpty()) {
|
||||
dto.setWorkOrderSnListString(String.join(",", workOrderSnList));
|
||||
}
|
||||
|
||||
List<WorkOrderDto.WorkOrderDataDto.WorkOrderBomDto> workOrderBomList = dto.getWorkOrderBomList();
|
||||
//保证一致
|
||||
|
||||
Reference in New Issue
Block a user