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")
private String tl;
@JSONField(name = "charg")
@JsonProperty("charg")
private String charg;
@JSONField(name = "backup1")
@JsonProperty("backup1")
private String backup1;

View File

@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.nl.common.domain.constant.RegionConstant;
import org.nl.common.exception.BadRequestException;
import org.nl.wms.ext_manage.sap.api.SapApi;
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.warehouse_manage.enums.IOSEnum;
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.stockReturn.service.IPmStockReturnService;
@@ -71,6 +74,8 @@ public class SapProductionOutboundDelivery implements CallbackStrategy {
@Autowired
private IOStorInvDtlMapper ioStorInvDtlMapper;
@Autowired
private IOStorInvDisMapper ioStorInvDisMapper;
@Autowired
private IPmDemandService iPmDemandService;
@Autowired
private ISysParamService sysParamService;
@@ -103,7 +108,7 @@ public class SapProductionOutboundDelivery implements CallbackStrategy {
throw new BadRequestException("生产投料回传失败:需求单" + demandId + "物料为空");
}
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()),
bill == null ? null : bill.getBill_code(), usedQtyByBom,param.getAssign_qty());
// if (postedTotal.signum() > 0) {
@@ -136,7 +141,7 @@ public class SapProductionOutboundDelivery implements CallbackStrategy {
throw new BadRequestException("生产领料回传失败:需求单" + demand.getId() + "存储地点为空");
}
//回传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);
if (postedTotal.compareTo(feedbackQty) != 0) {
@@ -151,7 +156,7 @@ public class SapProductionOutboundDelivery implements CallbackStrategy {
* @param usedQtyByBom 输出参数:key=bomId,value=过账后该BOM的已用数量
* @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) {
List<String> orderCodes = splitWorkOrders(demand.getWork_order_code());
if (orderCodes.isEmpty()) {
@@ -207,7 +212,7 @@ public class SapProductionOutboundDelivery implements CallbackStrategy {
}
// 请求号需全局唯一,SAP 侧按 docno 识别一次过账;一个工单一次请求,便于按工单隔离失败
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();
stockReturn.setRequest_Id(requestId);
stockReturn.setBill_code(billCode);
@@ -318,7 +323,7 @@ public class SapProductionOutboundDelivery implements CallbackStrategy {
* 组装单个工单的单条 PP055 报文:数量按 BOM 剩余量过账
*/
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) {
String workOrderCode = workOrder.getOrder_code().split("-")[0];
ProductionOutboundRequest request = new ProductionOutboundRequest();
@@ -344,6 +349,11 @@ public class SapProductionOutboundDelivery implements CallbackStrategy {
if (!withReserve) {
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("");
request.setBody(Collections.singletonList(body));
return request;

View File

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