add:海监品投料出库加批次

This commit is contained in:
zhaoyf
2026-11-17 20:43:42 +08:00
parent dc6a1eb412
commit 564f6fda4f
3 changed files with 33 additions and 9 deletions

View File

@@ -61,6 +61,10 @@ public class ProductionOutboundBody {
@JsonProperty("tl") @JsonProperty("tl")
private String tl; private String tl;
@JSONField(name = "charg")
@JsonProperty("charg")
private String charg;
@JSONField(name = "backup1") @JSONField(name = "backup1")
@JsonProperty("backup1") @JsonProperty("backup1")
private String backup1; private String backup1;

View File

@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.nl.common.domain.constant.RegionConstant;
import org.nl.common.exception.BadRequestException; import org.nl.common.exception.BadRequestException;
import org.nl.wms.ext_manage.sap.api.SapApi; import org.nl.wms.ext_manage.sap.api.SapApi;
import org.nl.wms.ext_manage.sap.api.dto.ProductionOutboundBody; import org.nl.wms.ext_manage.sap.api.dto.ProductionOutboundBody;
@@ -21,7 +22,9 @@ import org.nl.wms.system_manage.service.param.ISysParamService;
import org.nl.wms.system_manage.service.param.dao.Param; import org.nl.wms.system_manage.service.param.dao.Param;
import org.nl.wms.warehouse_manage.enums.IOSEnum; import org.nl.wms.warehouse_manage.enums.IOSEnum;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInv; 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.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.IOStorInvDtlMapper;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvMapper; import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvMapper;
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService; import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
@@ -71,6 +74,8 @@ public class SapProductionOutboundDelivery implements CallbackStrategy {
@Autowired @Autowired
private IOStorInvDtlMapper ioStorInvDtlMapper; private IOStorInvDtlMapper ioStorInvDtlMapper;
@Autowired @Autowired
private IOStorInvDisMapper ioStorInvDisMapper;
@Autowired
private IPmDemandService iPmDemandService; private IPmDemandService iPmDemandService;
@Autowired @Autowired
private ISysParamService sysParamService; private ISysParamService sysParamService;
@@ -103,7 +108,7 @@ public class SapProductionOutboundDelivery implements CallbackStrategy {
throw new BadRequestException("生产投料回传失败:需求单" + demandId + "物料为空"); throw new BadRequestException("生产投料回传失败:需求单" + demandId + "物料为空");
} }
Map<String, BigDecimal> usedQtyByBom = new LinkedHashMap<>(); Map<String, BigDecimal> usedQtyByBom = new LinkedHashMap<>();
BigDecimal postedTotal = postByBomRemain(demand, materialCode, lgort, BigDecimal postedTotal = postByBomRemain(demand, materialCode, lgort, param.getIostorinvdtl_id(),
StrUtil.blankToDefault(param.getIostorinv_id(), demand.getId()), StrUtil.blankToDefault(param.getIostorinv_id(), demand.getId()),
bill == null ? null : bill.getBill_code(), usedQtyByBom,param.getAssign_qty()); bill == null ? null : bill.getBill_code(), usedQtyByBom,param.getAssign_qty());
// if (postedTotal.signum() > 0) { // if (postedTotal.signum() > 0) {
@@ -136,7 +141,7 @@ public class SapProductionOutboundDelivery implements CallbackStrategy {
throw new BadRequestException("生产领料回传失败:需求单" + demand.getId() + "存储地点为空"); throw new BadRequestException("生产领料回传失败:需求单" + demand.getId() + "存储地点为空");
} }
//回传SAP //回传SAP
BigDecimal postedTotal = postByBomRemain(demand, StrUtil.trim(demand.getSku_code()), lgort, BigDecimal postedTotal = postByBomRemain(demand, StrUtil.trim(demand.getSku_code()), lgort,null,
demand.getId(), demand.getOrder_code(), new LinkedHashMap<>(),feedbackQty); demand.getId(), demand.getOrder_code(), new LinkedHashMap<>(),feedbackQty);
if (postedTotal.compareTo(feedbackQty) != 0) { if (postedTotal.compareTo(feedbackQty) != 0) {
@@ -151,7 +156,7 @@ public class SapProductionOutboundDelivery implements CallbackStrategy {
* @param usedQtyByBom 输出参数:key=bomId,value=过账后该BOM的已用数量 * @param usedQtyByBom 输出参数:key=bomId,value=过账后该BOM的已用数量
* @return 本次实际过账的数量合计 * @return 本次实际过账的数量合计
*/ */
private BigDecimal postByBomRemain(PmDemand demand, String materialCode, String lgort, String requestId, private BigDecimal postByBomRemain(PmDemand demand, String materialCode, String lgort,String invdtlId, String requestId,
String billCode, Map<String, BigDecimal> usedQtyByBom,BigDecimal feedbackQty) { String billCode, Map<String, BigDecimal> usedQtyByBom,BigDecimal feedbackQty) {
List<String> orderCodes = splitWorkOrders(demand.getWork_order_code()); List<String> orderCodes = splitWorkOrders(demand.getWork_order_code());
if (orderCodes.isEmpty()) { if (orderCodes.isEmpty()) {
@@ -207,7 +212,7 @@ public class SapProductionOutboundDelivery implements CallbackStrategy {
} }
// 请求号需全局唯一,SAP 侧按 docno 识别一次过账;一个工单一次请求,便于按工单隔离失败 // 请求号需全局唯一,SAP 侧按 docno 识别一次过账;一个工单一次请求,便于按工单隔离失败
String docno = "FEED" + System.currentTimeMillis(); String docno = "FEED" + System.currentTimeMillis();
ProductionOutboundRequest request = buildRequest(docno, today, workOrder, materialCode, lgort, rsnum,rspos, sapQty); ProductionOutboundRequest request = buildRequest(docno, today, workOrder, materialCode, lgort,invdtlId, rsnum,rspos, sapQty);
PmStockReturn stockReturn = new PmStockReturn(); PmStockReturn stockReturn = new PmStockReturn();
stockReturn.setRequest_Id(requestId); stockReturn.setRequest_Id(requestId);
stockReturn.setBill_code(billCode); stockReturn.setBill_code(billCode);
@@ -318,7 +323,7 @@ public class SapProductionOutboundDelivery implements CallbackStrategy {
* 组装单个工单的单条 PP055 报文:数量按 BOM 剩余量过账 * 组装单个工单的单条 PP055 报文:数量按 BOM 剩余量过账
*/ */
private ProductionOutboundRequest buildRequest(String docno, String today, WorkOrderDao workOrder, private ProductionOutboundRequest buildRequest(String docno, String today, WorkOrderDao workOrder,
String materialCode, String lgort,String rsnum,String rspos, String materialCode, String lgort,String invdtlId,String rsnum,String rspos,
BigDecimal postQty) { BigDecimal postQty) {
String workOrderCode = workOrder.getOrder_code().split("-")[0]; String workOrderCode = workOrder.getOrder_code().split("-")[0];
ProductionOutboundRequest request = new ProductionOutboundRequest(); ProductionOutboundRequest request = new ProductionOutboundRequest();
@@ -344,6 +349,11 @@ public class SapProductionOutboundDelivery implements CallbackStrategy {
if (!withReserve) { if (!withReserve) {
log.info("工单{}非G开头,按计划外投料过账(不带预留号/行项目)", workOrder.getOrder_code()); log.info("工单{}非G开头,按计划外投料过账(不带预留号/行项目)", workOrder.getOrder_code());
} }
if (RegionConstant.R004.equals(lgort)){//海监品库加批次号
List<IOStorInvDis> ioStorInvDis = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<IOStorInvDis>()
.eq(IOStorInvDis::getIostorinvdtl_id, invdtlId));
body.setCharg(ioStorInvDis.get(0).getPcsn());
}
body.setTl(""); body.setTl("");
request.setBody(Collections.singletonList(body)); request.setBody(Collections.singletonList(body));
return request; return request;

View File

@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.nl.common.domain.constant.RegionConstant;
import org.nl.common.exception.BadRequestException; import org.nl.common.exception.BadRequestException;
import org.nl.wms.ext_manage.sap.api.SapApi; import org.nl.wms.ext_manage.sap.api.SapApi;
import org.nl.wms.ext_manage.sap.api.dto.ProductionOutboundBody; import org.nl.wms.ext_manage.sap.api.dto.ProductionOutboundBody;
@@ -21,7 +22,9 @@ import org.nl.wms.system_manage.service.param.ISysParamService;
import org.nl.wms.system_manage.service.param.dao.Param; import org.nl.wms.system_manage.service.param.dao.Param;
import org.nl.wms.warehouse_manage.enums.IOSEnum; import org.nl.wms.warehouse_manage.enums.IOSEnum;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInv; 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.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.IOStorInvDtlMapper;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvMapper; import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvMapper;
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService; import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
@@ -73,6 +76,8 @@ public class SapStructureDemandOut implements CallbackStrategy {
@Autowired @Autowired
private IOStorInvDtlMapper ioStorInvDtlMapper; private IOStorInvDtlMapper ioStorInvDtlMapper;
@Autowired @Autowired
private IOStorInvDisMapper ioStorInvDisMapper;
@Autowired
private IPmStockReturnService iPmStockReturnService; private IPmStockReturnService iPmStockReturnService;
@Autowired @Autowired
private ISysParamService sysParamService; private ISysParamService sysParamService;
@@ -116,7 +121,7 @@ public class SapStructureDemandOut implements CallbackStrategy {
log.warn("结构件需求单{}出库明细{}已分配数量为0,跳过回传SAP", demandId, param.getIostorinvdtl_id()); log.warn("结构件需求单{}出库明细{}已分配数量为0,跳过回传SAP", demandId, param.getIostorinvdtl_id());
return; return;
} }
BigDecimal postedTotal = postByBomRemain(demand, materialCode, lgort, BigDecimal postedTotal = postByBomRemain(demand, materialCode, lgort, param.getIostorinvdtl_id(),
StrUtil.blankToDefault(param.getIostorinv_id(), demand.getId()), StrUtil.blankToDefault(param.getIostorinv_id(), demand.getId()),
bill == null ? null : bill.getBill_code(), feedbackQty); bill == null ? null : bill.getBill_code(), feedbackQty);
if (postedTotal.compareTo(feedbackQty) != 0) { if (postedTotal.compareTo(feedbackQty) != 0) {
@@ -137,7 +142,7 @@ public class SapStructureDemandOut implements CallbackStrategy {
* *
* @return 本次实际过账的数量合计 * @return 本次实际过账的数量合计
*/ */
private BigDecimal postByBomRemain(PmDemandStructure demand, String materialCode, String lgort, private BigDecimal postByBomRemain(PmDemandStructure demand, String materialCode, String lgort, String invdtlId,
String requestId, String billCode, BigDecimal feedbackQty) { String requestId, String billCode, BigDecimal feedbackQty) {
List<String> orderCodes = splitWorkOrders(demand.getWork_order_code()); List<String> orderCodes = splitWorkOrders(demand.getWork_order_code());
if (orderCodes.isEmpty()) { if (orderCodes.isEmpty()) {
@@ -186,7 +191,7 @@ public class SapStructureDemandOut implements CallbackStrategy {
// 请求号需全局唯一,SAP 侧按 docno 识别一次过账;一个工单一次请求,便于按工单隔离失败 // 请求号需全局唯一,SAP 侧按 docno 识别一次过账;一个工单一次请求,便于按工单隔离失败
String docno = "FEED" + System.currentTimeMillis(); String docno = "FEED" + System.currentTimeMillis();
ProductionOutboundRequest request = buildRequest(docno, today, workOrder, materialCode, ProductionOutboundRequest request = buildRequest(docno, today, workOrder, materialCode,
lgort, rsnum, rspos, postQty); lgort, invdtlId, rsnum, rspos, postQty);
PmStockReturn stockReturn = new PmStockReturn(); PmStockReturn stockReturn = new PmStockReturn();
stockReturn.setRequest_Id(requestId); stockReturn.setRequest_Id(requestId);
stockReturn.setBill_code(billCode); stockReturn.setBill_code(billCode);
@@ -234,7 +239,7 @@ public class SapStructureDemandOut implements CallbackStrategy {
* 组装单个工单的单条 PP055 报文:数量按 BOM 剩余量过账 * 组装单个工单的单条 PP055 报文:数量按 BOM 剩余量过账
*/ */
private ProductionOutboundRequest buildRequest(String docno, String today, WorkOrderDao workOrder, private ProductionOutboundRequest buildRequest(String docno, String today, WorkOrderDao workOrder,
String materialCode, String lgort, String rsnum, String rspos, String materialCode, String lgort, String invdtlId, String rsnum, String rspos,
BigDecimal postQty) { BigDecimal postQty) {
ProductionOutboundRequest request = new ProductionOutboundRequest(); ProductionOutboundRequest request = new ProductionOutboundRequest();
ProductionOutboundHeader header = new ProductionOutboundHeader(); ProductionOutboundHeader header = new ProductionOutboundHeader();
@@ -256,6 +261,11 @@ public class SapStructureDemandOut implements CallbackStrategy {
body.setRspos(rspos); body.setRspos(rspos);
// tl 为空表示投料 // tl 为空表示投料
body.setTl(""); body.setTl("");
if (RegionConstant.R004.equals(lgort)){//海监品库加批次号
List<IOStorInvDis> ioStorInvDis = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<IOStorInvDis>()
.eq(IOStorInvDis::getIostorinvdtl_id, invdtlId));
body.setCharg(ioStorInvDis.get(0).getPcsn());
}
request.setBody(Collections.singletonList(body)); request.setBody(Collections.singletonList(body));
return request; return request;
} }