|
|
|
@ -1155,12 +1155,8 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
} |
|
|
|
|
|
|
|
boolean containsSpain = containsSpainKeyword( |
|
|
|
notifyHeader == null ? "" : notifyHeader.getCustomerName(), |
|
|
|
notifyHeader == null ? "" : notifyHeader.getLocalShipAddress(), |
|
|
|
notifyHeader == null ? "" : notifyHeader.getOverseasAddress(), |
|
|
|
data == null ? "" : data.getLocalShipper(), |
|
|
|
data == null ? "" : data.getLocalShipAddress(), |
|
|
|
data == null ? "" : data.getOverseasAddress() |
|
|
|
notifyHeader == null ? "" : notifyHeader.getDestination(), |
|
|
|
data == null ? "" : data.getDestination() |
|
|
|
); |
|
|
|
return containsSpain ? "Loading No." : LOADING_NO_HIDE_MARKER; |
|
|
|
} |
|
|
|
@ -1181,6 +1177,52 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
private boolean isUsaCanadaPackageUnitBu(String buNo) { |
|
|
|
if (StringUtils.isBlank(buNo)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
String buNoTrim = buNo.trim(); |
|
|
|
return "05-Alpha".equalsIgnoreCase(buNoTrim) |
|
|
|
|| "02-Hardtag".equalsIgnoreCase(buNoTrim) |
|
|
|
|| "04-MHM".equalsIgnoreCase(buNoTrim); |
|
|
|
} |
|
|
|
|
|
|
|
private boolean containsUsaOrCanadaKeyword(String... sourceTexts) { |
|
|
|
if (sourceTexts == null || sourceTexts.length == 0) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
for (String sourceText : sourceTexts) { |
|
|
|
if (StringUtils.isBlank(sourceText)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
String normalizedText = normalizeCountryCompareText(sourceText); |
|
|
|
if (normalizedText.contains("USA") || normalizedText.contains("CANADA")) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Alpha/硬标/天线场景按目的地 Destination 是否包含 USA/Canada 决定默认包装单位。 |
|
|
|
*/ |
|
|
|
private String resolveDeclarationPackageUnit(EcssDeclarationHeaderData data, EcssCoDelNotifyHeaderData notifyHeader) { |
|
|
|
String packageUnit = data == null ? "" : stringInput(data.getPackageUnit()).trim(); |
|
|
|
if (StringUtils.isNotBlank(packageUnit)) { |
|
|
|
return packageUnit; |
|
|
|
} |
|
|
|
String buNo = notifyHeader != null && StringUtils.isNotBlank(notifyHeader.getBuNo()) |
|
|
|
? notifyHeader.getBuNo() : (data == null ? "" : data.getBuNo()); |
|
|
|
if (!isUsaCanadaPackageUnitBu(buNo)) { |
|
|
|
return packageUnit; |
|
|
|
} |
|
|
|
boolean containsUsaOrCanada = containsUsaOrCanadaKeyword( |
|
|
|
notifyHeader == null ? "" : notifyHeader.getDestination(), |
|
|
|
data == null ? "" : data.getDestination() |
|
|
|
); |
|
|
|
return containsUsaOrCanada ? "箱" : packageUnit; |
|
|
|
} |
|
|
|
|
|
|
|
private String normalizeCountryCompareText(String sourceText) { |
|
|
|
if (StringUtils.isBlank(sourceText)) { |
|
|
|
return ""; |
|
|
|
@ -2181,8 +2223,9 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
.map(EcssCoDelPalletHeaderData::getPalletQty) |
|
|
|
.filter(Objects::nonNull) // 防止空指针 |
|
|
|
.reduce(0, Integer::sum); |
|
|
|
template.addVar("packageQty", data.getPackageUnit()!=null&&data.getPackageUnit().equals("箱")?ecHeader.getBoxQty():totalPlt); |
|
|
|
template.addVar("packageUnit", data.getPackageUnit()); |
|
|
|
String packageUnit = resolveDeclarationPackageUnit(data, notifyHeader); |
|
|
|
template.addVar("packageQty", "箱".equals(packageUnit) ? ecHeader.getBoxQty() : totalPlt); |
|
|
|
template.addVar("packageUnit", packageUnit); |
|
|
|
// 托盘重量=根据每个pallet的重量*数量累加 |
|
|
|
BigDecimal palletWeight = BigDecimal.ZERO; |
|
|
|
for (EcssCoDelPalletHeaderData palletHeader : palletHeaderDataList) { |
|
|
|
@ -2860,6 +2903,11 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
.map(EcssCoDelPalletHeaderData::getPalletQty) |
|
|
|
.filter(Objects::nonNull) // 防止空指针 |
|
|
|
.reduce(0, Integer::sum); |
|
|
|
boolean hasPalletData = !palletHeaderDataList.isEmpty() && totalPlt > 0; |
|
|
|
if (!hasPalletData) { |
|
|
|
// Alpha箱单:无托盘时隐藏Pallet列(第9列,索引8) |
|
|
|
template.hideColumn(8); |
|
|
|
} |
|
|
|
// 发货通知单明细 |
|
|
|
List<Map> detailList = coDelMapper.exportEcssCoDelNotifyDetail(data); |
|
|
|
Set<String> poNoSet = detailList.stream() |
|
|
|
@ -2939,7 +2987,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
} |
|
|
|
Integer palletQty = palletQtyMap.get(palletSeqNo); |
|
|
|
// 第一列展示托号(pallet_no),按托盘首行显示,后续行留空再做按托合并 |
|
|
|
eorder.put("seq_no", showPalletQty ? palletNo : ""); |
|
|
|
eorder.put("seq_no", !hasPalletData?(showPalletQty ? palletNo : ""):boxNo); |
|
|
|
eorder.put("total_pallets", showPalletQty ? (palletQty != null ? palletQty : "") : ""); |
|
|
|
eorder.put("volume", isFirstRow ? volume : ""); |
|
|
|
eorder.put("gross_weight", isFirstRow ? ((BigDecimal) list.get(m).get("gross_weight")).setScale(2, RoundingMode.HALF_UP) : ""); |
|
|
|
@ -3025,7 +3073,15 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
} else { |
|
|
|
totalPlt = totalCartons.setScale(0, RoundingMode.HALF_UP).intValue(); |
|
|
|
} |
|
|
|
template.addVar("total_plt", totalPlt+plt); |
|
|
|
if (hasPalletData) { |
|
|
|
template.addVar("total_plt", totalPlt+"PLT"); |
|
|
|
template.addVar("plt(", "(="); |
|
|
|
template.addVar("plt)", ")"); |
|
|
|
template.addVar("PLT", "PLT"); |
|
|
|
template.addVar("InclPalletWeight", "(Incl.Pallet Weight)"); |
|
|
|
} else { |
|
|
|
template.addVar("PLT", "CTN"); |
|
|
|
} |
|
|
|
// 孟加拉需要的 |
|
|
|
if (data.getMaterial()!=null && data.getMaterial()) { |
|
|
|
template.addVar("RFIDBase", "RFID Base Material"); |
|
|
|
|