Browse Source

只在 05-Alpha、02-Hardtag 两个 BU 下启用 loadingNo 规则

master
han\hanst 3 weeks ago
parent
commit
177b943340
  1. 87
      src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java
  2. BIN
      src/main/resources/templates/ALPHA/declaration-all-template-pdf.xlsx
  3. BIN
      src/main/resources/templates/ALPHA/declaration-all-template.xlsx
  4. BIN
      src/main/resources/templates/TX/declaration-all-template-pdf.xlsx
  5. BIN
      src/main/resources/templates/TX/declaration-all-template.xlsx
  6. BIN
      src/main/resources/templates/TX/declaration-invoice2-template.xlsx
  7. BIN
      src/main/resources/templates/TX/export-goods-template.xlsx
  8. BIN
      src/main/resources/templates/YB/declaration-all-template-invoice-pdf.xlsx
  9. BIN
      src/main/resources/templates/YB/declaration-all-template-invoice.xlsx
  10. BIN
      src/main/resources/templates/YB/declaration-all-template-pdf.xlsx
  11. BIN
      src/main/resources/templates/YB/declaration-all-template.xlsx
  12. BIN
      src/main/resources/templates/YB/declaration-packingList-template.xlsx

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

@ -64,6 +64,8 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
"PO", "ERP编码", "名称", "PO", "ERP编码", "名称",
"Currency", "TP", "Total Revanue", "托数", "总体积", "净重", "毛重", "箱数","Qty" "Currency", "TP", "Total Revanue", "托数", "总体积", "净重", "毛重", "箱数","Qty"
); );
private static final String LOADING_NO_HIDE_MARKER = "__HIDE_LOADING_NO__";
private static final float LOADING_NO_COMPRESS_HEIGHT_POINTS = 4F;
@Override @Override
public Map<String, Object> previewExcelTX(MultipartFile file, EcssCoDelNotifyHeaderData inData) { public Map<String, Object> previewExcelTX(MultipartFile file, EcssCoDelNotifyHeaderData inData) {
String site = coDelMapper.getSiteByBu(inData.getBuNo()); String site = coDelMapper.getSiteByBu(inData.getBuNo());
@ -974,6 +976,87 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
|| "02-Hardtag".equalsIgnoreCase(buNoTrim); || "02-Hardtag".equalsIgnoreCase(buNoTrim);
} }
/**
* Alpha/硬标场景按客户名称客户地址收货地址是否包含 Spain/España 决定是否显示 Loading No.
*/
private String resolveLoadingNoTemplateValue(EcssDeclarationHeaderData data, EcssCoDelNotifyHeaderData notifyHeader) {
String buNo = notifyHeader != null && StringUtils.isNotBlank(notifyHeader.getBuNo())
? notifyHeader.getBuNo() : (data == null ? "" : data.getBuNo());
if (!isShowOrderNoBu(buNo)) {
return "";
}
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()
);
return containsSpain ? "Loading No." : LOADING_NO_HIDE_MARKER;
}
private boolean containsSpainKeyword(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("SPAIN") || normalizedText.contains("ESPANA")) {
return true;
}
}
return false;
}
private String normalizeCountryCompareText(String sourceText) {
if (StringUtils.isBlank(sourceText)) {
return "";
}
String normalized = java.text.Normalizer.normalize(sourceText, java.text.Normalizer.Form.NFD);
normalized = normalized.replaceAll("\\p{M}+", "");
return normalized.toUpperCase(Locale.ROOT);
}
/**
* 渲染后压缩隐藏 Loading No. 的行高避免空白占高
*/
private void compactLoadingNoRowIfNeeded(XSSFWorkbook workbook) {
if (workbook == null) {
return;
}
for (int sheetIndex = 0; sheetIndex < workbook.getNumberOfSheets(); sheetIndex++) {
Sheet sheet = workbook.getSheetAt(sheetIndex);
if (sheet == null) {
continue;
}
for (Row row : sheet) {
if (row == null) {
continue;
}
boolean needCompress = false;
for (Cell cell : row) {
if (cell == null || cell.getCellType() != CellType.STRING) {
continue;
}
if (LOADING_NO_HIDE_MARKER.equals(cell.getStringCellValue())) {
cell.setCellValue("");
needCompress = true;
}
}
if (needCompress) {
float defaultHeight = sheet.getDefaultRowHeightInPoints();
float targetHeight = Math.min(defaultHeight, LOADING_NO_COMPRESS_HEIGHT_POINTS);
row.setHeightInPoints(targetHeight);
}
}
}
}
/** /**
* 当前天线BU仅对 04-MHM 做报关单数值格式特殊处理 * 当前天线BU仅对 04-MHM 做报关单数值格式特殊处理
*/ */
@ -1344,6 +1427,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
ExcelTemplateTX template = ExcelTemplateTX.load(new ClassPathResource(xlsx).getInputStream()); ExcelTemplateTX template = ExcelTemplateTX.load(new ClassPathResource(xlsx).getInputStream());
extractedInvoice(data, new TxExcelTemplateAdapter(template), notifyHeader); extractedInvoice(data, new TxExcelTemplateAdapter(template), notifyHeader);
try (XSSFWorkbook workbook = template.render(0)) { try (XSSFWorkbook workbook = template.render(0)) {
compactLoadingNoRowIfNeeded(workbook);
workbook.write(response.getOutputStream()); workbook.write(response.getOutputStream());
} }
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
@ -1621,6 +1705,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
template.render(4); template.render(4);
} }
compactLoadingNoRowIfNeeded(workbook);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment; filename=\"danzheng.xlsx\""); response.setHeader("Content-Disposition", "attachment; filename=\"danzheng.xlsx\"");
workbook.write(response.getOutputStream()); workbook.write(response.getOutputStream());
@ -1739,6 +1824,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
template.render(3); template.render(3);
} }
compactLoadingNoRowIfNeeded(excelWorkbook);
// 将Excel转换为PDF // 将Excel转换为PDF
byte[] pdfBytes = convertExcelToPdf(excelWorkbook); byte[] pdfBytes = convertExcelToPdf(excelWorkbook);
@ -2137,6 +2223,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
template.addVar("Currency", currency); template.addVar("Currency", currency);
template.addVar("Incoterm", "EXW "); template.addVar("Incoterm", "EXW ");
template.addVar("shippingMode", stringInput(notifyHeader.getShippingMode())); template.addVar("shippingMode", stringInput(notifyHeader.getShippingMode()));
template.addVar("loadingNo", resolveLoadingNoTemplateValue(data, notifyHeader));
Map<String, EcssCoDelNotifyDetailData> notifyDetailMap = notifyDetailList.stream().collect( Map<String, EcssCoDelNotifyDetailData> notifyDetailMap = notifyDetailList.stream().collect(
Collectors.toMap(EcssCoDelNotifyDetailData::getPartNo,e->e)); Collectors.toMap(EcssCoDelNotifyDetailData::getPartNo,e->e));
// 装箱数据 // 装箱数据

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/TX/declaration-all-template-pdf.xlsx

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

BIN
src/main/resources/templates/TX/declaration-invoice2-template.xlsx

BIN
src/main/resources/templates/TX/export-goods-template.xlsx

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

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

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

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

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

Loading…
Cancel
Save