From f80b0bbddbf6c70ee016fb9c6514cfb2b380135a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E9=B8=BF=E5=B1=95?= <18031053041@163.com> Date: Mon, 6 Jul 2026 20:59:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E5=8A=A1=E6=8E=A8=E9=80=81=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/DocumentPushMaterialRecord.java | 6 + .../entity/MaterialPushRecord.java | 6 + .../service/MaterialPushRecordService.java | 122 ++++++++++++++++++ 3 files changed, 134 insertions(+) diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/documentPushMaterialRecord/entity/DocumentPushMaterialRecord.java b/mhd_oms/src/main/java/com/mhd/oms/domain/documentPushMaterialRecord/entity/DocumentPushMaterialRecord.java index de05502d3..b0ad4276b 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/documentPushMaterialRecord/entity/DocumentPushMaterialRecord.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/documentPushMaterialRecord/entity/DocumentPushMaterialRecord.java @@ -57,6 +57,12 @@ public class DocumentPushMaterialRecord implements Serializable { @ApiModelProperty("商品类型(0物料,1半成品,2成品)") private Integer goodsType; + @ApiModelProperty("总价") + private BigDecimal entTotal; + + @ApiModelProperty("原产国") + private String originCountry; + @ApiModelProperty("推送时间") private Date pushTime; diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/materialPushRecord/entity/MaterialPushRecord.java b/mhd_oms/src/main/java/com/mhd/oms/domain/materialPushRecord/entity/MaterialPushRecord.java index 01196e594..3cac7e9e5 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/materialPushRecord/entity/MaterialPushRecord.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/materialPushRecord/entity/MaterialPushRecord.java @@ -57,6 +57,12 @@ public class MaterialPushRecord implements Serializable { @ApiModelProperty("商品类型(0物料,1半成品,2成品)") private Integer goodsType; + @ApiModelProperty("总价") + private BigDecimal entTotal; + + @ApiModelProperty("原产国") + private String originCountry; + @ApiModelProperty("推送时间") private Date pushTime; diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/materialPushRecord/service/MaterialPushRecordService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/materialPushRecord/service/MaterialPushRecordService.java index 94999e8c1..8828d6aee 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/materialPushRecord/service/MaterialPushRecordService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/materialPushRecord/service/MaterialPushRecordService.java @@ -2,6 +2,8 @@ package com.mhd.oms.domain.materialPushRecord.service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.mhd.common.core.web.page.TableDataInfo; +import com.mhd.oms.domain.businessDocumentCargoMulti.entity.BusinessDocumentCargoMulti; +import com.mhd.oms.domain.businessDocumentCargoMulti.repository.mapper.BusinessDocumentCargoMultiMapper; import com.mhd.oms.domain.materialPushRecord.entity.MaterialPushRecord; import com.mhd.oms.domain.materialPushRecord.repository.mapper.MaterialPushRecordMapper; import com.mhd.oms.domain.documentPushMaterialRecord.entity.DocumentPushMaterialRecord; @@ -11,6 +13,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -27,6 +30,9 @@ public class MaterialPushRecordService { @Resource private DocumentPushMaterialRecordMapper documentPushMaterialRecordMapper; + @Resource + private BusinessDocumentCargoMultiMapper businessDocumentCargoMultiMapper; + /** * 按物料ID列表查询物料数据 * 先按orderId查单证推送快照,没有再查物料推送快照,最后调WMS @@ -40,6 +46,17 @@ public class MaterialPushRecordService { return emptyResult; } + // 查询订单货物明细数量(总价计算用) + Map cargoNumMap = queryCargoNumMap(orderId, materialBaseInfoIds); + // 查询WMS物料信息(原产国等) + Map> materialInfoMap = queryMaterialInfoMap(materialBaseInfoIds); + + TableDataInfo result = queryInternal(materialBaseInfoIds, orderId); + fillExtraFields(result.getData(), cargoNumMap, materialInfoMap); + return result; + } + + private TableDataInfo queryInternal(List materialBaseInfoIds, Long orderId) { // 1. 先按orderId查单证推送物料记录表 List docRecords = documentPushMaterialRecordMapper.selectList( new LambdaQueryWrapper() @@ -106,4 +123,109 @@ public class MaterialPushRecordService { return errorResult; } } + + /** + * 根据订单ID查询货物明细数量 + */ + private Map queryCargoNumMap(Long orderId, List materialBaseInfoIds) { + Map map = new HashMap<>(); + if (orderId == null || materialBaseInfoIds == null || materialBaseInfoIds.isEmpty()) { + return map; + } + try { + List cargoList = businessDocumentCargoMultiMapper.selectList( + new LambdaQueryWrapper() + .eq(BusinessDocumentCargoMulti::getOrderId, String.valueOf(orderId)) + .in(BusinessDocumentCargoMulti::getMaterialBaseInfoId, materialBaseInfoIds) + .eq(BusinessDocumentCargoMulti::getDelFlag, 1)); + for (BusinessDocumentCargoMulti cargo : cargoList) { + if (cargo.getMaterialBaseInfoId() != null && cargo.getCargoNum() != null) { + map.put(cargo.getMaterialBaseInfoId(), cargo.getCargoNum()); + } + } + } catch (Exception e) { + log.warn("查询订单货物明细失败 orderId={}", orderId, e); + } + return map; + } + + /** + * 批量查询WMS物料信息 + */ + private Map> queryMaterialInfoMap(List materialBaseInfoIds) { + Map> map = new HashMap<>(); + if (materialBaseInfoIds == null || materialBaseInfoIds.isEmpty()) { + return map; + } + try { + TableDataInfo wmsResult = wmsServiceFeign.getBatchByIds(materialBaseInfoIds); + if (wmsResult != null && wmsResult.getData() != null) { + for (Object obj : wmsResult.getData()) { + if (obj instanceof Map) { + Map item = (Map) obj; + Object mid = item.get("materialBaseInfoId"); + if (mid != null) { + map.put(Long.valueOf(String.valueOf(mid)), item); + } + } + } + } + } catch (Exception e) { + log.warn("调用WMS查询物料信息失败: {}", e.getMessage()); + } + return map; + } + + /** + * 统一补充总价和原产国字段 + */ + private void fillExtraFields(List dataList, Map cargoNumMap, Map> materialInfoMap) { + if (dataList == null) { + return; + } + for (Object obj : dataList) { + if (obj instanceof MaterialPushRecord) { + MaterialPushRecord r = (MaterialPushRecord) obj; + Long mid = r.getMaterialBaseInfoId(); + BigDecimal cargoNum = cargoNumMap.get(mid); + if (cargoNum != null && r.getUnitPrice() != null) { + r.setEntTotal(cargoNum.multiply(r.getUnitPrice())); + } + Map material = materialInfoMap.get(mid); + if (material != null && material.get("originCountry") != null) { + r.setOriginCountry(String.valueOf(material.get("originCountry"))); + } + } else if (obj instanceof DocumentPushMaterialRecord) { + DocumentPushMaterialRecord r = (DocumentPushMaterialRecord) obj; + Long mid = r.getMaterialBaseInfoId(); + BigDecimal cargoNum = cargoNumMap.get(mid); + if (cargoNum != null && r.getUnitPrice() != null) { + r.setEntTotal(cargoNum.multiply(r.getUnitPrice())); + } + Map material = materialInfoMap.get(mid); + if (material != null && material.get("originCountry") != null) { + r.setOriginCountry(String.valueOf(material.get("originCountry"))); + } + } else if (obj instanceof Map) { + Map item = (Map) obj; + Object mid = item.get("materialBaseInfoId"); + if (mid != null) { + Long materialBaseInfoId = Long.valueOf(String.valueOf(mid)); + BigDecimal cargoNum = cargoNumMap.get(materialBaseInfoId); + Object up = item.get("unitPrice"); + BigDecimal unitPrice = up != null ? new BigDecimal(String.valueOf(up)) : null; + if (cargoNum != null) { + item.put("cargoNum", cargoNum); + if (unitPrice != null) { + item.put("entTotal", cargoNum.multiply(unitPrice)); + } + } + Map material = materialInfoMap.get(materialBaseInfoId); + if (material != null && material.get("originCountry") != null) { + item.put("originCountry", material.get("originCountry")); + } + } + } + } + } }