From 1761df1c4ee0aecd850ad13e57559f73a1115ec1 Mon Sep 17 00:00:00 2001 From: shenzhouyu Date: Wed, 26 Nov 2025 16:30:38 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=80=E5=94=AE=E6=95=B0=E9=87=8F=E5=90=88?= =?UTF-8?q?=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customer/entity/vo/ShipmentGroupKey.java | 14 +++ .../impl/ShipmentIssueServiceImpl.java | 85 ++++++++++++++++++- .../entity/vo/PurchaseOrderAndMaterialVo.java | 60 +++++++++++++ .../impl/OutsourcingNotifyServiceImpl.java | 8 +- 4 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/gaotao/modules/customer/entity/vo/ShipmentGroupKey.java create mode 100644 src/main/java/com/gaotao/modules/outsourcing/entity/vo/PurchaseOrderAndMaterialVo.java diff --git a/src/main/java/com/gaotao/modules/customer/entity/vo/ShipmentGroupKey.java b/src/main/java/com/gaotao/modules/customer/entity/vo/ShipmentGroupKey.java new file mode 100644 index 0000000..5b8fda8 --- /dev/null +++ b/src/main/java/com/gaotao/modules/customer/entity/vo/ShipmentGroupKey.java @@ -0,0 +1,14 @@ +package com.gaotao.modules.customer.entity.vo; + +import lombok.Data; + +@Data +public class ShipmentGroupKey { + private String shipmentId; + private String sourcePartNo; + + public ShipmentGroupKey(String shipmentId, String sourcePartNo) { + this.shipmentId = shipmentId; + this.sourcePartNo = sourcePartNo; + } +} diff --git a/src/main/java/com/gaotao/modules/customer/service/impl/ShipmentIssueServiceImpl.java b/src/main/java/com/gaotao/modules/customer/service/impl/ShipmentIssueServiceImpl.java index 0a3ec9f..2b91401 100644 --- a/src/main/java/com/gaotao/modules/customer/service/impl/ShipmentIssueServiceImpl.java +++ b/src/main/java/com/gaotao/modules/customer/service/impl/ShipmentIssueServiceImpl.java @@ -21,6 +21,7 @@ import com.gaotao.modules.customer.entity.dto.ShipmentIssueDto; import com.gaotao.modules.customer.entity.dto.ShipmentIssueNotifyDto; import com.gaotao.modules.customer.entity.vo.SOIssueNotifyOrderMaterialListShipmentVo; import com.gaotao.modules.customer.entity.vo.ShipmentAndShipmentLineVo; +import com.gaotao.modules.customer.entity.vo.ShipmentGroupKey; import com.gaotao.modules.customer.service.ShipmentIssueService; import com.gaotao.modules.notify.entity.*; import com.gaotao.modules.notify.entity.dto.GroupKey; @@ -786,7 +787,10 @@ public class ShipmentIssueServiceImpl implements ShipmentIssueService { shipmentLineVos.add(vo); } - return shipmentLineVos; + //合并数量 + List sumQtyVos = merge(shipmentLineVos); + + return sumQtyVos; } return null; } @@ -891,4 +895,83 @@ public class ShipmentIssueServiceImpl implements ShipmentIssueService { .collect(Collectors.toList()); } + /**shipment数量合并*/ + public static List merge(List itemList) { + // 入参校验 + if (itemList == null || itemList.isEmpty()) { + return Collections.emptyList(); + } + + // 1. 按 shipmentId + sourcePartNo 分组 + Map mergedMap = itemList.stream() + .collect(Collectors.groupingBy( + // 分组键:组合 shipmentId 和 sourcePartNo + item -> new ShipmentGroupKey(item.getShipmentId(), item.getSourcePartNo()), + // 聚合逻辑:合并相同分组的元素 + Collectors.reducing( + null, // 初始值为 null,后续用第一个元素作为基础 + (mergedItem, currentItem) -> { + if (mergedItem == null) { + // 第一次遇到该分组,直接返回当前元素(作为合并后的基础) + return copyItem(currentItem); + } + // 后续元素:累加数值字段,保留第一个的 shipmentLineNo + mergedItem.setInventoryQty(addBigDecimal(mergedItem.getInventoryQty(), currentItem.getInventoryQty())); + mergedItem.setQtyAssigned(addBigDecimal(mergedItem.getQtyAssigned(), currentItem.getQtyAssigned())); + return mergedItem; + } + ) + )); + + // 2. 提取 Map 的 values 作为结果(有序性:若需保留原顺序,用 LinkedHashMap,见方式2) + return new ArrayList<>(mergedMap.values()); + } + + private static ShipmentAndShipmentLineVo copyItem(ShipmentAndShipmentLineVo source) { + ShipmentAndShipmentLineVo target = new ShipmentAndShipmentLineVo(); + target.setSourceRef1(source.getSourceRef1()); + target.setSourceRef2(source.getSourceRef2()); + target.setSourceRef3(source.getSourceRef3()); + target.setInventoryUom(source.getInventoryUom()); + target.setCreditBlocked(source.getCreditBlocked()); + target.setReceiverPartNo(source.getReceiverPartNo()); + target.setInventoryPartNo(source.getInventoryPartNo()); + target.setSourcePartNo(source.getSourcePartNo()); + target.setSourcePartDescription(source.getSourcePartDescription()); + target.setSourceUnitMeas(source.getSourceUnitMeas()); + target.setShipmentLineNo(source.getShipmentLineNo()); + target.setConnectedSourceQty(source.getConnectedSourceQty()); + target.setInventoryQty(source.getInventoryQty()); + target.setQtyAssigned(source.getQtyAssigned()); + target.setQtyPicked(source.getQtyPicked()); + target.setQtyShipped(source.getQtyShipped()); + target.setContract(source.getContract()); + target.setShipmentId(source.getShipmentId()); + target.setState(source.getState()); + target.setNextStepFlow(source.getNextStepFlow()); + target.setSourceRefType(source.getSourceRefType()); + target.setSourceRefTypeDb(source.getSourceRefTypeDb()); + target.setReceiverType(source.getReceiverType()); + target.setReceiverDesc(source.getReceiverDesc()); + target.setReceiverAddress(source.getReceiverAddress()); + target.setReceiverAddressName(source.getReceiverAddressName()); + target.setShipmentType(source.getShipmentType()); + target.setNoteText(source.getNoteText()); + target.setReceiverTypeDb(source.getReceiverTypeDb()); + target.setReceiverId(source.getReceiverId()); + target.setCreatedDate(source.getCreatedDate()); + target.setPlannedShipDate(source.getPlannedShipDate()); + target.setPlannedDeliveryDate(source.getPlannedDeliveryDate()); + target.setSite(source.getSite()); + target.setPartNo(source.getPartNo()); + target.setIsInWh(source.getIsInWh()); + return target; + } + + private static BigDecimal addBigDecimal(BigDecimal a, BigDecimal b) { + BigDecimal valA = a == null ? BigDecimal.ZERO : a; + BigDecimal valB = b == null ? BigDecimal.ZERO : b; + return valA.add(valB); + } + } diff --git a/src/main/java/com/gaotao/modules/outsourcing/entity/vo/PurchaseOrderAndMaterialVo.java b/src/main/java/com/gaotao/modules/outsourcing/entity/vo/PurchaseOrderAndMaterialVo.java new file mode 100644 index 0000000..36cf9f9 --- /dev/null +++ b/src/main/java/com/gaotao/modules/outsourcing/entity/vo/PurchaseOrderAndMaterialVo.java @@ -0,0 +1,60 @@ +package com.gaotao.modules.outsourcing.entity.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.util.Date; + +@Data +public class PurchaseOrderAndMaterialVo { + private String orderNo; + + // 合同编号(所属合同标识) + private String contract; + + // 行号(在订单中的行项目编号) + private String lineNo; + + // 释放编号(订单释放的批次编号) + private String releaseNo; + + // 结构行号(在BOM结构中的行号,null表示无结构关联) + private String lineItemNo; + + // 组件物料编号(所需物料的编码) + private String componentPartNo; + + // 组件物料描述(所需物料的详细说明) + private String componentPartDescription; + + // 需求数量(该物料的总需求量) + private BigDecimal qtyRequired; + + // 已预留数量(已从库存中预留的数量) + private BigDecimal reservedQty; + + // 计量单位(数量的计量单位) + private String uom; + + // 需求日期(物料需要到位的日期时间) + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date dateRequired; + + // 已发放数量(已实际发放的物料数量) + private BigDecimal qtyIssued; + + // 倒冲标识(是否启用倒冲领料,FALSE表示不启用) + private String backflush; + + // 单位数量(可能表示每个父项所需的子项数量) + private BigDecimal qpa; + + // 组件损耗率(物料在生产过程中的损耗百分比) + private BigDecimal componentScrap; + + // 报废因子(可能用于计算损耗的系数) + private BigDecimal scrapFactor; +} diff --git a/src/main/java/com/gaotao/modules/outsourcing/service/impl/OutsourcingNotifyServiceImpl.java b/src/main/java/com/gaotao/modules/outsourcing/service/impl/OutsourcingNotifyServiceImpl.java index bf06a30..2314d1d 100644 --- a/src/main/java/com/gaotao/modules/outsourcing/service/impl/OutsourcingNotifyServiceImpl.java +++ b/src/main/java/com/gaotao/modules/outsourcing/service/impl/OutsourcingNotifyServiceImpl.java @@ -2,6 +2,8 @@ package com.gaotao.modules.outsourcing.service.impl; import com.gaotao.modules.api.entity.IfsShopOrder; +import com.gaotao.modules.api.entity.issueAndReturnVo.POLineSupplierMaterialVo; +import com.gaotao.modules.api.entity.issueAndReturnVo.PurchaseOrderLineVo; import com.gaotao.modules.api.entity.issueAndReturnVo.PurchaseOrderVo; import com.gaotao.modules.api.service.IfsApiIssueAndReturnService; import com.gaotao.modules.notify.entity.SOIssueNotifyHeaderData; @@ -72,8 +74,12 @@ public class OutsourcingNotifyServiceImpl implements OutsourcingNotifyService { @Override public List getShopOrderAndMaterialByShoporder(IfsOutsourcingOrderDto data) throws Exception{ List purchaseOrder = ifsApiIssueAndReturnService.getPurchaseOrder(data.getOutsourcingNo(), data.getSite()); - if(purchaseOrder != null && purchaseOrder.size()>0) { + List purchaseOrderLine = ifsApiIssueAndReturnService.getPurchaseOrderLine(data.getOutsourcingNo(), data.getSite()); + if(purchaseOrderLine != null && purchaseOrderLine.size()>0) { + List poLineSupplierMaterial = ifsApiIssueAndReturnService.getPOLineSupplierMaterial(data.getOutsourcingNo(), data.getSite()); + for(POLineSupplierMaterialVo materialVo:poLineSupplierMaterial){ + } }else{ }