diff --git a/src/main/java/com/xujie/sys/common/utils/ExcelTemplateALPHA.java b/src/main/java/com/xujie/sys/common/utils/ExcelTemplateALPHA.java index f666fb3f..e1179514 100644 --- a/src/main/java/com/xujie/sys/common/utils/ExcelTemplateALPHA.java +++ b/src/main/java/com/xujie/sys/common/utils/ExcelTemplateALPHA.java @@ -302,6 +302,7 @@ public class ExcelTemplateALPHA { Set invoiceUnitPriceCols = new HashSet<>(); Set invoiceTotalPriceCols = new HashSet<>(); Set declarationFixedPriceCols = new HashSet<>(); + Set declarationUnitPriceCols = new HashSet<>(); Set declarationQtyCols = new HashSet<>(); Set declarationHsCodeDescCols = new HashSet<>(); //整体填值 @@ -335,6 +336,8 @@ public class ExcelTemplateALPHA { invoiceUnitPriceCols.add(j); } else if (isInvoiceTotalPriceField(dtlField)) { invoiceTotalPriceCols.add(j); + } else if (isDeclarationUnitPriceField(dtlField)) { + declarationUnitPriceCols.add(j); } else if (isDeclarationFixedPriceField(dtlField)) { declarationFixedPriceCols.add(j); } else if (isDeclarationQtyField(dtlField)) { @@ -632,9 +635,10 @@ public class ExcelTemplateALPHA { style.setWrapText(keepWrapText || declarationHsCodeDescColumn); c7.setCellStyle(style); boolean declarationFixedTwoScaleColumn = fixedDeclarationPriceScale && declarationFixedPriceCols.contains(i); + boolean declarationFixedFiveScaleColumn = fixedDeclarationPriceScale && declarationUnitPriceCols.contains(i); boolean declarationQtyColumn = fixedDeclarationPriceScale && declarationQtyCols.contains(i); boolean declarationNumberColumn = fixedDeclarationPriceScale - ? (declarationFixedTwoScaleColumn || declarationQtyColumn) + ? (declarationFixedTwoScaleColumn || declarationFixedFiveScaleColumn || declarationQtyColumn) : (i == 6 || i == 11); if (declarationNumberColumn) { BigDecimal numericValue = null; @@ -644,7 +648,9 @@ public class ExcelTemplateALPHA { numericValue = BigDecimal.valueOf(c7.getNumericCellValue()); } if (numericValue != null) { - if (declarationFixedTwoScaleColumn) { + if (declarationFixedFiveScaleColumn) { + numericValue = numericValue.setScale(5, RoundingMode.HALF_UP); + } else if (declarationFixedTwoScaleColumn) { numericValue = numericValue.setScale(2, RoundingMode.HALF_UP); } c7.setCellValue(numericValue.doubleValue()); @@ -664,7 +670,9 @@ public class ExcelTemplateALPHA { // 设置千分位格式(根据单元格实际小数位动态决定格式) DataFormat dataFormat = workbook.createDataFormat(); String numFmt3; - if (declarationFixedTwoScaleColumn) { + if (declarationFixedFiveScaleColumn) { + numFmt3 = "#,##0.00000"; + } else if (declarationFixedTwoScaleColumn) { numFmt3 = "#,##0.00"; } else if (declarationQtyColumn) { numFmt3 = "#,##0"; @@ -913,10 +921,13 @@ public class ExcelTemplateALPHA { private boolean isDeclarationFixedPriceField(String field) { return "net_weight".equalsIgnoreCase(field) - || "unit_price".equalsIgnoreCase(field) || "total_price".equalsIgnoreCase(field); } + private boolean isDeclarationUnitPriceField(String field) { + return "unit_price".equalsIgnoreCase(field); + } + private boolean isDeclarationQtyField(String field) { return "qty".equalsIgnoreCase(field); } diff --git a/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java b/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java index 30376864..839c2afd 100644 --- a/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java +++ b/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java @@ -1075,10 +1075,27 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { @Override public void downloadDeclaration(HttpServletResponse response, EcssDeclarationHeaderData data) { try { - ExcelTemplateTX template = ExcelTemplateTX.load(new ClassPathResource("templates/TX/declaration-template.xlsx").getInputStream()); - extractedDeclaration(data, new TxExcelTemplateAdapter(template)); - try (XSSFWorkbook workbook = template.render(0)) { - workbook.write(response.getOutputStream()); + EcssCoDelNotifyHeaderData notifyHeader = coDelMapper.getEcssCoDelNotifyHeader(data.getSite(), data.getDelNo()); + String buNo = notifyHeader != null && StringUtils.isNotBlank(notifyHeader.getBuNo()) + ? notifyHeader.getBuNo() : data.getBuNo(); + if ("04-MHM".equalsIgnoreCase(buNo)) { + ExcelTemplateTX template = ExcelTemplateTX.load(new ClassPathResource("templates/TX/declaration-template.xlsx").getInputStream()); + extractedDeclaration(data, new TxExcelTemplateAdapter(template)); + try (XSSFWorkbook workbook = template.render(0)) { + workbook.write(response.getOutputStream()); + } + } else if ("02-Hardtag".equalsIgnoreCase(buNo)) { + ExcelTemplateYB template = ExcelTemplateYB.load(new ClassPathResource("templates/TX/declaration-template.xlsx").getInputStream()); + extractedDeclaration(data, new Yb2ExcelTemplateAdapter(template)); + try (XSSFWorkbook workbook = template.render(0)) { + workbook.write(response.getOutputStream()); + } + } else { + ExcelTemplateALPHA template = ExcelTemplateALPHA.load(new ClassPathResource("templates/TX/declaration-template.xlsx").getInputStream()); + extractedDeclaration(data, new YbExcelTemplateAdapter(template)); + try (XSSFWorkbook workbook = template.render(0)) { + workbook.write(response.getOutputStream()); + } } response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setHeader("Content-Disposition", "attachment; filename=\"danzheng.xlsx\""); @@ -3533,10 +3550,13 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { } template.addVar("Gross_Weight", (grossWeight.add(palletWeight)).setScale(2, RoundingMode.HALF_UP)); - if (palletHeaderDataList.isEmpty()) { + String unit = "托"; + if (palletHeaderDataList.isEmpty() || totalPlt == 0) { totalPlt = totalCartons.setScale(0, RoundingMode.HALF_UP).intValue(); + unit = "箱"; } template.addVar("total_plt", totalPlt); + template.addVar("unit", unit); } /** diff --git a/src/main/resources/templates/YB/declaration-all-template-invoice.xlsx b/src/main/resources/templates/YB/declaration-all-template-invoice.xlsx index ab18090b..8d98d41a 100644 Binary files a/src/main/resources/templates/YB/declaration-all-template-invoice.xlsx and b/src/main/resources/templates/YB/declaration-all-template-invoice.xlsx differ diff --git a/src/main/resources/templates/YB/declaration-all-template.xlsx b/src/main/resources/templates/YB/declaration-all-template.xlsx index ad100a93..497ef28d 100644 Binary files a/src/main/resources/templates/YB/declaration-all-template.xlsx and b/src/main/resources/templates/YB/declaration-all-template.xlsx differ