关务推送增加字段
This commit is contained in:
+6
@@ -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;
|
||||
|
||||
|
||||
+6
@@ -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;
|
||||
|
||||
|
||||
+122
@@ -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<Long, BigDecimal> cargoNumMap = queryCargoNumMap(orderId, materialBaseInfoIds);
|
||||
// 查询WMS物料信息(原产国等)
|
||||
Map<Long, Map<String, Object>> materialInfoMap = queryMaterialInfoMap(materialBaseInfoIds);
|
||||
|
||||
TableDataInfo result = queryInternal(materialBaseInfoIds, orderId);
|
||||
fillExtraFields(result.getData(), cargoNumMap, materialInfoMap);
|
||||
return result;
|
||||
}
|
||||
|
||||
private TableDataInfo queryInternal(List<Long> materialBaseInfoIds, Long orderId) {
|
||||
// 1. 先按orderId查单证推送物料记录表
|
||||
List<DocumentPushMaterialRecord> docRecords = documentPushMaterialRecordMapper.selectList(
|
||||
new LambdaQueryWrapper<DocumentPushMaterialRecord>()
|
||||
@@ -106,4 +123,109 @@ public class MaterialPushRecordService {
|
||||
return errorResult;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单ID查询货物明细数量
|
||||
*/
|
||||
private Map<Long, BigDecimal> queryCargoNumMap(Long orderId, List<Long> materialBaseInfoIds) {
|
||||
Map<Long, BigDecimal> map = new HashMap<>();
|
||||
if (orderId == null || materialBaseInfoIds == null || materialBaseInfoIds.isEmpty()) {
|
||||
return map;
|
||||
}
|
||||
try {
|
||||
List<BusinessDocumentCargoMulti> cargoList = businessDocumentCargoMultiMapper.selectList(
|
||||
new LambdaQueryWrapper<BusinessDocumentCargoMulti>()
|
||||
.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<Long, Map<String, Object>> queryMaterialInfoMap(List<Long> materialBaseInfoIds) {
|
||||
Map<Long, Map<String, Object>> 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<String, Object> item = (Map<String, Object>) 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<Long, BigDecimal> cargoNumMap, Map<Long, Map<String, Object>> 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<String, Object> 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<String, Object> material = materialInfoMap.get(mid);
|
||||
if (material != null && material.get("originCountry") != null) {
|
||||
r.setOriginCountry(String.valueOf(material.get("originCountry")));
|
||||
}
|
||||
} else if (obj instanceof Map) {
|
||||
Map<String, Object> item = (Map<String, Object>) 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<String, Object> material = materialInfoMap.get(materialBaseInfoId);
|
||||
if (material != null && material.get("originCountry") != null) {
|
||||
item.put("originCountry", material.get("originCountry"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user