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 a7b4d44e..125cea16 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java @@ -2149,6 +2149,8 @@ public class EstimateService { elm.text(StringUtils.defaultString(data.getObjectNameOmit())); sb = new StringBuilder(); + BigDecimal totGrossWt = BigDecimal.ZERO; + for (ItemResponse itemResponse : list) { String amountStr = StringUtils.defaultString(itemResponse.getAmount()); @@ -2163,6 +2165,9 @@ public class EstimateService { // grossWt가 0보다 큰지 체크 if (grossWt.compareTo(BigDecimal.ZERO) > 0) { BigDecimal totalWeight = amount.multiply(grossWt); + totGrossWt = totGrossWt.add(totalWeight); + elm = doc.getElementById("totGrossWt"); + elm.text(totGrossWt.toString()); sb.append(""); sb.append("") diff --git a/src/main/java/com/interplug/qcast/util/ExcelUtil.java b/src/main/java/com/interplug/qcast/util/ExcelUtil.java index 90814168..a25288cb 100644 --- a/src/main/java/com/interplug/qcast/util/ExcelUtil.java +++ b/src/main/java/com/interplug/qcast/util/ExcelUtil.java @@ -26,22 +26,6 @@ public class ExcelUtil { // DecimalFormat 인스턴스를 미리 생성 private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#,##0.000"); - /** - * 숫자 포맷팅을 위한 헬퍼 메서드 - */ - public static String formatNumber(Object amount, Object grossWt) { - try { - if (amount != null && grossWt != null) { - double amountValue = Double.parseDouble(amount.toString()); - double grossWtValue = Double.parseDouble(grossWt.toString()); - return DECIMAL_FORMAT.format(amountValue * grossWtValue); - } - } catch (NumberFormatException e) { - log.warn("Number formatting error: {}", e.getMessage()); - } - return "0.000"; - } - /** * jxls을 이용한 엑셀데이터 축출 * @@ -127,6 +111,10 @@ public class ExcelUtil { context.putVar("data", map); context.putVar("list", list); + // 포맷팅 함수를 컨텍스트에 추가 + context.putVar("formatNumber", new FormatNumberFunction()); + context.putVar("decimalFormat", DECIMAL_FORMAT); + JxlsHelper.getInstance().processTemplate(is, os, context); } } catch (Exception e) { @@ -192,8 +180,49 @@ public class ExcelUtil { * JXLS 템플릿에서 사용할 수 있는 포맷팅 함수 클래스 */ public static class FormatNumberFunction { + + /** + * 숫자 포맷팅을 위한 헬퍼 메서드 + */ + public static String formatNumber(Object amount, Object grossWt) { + + try { + if (amount != null && grossWt != null) { + double amountValue = Double.parseDouble(amount.toString()); + double grossWtValue = Double.parseDouble(grossWt.toString()); + return DECIMAL_FORMAT.format(amountValue * grossWtValue); + } + } catch (NumberFormatException e) { + log.warn("Number formatting error: {}", e.getMessage()); + } + return "0.000"; + } + public String format(Object amount, Object grossWt) { return formatNumber(amount, grossWt); } + + // 합계 계산을 위한 숫자 값 반환 메서드 + public Double calculate(Object amount, Object grossWt) { + try { + if (amount != null && grossWt != null) { + double amountValue = Double.parseDouble(amount.toString()); + double grossWtValue = Double.parseDouble(grossWt.toString()); + return amountValue * grossWtValue; + } + } catch (NumberFormatException e) { + log.warn("Number calculation error: {}", e.getMessage()); + } + return 0.0; + } + + // 리스트의 합계를 계산하고 포맷팅하는 메서드 + public String formatSum(List> items) { + double sum = 0.0; + for (Map item : items) { + sum += calculate(item.get("amount"), item.get("grossWt")); + } + return DECIMAL_FORMAT.format(sum); + } } -} +} \ No newline at end of file diff --git a/src/main/resources/mappers/estimate/estimateMapper.xml b/src/main/resources/mappers/estimate/estimateMapper.xml index ede876bc..87728112 100644 --- a/src/main/resources/mappers/estimate/estimateMapper.xml +++ b/src/main/resources/mappers/estimate/estimateMapper.xml @@ -286,7 +286,8 @@ , PEI.DISP_CABLE_FLG , PEI.ITEM_TP_CD , I.PNOW_W - , II.GROSS_WT + , CASE WHEN II.GROSS_WT > 0 AND I.ITEM_GROUP IN ('CABLE_','MODULE_','STAND_') THEN II.GROSS_WT + ELSE 0 END AS GROSS_WT , CASE WHEN I.POWER_COM_FLG = '1' THEN 'PC_' WHEN I.ITEM_GROUP = 'PC_' AND I.POWER_COM_FLG = '0' THEN 'STORAGE_BATTERY' ELSE I.ITEM_GROUP END AS ITEM_GROUP 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 c1e716a2..fb4ad026 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 diff --git a/src/main/resources/template/pdf/pdf_download_quotation_detail_template.html b/src/main/resources/template/pdf/pdf_download_quotation_detail_template.html index f71e6e9b..d96e776a 100644 --- a/src/main/resources/template/pdf/pdf_download_quotation_detail_template.html +++ b/src/main/resources/template/pdf/pdf_download_quotation_detail_template.html @@ -851,12 +851,12 @@ -
- システム重量合計 +
+ システム重量合計: kg
-
+
※システム重量は製品公差により変わる可能性があります。