[1157] DESING 견적 출력 시 중량표가 출력되지 않음 - 합계계산추가, 조건추가
This commit is contained in:
parent
b213960d9a
commit
2b1bbc75ad
@ -2149,6 +2149,8 @@ public class EstimateService {
|
|||||||
elm.text(StringUtils.defaultString(data.getObjectNameOmit()));
|
elm.text(StringUtils.defaultString(data.getObjectNameOmit()));
|
||||||
|
|
||||||
sb = new StringBuilder();
|
sb = new StringBuilder();
|
||||||
|
BigDecimal totGrossWt = BigDecimal.ZERO;
|
||||||
|
|
||||||
for (ItemResponse itemResponse : list) {
|
for (ItemResponse itemResponse : list) {
|
||||||
|
|
||||||
String amountStr = StringUtils.defaultString(itemResponse.getAmount());
|
String amountStr = StringUtils.defaultString(itemResponse.getAmount());
|
||||||
@ -2163,6 +2165,9 @@ public class EstimateService {
|
|||||||
// grossWt가 0보다 큰지 체크
|
// grossWt가 0보다 큰지 체크
|
||||||
if (grossWt.compareTo(BigDecimal.ZERO) > 0) {
|
if (grossWt.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
BigDecimal totalWeight = amount.multiply(grossWt);
|
BigDecimal totalWeight = amount.multiply(grossWt);
|
||||||
|
totGrossWt = totGrossWt.add(totalWeight);
|
||||||
|
elm = doc.getElementById("totGrossWt");
|
||||||
|
elm.text(totGrossWt.toString());
|
||||||
|
|
||||||
sb.append("<tr>");
|
sb.append("<tr>");
|
||||||
sb.append("<td style='width:120px;text-align:left;'>")
|
sb.append("<td style='width:120px;text-align:left;'>")
|
||||||
|
|||||||
@ -26,22 +26,6 @@ public class ExcelUtil {
|
|||||||
// DecimalFormat 인스턴스를 미리 생성
|
// DecimalFormat 인스턴스를 미리 생성
|
||||||
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#,##0.000");
|
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을 이용한 엑셀데이터 축출
|
* jxls을 이용한 엑셀데이터 축출
|
||||||
*
|
*
|
||||||
@ -127,6 +111,10 @@ public class ExcelUtil {
|
|||||||
context.putVar("data", map);
|
context.putVar("data", map);
|
||||||
context.putVar("list", list);
|
context.putVar("list", list);
|
||||||
|
|
||||||
|
// 포맷팅 함수를 컨텍스트에 추가
|
||||||
|
context.putVar("formatNumber", new FormatNumberFunction());
|
||||||
|
context.putVar("decimalFormat", DECIMAL_FORMAT);
|
||||||
|
|
||||||
JxlsHelper.getInstance().processTemplate(is, os, context);
|
JxlsHelper.getInstance().processTemplate(is, os, context);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -192,8 +180,49 @@ public class ExcelUtil {
|
|||||||
* JXLS 템플릿에서 사용할 수 있는 포맷팅 함수 클래스
|
* JXLS 템플릿에서 사용할 수 있는 포맷팅 함수 클래스
|
||||||
*/
|
*/
|
||||||
public static class FormatNumberFunction {
|
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) {
|
public String format(Object amount, Object grossWt) {
|
||||||
return formatNumber(amount, 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<Map<String, Object>> items) {
|
||||||
|
double sum = 0.0;
|
||||||
|
for (Map<String, Object> item : items) {
|
||||||
|
sum += calculate(item.get("amount"), item.get("grossWt"));
|
||||||
|
}
|
||||||
|
return DECIMAL_FORMAT.format(sum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -286,7 +286,8 @@
|
|||||||
, PEI.DISP_CABLE_FLG
|
, PEI.DISP_CABLE_FLG
|
||||||
, PEI.ITEM_TP_CD
|
, PEI.ITEM_TP_CD
|
||||||
, I.PNOW_W
|
, 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_'
|
, CASE WHEN I.POWER_COM_FLG = '1' THEN 'PC_'
|
||||||
WHEN I.ITEM_GROUP = 'PC_' AND I.POWER_COM_FLG = '0' THEN 'STORAGE_BATTERY'
|
WHEN I.ITEM_GROUP = 'PC_' AND I.POWER_COM_FLG = '0' THEN 'STORAGE_BATTERY'
|
||||||
ELSE I.ITEM_GROUP END AS ITEM_GROUP
|
ELSE I.ITEM_GROUP END AS ITEM_GROUP
|
||||||
|
|||||||
Binary file not shown.
@ -851,12 +851,12 @@
|
|||||||
|
|
||||||
<!-- 시스템 중량 정보 -->
|
<!-- 시스템 중량 정보 -->
|
||||||
|
|
||||||
<div style="text-align: center; font-size: 12px;">
|
<div style="text-align: right; font-size: 11px;">
|
||||||
<span>システム重量合計</span>
|
<span>システム重量合計: </span><span id="totGrossWt"></span> kg
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div style="text-align: center; font-size: 10px; color: #666; margin-bottom: 20px;">
|
<div style="text-align: right; font-size: 10px; color: #666; margin-bottom: 20px;">
|
||||||
※システム重量は製品公差により変わる可能性があります。
|
※システム重量は製品公差により変わる可能性があります。
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user