#fix 견적서 복사 시 봄 컴포넌트 제품 형명, 단위 셋팅

This commit is contained in:
basssy 2025-03-14 14:19:59 +09:00
parent c4844d4cd3
commit e51481b07a
2 changed files with 320 additions and 469 deletions

View File

@ -1,5 +1,35 @@
package com.interplug.qcast.biz.estimate; package com.interplug.qcast.biz.estimate;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jxls.util.Util;
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.canvasStatus.CanvasStatusService; import com.interplug.qcast.biz.canvasStatus.CanvasStatusService;
import com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusCopyRequest; import com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusCopyRequest;
@ -36,24 +66,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.io.*;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jxls.util.Util;
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
@ -61,7 +75,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;
@ -78,9 +93,11 @@ public class EstimateService {
private final FileMapper fileMapper; private final FileMapper fileMapper;
@Autowired private CanvasStatusService canvasStatusService; @Autowired
private CanvasStatusService canvasStatusService;
@Autowired private PwrGnrSimService pwrGnrSimService; @Autowired
private PwrGnrSimService pwrGnrSimService;
/** /**
* QSP 1차점 price 관리 목록 조회 * QSP 1차점 price 관리 목록 조회
@ -92,31 +109,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);
@ -144,26 +155,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 =
@ -211,13 +218,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"));
} }
@ -252,13 +257,11 @@ public class EstimateService {
if (!roofCheckDatas.contains( if (!roofCheckDatas.contains(
arrOrgRoofMaterialIdMultis[i] + "_" + arrOrgConstructSpecificationMultis[i])) { arrOrgRoofMaterialIdMultis[i] + "_" + arrOrgConstructSpecificationMultis[i])) {
roofMaterialIdMultis += roofMaterialIdMultis +=
StringUtils.isEmpty(roofMaterialIdMultis) StringUtils.isEmpty(roofMaterialIdMultis) ? arrOrgRoofMaterialIdMultis[i]
? arrOrgRoofMaterialIdMultis[i]
: splitStr + arrOrgRoofMaterialIdMultis[i]; : splitStr + arrOrgRoofMaterialIdMultis[i];
constructSpecificationMultis += constructSpecificationMultis += StringUtils.isEmpty(constructSpecificationMultis)
StringUtils.isEmpty(constructSpecificationMultis) ? arrOrgConstructSpecificationMultis[i]
? arrOrgConstructSpecificationMultis[i] : splitStr + arrOrgConstructSpecificationMultis[i];
: splitStr + arrOrgConstructSpecificationMultis[i];
} }
roofCheckDatas += roofCheckDatas +=
@ -303,23 +306,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.getUserId())) { if (StringUtils.isEmpty(estimateRequest.getUserId())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "User ID")); message.getMessage("common.message.required.data", "User ID"));
} }
@ -345,8 +344,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());
} }
@ -475,10 +474,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());
@ -528,7 +525,7 @@ public class EstimateService {
estimateOptions += !StringUtils.isEmpty(estimateOptions) ? splitStr : ""; estimateOptions += !StringUtils.isEmpty(estimateOptions) ? splitStr : "";
estimateOptions += "ATTR005"; // 염해지역 체크 estimateOptions += "ATTR005"; // 염해지역 체크
} else if ("ATTR006" } else if ("ATTR006"
.equals(objectResponse != null ? objectResponse.getColdRegionFlg() : "") .equals(objectResponse != null ? objectResponse.getColdRegionFlg() : "")
&& "1".equals(estimateRequest.getNorthArrangement())) { && "1".equals(estimateRequest.getNorthArrangement())) {
estimateOptions += !StringUtils.isEmpty(estimateOptions) ? splitStr : ""; estimateOptions += !StringUtils.isEmpty(estimateOptions) ? splitStr : "";
estimateOptions += "ATTR006"; // 적설지역 체크 estimateOptions += "ATTR006"; // 적설지역 체크
@ -578,29 +575,24 @@ public class EstimateService {
for (ItemRequest itemRequest : itemList) { for (ItemRequest itemRequest : itemList) {
if (!"1".equals(itemRequest.getDelFlg())) { if (!"1".equals(itemRequest.getDelFlg())) {
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())) {
@ -632,8 +624,7 @@ public class EstimateService {
// 견적서 정보 수정 // 견적서 정보 수정
estimateRequest.setPriceCd( estimateRequest.setPriceCd(
!StringUtils.isEmpty(estimateRequest.getPriceCd()) !StringUtils.isEmpty(estimateRequest.getPriceCd()) ? estimateRequest.getPriceCd()
? estimateRequest.getPriceCd()
: "UNIT_PRICE"); : "UNIT_PRICE");
estimateMapper.updateEstimate(estimateRequest); estimateMapper.updateEstimate(estimateRequest);
estimateMapper.updateEstimateInfo(estimateRequest); estimateMapper.updateEstimateInfo(estimateRequest);
@ -663,8 +654,8 @@ public class EstimateService {
for (ItemRequest data : roofItemList) { for (ItemRequest data : roofItemList) {
if (itemRequest.getItemId().equals(data.getItemId()) if (itemRequest.getItemId().equals(data.getItemId())
&& itemRequest.getPcItemId().equals(data.getPcItemId())) { && itemRequest.getPcItemId().equals(data.getPcItemId())) {
data.setAmount( data.setAmount(String.valueOf(Integer.parseInt(data.getAmount()) + 1)); // 데이터 존재하면
String.valueOf(Integer.parseInt(data.getAmount()) + 1)); // 데이터 존재하면 카운팅 + 1 // 카운팅 + 1
overLap = true; overLap = true;
break; break;
} }
@ -739,12 +730,10 @@ public class EstimateService {
itemRequest.setOpenFlg( itemRequest.setOpenFlg(
!StringUtils.isEmpty(itemRequest.getOpenFlg()) ? itemRequest.getOpenFlg() : "0"); !StringUtils.isEmpty(itemRequest.getOpenFlg()) ? itemRequest.getOpenFlg() : "0");
itemRequest.setItemChangeFlg( itemRequest.setItemChangeFlg(
!StringUtils.isEmpty(itemRequest.getItemChangeFlg()) !StringUtils.isEmpty(itemRequest.getItemChangeFlg()) ? itemRequest.getItemChangeFlg()
? itemRequest.getItemChangeFlg()
: "0"); : "0");
itemRequest.setDispCableFlg( itemRequest.setDispCableFlg(
!StringUtils.isEmpty(itemRequest.getDispCableFlg()) !StringUtils.isEmpty(itemRequest.getDispCableFlg()) ? itemRequest.getDispCableFlg()
? itemRequest.getDispCableFlg()
: "0"); : "0");
itemRequest.setUserId(estimateRequest.getUserId()); itemRequest.setUserId(estimateRequest.getUserId());
@ -805,18 +794,15 @@ 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"));
} }
if (StringUtils.isEmpty(estimateCopyRequest.getUserId())) { if (StringUtils.isEmpty(estimateCopyRequest.getUserId())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "User ID")); message.getMessage("common.message.required.data", "User ID"));
} }
@ -827,8 +813,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("1"); objectRequest.setDelFlg("1");
objectRequest.setOrgDelFlg("0"); objectRequest.setOrgDelFlg("0");
objectRequest.setTempFlg("0"); objectRequest.setTempFlg("0");
@ -859,6 +845,9 @@ public class EstimateService {
itemRequest.setDispOrder(itemResponse.getDispOrder()); itemRequest.setDispOrder(itemResponse.getDispOrder());
itemRequest.setPaDispOrder(itemResponse.getPaDispOrder()); itemRequest.setPaDispOrder(itemResponse.getPaDispOrder());
itemRequest.setItemId(itemResponse.getItemId()); itemRequest.setItemId(itemResponse.getItemId());
itemRequest.setItemNo(itemResponse.getItemNo());
itemRequest.setItemName(itemResponse.getItemName());
itemRequest.setUnit(itemResponse.getUnit());
itemRequest.setAmount(itemResponse.getAmount()); itemRequest.setAmount(itemResponse.getAmount());
itemRequest.setBomAmount(itemResponse.getBomAmount()); itemRequest.setBomAmount(itemResponse.getBomAmount());
itemRequest.setSpecialNoteCd(itemResponse.getSpecialNoteCd()); itemRequest.setSpecialNoteCd(itemResponse.getSpecialNoteCd());
@ -912,8 +901,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());
@ -960,26 +948,23 @@ public class EstimateService {
public EstimateResponse updateEstimateReset(EstimateRequest estimateRequest) throws Exception { public EstimateResponse updateEstimateReset(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.getUserId())) { if (StringUtils.isEmpty(estimateRequest.getUserId())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "User ID")); message.getMessage("common.message.required.data", "User ID"));
} }
// 견적서 상세 조회 // 견적서 상세 조회
EstimateResponse estimateResponse = estimateMapper.selectEstimateDetail(estimateRequest); EstimateResponse estimateResponse = estimateMapper.selectEstimateDetail(estimateRequest);
if (estimateResponse == null) { if (estimateResponse == null) {
throw new QcastException( throw new QcastException(ErrorCode.NOT_FOUND,
ErrorCode.NOT_FOUND, message.getMessage("common.message.required.data", "Estimate Info")); message.getMessage("common.message.required.data", "Estimate Info"));
} }
// 응답 객체 // 응답 객체
@ -996,8 +981,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());
} }
@ -1070,10 +1055,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());
@ -1170,29 +1153,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())) {
@ -1233,8 +1211,7 @@ public class EstimateService {
itemRequest.setOpenFlg( itemRequest.setOpenFlg(
!StringUtils.isEmpty(itemRequest.getOpenFlg()) ? itemRequest.getOpenFlg() : "0"); !StringUtils.isEmpty(itemRequest.getOpenFlg()) ? itemRequest.getOpenFlg() : "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());
@ -1281,23 +1258,19 @@ public class EstimateService {
public void updateEstimateLock(EstimateRequest estimateRequest) throws Exception { public void updateEstimateLock(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.getLockFlg())) { if (StringUtils.isEmpty(estimateRequest.getLockFlg())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Lock Flag")); message.getMessage("common.message.required.data", "Lock Flag"));
} }
if (StringUtils.isEmpty(estimateRequest.getUserId())) { if (StringUtils.isEmpty(estimateRequest.getUserId())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "User ID")); message.getMessage("common.message.required.data", "User ID"));
} }
@ -1317,22 +1290,19 @@ 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 {
EstimateResponse estimateResponse = new EstimateResponse(); EstimateResponse estimateResponse = new EstimateResponse();
String splitStr = ""; String splitStr = "";
// 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"));
} }
@ -1342,10 +1312,8 @@ public class EstimateService {
// file Name 명이 없는경우 // file Name 명이 없는경우
if (estimateRequest.getFileName() == null || "".equals(estimateRequest.getFileName())) { if (estimateRequest.getFileName() == null || "".equals(estimateRequest.getFileName())) {
estimateRequest.setFileName( estimateRequest.setFileName(estimateResponse.getObjectNo() + "_"
estimateResponse.getObjectNo() + new SimpleDateFormat("yyyyMMdd").format(new Date()));
+ "_"
+ new SimpleDateFormat("yyyyMMdd").format(new Date()));
} }
if ("1".equals(estimateRequest.getSchDisplayFlg())) { if ("1".equals(estimateRequest.getSchDisplayFlg())) {
@ -1420,8 +1388,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) {
@ -1430,8 +1398,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())));
@ -1445,14 +1413,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(
@ -1483,8 +1451,7 @@ public class EstimateService {
} }
pwrGnrSimResponse.setIntFrcPwrGnrList( pwrGnrSimResponse.setIntFrcPwrGnrList(
Arrays.stream(pwrGnrSimResponse.getFrcPwrGnrList()) Arrays.stream(pwrGnrSimResponse.getFrcPwrGnrList()).map(s -> s.replace(",", "")) // , 제거
.map(s -> s.replace(",", "")) // , 제거
.mapToInt(Integer::parseInt) // 문자열을 int로 변환 .mapToInt(Integer::parseInt) // 문자열을 int로 변환
.toArray()); .toArray());
@ -1574,12 +1541,8 @@ public class EstimateService {
ExcelUtil excelUtil = new ExcelUtil(); ExcelUtil excelUtil = new ExcelUtil();
byte[] excelBytes = byte[] excelBytes =
excelUtil.download( excelUtil.download(request, response, excelUtil.convertVoToMap(estimateResponse),
request, excelUtil.convertListToMap(estimateItemList), excelTemplateNam);
response,
excelUtil.convertVoToMap(estimateResponse),
excelUtil.convertListToMap(estimateItemList),
excelTemplateNam);
InputStream in = new ByteArrayInputStream(excelBytes); InputStream in = new ByteArrayInputStream(excelBytes);
workbook = WorkbookFactory.create(in); // JXLS POI 엑셀로 재변환 workbook = WorkbookFactory.create(in); // JXLS POI 엑셀로 재변환
@ -1603,14 +1566,14 @@ public class EstimateService {
} }
// 추후 개발 (가대중량표) // 추후 개발 (가대중량표)
if (estimateRequest.getSchDrawingFlg().indexOf("4") < 0) {} if (estimateRequest.getSchDrawingFlg().indexOf("4") < 0) {
}
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
workbook.write(byteArrayOutputStream); workbook.write(byteArrayOutputStream);
excelBytes = byteArrayOutputStream.toByteArray(); excelBytes = byteArrayOutputStream.toByteArray();
response.setHeader( response.setHeader("Content-Disposition",
"Content-Disposition",
"attachment; filename=\"" + estimateRequest.getFileName() + ".xlsx\""); "attachment; filename=\"" + estimateRequest.getFileName() + ".xlsx\"");
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition"); response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.getOutputStream().write(excelBytes); response.getOutputStream().write(excelBytes);
@ -1630,9 +1593,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;
@ -1643,36 +1605,27 @@ 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());
itemResponse.setSalePrice(String.valueOf(salePrice)); itemResponse.setSalePrice(String.valueOf(salePrice));
} 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)));
@ -1716,11 +1669,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)));
} }
@ -1776,9 +1728,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 =
@ -1845,14 +1796,11 @@ public class EstimateService {
elm.text(StringUtils.defaultString(data.getObjectNameOmit())); elm.text(StringUtils.defaultString(data.getObjectNameOmit()));
elm = doc.getElementById("objectNo1"); elm = doc.getElementById("objectNo1");
elm.text( elm.text(StringUtils.defaultString(data.getObjectNo()) + " / "
StringUtils.defaultString(data.getObjectNo()) + StringUtils.defaultString(data.getPlanNo()));
+ " / "
+ StringUtils.defaultString(data.getPlanNo()));
/* /*
elm = doc.getElementById("planNo"); * elm = doc.getElementById("planNo"); elm.text(StringUtils.defaultString(data.getPlanNo()));
elm.text(StringUtils.defaultString(data.getPlanNo()));
*/ */
elm = doc.getElementById("estimateDate"); elm = doc.getElementById("estimateDate");
@ -1887,28 +1835,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())) {
@ -1916,19 +1854,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");
@ -1956,15 +1888,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;'>" + StringUtils
+ "</td>"); .defaultString(noteResponse.getRemarks()).replaceAll("\r\n|\r|\n", "<br />") + "</td>");
sb.append(
"<td style='text-align:left;'>"
+ StringUtils.defaultString(noteResponse.getRemarks())
.replaceAll("\r\n|\r|\n", "<br />")
+ "</td>");
sb.append("</tr>"); sb.append("</tr>");
} }
elm = doc.getElementById("noteList_detail"); elm = doc.getElementById("noteList_detail");
@ -1973,11 +1900,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()));
@ -2016,14 +1940,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>");
} }
} }
@ -2037,12 +1957,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(itemResponse.getItemNo())
+ StringUtils.defaultString(itemResponse.getItemNo()) + " [" + itemResponse.getCircuitCfg() + "]" + "</td>");
+ " ["
+ itemResponse.getCircuitCfg()
+ "]"
+ "</td>");
sb.append("</tr>"); sb.append("</tr>");
} }
elm = doc.getElementById("pcsItemList_detail"); elm = doc.getElementById("pcsItemList_detail");
@ -2056,10 +1972,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");
@ -2077,19 +1991,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>");
@ -2099,11 +2007,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()));
@ -2142,14 +2047,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>");
} }
} }
@ -2161,19 +2062,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>");
@ -2281,14 +2176,14 @@ public class EstimateService {
* @param moduleList * @param moduleList
* @return * @return
*/ */
private List<ItemRequest> getPcsCircuitList( private List<ItemRequest> getPcsCircuitList(List<ItemRequest> pcsItemList,
List<ItemRequest> pcsItemList, List<ItemRequest> moduleList) { List<ItemRequest> moduleList) {
if (pcsItemList != null && pcsItemList.size() > 0) { if (pcsItemList != null && pcsItemList.size() > 0) {
for (ItemRequest itemRequest : moduleList) { for (ItemRequest itemRequest : moduleList) {
itemRequest.setCircuit( itemRequest
itemRequest.getCircuit().replaceAll("\\(", "").replaceAll("\\)", "")); .setCircuit(itemRequest.getCircuit().replaceAll("\\(", "").replaceAll("\\)", ""));
} }
if (pcsItemList.size() == 1) { if (pcsItemList.size() == 1) {
@ -2299,10 +2194,9 @@ public class EstimateService {
for (ItemRequest data : pcsItemList) { for (ItemRequest data : pcsItemList) {
String val = String.valueOf(j); String val = String.valueOf(j);
List<ItemRequest> resultList = List<ItemRequest> resultList = moduleList.stream()
moduleList.stream() .filter(t -> StringUtils.equals(val, t.getCircuit().split("-")[0]))
.filter(t -> StringUtils.equals(val, t.getCircuit().split("-")[0])) .collect(Collectors.toList());
.collect(Collectors.toList());
data.setCircuitCfg(this.getPcsCircuitCtg(resultList)); data.setCircuitCfg(this.getPcsCircuitCtg(resultList));
j++; j++;
} }
@ -2334,19 +2228,18 @@ public class EstimateService {
Set<String> set = new HashSet<String>(list); Set<String> set = new HashSet<String>(list);
List<String> setList = new ArrayList<>(set); List<String> setList = new ArrayList<>(set);
Collections.sort( Collections.sort(setList, new Comparator<String>() {
setList, @Override
new Comparator<String>() { public int compare(String o1, String o2) {
@Override int first = Integer.parseInt(o1.split("-")[0]);
public int compare(String o1, String o2) { int second = Integer.parseInt(o2.split("-")[0]);
int first = Integer.parseInt(o1.split("-")[0]); return second > first ? -1 : second < first ? 1 : 0; // 오름차순 정렬
int second = Integer.parseInt(o2.split("-")[0]); }
return second > first ? -1 : second < first ? 1 : 0; // 오름차순 정렬 });
}
});
for (String str : setList) { for (String str : setList) {
if (!StringUtils.isEmpty(circuitCfg)) circuitCfg += ", "; if (!StringUtils.isEmpty(circuitCfg))
circuitCfg += ", ";
circuitCfg += Collections.frequency(list, str); circuitCfg += Collections.frequency(list, str);
} }
} }

View File

@ -1,11 +1,28 @@
package com.interplug.qcast.biz.object; package com.interplug.qcast.biz.object;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.RandomStringUtils;
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.canvasStatus.CanvasStatusService; import com.interplug.qcast.biz.canvasStatus.CanvasStatusService;
import com.interplug.qcast.biz.canvasStatus.dto.CanvasStatus; import com.interplug.qcast.biz.canvasStatus.dto.CanvasStatus;
import com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusCopyRequest; import com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusCopyRequest;
import com.interplug.qcast.biz.estimate.EstimateMapper; import com.interplug.qcast.biz.estimate.EstimateMapper;
import com.interplug.qcast.biz.estimate.dto.*; 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.ItemRequest;
import com.interplug.qcast.biz.estimate.dto.ItemResponse;
import com.interplug.qcast.biz.object.dto.ObjectRequest; import com.interplug.qcast.biz.object.dto.ObjectRequest;
import com.interplug.qcast.biz.object.dto.ObjectResponse; import com.interplug.qcast.biz.object.dto.ObjectResponse;
import com.interplug.qcast.biz.object.dto.PlanReqRequest; import com.interplug.qcast.biz.object.dto.PlanReqRequest;
@ -21,18 +38,8 @@ import com.interplug.qcast.config.Exception.QcastException;
import com.interplug.qcast.config.message.Messages; import com.interplug.qcast.config.message.Messages;
import com.interplug.qcast.util.InterfaceQsp; import com.interplug.qcast.util.InterfaceQsp;
import io.micrometer.common.util.StringUtils; import io.micrometer.common.util.StringUtils;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
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
@ -40,7 +47,8 @@ import org.springframework.web.util.UriComponentsBuilder;
public class ObjectService { public class ObjectService {
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;
@ -54,7 +62,8 @@ public class ObjectService {
private final StoreFavoriteService storeFavoriteService; private final StoreFavoriteService storeFavoriteService;
@Autowired private CanvasStatusService canvasStatusService; @Autowired
private CanvasStatusService canvasStatusService;
/** /**
* 도도부현 목록 조회 * 도도부현 목록 조회
@ -100,13 +109,11 @@ public class ObjectService {
throws Exception { throws Exception {
// Validation // Validation
if (StringUtils.isEmpty(saleStoreId)) { if (StringUtils.isEmpty(saleStoreId)) {
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(userId)) { if (StringUtils.isEmpty(userId)) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "User ID")); message.getMessage("common.message.required.data", "User ID"));
} }
@ -129,17 +136,15 @@ public class ObjectService {
* @return List<SaleStoreResponse> 하위 판매점 목록 * @return List<SaleStoreResponse> 하위 판매점 목록
* @throws Exception * @throws Exception
*/ */
public List<SaleStoreResponse> selectSaleStoreList( public List<SaleStoreResponse> selectSaleStoreList(String saleStoreId, String firstFlg,
String saleStoreId, String firstFlg, String userId) throws Exception { String userId) throws Exception {
// Validation // Validation
if (StringUtils.isEmpty(saleStoreId)) { if (StringUtils.isEmpty(saleStoreId)) {
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(userId)) { if (StringUtils.isEmpty(userId)) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "User ID")); message.getMessage("common.message.required.data", "User ID"));
} }
@ -170,8 +175,7 @@ public class ObjectService {
*/ */
public List<ObjectResponse> selectObjectMainList(ObjectRequest objectRequest) throws Exception { public List<ObjectResponse> selectObjectMainList(ObjectRequest objectRequest) throws Exception {
if (StringUtils.isEmpty(objectRequest.getSaleStoreId())) { if (StringUtils.isEmpty(objectRequest.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"));
} }
@ -187,8 +191,7 @@ public class ObjectService {
*/ */
public List<ObjectResponse> selectObjectList(ObjectRequest objectRequest) throws Exception { public List<ObjectResponse> selectObjectList(ObjectRequest objectRequest) throws Exception {
if (StringUtils.isEmpty(objectRequest.getSaleStoreId())) { if (StringUtils.isEmpty(objectRequest.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"));
} }
@ -240,13 +243,11 @@ public class ObjectService {
if (!roofCheckDatas.contains( if (!roofCheckDatas.contains(
arrOrgRoofMaterialIdMultis[i] + "_" + arrOrgConstructSpecificationMultis[i])) { arrOrgRoofMaterialIdMultis[i] + "_" + arrOrgConstructSpecificationMultis[i])) {
roofMaterialIdMultis += roofMaterialIdMultis +=
StringUtils.isEmpty(roofMaterialIdMultis) StringUtils.isEmpty(roofMaterialIdMultis) ? arrOrgRoofMaterialIdMultis[i]
? arrOrgRoofMaterialIdMultis[i]
: splitStr + arrOrgRoofMaterialIdMultis[i]; : splitStr + arrOrgRoofMaterialIdMultis[i];
constructSpecificationMultis += constructSpecificationMultis += StringUtils.isEmpty(constructSpecificationMultis)
StringUtils.isEmpty(constructSpecificationMultis) ? arrOrgConstructSpecificationMultis[i]
? arrOrgConstructSpecificationMultis[i] : splitStr + arrOrgConstructSpecificationMultis[i];
: splitStr + arrOrgConstructSpecificationMultis[i];
} }
roofCheckDatas += roofCheckDatas +=
@ -297,18 +298,15 @@ public class ObjectService {
// Validation // Validation
if (StringUtils.isEmpty(objectRequest.getSaleStoreId())) { if (StringUtils.isEmpty(objectRequest.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(objectRequest.getSaleStoreLevel())) { if (StringUtils.isEmpty(objectRequest.getSaleStoreLevel())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sale Store Level")); message.getMessage("common.message.required.data", "Sale Store Level"));
} }
if (StringUtils.isEmpty(objectRequest.getUserId())) { if (StringUtils.isEmpty(objectRequest.getUserId())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "User ID")); message.getMessage("common.message.required.data", "User ID"));
} }
@ -353,18 +351,12 @@ public class ObjectService {
// 디폴트 Plan 등록 // 디폴트 Plan 등록
/* /*
PlanRequest planRequest = new PlanRequest(); * PlanRequest planRequest = new PlanRequest(); planRequest.setObjectNo(objectNo);
planRequest.setObjectNo(objectNo); * planRequest.setRoofKindId("0"); planRequest.setCharger(objectRequest.getReceiveUser());
planRequest.setRoofKindId("0"); * planRequest.setStatus("1"); planRequest.setDelFlg("0"); planRequest.setNorthArrangement("0");
planRequest.setCharger(objectRequest.getReceiveUser()); * planRequest.setDiffRoofEnabled("0"); planRequest.setOrderFlg("0");
planRequest.setStatus("1"); * planRequest.setTempFlg("1"); planRequest.setUserId(objectRequest.getUserId()); result +=
planRequest.setDelFlg("0"); * objectMapper.insertPlan(planRequest);
planRequest.setNorthArrangement("0");
planRequest.setDiffRoofEnabled("0");
planRequest.setOrderFlg("0");
planRequest.setTempFlg("1");
planRequest.setUserId(objectRequest.getUserId());
result += objectMapper.insertPlan(planRequest);
*/ */
// 설계의뢰번호 존재 물건번호 업데이트 // 설계의뢰번호 존재 물건번호 업데이트
@ -378,9 +370,8 @@ public class ObjectService {
planReqRequest.setPlanReqNo(objectRequest.getPlanReqNo()); planReqRequest.setPlanReqNo(objectRequest.getPlanReqNo());
planReqRequest.setObjectNo(objectRequest.getObjectNo()); planReqRequest.setObjectNo(objectRequest.getObjectNo());
String strResponse = String strResponse = interfaceQsp.callApi(HttpMethod.POST,
interfaceQsp.callApi( QSP_API_URL + "/api/planReq/updateObjectNo", planReqRequest);
HttpMethod.POST, QSP_API_URL + "/api/planReq/updateObjectNo", planReqRequest);
if (!"".equals(strResponse)) { if (!"".equals(strResponse)) {
com.fasterxml.jackson.databind.ObjectMapper om = com.fasterxml.jackson.databind.ObjectMapper om =
new com.fasterxml.jackson.databind.ObjectMapper() new com.fasterxml.jackson.databind.ObjectMapper()
@ -389,8 +380,8 @@ public class ObjectService {
Map<String, Object> map = (Map<String, Object>) response.getResult(); Map<String, Object> map = (Map<String, Object>) response.getResult();
if ("E".equals(String.valueOf(map.get("resultCode")))) { if ("E".equals(String.valueOf(map.get("resultCode")))) {
throw new QcastException( throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR,
ErrorCode.INTERNAL_SERVER_ERROR, String.valueOf(map.get("resultMsg"))); String.valueOf(map.get("resultMsg")));
} }
} }
} }
@ -414,18 +405,15 @@ public class ObjectService {
// Validation // Validation
if (StringUtils.isEmpty(objectRequest.getSaleStoreId())) { if (StringUtils.isEmpty(objectRequest.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(objectRequest.getSaleStoreLevel())) { if (StringUtils.isEmpty(objectRequest.getSaleStoreLevel())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sale Store Level")); message.getMessage("common.message.required.data", "Sale Store Level"));
} }
if (StringUtils.isEmpty(objectRequest.getUserId())) { if (StringUtils.isEmpty(objectRequest.getUserId())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "User ID")); message.getMessage("common.message.required.data", "User ID"));
} }
@ -447,10 +435,8 @@ public class ObjectService {
objectRequest.setAddresseeCompanyName( objectRequest.setAddresseeCompanyName(
objectRequest.getObjectName() + ' ' + objectRequest.getObjectNameOmit()); objectRequest.getObjectName() + ' ' + objectRequest.getObjectNameOmit());
objectRequest.setAddresseeCompanyNameOmit(objectRequest.getObjectNameOmit()); objectRequest.setAddresseeCompanyNameOmit(objectRequest.getObjectNameOmit());
objectRequest.setContentsPath( objectRequest.setContentsPath(baseDirPath + "\\\\"
baseDirPath + (tempChgFlg ? objectRequest.getNewObjectNo() : objectRequest.getObjectNo()));
+ "\\\\"
+ (tempChgFlg ? objectRequest.getNewObjectNo() : objectRequest.getObjectNo()));
result += objectMapper.updateObject(objectRequest); result += objectMapper.updateObject(objectRequest);
result += objectMapper.updateObjectInfo(objectRequest); result += objectMapper.updateObjectInfo(objectRequest);
@ -470,9 +456,8 @@ public class ObjectService {
planReqRequest.setPlanReqNo(objectRequest.getPlanReqNo()); planReqRequest.setPlanReqNo(objectRequest.getPlanReqNo());
planReqRequest.setObjectNo(objectRequest.getNewObjectNo()); planReqRequest.setObjectNo(objectRequest.getNewObjectNo());
String strResponse = String strResponse = interfaceQsp.callApi(HttpMethod.POST,
interfaceQsp.callApi( QSP_API_URL + "/api/planReq/updateObjectNo", planReqRequest);
HttpMethod.POST, QSP_API_URL + "/api/planReq/updateObjectNo", planReqRequest);
if (!"".equals(strResponse)) { if (!"".equals(strResponse)) {
com.fasterxml.jackson.databind.ObjectMapper om = com.fasterxml.jackson.databind.ObjectMapper om =
new com.fasterxml.jackson.databind.ObjectMapper() new com.fasterxml.jackson.databind.ObjectMapper()
@ -481,8 +466,8 @@ public class ObjectService {
Map<String, Object> map = (Map<String, Object>) response.getResult(); Map<String, Object> map = (Map<String, Object>) response.getResult();
if ("E".equals(String.valueOf(map.get("resultCode")))) { if ("E".equals(String.valueOf(map.get("resultCode")))) {
throw new QcastException( throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR,
ErrorCode.INTERNAL_SERVER_ERROR, String.valueOf(map.get("resultMsg"))); String.valueOf(map.get("resultMsg")));
} }
} }
} }
@ -490,9 +475,8 @@ public class ObjectService {
} }
// 모든 변경 완료 재호출 // 모든 변경 완료 재호출
objectResponse = objectResponse = objectMapper.selectObjectDetail(
objectMapper.selectObjectDetail( (tempChgFlg ? objectRequest.getNewObjectNo() : objectRequest.getObjectNo()));
(tempChgFlg ? objectRequest.getNewObjectNo() : objectRequest.getObjectNo()));
return objectResponse; return objectResponse;
} }
@ -505,13 +489,11 @@ public class ObjectService {
public void updateObjectLastEditDate(ObjectRequest objectRequest) throws Exception { public void updateObjectLastEditDate(ObjectRequest objectRequest) throws Exception {
// Validation // Validation
if (StringUtils.isEmpty(objectRequest.getObjectNo())) { if (StringUtils.isEmpty(objectRequest.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(objectRequest.getUserId())) { if (StringUtils.isEmpty(objectRequest.getUserId())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "User ID")); message.getMessage("common.message.required.data", "User ID"));
} }
@ -536,8 +518,7 @@ public class ObjectService {
// Validation // Validation
if (StringUtils.isEmpty(objectRequest.getObjectNo())) { if (StringUtils.isEmpty(objectRequest.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"));
} }
@ -556,9 +537,8 @@ public class ObjectService {
planReqRequest.setPlanReqNo(objectResponse.getPlanReqNo()); planReqRequest.setPlanReqNo(objectResponse.getPlanReqNo());
planReqRequest.setDelFlg("1"); planReqRequest.setDelFlg("1");
String strResponse = String strResponse = interfaceQsp.callApi(HttpMethod.POST,
interfaceQsp.callApi( QSP_API_URL + "/api/planReq/updateObjectNo", planReqRequest);
HttpMethod.POST, QSP_API_URL + "/api/planReq/updateObjectNo", planReqRequest);
if (!"".equals(strResponse)) { if (!"".equals(strResponse)) {
com.fasterxml.jackson.databind.ObjectMapper om = com.fasterxml.jackson.databind.ObjectMapper om =
new com.fasterxml.jackson.databind.ObjectMapper() new com.fasterxml.jackson.databind.ObjectMapper()
@ -567,8 +547,8 @@ public class ObjectService {
Map<String, Object> map = (Map<String, Object>) response.getResult(); Map<String, Object> map = (Map<String, Object>) response.getResult();
if ("E".equals(String.valueOf(map.get("resultCode")))) { if ("E".equals(String.valueOf(map.get("resultCode")))) {
throw new QcastException( throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR,
ErrorCode.INTERNAL_SERVER_ERROR, String.valueOf(map.get("resultMsg"))); String.valueOf(map.get("resultMsg")));
} }
} }
} }
@ -594,27 +574,24 @@ public class ObjectService {
// Validation // Validation
if (StringUtils.isEmpty(planRequest.getObjectNo())) { if (StringUtils.isEmpty(planRequest.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(planRequest.getUserId())) { if (StringUtils.isEmpty(planRequest.getUserId())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "User ID")); message.getMessage("common.message.required.data", "User ID"));
} }
if ("1".equals(planRequest.getCopyFlg()) && StringUtils.isEmpty(planRequest.getPlanNo())) { if ("1".equals(planRequest.getCopyFlg()) && StringUtils.isEmpty(planRequest.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"));
} }
// Plan 추가 가능 체크 // Plan 추가 가능 체크
List<PlanResponse> planList = objectMapper.selectPlanList(planRequest); List<PlanResponse> planList = objectMapper.selectPlanList(planRequest);
if (planList.size() > 9) { if (planList.size() > 9) {
throw new QcastException( throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR,
ErrorCode.INTERNAL_SERVER_ERROR, message.getMessage("common.message.plan.save.limit")); message.getMessage("common.message.plan.save.limit"));
} }
try { try {
@ -639,6 +616,9 @@ public class ObjectService {
itemRequest.setDispOrder(itemResponse.getDispOrder()); itemRequest.setDispOrder(itemResponse.getDispOrder());
itemRequest.setPaDispOrder(itemResponse.getPaDispOrder()); itemRequest.setPaDispOrder(itemResponse.getPaDispOrder());
itemRequest.setItemId(itemResponse.getItemId()); itemRequest.setItemId(itemResponse.getItemId());
itemRequest.setItemNo(itemResponse.getItemNo());
itemRequest.setItemName(itemResponse.getItemName());
itemRequest.setUnit(itemResponse.getUnit());
itemRequest.setAmount(itemResponse.getAmount()); itemRequest.setAmount(itemResponse.getAmount());
itemRequest.setBomAmount(itemResponse.getBomAmount()); itemRequest.setBomAmount(itemResponse.getBomAmount());
itemRequest.setSpecialNoteCd(itemResponse.getSpecialNoteCd()); itemRequest.setSpecialNoteCd(itemResponse.getSpecialNoteCd());
@ -695,8 +675,8 @@ public class ObjectService {
for (ItemRequest itemRequest : itemList) { for (ItemRequest itemRequest : itemList) {
itemRequest.setObjectNo(estimateCopyRequest.getCopyObjectNo()); itemRequest.setObjectNo(estimateCopyRequest.getCopyObjectNo());
itemRequest.setPlanNo(estimateCopyRequest.getCopyPlanNo()); itemRequest.setPlanNo(estimateCopyRequest.getCopyPlanNo());
itemRequest.setPartAdd( itemRequest
!org.apache.commons.lang3.StringUtils.isEmpty(itemRequest.getPartAdd()) .setPartAdd(!org.apache.commons.lang3.StringUtils.isEmpty(itemRequest.getPartAdd())
? itemRequest.getPartAdd() ? itemRequest.getPartAdd()
: "0"); : "0");
itemRequest.setItemChangeFlg( itemRequest.setItemChangeFlg(
@ -774,26 +754,23 @@ public class ObjectService {
public void deletePlan(PlanRequest planRequest) throws Exception { public void deletePlan(PlanRequest planRequest) throws Exception {
// Validation // Validation
if (StringUtils.isEmpty(planRequest.getObjectNo())) { if (StringUtils.isEmpty(planRequest.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(planRequest.getPlanNo())) { if (StringUtils.isEmpty(planRequest.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(planRequest.getUserId())) { if (StringUtils.isEmpty(planRequest.getUserId())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "User ID")); message.getMessage("common.message.required.data", "User ID"));
} }
// Plan 삭제 가능 체크 // Plan 삭제 가능 체크
List<PlanResponse> planList = objectMapper.selectPlanList(planRequest); List<PlanResponse> planList = objectMapper.selectPlanList(planRequest);
if (planList.size() < 2) { if (planList.size() < 2) {
throw new QcastException( throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR,
ErrorCode.INTERNAL_SERVER_ERROR, message.getMessage("common.message.plan.delete.limit")); message.getMessage("common.message.plan.delete.limit"));
} }
// Plan 삭제 // Plan 삭제
@ -811,13 +788,11 @@ public class ObjectService {
// Validation // Validation
if (StringUtils.isEmpty(planReqRequest.getSaleStoreId())) { if (StringUtils.isEmpty(planReqRequest.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(planReqRequest.getSaleStoreLevel())) { if (StringUtils.isEmpty(planReqRequest.getSaleStoreLevel())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sale Store Level")); message.getMessage("common.message.required.data", "Sale Store Level"));
} }
@ -825,54 +800,37 @@ public class ObjectService {
/* [1]. QSP API (url + param) Setting */ /* [1]. QSP API (url + param) Setting */
String encodedSchPlanReqNo = String encodedSchPlanReqNo =
URLEncoder.encode( URLEncoder.encode(StringUtils.isEmpty(planReqRequest.getSchPlanReqNo()) ? ""
StringUtils.isEmpty(planReqRequest.getSchPlanReqNo()) : planReqRequest.getSchPlanReqNo(), StandardCharsets.UTF_8);
? "" String encodedSchTitle = URLEncoder.encode(
: planReqRequest.getSchPlanReqNo(), StringUtils.isEmpty(planReqRequest.getSchTitle()) ? "" : planReqRequest.getSchTitle(),
StandardCharsets.UTF_8); StandardCharsets.UTF_8);
String encodedSchTitle = String encodedSchAddress = URLEncoder.encode(
URLEncoder.encode( StringUtils.isEmpty(planReqRequest.getSchAddress()) ? "" : planReqRequest.getSchAddress(),
StringUtils.isEmpty(planReqRequest.getSchTitle()) ? "" : planReqRequest.getSchTitle(), StandardCharsets.UTF_8);
StandardCharsets.UTF_8);
String encodedSchAddress =
URLEncoder.encode(
StringUtils.isEmpty(planReqRequest.getSchAddress())
? ""
: planReqRequest.getSchAddress(),
StandardCharsets.UTF_8);
String encodedSchSaleStoreName = String encodedSchSaleStoreName =
URLEncoder.encode( URLEncoder.encode(StringUtils.isEmpty(planReqRequest.getSchSaleStoreName()) ? ""
StringUtils.isEmpty(planReqRequest.getSchSaleStoreName()) : planReqRequest.getSchSaleStoreName(), StandardCharsets.UTF_8);
? ""
: planReqRequest.getSchSaleStoreName(),
StandardCharsets.UTF_8);
String encodedSchPlanReqName = String encodedSchPlanReqName =
URLEncoder.encode( URLEncoder.encode(StringUtils.isEmpty(planReqRequest.getSchPlanReqName()) ? ""
StringUtils.isEmpty(planReqRequest.getSchPlanReqName()) : planReqRequest.getSchPlanReqName(), StandardCharsets.UTF_8);
? ""
: planReqRequest.getSchPlanReqName(),
StandardCharsets.UTF_8);
String url = QSP_API_URL + "/api/planReq/list"; String url = QSP_API_URL + "/api/planReq/list";
String apiUrl = String apiUrl = UriComponentsBuilder.fromHttpUrl(url)
UriComponentsBuilder.fromHttpUrl(url) .queryParam("saleStoreId", planReqRequest.getSaleStoreId())
.queryParam("saleStoreId", planReqRequest.getSaleStoreId()) .queryParam("saleStoreLevel", planReqRequest.getSaleStoreLevel())
.queryParam("saleStoreLevel", planReqRequest.getSaleStoreLevel()) .queryParam("schPlanReqNo", encodedSchPlanReqNo).queryParam("schTitle", encodedSchTitle)
.queryParam("schPlanReqNo", encodedSchPlanReqNo) .queryParam("schAddress", encodedSchAddress)
.queryParam("schTitle", encodedSchTitle) .queryParam("schSaleStoreName", encodedSchSaleStoreName)
.queryParam("schAddress", encodedSchAddress) .queryParam("schPlanReqName", encodedSchPlanReqName)
.queryParam("schSaleStoreName", encodedSchSaleStoreName) .queryParam("schPlanStatCd", planReqRequest.getSchPlanStatCd())
.queryParam("schPlanReqName", encodedSchPlanReqName) .queryParam("schDateGbn", planReqRequest.getSchDateGbn())
.queryParam("schPlanStatCd", planReqRequest.getSchPlanStatCd()) .queryParam("schStartDt", planReqRequest.getSchStartDt())
.queryParam("schDateGbn", planReqRequest.getSchDateGbn()) .queryParam("schEndDt", planReqRequest.getSchEndDt())
.queryParam("schStartDt", planReqRequest.getSchStartDt()) .queryParam("startRow", planReqRequest.getStartRow())
.queryParam("schEndDt", planReqRequest.getSchEndDt()) .queryParam("endRow", planReqRequest.getEndRow()).build().toUriString();
.queryParam("startRow", planReqRequest.getStartRow())
.queryParam("endRow", planReqRequest.getEndRow())
.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);