一般贸易推送添加字段

This commit is contained in:
秦鸿展
2026-07-01 15:28:30 +08:00
parent bc962c3131
commit 9511a38946
3 changed files with 145 additions and 13 deletions
@@ -819,6 +819,18 @@ public class OrderWithMaterialDTO {
@ApiModelProperty("启运/运抵国地区")
private String stshipTrsarvNatcd;
@ApiModelProperty("贸易国地区")
private String tradeAreaCode;
@ApiModelProperty("企业总价")
private BigDecimal entTotal;
@ApiModelProperty("原产国(与originCountry同源)")
private String countryCode;
@ApiModelProperty("删改单申请类型:0-改单 1-删除 2-作废")
private Integer reviseApplyType;
@@ -13,11 +13,16 @@ import com.mhd.oms.domain.businessDocumentCargoMulti.entity.BusinessDocumentCarg
import com.mhd.oms.domain.businessDocumentCargoMulti.repository.mapper.BusinessDocumentCargoMultiMapper;
import com.mhd.oms.domain.businessDocumentOrder.repository.po.BusinessDocumentOrderPO;
import com.mhd.oms.domain.businessDocumentOrder.repository.todo.BusinessDocumentOrderDO;
import com.mhd.oms.domain.erpCountry.entity.ErpCountry;
import com.mhd.oms.domain.erpCountry.repository.mapper.ErpCountryMapper;
import com.mhd.oms.domain.reservationStockInOrder.repository.mapper.ReservationStockInOrderMapper;
import com.mhd.oms.domain.reservationStockInOrder.repository.po.MaterialBaseInfoPO;
import com.mhd.oms.interfaces.assembler.businessDocumentOrder.BusinessDocumentOrderAssembler;
import com.mhd.oms.interfaces.dto.businessDocumentOrder.BusinessDocumentOrderDTO;
import com.mhd.oms.interfaces.dto.originalImportExportDocument.OrderWithMaterialDTO;
import com.mhd.system.api.WmsServiceFeign;
import com.mhd.system.api.domain.MaterialInfoDTO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
@@ -29,6 +34,8 @@ import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import static org.reflections.Reflections.log;
@Api(tags = "进出口原始单证")
@RestController
@RequestMapping("/OriginalImportExportDocumentApi")
@@ -43,6 +50,12 @@ public class OriginalImportExportDocumentApi extends BaseController {
@Resource
private BusinessDocumentOrderAssembler businessDocumentOrderAssembler;
@Resource
private ErpCountryMapper erpCountryMapper;
@Resource
private ReservationStockInOrderMapper reservationStockInOrderMapper;
@Resource
private WmsServiceFeign wmsServiceFeign;
@@ -117,6 +130,7 @@ public class OriginalImportExportDocumentApi extends BaseController {
Page<BusinessDocumentOrderPO> page = (Page<BusinessDocumentOrderPO>) orderList;
List<OrderWithMaterialDTO> resultList = convertToOrderWithMaterialList(orderList);
populateTradeFields(resultList, orderList);
//return getDataTable(resultList);
TableDataInfo tableDataInfo = new TableDataInfo();
tableDataInfo.setData(resultList);
@@ -185,6 +199,53 @@ public class OriginalImportExportDocumentApi extends BaseController {
return resultList;
}
/** 填充贸易相关字段:启运/运抵国地区、贸易国地区、企业总价、原产国 */
private void populateTradeFields(List<OrderWithMaterialDTO> resultList, List<BusinessDocumentOrderPO> orderList) {
for (int i = 0; i < resultList.size(); i++) {
OrderWithMaterialDTO dto = resultList.get(i);
BusinessDocumentOrderPO order = orderList.get(i);
// 启运/运抵国地区(收货地 → ErpCountry
dto.setStshipTrsarvNatcd(lookupCountryCode(order.getUnloadAreaId(), order.getUnloadName()));
// 贸易国地区(发货地 → ErpCountry
dto.setTradeAreaCode(lookupCountryCode(order.getLoadingAreaId(), order.getLoadingName()));
// 原产国(直接取originCountry
dto.setCountryCode(dto.getOriginCountry());
// 企业总价 = 数量 × 单价
List<BusinessDocumentCargoMulti> cargoList = order.getBusinessDocumentCargoMultiList();
if (cargoList != null && !cargoList.isEmpty()) {
BusinessDocumentCargoMulti cargo = cargoList.get(0);
if (cargo.getMaterialBaseInfoId() != null) {
MaterialBaseInfoPO material = reservationStockInOrderMapper.getinfo(cargo.getMaterialBaseInfoId());
if (material != null && material.getUnitPrice() != null && cargo.getCargoNum() != null) {
dto.setEntTotal(material.getUnitPrice().multiply(cargo.getCargoNum()));
}
}
}
}
}
/** 查 ErpCountry 表获取国别编码 */
private String lookupCountryCode(String areaId, String areaName) {
if (areaId == null && areaName == null) return "";
try {
LambdaQueryWrapper<ErpCountry> qw = new LambdaQueryWrapper<>();
qw.eq(ErpCountry::getDelFlag, 1);
if (areaId != null) qw.eq(ErpCountry::getErpCountryCode, areaId);
List<ErpCountry> list = erpCountryMapper.selectList(qw);
if (!list.isEmpty()) return list.get(0).getErpCountryCode();
if (areaName != null) {
LambdaQueryWrapper<ErpCountry> qw2 = new LambdaQueryWrapper<>();
qw2.eq(ErpCountry::getDelFlag, 1).like(ErpCountry::getErpCountryName, areaName);
List<ErpCountry> list2 = erpCountryMapper.selectList(qw2);
if (!list2.isEmpty()) return list2.get(0).getErpCountryCode();
}
} catch (Exception e) { log.warn("查ErpCountry失败", e); }
return areaId != null ? areaId : "";
}
@ApiOperation("批量推送")
@PostMapping("/batchPushForReviseApply")