一般贸易推送添加字段
This commit is contained in:
+72
-13
@@ -25,6 +25,8 @@ import com.mhd.oms.domain.gwLog.entity.GwLog;
|
||||
import com.mhd.oms.domain.gwLog.repository.mapper.GwLogMapper;
|
||||
import com.mhd.oms.domain.documentPushMaterialRecord.entity.DocumentPushMaterialRecord;
|
||||
import com.mhd.oms.domain.documentPushMaterialRecord.repository.mapper.DocumentPushMaterialRecordMapper;
|
||||
import com.mhd.oms.domain.erpCountry.entity.ErpCountry;
|
||||
import com.mhd.oms.domain.erpCountry.repository.mapper.ErpCountryMapper;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentAddressMulti.BusinessAuditDTO;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrder.BusinessDocumentOrderDTO;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
@@ -42,6 +44,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@@ -93,6 +96,9 @@ public class BusinessDocumentOrderApplicationService {
|
||||
@Resource
|
||||
private DocumentPushMaterialRecordMapper documentPushMaterialRecordMapper;
|
||||
|
||||
@Resource
|
||||
private ErpCountryMapper erpCountryMapper;
|
||||
|
||||
/**
|
||||
* 分页查询【请填写功能名称】列表
|
||||
*/
|
||||
@@ -246,6 +252,10 @@ public class BusinessDocumentOrderApplicationService {
|
||||
body.put("goodsType", goodsType != null ? goodsType : "");
|
||||
body.put("ieFlag", order.getIeType() != null ? order.getIeType() : "");
|
||||
body.put("corpCode", corpCode != null ? corpCode : "");
|
||||
// 启运/运抵国地区(收货地→ErpCountry表)
|
||||
body.put("stshipTrsarvNatcd", lookupErpCountryCode(order.getUnloadAreaId(), order.getUnloadName()));
|
||||
// 贸易国地区(发货地→ErpCountry表)
|
||||
body.put("tradeAreaCode", lookupErpCountryCode(order.getLoadingAreaId(), order.getLoadingName()));
|
||||
|
||||
List<Map<String, Object>> billList = new ArrayList<>();
|
||||
if (cargoList != null && !cargoList.isEmpty()) {
|
||||
@@ -257,28 +267,53 @@ public class BusinessDocumentOrderApplicationService {
|
||||
billMap.put("packNo", cargo.getCargoNum() != null ? cargo.getCargoNum() : "");
|
||||
billMap.put("erpQty", cargo.getCargoNum() != null ? cargo.getCargoNum() : "");
|
||||
|
||||
// 查询物料基础信息,计算净重和毛重
|
||||
// 查询物料基础信息
|
||||
MaterialBaseInfoPO material = null;
|
||||
if (cargo.getMaterialBaseInfoId() != null) {
|
||||
MaterialBaseInfoPO material = reservationStockInOrderMapper.getinfo(cargo.getMaterialBaseInfoId());
|
||||
if (material != null && cargo.getCargoNum() != null) {
|
||||
if (material.getWeightLimit() != null) {
|
||||
billMap.put("netWt", material.getWeightLimit().multiply(cargo.getCargoNum()));
|
||||
} else {
|
||||
billMap.put("netWt", "");
|
||||
}
|
||||
if (material.getGrossWeight() != null) {
|
||||
billMap.put("grossWt", material.getGrossWeight().multiply(cargo.getCargoNum()));
|
||||
} else {
|
||||
billMap.put("grossWt", "");
|
||||
}
|
||||
material = reservationStockInOrderMapper.getinfo(cargo.getMaterialBaseInfoId());
|
||||
}
|
||||
if (material != null) {
|
||||
// 净重和毛重
|
||||
if (cargo.getCargoNum() != null) {
|
||||
billMap.put("netWt", material.getWeightLimit() != null
|
||||
? material.getWeightLimit().multiply(cargo.getCargoNum()) : "");
|
||||
billMap.put("grossWt", material.getGrossWeight() != null
|
||||
? material.getGrossWeight().multiply(cargo.getCargoNum()) : "");
|
||||
} else {
|
||||
billMap.put("netWt", "");
|
||||
billMap.put("grossWt", "");
|
||||
}
|
||||
// 货物名称
|
||||
billMap.put("goodsName", material.getMaterialName() != null ? material.getMaterialName() : "");
|
||||
// 成交单位(申报单位)
|
||||
billMap.put("gUnit", material.getDeclarationUnit() != null ? material.getDeclarationUnit() : "");
|
||||
// 币制
|
||||
billMap.put("currency", material.getCurrency() != null ? material.getCurrency() : "");
|
||||
// 原产国(countryCode)
|
||||
billMap.put("countryCode", material.getOriginCountry() != null ? material.getOriginCountry() : "");
|
||||
// 单价(企业单价)
|
||||
BigDecimal unitPrice = material.getUnitPrice();
|
||||
billMap.put("unitPrice", unitPrice != null ? unitPrice : "");
|
||||
// 总价(entTotal = 成交数量 × 单价)
|
||||
if (unitPrice != null && cargo.getCargoNum() != null) {
|
||||
billMap.put("entTotal", unitPrice.multiply(cargo.getCargoNum()));
|
||||
} else {
|
||||
billMap.put("entTotal", "");
|
||||
}
|
||||
} else {
|
||||
billMap.put("netWt", "");
|
||||
billMap.put("grossWt", "");
|
||||
billMap.put("goodsName", "");
|
||||
billMap.put("gUnit", "");
|
||||
billMap.put("currency", "");
|
||||
billMap.put("countryCode", "");
|
||||
billMap.put("unitPrice", "");
|
||||
billMap.put("entTotal", "");
|
||||
}
|
||||
// 最终目的国(收货地)
|
||||
billMap.put("destinationCountry", order.getUnloadName() != null ? order.getUnloadName() : "");
|
||||
// 境内货源地(发货地)
|
||||
billMap.put("domesticSourcePlace", order.getLoadingName() != null ? order.getLoadingName() : "");
|
||||
billList.add(billMap);
|
||||
}
|
||||
}
|
||||
@@ -401,6 +436,30 @@ public class BusinessDocumentOrderApplicationService {
|
||||
|
||||
}
|
||||
|
||||
/** 根据区域ID或名称查ErpCountry表获取国别编码 */
|
||||
private String lookupErpCountryCode(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失败 areaId={} areaName={}", areaId, areaName, e);
|
||||
}
|
||||
return areaId != null ? areaId : "";
|
||||
}
|
||||
|
||||
|
||||
private void updatePushStatus(Long id, Integer pushStatus, Date pushTime, String pushBy, String pushByName) {
|
||||
try {
|
||||
|
||||
+12
@@ -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;
|
||||
|
||||
|
||||
+61
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user