diff --git a/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java b/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java index 50bb33ba..762dd534 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java @@ -6,6 +6,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; +import java.math.RoundingMode; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; @@ -1869,8 +1870,8 @@ public class EstimateService { } applyExcelNumberFormat(workbook); - applyExcelFixedNumberFormat(workbook, Arrays.asList("H25", "C12"), "#,##0.00"); - applyExcelFixedNumberFormat(workbook, Arrays.asList("X32", "I44"), "#,##0.00"); +// applyExcelFixedNumberFormat(workbook, Arrays.asList("H25", "C12"), "#,##0.00"); +// applyExcelFixedNumberFormat(workbook, Arrays.asList("X32", "I44"), "#,##0.00"); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); workbook.write(byteArrayOutputStream); @@ -2002,6 +2003,7 @@ public class EstimateService { private static void coerceExcelDataNumberFields(Map map) { coerceExcelNumberFields(map, EXCEL_DATA_NUMBER_FIELDS); + coerceExcelScale(map, "totVol", 2); } private static void coerceExcelRoofNumberFields(List> list) { @@ -2052,6 +2054,24 @@ public class EstimateService { } } + private static void coerceExcelScale(Map map, String key, int scale) { + if (map == null || key == null) { + return; + } + Object value = map.get(key); + Object parsed = parseExcelNumber(value); + if (!(parsed instanceof Number)) { + return; + } + BigDecimal decimal; + if (parsed instanceof BigDecimal) { + decimal = (BigDecimal) parsed; + } else { + decimal = new BigDecimal(parsed.toString()); + } + map.put(key, decimal.setScale(scale, RoundingMode.HALF_UP)); + } + private static void putExcelItemList(Map excelData, String key, List items) { if (excelData == null || items == null) { diff --git a/src/main/resources/template/excel/excel_download_quotation_detail_template.xlsx b/src/main/resources/template/excel/excel_download_quotation_detail_template.xlsx index 44c1ae17..1879e004 100644 Binary files a/src/main/resources/template/excel/excel_download_quotation_detail_template.xlsx and b/src/main/resources/template/excel/excel_download_quotation_detail_template.xlsx differ