|
|
@ -52,7 +52,7 @@ public class ExcelTemplateYB { |
|
|
// 发票价格列是否使用固定小数位(单价5位、总价2位) |
|
|
// 发票价格列是否使用固定小数位(单价5位、总价2位) |
|
|
@Setter |
|
|
@Setter |
|
|
private boolean fixedInvoicePriceScale = false; |
|
|
private boolean fixedInvoicePriceScale = false; |
|
|
// 报关单价格列是否固定两位小数(净重/单价/总价) |
|
|
|
|
|
|
|
|
// 报关单价格列是否固定小数位(净重/总价2位,单价5位) |
|
|
@Setter |
|
|
@Setter |
|
|
private boolean fixedDeclarationPriceScale = false; |
|
|
private boolean fixedDeclarationPriceScale = false; |
|
|
// 数字靠右 箱单 |
|
|
// 数字靠右 箱单 |
|
|
@ -316,6 +316,7 @@ public class ExcelTemplateYB { |
|
|
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<>(); |
|
|
//整体填值 |
|
|
//整体填值 |
|
|
@ -349,6 +350,8 @@ public class ExcelTemplateYB { |
|
|
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)) { |
|
|
@ -647,9 +650,10 @@ public class ExcelTemplateYB { |
|
|
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; |
|
|
@ -659,7 +663,9 @@ public class ExcelTemplateYB { |
|
|
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()); |
|
|
@ -679,7 +685,9 @@ public class ExcelTemplateYB { |
|
|
// 设置千分位格式(根据单元格实际小数位动态决定格式) |
|
|
// 设置千分位格式(根据单元格实际小数位动态决定格式) |
|
|
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"; |
|
|
@ -937,10 +945,13 @@ public class ExcelTemplateYB { |
|
|
|
|
|
|
|
|
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); |
|
|
} |
|
|
} |
|
|
|