Browse Source

出货通知这边,如果是散箱出货的时候,需要显示对应的箱数

master
han\hanst 1 week ago
parent
commit
fb4fce6166
  1. 19
      src/main/java/com/xujie/sys/common/utils/ExcelTemplateALPHA.java
  2. 30
      src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java
  3. BIN
      src/main/resources/templates/YB/declaration-all-template-invoice.xlsx
  4. BIN
      src/main/resources/templates/YB/declaration-all-template.xlsx

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

@ -302,6 +302,7 @@ public class ExcelTemplateALPHA {
Set<Integer> invoiceUnitPriceCols = new HashSet<>(); Set<Integer> invoiceUnitPriceCols = new HashSet<>();
Set<Integer> invoiceTotalPriceCols = new HashSet<>(); Set<Integer> invoiceTotalPriceCols = new HashSet<>();
Set<Integer> declarationFixedPriceCols = new HashSet<>(); Set<Integer> declarationFixedPriceCols = new HashSet<>();
Set<Integer> declarationUnitPriceCols = new HashSet<>();
Set<Integer> declarationQtyCols = new HashSet<>(); Set<Integer> declarationQtyCols = new HashSet<>();
Set<Integer> declarationHsCodeDescCols = new HashSet<>(); Set<Integer> declarationHsCodeDescCols = new HashSet<>();
//整体填值 //整体填值
@ -335,6 +336,8 @@ public class ExcelTemplateALPHA {
invoiceUnitPriceCols.add(j); invoiceUnitPriceCols.add(j);
} else if (isInvoiceTotalPriceField(dtlField)) { } else if (isInvoiceTotalPriceField(dtlField)) {
invoiceTotalPriceCols.add(j); invoiceTotalPriceCols.add(j);
} else if (isDeclarationUnitPriceField(dtlField)) {
declarationUnitPriceCols.add(j);
} else if (isDeclarationFixedPriceField(dtlField)) { } else if (isDeclarationFixedPriceField(dtlField)) {
declarationFixedPriceCols.add(j); declarationFixedPriceCols.add(j);
} else if (isDeclarationQtyField(dtlField)) { } else if (isDeclarationQtyField(dtlField)) {
@ -632,9 +635,10 @@ public class ExcelTemplateALPHA {
style.setWrapText(keepWrapText || declarationHsCodeDescColumn); style.setWrapText(keepWrapText || declarationHsCodeDescColumn);
c7.setCellStyle(style); c7.setCellStyle(style);
boolean declarationFixedTwoScaleColumn = fixedDeclarationPriceScale && declarationFixedPriceCols.contains(i); boolean declarationFixedTwoScaleColumn = fixedDeclarationPriceScale && declarationFixedPriceCols.contains(i);
boolean declarationFixedFiveScaleColumn = fixedDeclarationPriceScale && declarationUnitPriceCols.contains(i);
boolean declarationQtyColumn = fixedDeclarationPriceScale && declarationQtyCols.contains(i); boolean declarationQtyColumn = fixedDeclarationPriceScale && declarationQtyCols.contains(i);
boolean declarationNumberColumn = fixedDeclarationPriceScale boolean declarationNumberColumn = fixedDeclarationPriceScale
? (declarationFixedTwoScaleColumn || declarationQtyColumn)
? (declarationFixedTwoScaleColumn || declarationFixedFiveScaleColumn || declarationQtyColumn)
: (i == 6 || i == 11); : (i == 6 || i == 11);
if (declarationNumberColumn) { if (declarationNumberColumn) {
BigDecimal numericValue = null; BigDecimal numericValue = null;
@ -644,7 +648,9 @@ public class ExcelTemplateALPHA {
numericValue = BigDecimal.valueOf(c7.getNumericCellValue()); numericValue = BigDecimal.valueOf(c7.getNumericCellValue());
} }
if (numericValue != null) { if (numericValue != null) {
if (declarationFixedTwoScaleColumn) {
if (declarationFixedFiveScaleColumn) {
numericValue = numericValue.setScale(5, RoundingMode.HALF_UP);
} else if (declarationFixedTwoScaleColumn) {
numericValue = numericValue.setScale(2, RoundingMode.HALF_UP); numericValue = numericValue.setScale(2, RoundingMode.HALF_UP);
} }
c7.setCellValue(numericValue.doubleValue()); c7.setCellValue(numericValue.doubleValue());
@ -664,7 +670,9 @@ public class ExcelTemplateALPHA {
// 设置千分位格式根据单元格实际小数位动态决定格式 // 设置千分位格式根据单元格实际小数位动态决定格式
DataFormat dataFormat = workbook.createDataFormat(); DataFormat dataFormat = workbook.createDataFormat();
String numFmt3; String numFmt3;
if (declarationFixedTwoScaleColumn) {
if (declarationFixedFiveScaleColumn) {
numFmt3 = "#,##0.00000";
} else if (declarationFixedTwoScaleColumn) {
numFmt3 = "#,##0.00"; numFmt3 = "#,##0.00";
} else if (declarationQtyColumn) { } else if (declarationQtyColumn) {
numFmt3 = "#,##0"; numFmt3 = "#,##0";
@ -913,10 +921,13 @@ public class ExcelTemplateALPHA {
private boolean isDeclarationFixedPriceField(String field) { private boolean isDeclarationFixedPriceField(String field) {
return "net_weight".equalsIgnoreCase(field) return "net_weight".equalsIgnoreCase(field)
|| "unit_price".equalsIgnoreCase(field)
|| "total_price".equalsIgnoreCase(field); || "total_price".equalsIgnoreCase(field);
} }
private boolean isDeclarationUnitPriceField(String field) {
return "unit_price".equalsIgnoreCase(field);
}
private boolean isDeclarationQtyField(String field) { private boolean isDeclarationQtyField(String field) {
return "qty".equalsIgnoreCase(field); return "qty".equalsIgnoreCase(field);
} }

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

@ -1075,10 +1075,27 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
@Override @Override
public void downloadDeclaration(HttpServletResponse response, EcssDeclarationHeaderData data) { public void downloadDeclaration(HttpServletResponse response, EcssDeclarationHeaderData data) {
try { 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.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment; filename=\"danzheng.xlsx\""); 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)); 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(); totalPlt = totalCartons.setScale(0, RoundingMode.HALF_UP).intValue();
unit = "箱";
} }
template.addVar("total_plt", totalPlt); template.addVar("total_plt", totalPlt);
template.addVar("unit", unit);
} }
/** /**

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

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

Loading…
Cancel
Save