Merge pull request '[1383]견적서 아이템 인코딩' (#311) from dev_cha into dev

Reviewed-on: #311
This commit is contained in:
ysCha 2026-01-12 16:58:18 +09:00
commit 2746e171d0

View File

@ -9,6 +9,8 @@ import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -16,6 +18,7 @@ import java.util.stream.Collectors;
import com.interplug.qcast.biz.canvaspopupstatus.CanvasPopupStatusService;
import com.interplug.qcast.biz.canvaspopupstatus.dto.CanvasPopupStatus;
import com.interplug.qcast.biz.pwrGnrSimulation.dto.PwrGnrSimRoofResponse;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
@ -26,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
import org.springframework.web.util.HtmlUtils;
import org.springframework.web.util.UriComponentsBuilder;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.interplug.qcast.biz.canvasStatus.CanvasStatusService;
@ -1421,16 +1425,7 @@ public class EstimateService {
// 각도 매핑 함수 호출
String mappedDegree = excelUtil.mapCompassDegree(degreeValue);
// String compasDegImgUrl = frontUrl + "/static/images/canvas/deg/" + mappedDegree + ".png";
// URL url = new URL(compasDegImgUrl);
// URLConnection con = url.openConnection();
// HttpURLConnection exitCode = (HttpURLConnection)con;
// if (exitCode.getResponseCode() == 200) {
// InputStream imageInputStream = new URL(compasDegImgUrl).openStream();
// byte[] degImg = Util.toByteArray(imageInputStream);
// roofInfoResponse.setCompasDegImg(degImg);
// }
try {
// classpath에서 리소스 파일을 읽어옵니다
@ -1469,6 +1464,31 @@ public class EstimateService {
for (ItemResponse itemResponse : estimateItemList) {
itemResponse.setNo(String.valueOf(j++));
// itemName 디코딩 HTML Unescape 처리
String itemName = itemResponse.getItemName();
if (StringUtils.isNotEmpty(itemName)) {
try {
// 1. URL 디코딩 (% 처리)
if (itemName.contains("%")) {
itemName = URLDecoder.decode(itemName, StandardCharsets.UTF_8);
}
// 2. HTML Unescape 처리 (& 포함된 경우만)
// Φ1 -> Φ1 -> Φ1 순차적으로 복원
if (itemName.contains("&")) {
String prevName;
do {
prevName = itemName;
itemName = HtmlUtils.htmlUnescape(itemName);
} while (!prevName.equals(itemName) && itemName.contains("&"));
}
itemResponse.setItemName(itemName);
} catch (Exception e) {
log.warn("Excel itemName processing failed: {}", itemName);
}
}
// 문자열 통화로 변환 처리
itemResponse.setSalePrice(
String.format("%1$,.0f", Double.parseDouble(itemResponse.getSalePrice())));