Browse Source

Alpha发票、报关单的单价是保留小数点后四位

箱单的重量都保留小数点后两位Alpha的箱单,散箱出货时,列号一栏表头需显示:CTN No",下面显示箱号,总托数那一栏可以不显示,下面的托数也不用显示美国跟加拿大的报关单上的件数要显示箱数,请帮忙修改下
master
han\hanst 6 days ago
parent
commit
4ca49a9b34
  1. 27
      src/main/java/com/xujie/sys/common/utils/ExcelTemplateALPHA.java
  2. 76
      src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java
  3. BIN
      src/main/resources/templates/ALPHA/declaration-all-template-pdf.xlsx
  4. BIN
      src/main/resources/templates/ALPHA/declaration-all-template.xlsx
  5. BIN
      src/main/resources/templates/ALPHA/declaration-packingList-template.xlsx

27
src/main/java/com/xujie/sys/common/utils/ExcelTemplateALPHA.java

@ -26,6 +26,8 @@ public class ExcelTemplateALPHA {
private List<int[]> mergeRegions = new ArrayList<>();
// 存储需要设置行高的行信息[起始行索引, 结束行索引, 行高]
private List<int[]> rowHeights = new ArrayList<>();
// 需要隐藏的列0-based
private Set<Integer> hiddenColumns = new LinkedHashSet<>();
// 是否下移形状格式
@Setter
private boolean moveShape = false;
@ -138,11 +140,21 @@ public class ExcelTemplateALPHA {
}
}
/**
* 隐藏指定列0-based
*/
public void hideColumn(int colIndex) {
if (colIndex >= 0) {
hiddenColumns.add(colIndex);
}
}
public void clearAll(){
variables.clear();
listVariables.clear();
mergeRegions.clear();
rowHeights.clear();
hiddenColumns.clear();
moveShape = false;
moveSeal = false;
cellStyle = false;
@ -511,7 +523,7 @@ public class ExcelTemplateALPHA {
DataFormat dataFormat = workbook.createDataFormat();
String numFmt;
if (fixedInvoicePriceScale && invoiceUnitPriceCols.contains(i)) {
numFmt = "#,##0.00000";
numFmt = "#,##0.0000";
} else if (fixedInvoicePriceScale && invoiceTotalPriceCols.contains(i)) {
numFmt = "#,##0.00";
} else if (c7.getCellType() == CellType.NUMERIC) {
@ -587,7 +599,7 @@ public class ExcelTemplateALPHA {
} else {
numFmt2 = "#,##0";
}
style7.setDataFormat(dataFormat.getFormat(numFmt2));
style7.setDataFormat(i==9||i==10?dataFormat.getFormat("#,##0.00"):dataFormat.getFormat(numFmt2));
}
c7.setCellStyle(style7);
}
@ -671,7 +683,7 @@ public class ExcelTemplateALPHA {
DataFormat dataFormat = workbook.createDataFormat();
String numFmt3;
if (declarationFixedFiveScaleColumn) {
numFmt3 = "#,##0.00000";
numFmt3 = "#,##0.0000";
} else if (declarationFixedTwoScaleColumn) {
numFmt3 = "#,##0.00";
} else if (declarationQtyColumn) {
@ -802,6 +814,15 @@ public class ExcelTemplateALPHA {
}
}
// 处理列隐藏
if (!hiddenColumns.isEmpty()) {
for (Integer colIndex : hiddenColumns) {
if (colIndex != null && colIndex >= 0) {
sheet.setColumnHidden(colIndex, true);
}
}
}
return workbook;
}

76
src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java

@ -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");

BIN
src/main/resources/templates/ALPHA/declaration-all-template-pdf.xlsx

BIN
src/main/resources/templates/ALPHA/declaration-all-template.xlsx

BIN
src/main/resources/templates/ALPHA/declaration-packingList-template.xlsx

Loading…
Cancel
Save