Browse Source

销售数量合并

master
shenzhouyu 2 months ago
parent
commit
1761df1c4e
  1. 14
      src/main/java/com/gaotao/modules/customer/entity/vo/ShipmentGroupKey.java
  2. 85
      src/main/java/com/gaotao/modules/customer/service/impl/ShipmentIssueServiceImpl.java
  3. 60
      src/main/java/com/gaotao/modules/outsourcing/entity/vo/PurchaseOrderAndMaterialVo.java
  4. 8
      src/main/java/com/gaotao/modules/outsourcing/service/impl/OutsourcingNotifyServiceImpl.java

14
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;
}
}

85
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<ShipmentAndShipmentLineVo> sumQtyVos = merge(shipmentLineVos);
return sumQtyVos;
}
return null;
}
@ -891,4 +895,83 @@ public class ShipmentIssueServiceImpl implements ShipmentIssueService {
.collect(Collectors.toList());
}
/**shipment数量合并*/
public static List<ShipmentAndShipmentLineVo> merge(List<ShipmentAndShipmentLineVo> itemList) {
// 入参校验
if (itemList == null || itemList.isEmpty()) {
return Collections.emptyList();
}
// 1. shipmentId + sourcePartNo 分组
Map<ShipmentGroupKey, ShipmentAndShipmentLineVo> 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);
}
}

60
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;
}

8
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<ShopOrderAndMaterialVo> getShopOrderAndMaterialByShoporder(IfsOutsourcingOrderDto data) throws Exception{
List<PurchaseOrderVo> purchaseOrder = ifsApiIssueAndReturnService.getPurchaseOrder(data.getOutsourcingNo(), data.getSite());
if(purchaseOrder != null && purchaseOrder.size()>0) {
List<PurchaseOrderLineVo> purchaseOrderLine = ifsApiIssueAndReturnService.getPurchaseOrderLine(data.getOutsourcingNo(), data.getSite());
if(purchaseOrderLine != null && purchaseOrderLine.size()>0) {
List<POLineSupplierMaterialVo> poLineSupplierMaterial = ifsApiIssueAndReturnService.getPOLineSupplierMaterial(data.getOutsourcingNo(), data.getSite());
for(POLineSupplierMaterialVo materialVo:poLineSupplierMaterial){
}
}else{
}

Loading…
Cancel
Save