견적서 문서 다운로드 옵션 관련 수정

This commit is contained in:
basssy 2024-11-21 11:29:24 +09:00
parent 717ae6cfb9
commit 306d15f531

View File

@ -1,7 +1,43 @@
package com.interplug.qcast.biz.estimate; package com.interplug.qcast.biz.estimate;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
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.UriComponentsBuilder;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.interplug.qcast.biz.estimate.dto.*; import com.interplug.qcast.biz.estimate.dto.EstimateApiResponse;
import com.interplug.qcast.biz.estimate.dto.EstimateCopyRequest;
import com.interplug.qcast.biz.estimate.dto.EstimateRequest;
import com.interplug.qcast.biz.estimate.dto.EstimateResponse;
import com.interplug.qcast.biz.estimate.dto.EstimateSendRequest;
import com.interplug.qcast.biz.estimate.dto.EstimateSendResponse;
import com.interplug.qcast.biz.estimate.dto.ItemRequest;
import com.interplug.qcast.biz.estimate.dto.ItemResponse;
import com.interplug.qcast.biz.estimate.dto.NoteRequest;
import com.interplug.qcast.biz.estimate.dto.NoteResponse;
import com.interplug.qcast.biz.estimate.dto.PlanSyncResponse;
import com.interplug.qcast.biz.estimate.dto.PriceRequest;
import com.interplug.qcast.biz.estimate.dto.RoofInfoResponse;
import com.interplug.qcast.biz.estimate.dto.RoofRequest;
import com.interplug.qcast.biz.estimate.dto.RoofResponse;
import com.interplug.qcast.biz.file.FileMapper; import com.interplug.qcast.biz.file.FileMapper;
import com.interplug.qcast.biz.file.dto.FileRequest; import com.interplug.qcast.biz.file.dto.FileRequest;
import com.interplug.qcast.biz.file.dto.FileResponse; import com.interplug.qcast.biz.file.dto.FileResponse;
@ -19,26 +55,8 @@ import com.interplug.qcast.util.InterfaceQsp;
import com.interplug.qcast.util.PdfUtil; import com.interplug.qcast.util.PdfUtil;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
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.UriComponentsBuilder;
@Slf4j @Slf4j
@Service @Service
@ -46,7 +64,8 @@ import org.springframework.web.util.UriComponentsBuilder;
public class EstimateService { public class EstimateService {
private final InterfaceQsp interfaceQsp; private final InterfaceQsp interfaceQsp;
@Autowired Messages message; @Autowired
Messages message;
@Value("${file.ini.root.path}") @Value("${file.ini.root.path}")
private String baseDirPath; private String baseDirPath;
@ -63,7 +82,8 @@ public class EstimateService {
private final FileMapper fileMapper; private final FileMapper fileMapper;
@Autowired private PwrGnrSimService pwrGnrSimService; @Autowired
private PwrGnrSimService pwrGnrSimService;
/** /**
* QSP 1차점 price 관리 목록 조회 * QSP 1차점 price 관리 목록 조회
@ -75,31 +95,25 @@ public class EstimateService {
public EstimateApiResponse selectStorePriceList(PriceRequest priceRequest) throws Exception { public EstimateApiResponse selectStorePriceList(PriceRequest priceRequest) throws Exception {
// Validation // Validation
if (StringUtils.isEmpty(priceRequest.getSaleStoreId())) { if (StringUtils.isEmpty(priceRequest.getSaleStoreId())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sale Store ID")); message.getMessage("common.message.required.data", "Sale Store ID"));
} }
if (StringUtils.isEmpty(priceRequest.getSapSalesStoreCd())) { if (StringUtils.isEmpty(priceRequest.getSapSalesStoreCd())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sap Sale Store Code")); message.getMessage("common.message.required.data", "Sap Sale Store Code"));
} }
if (StringUtils.isEmpty(priceRequest.getDocTpCd())) { if (StringUtils.isEmpty(priceRequest.getDocTpCd())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Estimate Type")); message.getMessage("common.message.required.data", "Estimate Type"));
} }
EstimateApiResponse response = null; EstimateApiResponse response = null;
/* [1]. QSP API (url + param) Setting */ /* [1]. QSP API (url + param) Setting */
String url = QSP_API_URL + "/api/price/storePriceList"; String url = QSP_API_URL + "/api/price/storePriceList";
String apiUrl = String apiUrl = UriComponentsBuilder.fromHttpUrl(url)
UriComponentsBuilder.fromHttpUrl(url) .queryParam("saleStoreId", priceRequest.getSaleStoreId())
.queryParam("saleStoreId", priceRequest.getSaleStoreId()) .queryParam("sapSalesStoreCd", priceRequest.getSapSalesStoreCd())
.queryParam("sapSalesStoreCd", priceRequest.getSapSalesStoreCd()) .queryParam("docTpCd", priceRequest.getDocTpCd()).build().toUriString();
.queryParam("docTpCd", priceRequest.getDocTpCd())
.build()
.toUriString();
/* [2]. QSP API CALL -> Response */ /* [2]. QSP API CALL -> Response */
String strResponse = interfaceQsp.callApi(HttpMethod.GET, apiUrl, null); String strResponse = interfaceQsp.callApi(HttpMethod.GET, apiUrl, null);
@ -127,26 +141,22 @@ public class EstimateService {
public EstimateApiResponse selectItemPriceList(PriceRequest priceRequest) throws Exception { public EstimateApiResponse selectItemPriceList(PriceRequest priceRequest) throws Exception {
// Validation // Validation
if (StringUtils.isEmpty(priceRequest.getSaleStoreId())) { if (StringUtils.isEmpty(priceRequest.getSaleStoreId())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sale Store ID")); message.getMessage("common.message.required.data", "Sale Store ID"));
} }
if (StringUtils.isEmpty(priceRequest.getSapSalesStoreCd())) { if (StringUtils.isEmpty(priceRequest.getSapSalesStoreCd())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sap Sale Store Code")); message.getMessage("common.message.required.data", "Sap Sale Store Code"));
} }
if (StringUtils.isEmpty(priceRequest.getPriceCd())) { if (StringUtils.isEmpty(priceRequest.getPriceCd())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Price Code")); message.getMessage("common.message.required.data", "Price Code"));
} }
EstimateApiResponse response = null; EstimateApiResponse response = null;
/* [1]. QSP API CALL -> Response */ /* [1]. QSP API CALL -> Response */
String strResponse = String strResponse = interfaceQsp.callApi(HttpMethod.POST,
interfaceQsp.callApi( QSP_API_URL + "/api//price/storePriceItemList", priceRequest);
HttpMethod.POST, QSP_API_URL + "/api//price/storePriceItemList", priceRequest);
if (!"".equals(strResponse)) { if (!"".equals(strResponse)) {
com.fasterxml.jackson.databind.ObjectMapper om = com.fasterxml.jackson.databind.ObjectMapper om =
@ -183,13 +193,11 @@ public class EstimateService {
public EstimateResponse selectEstimateDetail(String objectNo, String planNo) throws Exception { public EstimateResponse selectEstimateDetail(String objectNo, String planNo) throws Exception {
// Validation // Validation
if (StringUtils.isEmpty(objectNo)) { if (StringUtils.isEmpty(objectNo)) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Object No")); message.getMessage("common.message.required.data", "Object No"));
} }
if (StringUtils.isEmpty(planNo)) { if (StringUtils.isEmpty(planNo)) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Plan No")); message.getMessage("common.message.required.data", "Plan No"));
} }
@ -233,23 +241,19 @@ public class EstimateService {
public void insertEstimate(EstimateRequest estimateRequest) throws Exception { public void insertEstimate(EstimateRequest estimateRequest) throws Exception {
// Validation // Validation
if (StringUtils.isEmpty(estimateRequest.getObjectNo())) { if (StringUtils.isEmpty(estimateRequest.getObjectNo())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Object No")); message.getMessage("common.message.required.data", "Object No"));
} }
if (StringUtils.isEmpty(estimateRequest.getPlanNo())) { if (StringUtils.isEmpty(estimateRequest.getPlanNo())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Plan No")); message.getMessage("common.message.required.data", "Plan No"));
} }
if (StringUtils.isEmpty(estimateRequest.getSaleStoreId())) { if (StringUtils.isEmpty(estimateRequest.getSaleStoreId())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sale Store ID")); message.getMessage("common.message.required.data", "Sale Store ID"));
} }
if (StringUtils.isEmpty(estimateRequest.getSapSalesStoreCd())) { if (StringUtils.isEmpty(estimateRequest.getSapSalesStoreCd())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sap Sale Store Code")); message.getMessage("common.message.required.data", "Sap Sale Store Code"));
} }
@ -268,8 +272,8 @@ public class EstimateService {
ObjectResponse objectResponse = ObjectResponse objectResponse =
objectMapper.selectObjectDetail(estimateRequest.getObjectNo()); objectMapper.selectObjectDetail(estimateRequest.getObjectNo());
if (objectResponse != null) { if (objectResponse != null) {
estimateRequest.setWeatherPoint( estimateRequest
objectResponse.getPrefName() + " - " + objectResponse.getAreaName()); .setWeatherPoint(objectResponse.getPrefName() + " - " + objectResponse.getAreaName());
estimateRequest.setCharger(objectResponse.getReceiveUser()); estimateRequest.setCharger(objectResponse.getReceiveUser());
} }
@ -391,10 +395,8 @@ public class EstimateService {
bomItem.setUnit(itemResponse.getUnit()); bomItem.setUnit(itemResponse.getUnit());
bomItem.setPnowW(itemResponse.getPnowW()); bomItem.setPnowW(itemResponse.getPnowW());
bomItem.setSpecification(itemResponse.getPnowW()); bomItem.setSpecification(itemResponse.getPnowW());
bomItem.setAmount( bomItem.setAmount(String.valueOf(Integer.parseInt(itemResponse.getBomAmount())
String.valueOf( * Integer.parseInt(itemRequest.getAmount())));
Integer.parseInt(itemResponse.getBomAmount())
* Integer.parseInt(itemRequest.getAmount())));
bomItem.setBomAmount(itemResponse.getBomAmount()); bomItem.setBomAmount(itemResponse.getBomAmount());
bomItem.setUnitPrice(itemResponse.getSalePrice()); bomItem.setUnitPrice(itemResponse.getSalePrice());
bomItem.setSalePrice(itemResponse.getSalePrice()); bomItem.setSalePrice(itemResponse.getSalePrice());
@ -485,29 +487,24 @@ public class EstimateService {
String pcTypeNo = ""; String pcTypeNo = "";
for (ItemRequest itemRequest : itemList) { for (ItemRequest itemRequest : itemList) {
if (StringUtils.isEmpty(itemRequest.getDispOrder())) { if (StringUtils.isEmpty(itemRequest.getDispOrder())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Display Order")); message.getMessage("common.message.required.data", "Display Order"));
} }
if (StringUtils.isEmpty(itemRequest.getItemId())) { if (StringUtils.isEmpty(itemRequest.getItemId())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Item ID")); message.getMessage("common.message.required.data", "Item ID"));
} }
if (StringUtils.isEmpty(itemRequest.getAmount())) { if (StringUtils.isEmpty(itemRequest.getAmount())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Item Amount")); message.getMessage("common.message.required.data", "Item Amount"));
} }
// 수량 // 수량
BigDecimal amount = BigDecimal amount = new BigDecimal(
new BigDecimal( StringUtils.isEmpty(itemRequest.getAmount()) ? "0" : itemRequest.getAmount());
StringUtils.isEmpty(itemRequest.getAmount()) ? "0" : itemRequest.getAmount());
// 아이템용량 // 아이템용량
BigDecimal pnowW = BigDecimal pnowW = new BigDecimal(
new BigDecimal( StringUtils.isEmpty(itemRequest.getPnowW()) ? "0" : itemRequest.getPnowW());
StringUtils.isEmpty(itemRequest.getPnowW()) ? "0" : itemRequest.getPnowW());
// 모듈/PC 체크 // 모듈/PC 체크
if ("MODULE_".equals(itemRequest.getItemGroup())) { if ("MODULE_".equals(itemRequest.getItemGroup())) {
@ -576,8 +573,7 @@ public class EstimateService {
itemRequest.setPartAdd( itemRequest.setPartAdd(
!StringUtils.isEmpty(itemRequest.getPartAdd()) ? itemRequest.getPartAdd() : "0"); !StringUtils.isEmpty(itemRequest.getPartAdd()) ? itemRequest.getPartAdd() : "0");
itemRequest.setItemChangeFlg( itemRequest.setItemChangeFlg(
!StringUtils.isEmpty(itemRequest.getItemChangeFlg()) !StringUtils.isEmpty(itemRequest.getItemChangeFlg()) ? itemRequest.getItemChangeFlg()
? itemRequest.getItemChangeFlg()
: "0"); : "0");
itemRequest.setUserId(estimateRequest.getUserId()); itemRequest.setUserId(estimateRequest.getUserId());
@ -616,13 +612,11 @@ public class EstimateService {
throws Exception { throws Exception {
// Validation // Validation
if (StringUtils.isEmpty(estimateCopyRequest.getObjectNo())) { if (StringUtils.isEmpty(estimateCopyRequest.getObjectNo())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Object No")); message.getMessage("common.message.required.data", "Object No"));
} }
if (StringUtils.isEmpty(estimateCopyRequest.getPlanNo())) { if (StringUtils.isEmpty(estimateCopyRequest.getPlanNo())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Plan No")); message.getMessage("common.message.required.data", "Plan No"));
} }
// 응답 객체 // 응답 객체
@ -632,8 +626,8 @@ public class EstimateService {
ObjectRequest objectRequest = new ObjectRequest(); ObjectRequest objectRequest = new ObjectRequest();
objectRequest.setSaleStoreId(estimateCopyRequest.getCopySaleStoreId()); objectRequest.setSaleStoreId(estimateCopyRequest.getCopySaleStoreId());
objectRequest.setReceiveUser( objectRequest
StringUtils.defaultString(estimateCopyRequest.getCopyReceiveUser())); .setReceiveUser(StringUtils.defaultString(estimateCopyRequest.getCopyReceiveUser()));
objectRequest.setDelFlg("0"); objectRequest.setDelFlg("0");
objectRequest.setTempFlg("0"); objectRequest.setTempFlg("0");
objectRequest.setTempDelFlg("0"); objectRequest.setTempDelFlg("0");
@ -710,8 +704,7 @@ public class EstimateService {
itemRequest.setPartAdd( itemRequest.setPartAdd(
!StringUtils.isEmpty(itemRequest.getPartAdd()) ? itemRequest.getPartAdd() : "0"); !StringUtils.isEmpty(itemRequest.getPartAdd()) ? itemRequest.getPartAdd() : "0");
itemRequest.setItemChangeFlg( itemRequest.setItemChangeFlg(
!StringUtils.isEmpty(itemRequest.getItemChangeFlg()) !StringUtils.isEmpty(itemRequest.getItemChangeFlg()) ? itemRequest.getItemChangeFlg()
? itemRequest.getItemChangeFlg()
: "0"); : "0");
itemRequest.setUserId(estimateCopyRequest.getUserId()); itemRequest.setUserId(estimateCopyRequest.getUserId());
@ -800,14 +793,13 @@ public class EstimateService {
* @param estimateRequest 견적서 엑셀 다운로드 요청 정보 * @param estimateRequest 견적서 엑셀 다운로드 요청 정보
* @throws Exception * @throws Exception
*/ */
public void excelDownload( public void excelDownload(HttpServletRequest request, HttpServletResponse response,
HttpServletRequest request, HttpServletResponse response, EstimateRequest estimateRequest) EstimateRequest estimateRequest) throws Exception {
throws Exception {
// file Name 명이 없는경우 // file Name 명이 없는경우
if (estimateRequest.getFileName() == null || "".equals(estimateRequest.getFileName())) { if (estimateRequest.getFileName() == null || "".equals(estimateRequest.getFileName())) {
estimateRequest.setFileName( estimateRequest
"Quation_Detail_" + new SimpleDateFormat("yyyyMMdd").format(new Date())); .setFileName("Quation_Detail_" + new SimpleDateFormat("yyyyMMdd").format(new Date()));
} }
EstimateResponse estimateResponse = new EstimateResponse(); EstimateResponse estimateResponse = new EstimateResponse();
@ -883,8 +875,8 @@ public class EstimateService {
List<ItemResponse> estimateItemList = estimateMapper.selectEstimateItemList(estimateRequest); List<ItemResponse> estimateItemList = estimateMapper.selectEstimateItemList(estimateRequest);
// 합산금액 계산 // 합산금액 계산
this.selectTotalPriceInfo( this.selectTotalPriceInfo(estimateResponse, estimateItemList,
estimateResponse, estimateItemList, estimateRequest.getSchUnitPriceFlg()); estimateRequest.getSchUnitPriceFlg());
int j = 1; int j = 1;
for (ItemResponse itemResponse : estimateItemList) { for (ItemResponse itemResponse : estimateItemList) {
@ -893,8 +885,8 @@ public class EstimateService {
// 문자열 통화로 변환 처리 // 문자열 통화로 변환 처리
itemResponse.setSalePrice( itemResponse.setSalePrice(
String.format("%1$,.0f", Double.parseDouble(itemResponse.getSalePrice()))); String.format("%1$,.0f", Double.parseDouble(itemResponse.getSalePrice())));
itemResponse.setAmount( itemResponse
String.format("%1$,.0f", Double.parseDouble(itemResponse.getAmount()))); .setAmount(String.format("%1$,.0f", Double.parseDouble(itemResponse.getAmount())));
itemResponse.setSaleTotPrice( itemResponse.setSaleTotPrice(
String.format("%1$,.0f", Double.parseDouble(itemResponse.getSaleTotPrice()))); String.format("%1$,.0f", Double.parseDouble(itemResponse.getSaleTotPrice())));
@ -908,14 +900,14 @@ public class EstimateService {
// 합산 문자열 통화로 변환 처리 // 합산 문자열 통화로 변환 처리
estimateResponse.setPkgYn("YJSS".equals(estimateResponse.getEstimateType()) ? "Y" : "N"); estimateResponse.setPkgYn("YJSS".equals(estimateResponse.getEstimateType()) ? "Y" : "N");
estimateResponse.setPkgNo( estimateResponse
"YJSS".equals(estimateResponse.getEstimateType()) ? String.valueOf(j++) : ""); .setPkgNo("YJSS".equals(estimateResponse.getEstimateType()) ? String.valueOf(j++) : "");
if ("YJSS".equals(estimateResponse.getEstimateType())) { if ("YJSS".equals(estimateResponse.getEstimateType())) {
estimateResponse.setPkgAsp( estimateResponse
String.format("%1$,.0f", Double.parseDouble(estimateResponse.getPkgAsp()))); .setPkgAsp(String.format("%1$,.0f", Double.parseDouble(estimateResponse.getPkgAsp())));
} }
estimateResponse.setTotVol( estimateResponse
String.format("%1$,.0f", Double.parseDouble(estimateResponse.getTotVol()))); .setTotVol(String.format("%1$,.0f", Double.parseDouble(estimateResponse.getTotVol())));
estimateResponse.setPkgTotPrice( estimateResponse.setPkgTotPrice(
String.format("%1$,.0f", Double.parseDouble(estimateResponse.getPkgTotPrice()))); String.format("%1$,.0f", Double.parseDouble(estimateResponse.getPkgTotPrice())));
estimateResponse.setSupplyPrice( estimateResponse.setSupplyPrice(
@ -925,7 +917,7 @@ public class EstimateService {
estimateResponse.setTotPrice( estimateResponse.setTotPrice(
String.format("%1$,.0f", Double.parseDouble(estimateResponse.getTotPrice()))); String.format("%1$,.0f", Double.parseDouble(estimateResponse.getTotPrice())));
// 발전시뮬레이션 계산 // 발전시뮬레이션 계산
PwrGnrSimRequest pwrGnrSimRequest = new PwrGnrSimRequest(); PwrGnrSimRequest pwrGnrSimRequest = new PwrGnrSimRequest();
pwrGnrSimRequest.setObjectNo(estimateResponse.getObjectNo()); pwrGnrSimRequest.setObjectNo(estimateResponse.getObjectNo());
pwrGnrSimRequest.setPlanNo(estimateResponse.getPlanNo()); pwrGnrSimRequest.setPlanNo(estimateResponse.getPlanNo());
@ -937,11 +929,11 @@ public class EstimateService {
if (pwrGnrSimResponse != null) { if (pwrGnrSimResponse != null) {
try { try {
// 발전시뮬레이션 안내사항 조회 // 발전시뮬레이션 안내사항 조회
// PwrGnrSimGuideResponse pwrGnrSimGuideInfo = // PwrGnrSimGuideResponse pwrGnrSimGuideInfo =
// pwrGnrSimService.selectPwrGnrSimulationGuideInfo(); // pwrGnrSimService.selectPwrGnrSimulationGuideInfo();
// if (pwrGnrSimGuideInfo != null) { // if (pwrGnrSimGuideInfo != null) {
// pwrGnrSimResponse.setGuideInfo(pwrGnrSimGuideInfo.getData()); // pwrGnrSimResponse.setGuideInfo(pwrGnrSimGuideInfo.getData());
// } // }
} catch (Exception e) { } catch (Exception e) {
} }
} }
@ -949,7 +941,7 @@ public class EstimateService {
estimateResponse.setPwrGnrSim(pwrGnrSimResponse); estimateResponse.setPwrGnrSim(pwrGnrSimResponse);
if ("PDF".equals(estimateRequest.getSchDownload())) { // PDF 다운로드 if ("PDF".equals(estimateRequest.getSchDownload())) { // PDF 다운로드
String[] arrSection = new String[5]; String[] arrSection = new String[6];
int iSection = 0; int iSection = 0;
String templateFilePath = "pdf_download_quotation_detail_template.html"; String templateFilePath = "pdf_download_quotation_detail_template.html";
@ -997,12 +989,8 @@ public class EstimateService {
String excelTemplateNam = "excel_download_quotation_detail_template.xlsx"; String excelTemplateNam = "excel_download_quotation_detail_template.xlsx";
ExcelUtil excelUtil = new ExcelUtil(); ExcelUtil excelUtil = new ExcelUtil();
excelUtil.download( excelUtil.download(request, response, this.convertVoToMap(estimateResponse),
request, this.convertListToMap(estimateItemList), estimateRequest.getFileName(),
response,
this.convertVoToMap(estimateResponse),
this.convertListToMap(estimateItemList),
estimateRequest.getFileName(),
excelTemplateNam); excelTemplateNam);
} }
@ -1019,9 +1007,8 @@ public class EstimateService {
* @param unitPriceFlg 가격 표시 코드 * @param unitPriceFlg 가격 표시 코드
* @throws Exception * @throws Exception
*/ */
public void selectTotalPriceInfo( public void selectTotalPriceInfo(EstimateResponse estimateResponse, List<ItemResponse> itemList,
EstimateResponse estimateResponse, List<ItemResponse> itemList, String unitPriceFlg) String unitPriceFlg) throws Exception {
throws Exception {
BigDecimal totAmount = BigDecimal.ZERO; BigDecimal totAmount = BigDecimal.ZERO;
BigDecimal totVol = BigDecimal.ZERO; BigDecimal totVol = BigDecimal.ZERO;
BigDecimal pkgTotPrice = BigDecimal.ZERO; BigDecimal pkgTotPrice = BigDecimal.ZERO;
@ -1032,34 +1019,25 @@ public class EstimateService {
String estimateType = estimateResponse.getEstimateType(); String estimateType = estimateResponse.getEstimateType();
// 주택패키지 단가 // 주택패키지 단가
BigDecimal pkgAsp = BigDecimal pkgAsp = new BigDecimal(
new BigDecimal( StringUtils.isEmpty(estimateResponse.getPkgAsp()) ? "0" : estimateResponse.getPkgAsp());
StringUtils.isEmpty(estimateResponse.getPkgAsp()) ? "0" : estimateResponse.getPkgAsp());
for (ItemResponse itemResponse : itemList) { for (ItemResponse itemResponse : itemList) {
// 수량 // 수량
BigDecimal amount = BigDecimal amount = new BigDecimal(
new BigDecimal( StringUtils.isEmpty(itemResponse.getAmount()) ? "0" : itemResponse.getAmount());
StringUtils.isEmpty(itemResponse.getAmount()) ? "0" : itemResponse.getAmount());
// 판매가 // 판매가
BigDecimal salePrice = BigDecimal.ZERO; BigDecimal salePrice = BigDecimal.ZERO;
if ("1".equals(unitPriceFlg)) { if ("1".equals(unitPriceFlg)) {
salePrice = salePrice = new BigDecimal(
new BigDecimal( StringUtils.isEmpty(itemResponse.getUnitPrice()) ? "0" : itemResponse.getUnitPrice());
StringUtils.isEmpty(itemResponse.getUnitPrice())
? "0"
: itemResponse.getUnitPrice());
} else { } else {
salePrice = salePrice = new BigDecimal(
new BigDecimal( StringUtils.isEmpty(itemResponse.getSalePrice()) ? "0" : itemResponse.getSalePrice());
StringUtils.isEmpty(itemResponse.getSalePrice())
? "0"
: itemResponse.getSalePrice());
} }
// 아이템용량 // 아이템용량
BigDecimal pnowW = BigDecimal pnowW = new BigDecimal(
new BigDecimal( StringUtils.isEmpty(itemResponse.getPnowW()) ? "0" : itemResponse.getPnowW());
StringUtils.isEmpty(itemResponse.getPnowW()) ? "0" : itemResponse.getPnowW());
// 아이템 단가 합산 // 아이템 단가 합산
itemResponse.setSaleTotPrice(String.valueOf(salePrice.multiply(amount))); itemResponse.setSaleTotPrice(String.valueOf(salePrice.multiply(amount)));
@ -1103,11 +1081,10 @@ public class EstimateService {
estimateResponse.setPkgTotPrice(String.valueOf(pkgTotPrice)); estimateResponse.setPkgTotPrice(String.valueOf(pkgTotPrice));
estimateResponse.setTotAmount(String.valueOf(totAmount.setScale(0, BigDecimal.ROUND_HALF_UP))); estimateResponse.setTotAmount(String.valueOf(totAmount.setScale(0, BigDecimal.ROUND_HALF_UP)));
estimateResponse.setTotVol(String.valueOf(totVol)); estimateResponse.setTotVol(String.valueOf(totVol));
estimateResponse.setTotVolKw( estimateResponse.setTotVolKw(String
String.valueOf( .valueOf(totVol.multiply(new BigDecimal("0.001")).setScale(3, BigDecimal.ROUND_FLOOR)));
totVol.multiply(new BigDecimal("0.001")).setScale(3, BigDecimal.ROUND_FLOOR))); estimateResponse
estimateResponse.setSupplyPrice( .setSupplyPrice(String.valueOf(supplyPrice.setScale(0, BigDecimal.ROUND_HALF_UP)));
String.valueOf(supplyPrice.setScale(0, BigDecimal.ROUND_HALF_UP)));
estimateResponse.setVatPrice(String.valueOf(vatPrice.setScale(0, BigDecimal.ROUND_HALF_UP))); estimateResponse.setVatPrice(String.valueOf(vatPrice.setScale(0, BigDecimal.ROUND_HALF_UP)));
estimateResponse.setTotPrice(String.valueOf(totPrice.setScale(0, BigDecimal.ROUND_HALF_UP))); estimateResponse.setTotPrice(String.valueOf(totPrice.setScale(0, BigDecimal.ROUND_HALF_UP)));
} }
@ -1160,9 +1137,8 @@ public class EstimateService {
EstimateApiResponse response = null; EstimateApiResponse response = null;
/* [1]. QSP API CALL -> Response */ /* [1]. QSP API CALL -> Response */
String strResponse = String strResponse = interfaceQsp.callApi(HttpMethod.POST,
interfaceQsp.callApi( QSP_API_URL + "/api/order/qcastQuotationSave", estimateSendRequest);
HttpMethod.POST, QSP_API_URL + "/api/order/qcastQuotationSave", estimateSendRequest);
if (!"".equals(strResponse)) { if (!"".equals(strResponse)) {
com.fasterxml.jackson.databind.ObjectMapper om = com.fasterxml.jackson.databind.ObjectMapper om =
@ -1256,28 +1232,18 @@ public class EstimateService {
sb.append("<tr>"); sb.append("<tr>");
sb.append( sb.append(
"<td style='width:60px;'>" + StringUtils.defaultString(itemResponse.getNo()) + "</td>"); "<td style='width:60px;'>" + StringUtils.defaultString(itemResponse.getNo()) + "</td>");
sb.append( sb.append("<td style='width:120px;text-align:left;'>"
"<td style='width:120px;text-align:left;'>" + StringUtils.defaultString(itemResponse.getItemName()) + "</td>");
+ StringUtils.defaultString(itemResponse.getItemName()) sb.append("<td style='width:120px;'>" + StringUtils.defaultString(itemResponse.getItemNo())
+ "</td>"); + "</td>");
sb.append( sb.append("<td style='width:80px;text-align:right;'>"
"<td style='width:120px;'>" + StringUtils.defaultString(itemResponse.getSalePrice()) + "</td>");
+ StringUtils.defaultString(itemResponse.getItemNo()) sb.append("<td style='width:60px;text-align:right;'>"
+ "</td>"); + StringUtils.defaultString(itemResponse.getAmount()) + "</td>");
sb.append(
"<td style='width:80px;text-align:right;'>"
+ StringUtils.defaultString(itemResponse.getSalePrice())
+ "</td>");
sb.append(
"<td style='width:60px;text-align:right;'>"
+ StringUtils.defaultString(itemResponse.getAmount())
+ "</td>");
sb.append( sb.append(
"<td style='width:60px;'>" + StringUtils.defaultString(itemResponse.getUnit()) + "</td>"); "<td style='width:60px;'>" + StringUtils.defaultString(itemResponse.getUnit()) + "</td>");
sb.append( sb.append("<td style='width:80px;text-align:right;'>"
"<td style='width:80px;text-align:right;'>" + StringUtils.defaultString(itemResponse.getSaleTotPrice()) + "</td>");
+ StringUtils.defaultString(itemResponse.getSaleTotPrice())
+ "</td>");
sb.append("</tr>"); sb.append("</tr>");
} }
if ("Y".equals(data.getPkgYn())) { if ("Y".equals(data.getPkgYn())) {
@ -1285,19 +1251,13 @@ public class EstimateService {
sb.append("<td style='width:60px;'>" + StringUtils.defaultString(data.getPkgNo()) + "</td>"); sb.append("<td style='width:60px;'>" + StringUtils.defaultString(data.getPkgNo()) + "</td>");
sb.append("<td style='width:120px;text-align:left;'>住宅 PKG</td>"); sb.append("<td style='width:120px;text-align:left;'>住宅 PKG</td>");
sb.append("<td style='width:120px;'>-</td>"); sb.append("<td style='width:120px;'>-</td>");
sb.append( sb.append("<td style='width:80px;text-align:right;'>"
"<td style='width:80px;text-align:right;'>" + StringUtils.defaultString(data.getPkgAsp()) + "</td>");
+ StringUtils.defaultString(data.getPkgAsp()) sb.append("<td style='width:60px;text-align:right;'>"
+ "</td>"); + StringUtils.defaultString(data.getTotVol()) + "</td>");
sb.append(
"<td style='width:60px;text-align:right;'>"
+ StringUtils.defaultString(data.getTotVol())
+ "</td>");
sb.append("<td style='width:60px;'>W</td>"); sb.append("<td style='width:60px;'>W</td>");
sb.append( sb.append("<td style='width:80px;text-align:right;'>"
"<td style='width:80px;text-align:right;'>" + StringUtils.defaultString(data.getPkgTotPrice()) + "</td>");
+ StringUtils.defaultString(data.getPkgTotPrice())
+ "</td>");
sb.append("</tr>"); sb.append("</tr>");
} }
elm = doc.getElementById("itemList_detail"); elm = doc.getElementById("itemList_detail");
@ -1320,14 +1280,10 @@ public class EstimateService {
sb = new StringBuilder(); sb = new StringBuilder();
for (NoteResponse noteResponse : data.getNoteList()) { for (NoteResponse noteResponse : data.getNoteList()) {
sb.append("<tr>"); sb.append("<tr>");
sb.append( sb.append("<td style='text-align:left;'>"
"<td style='text-align:left;'>" + StringUtils.defaultString(noteResponse.getCodeNm()) + "</td>");
+ StringUtils.defaultString(noteResponse.getCodeNm()) sb.append("<td style='text-align:left;'>"
+ "</td>"); + StringUtils.defaultString(noteResponse.getRemarks()) + "</td>");
sb.append(
"<td style='text-align:left;'>"
+ StringUtils.defaultString(noteResponse.getRemarks())
+ "</td>");
sb.append("</tr>"); sb.append("</tr>");
} }
elm = doc.getElementById("noteList_detail"); elm = doc.getElementById("noteList_detail");
@ -1336,11 +1292,8 @@ public class EstimateService {
// 도면 설정 // 도면 설정
elm = doc.getElementById("objectNo4"); elm = doc.getElementById("objectNo4");
elm.text( elm.text(StringUtils.defaultString(data.getObjectNo()) + " (Plan No : "
StringUtils.defaultString(data.getObjectNo()) + StringUtils.defaultString(data.getPlanNo()) + ")");
+ " (Plan No : "
+ StringUtils.defaultString(data.getPlanNo())
+ ")");
elm = doc.getElementById("objectName"); elm = doc.getElementById("objectName");
elm.text(StringUtils.defaultString(data.getObjectName())); elm.text(StringUtils.defaultString(data.getObjectName()));
@ -1374,14 +1327,10 @@ public class EstimateService {
if (!"STAND_".equals(itemResponse.getItemGroup())) { if (!"STAND_".equals(itemResponse.getItemGroup())) {
sb.append("<tr>"); sb.append("<tr>");
sb.append("<td>" + (no++) + "</td>"); sb.append("<td>" + (no++) + "</td>");
sb.append( sb.append("<td style='text-align:left;'>"
"<td style='text-align:left;'>" + StringUtils.defaultString(itemResponse.getItemNo()) + "</td>");
+ StringUtils.defaultString(itemResponse.getItemNo()) sb.append("<td style='text-align:right;'>"
+ "</td>"); + StringUtils.defaultString(itemResponse.getAmount()) + "</td>");
sb.append(
"<td style='text-align:right;'>"
+ StringUtils.defaultString(itemResponse.getAmount())
+ "</td>");
sb.append("</tr>"); sb.append("</tr>");
} }
} }
@ -1395,12 +1344,8 @@ public class EstimateService {
sb.append("<tr>"); sb.append("<tr>");
sb.append("<td>" + (no++) + "</td>"); sb.append("<td>" + (no++) + "</td>");
sb.append( sb.append(
"<td style='text-align:left;'>" "<td style='text-align:left;'>" + StringUtils.defaultString(roofResponse.getItemNo())
+ StringUtils.defaultString(roofResponse.getItemNo()) + "[" + roofResponse.getPcModuleAmount() + "]" + "</td>");
+ "["
+ roofResponse.getPcModuleAmount()
+ "]"
+ "</td>");
sb.append("</tr>"); sb.append("</tr>");
} }
elm = doc.getElementById("pcsItemList_detail"); elm = doc.getElementById("pcsItemList_detail");
@ -1414,10 +1359,8 @@ public class EstimateService {
sb.append("<td>" + StringUtils.defaultString(roofResponse.getRoofSurface()) + "</td>"); sb.append("<td>" + StringUtils.defaultString(roofResponse.getRoofSurface()) + "</td>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getClassTypeName()) + "</td>"); sb.append("<td>" + StringUtils.defaultString(roofResponse.getClassTypeName()) + "</td>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getAmount()) + "</td>"); sb.append("<td>" + StringUtils.defaultString(roofResponse.getAmount()) + "</td>");
sb.append( sb.append("<td style='text-align:right;'>"
"<td style='text-align:right;'>" + StringUtils.defaultString(roofResponse.getVolKw()) + "</td>");
+ StringUtils.defaultString(roofResponse.getVolKw())
+ "</td>");
sb.append("</tr>"); sb.append("</tr>");
} }
elm = doc.getElementById("surFaceList_detail"); elm = doc.getElementById("surFaceList_detail");
@ -1435,19 +1378,13 @@ public class EstimateService {
for (RoofResponse roofResponse : data.getRoofInfo().getRoofList()) { for (RoofResponse roofResponse : data.getRoofInfo().getRoofList()) {
sb.append("<tr>"); sb.append("<tr>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getRoofSurface()) + "</td>"); sb.append("<td>" + StringUtils.defaultString(roofResponse.getRoofSurface()) + "</td>");
sb.append( sb.append("<td style='text-align:left;'>"
"<td style='text-align:left;'>" + StringUtils.defaultString(roofResponse.getRoofMaterialName()) + "</td>");
+ StringUtils.defaultString(roofResponse.getRoofMaterialName())
+ "</td>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getSlope()) + "寸</td>"); sb.append("<td>" + StringUtils.defaultString(roofResponse.getSlope()) + "寸</td>");
sb.append( sb.append("<td>" + StringUtils.defaultString(roofResponse.getConstructSpecificationName())
"<td>" + "</td>");
+ StringUtils.defaultString(roofResponse.getConstructSpecificationName()) sb.append("<td style='text-align:left;'>"
+ "</td>"); + StringUtils.defaultString(roofResponse.getSupportMethodName()) + "</td>");
sb.append(
"<td style='text-align:left;'>"
+ StringUtils.defaultString(roofResponse.getSupportMethodName())
+ "</td>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getSurfaceType()) + "</td>"); sb.append("<td>" + StringUtils.defaultString(roofResponse.getSurfaceType()) + "</td>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getSetupHeight()) + "</td>"); sb.append("<td>" + StringUtils.defaultString(roofResponse.getSetupHeight()) + "</td>");
sb.append("</tr>"); sb.append("</tr>");
@ -1457,11 +1394,8 @@ public class EstimateService {
} }
elm = doc.getElementById("objectNo5"); elm = doc.getElementById("objectNo5");
elm.text( elm.text(StringUtils.defaultString(data.getObjectNo()) + " (Plan No : "
StringUtils.defaultString(data.getObjectNo()) + StringUtils.defaultString(data.getPlanNo()) + ")");
+ " (Plan No : "
+ StringUtils.defaultString(data.getPlanNo())
+ ")");
elm = doc.getElementById("objectName5"); elm = doc.getElementById("objectName5");
elm.text(StringUtils.defaultString(data.getObjectName())); elm.text(StringUtils.defaultString(data.getObjectName()));
@ -1495,14 +1429,10 @@ public class EstimateService {
if ("STAND_".equals(itemResponse.getItemGroup())) { if ("STAND_".equals(itemResponse.getItemGroup())) {
sb.append("<tr>"); sb.append("<tr>");
sb.append("<td>" + (no++) + "</td>"); sb.append("<td>" + (no++) + "</td>");
sb.append( sb.append("<td style='text-align:left;'>"
"<td style='text-align:left;'>" + StringUtils.defaultString(itemResponse.getItemNo()) + "</td>");
+ StringUtils.defaultString(itemResponse.getItemNo()) sb.append("<td style='text-align:right;'>"
+ "</td>"); + StringUtils.defaultString(itemResponse.getAmount()) + "</td>");
sb.append(
"<td style='text-align:right;'>"
+ StringUtils.defaultString(itemResponse.getAmount())
+ "</td>");
sb.append("</tr>"); sb.append("</tr>");
} }
} }
@ -1514,19 +1444,13 @@ public class EstimateService {
for (RoofResponse roofResponse : data.getRoofInfo().getRoofList()) { for (RoofResponse roofResponse : data.getRoofInfo().getRoofList()) {
sb.append("<tr>"); sb.append("<tr>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getRoofSurface()) + "</td>"); sb.append("<td>" + StringUtils.defaultString(roofResponse.getRoofSurface()) + "</td>");
sb.append( sb.append("<td style='text-align:left;'>"
"<td style='text-align:left;'>" + StringUtils.defaultString(roofResponse.getRoofMaterialName()) + "</td>");
+ StringUtils.defaultString(roofResponse.getRoofMaterialName())
+ "</td>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getSlope()) + "寸</td>"); sb.append("<td>" + StringUtils.defaultString(roofResponse.getSlope()) + "寸</td>");
sb.append( sb.append("<td>" + StringUtils.defaultString(roofResponse.getConstructSpecificationName())
"<td>" + "</td>");
+ StringUtils.defaultString(roofResponse.getConstructSpecificationName()) sb.append("<td style='text-align:left;'>"
+ "</td>"); + StringUtils.defaultString(roofResponse.getSupportMethodName()) + "</td>");
sb.append(
"<td style='text-align:left;'>"
+ StringUtils.defaultString(roofResponse.getSupportMethodName())
+ "</td>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getSurfaceType()) + "</td>"); sb.append("<td>" + StringUtils.defaultString(roofResponse.getSurfaceType()) + "</td>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getSetupHeight()) + "</td>"); sb.append("<td>" + StringUtils.defaultString(roofResponse.getSetupHeight()) + "</td>");
sb.append("</tr>"); sb.append("</tr>");