#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;
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.interplug.qcast.biz.canvasStatus.CanvasStatusService;
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 jakarta.servlet.http.HttpServletRequest;
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.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
@Service
@ -61,7 +75,8 @@ import org.springframework.web.util.UriComponentsBuilder;
public class EstimateService {
private final InterfaceQsp interfaceQsp;
@Autowired Messages message;
@Autowired
Messages message;
@Value("${file.ini.root.path}")
private String baseDirPath;
@ -78,9 +93,11 @@ public class EstimateService {
private final FileMapper fileMapper;
@Autowired private CanvasStatusService canvasStatusService;
@Autowired
private CanvasStatusService canvasStatusService;
@Autowired private PwrGnrSimService pwrGnrSimService;
@Autowired
private PwrGnrSimService pwrGnrSimService;
/**
* QSP 1차점 price 관리 목록 조회
@ -92,31 +109,25 @@ public class EstimateService {
public EstimateApiResponse selectStorePriceList(PriceRequest priceRequest) throws Exception {
// Validation
if (StringUtils.isEmpty(priceRequest.getSaleStoreId())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sale Store ID"));
}
if (StringUtils.isEmpty(priceRequest.getSapSalesStoreCd())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sap Sale Store Code"));
}
if (StringUtils.isEmpty(priceRequest.getDocTpCd())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Estimate Type"));
}
EstimateApiResponse response = null;
/* [1]. QSP API (url + param) Setting */
String url = QSP_API_URL + "/api/price/storePriceList";
String apiUrl =
UriComponentsBuilder.fromHttpUrl(url)
.queryParam("saleStoreId", priceRequest.getSaleStoreId())
.queryParam("sapSalesStoreCd", priceRequest.getSapSalesStoreCd())
.queryParam("docTpCd", priceRequest.getDocTpCd())
.build()
.toUriString();
String apiUrl = UriComponentsBuilder.fromHttpUrl(url)
.queryParam("saleStoreId", priceRequest.getSaleStoreId())
.queryParam("sapSalesStoreCd", priceRequest.getSapSalesStoreCd())
.queryParam("docTpCd", priceRequest.getDocTpCd()).build().toUriString();
/* [2]. QSP API CALL -> Response */
String strResponse = interfaceQsp.callApi(HttpMethod.GET, apiUrl, null);
@ -144,26 +155,22 @@ public class EstimateService {
public EstimateApiResponse selectItemPriceList(PriceRequest priceRequest) throws Exception {
// Validation
if (StringUtils.isEmpty(priceRequest.getSaleStoreId())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sale Store ID"));
}
if (StringUtils.isEmpty(priceRequest.getSapSalesStoreCd())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sap Sale Store Code"));
}
if (StringUtils.isEmpty(priceRequest.getPriceCd())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Price Code"));
}
EstimateApiResponse response = null;
/* [1]. QSP API CALL -> Response */
String strResponse =
interfaceQsp.callApi(
HttpMethod.POST, QSP_API_URL + "/api//price/storePriceItemList", priceRequest);
String strResponse = interfaceQsp.callApi(HttpMethod.POST,
QSP_API_URL + "/api//price/storePriceItemList", priceRequest);
if (!"".equals(strResponse)) {
com.fasterxml.jackson.databind.ObjectMapper om =
@ -211,13 +218,11 @@ public class EstimateService {
public EstimateResponse selectEstimateDetail(String objectNo, String planNo) throws Exception {
// Validation
if (StringUtils.isEmpty(objectNo)) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Object No"));
}
if (StringUtils.isEmpty(planNo)) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Plan No"));
}
@ -252,13 +257,11 @@ public class EstimateService {
if (!roofCheckDatas.contains(
arrOrgRoofMaterialIdMultis[i] + "_" + arrOrgConstructSpecificationMultis[i])) {
roofMaterialIdMultis +=
StringUtils.isEmpty(roofMaterialIdMultis)
? arrOrgRoofMaterialIdMultis[i]
StringUtils.isEmpty(roofMaterialIdMultis) ? arrOrgRoofMaterialIdMultis[i]
: splitStr + arrOrgRoofMaterialIdMultis[i];
constructSpecificationMultis +=
StringUtils.isEmpty(constructSpecificationMultis)
? arrOrgConstructSpecificationMultis[i]
: splitStr + arrOrgConstructSpecificationMultis[i];
constructSpecificationMultis += StringUtils.isEmpty(constructSpecificationMultis)
? arrOrgConstructSpecificationMultis[i]
: splitStr + arrOrgConstructSpecificationMultis[i];
}
roofCheckDatas +=
@ -303,23 +306,19 @@ public class EstimateService {
public void insertEstimate(EstimateRequest estimateRequest) throws Exception {
// Validation
if (StringUtils.isEmpty(estimateRequest.getObjectNo())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Object No"));
}
if (StringUtils.isEmpty(estimateRequest.getPlanNo())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Plan No"));
}
if (StringUtils.isEmpty(estimateRequest.getSaleStoreId())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sale Store ID"));
}
if (StringUtils.isEmpty(estimateRequest.getUserId())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "User ID"));
}
@ -345,8 +344,8 @@ public class EstimateService {
ObjectResponse objectResponse =
objectMapper.selectObjectDetail(estimateRequest.getObjectNo());
if (objectResponse != null) {
estimateRequest.setWeatherPoint(
objectResponse.getPrefName() + " - " + objectResponse.getAreaName());
estimateRequest
.setWeatherPoint(objectResponse.getPrefName() + " - " + objectResponse.getAreaName());
estimateRequest.setCharger(objectResponse.getReceiveUser());
}
@ -475,10 +474,8 @@ public class EstimateService {
bomItem.setUnit(itemResponse.getUnit());
bomItem.setPnowW(itemResponse.getPnowW());
bomItem.setSpecification(itemResponse.getPnowW());
bomItem.setAmount(
String.valueOf(
Integer.parseInt(itemResponse.getBomAmount())
* Integer.parseInt(itemRequest.getAmount())));
bomItem.setAmount(String.valueOf(Integer.parseInt(itemResponse.getBomAmount())
* Integer.parseInt(itemRequest.getAmount())));
bomItem.setBomAmount(itemResponse.getBomAmount());
bomItem.setUnitPrice(itemResponse.getSalePrice());
bomItem.setSalePrice(itemResponse.getSalePrice());
@ -528,7 +525,7 @@ public class EstimateService {
estimateOptions += !StringUtils.isEmpty(estimateOptions) ? splitStr : "";
estimateOptions += "ATTR005"; // 염해지역 체크
} else if ("ATTR006"
.equals(objectResponse != null ? objectResponse.getColdRegionFlg() : "")
.equals(objectResponse != null ? objectResponse.getColdRegionFlg() : "")
&& "1".equals(estimateRequest.getNorthArrangement())) {
estimateOptions += !StringUtils.isEmpty(estimateOptions) ? splitStr : "";
estimateOptions += "ATTR006"; // 적설지역 체크
@ -578,29 +575,24 @@ public class EstimateService {
for (ItemRequest itemRequest : itemList) {
if (!"1".equals(itemRequest.getDelFlg())) {
if (StringUtils.isEmpty(itemRequest.getDispOrder())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Display Order"));
}
if (StringUtils.isEmpty(itemRequest.getItemId())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Item ID"));
}
if (StringUtils.isEmpty(itemRequest.getAmount())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Item Amount"));
}
// 수량
BigDecimal amount =
new BigDecimal(
StringUtils.isEmpty(itemRequest.getAmount()) ? "0" : itemRequest.getAmount());
BigDecimal amount = new BigDecimal(
StringUtils.isEmpty(itemRequest.getAmount()) ? "0" : itemRequest.getAmount());
// 아이템용량
BigDecimal pnowW =
new BigDecimal(
StringUtils.isEmpty(itemRequest.getPnowW()) ? "0" : itemRequest.getPnowW());
BigDecimal pnowW = new BigDecimal(
StringUtils.isEmpty(itemRequest.getPnowW()) ? "0" : itemRequest.getPnowW());
// 모듈/PC 체크
if ("MODULE_".equals(itemRequest.getItemGroup())) {
@ -632,8 +624,7 @@ public class EstimateService {
// 견적서 정보 수정
estimateRequest.setPriceCd(
!StringUtils.isEmpty(estimateRequest.getPriceCd())
? estimateRequest.getPriceCd()
!StringUtils.isEmpty(estimateRequest.getPriceCd()) ? estimateRequest.getPriceCd()
: "UNIT_PRICE");
estimateMapper.updateEstimate(estimateRequest);
estimateMapper.updateEstimateInfo(estimateRequest);
@ -663,8 +654,8 @@ public class EstimateService {
for (ItemRequest data : roofItemList) {
if (itemRequest.getItemId().equals(data.getItemId())
&& itemRequest.getPcItemId().equals(data.getPcItemId())) {
data.setAmount(
String.valueOf(Integer.parseInt(data.getAmount()) + 1)); // 데이터 존재하면 카운팅 + 1
data.setAmount(String.valueOf(Integer.parseInt(data.getAmount()) + 1)); // 데이터 존재하면
// 카운팅 + 1
overLap = true;
break;
}
@ -739,12 +730,10 @@ public class EstimateService {
itemRequest.setOpenFlg(
!StringUtils.isEmpty(itemRequest.getOpenFlg()) ? itemRequest.getOpenFlg() : "0");
itemRequest.setItemChangeFlg(
!StringUtils.isEmpty(itemRequest.getItemChangeFlg())
? itemRequest.getItemChangeFlg()
!StringUtils.isEmpty(itemRequest.getItemChangeFlg()) ? itemRequest.getItemChangeFlg()
: "0");
itemRequest.setDispCableFlg(
!StringUtils.isEmpty(itemRequest.getDispCableFlg())
? itemRequest.getDispCableFlg()
!StringUtils.isEmpty(itemRequest.getDispCableFlg()) ? itemRequest.getDispCableFlg()
: "0");
itemRequest.setUserId(estimateRequest.getUserId());
@ -805,18 +794,15 @@ public class EstimateService {
throws Exception {
// Validation
if (StringUtils.isEmpty(estimateCopyRequest.getObjectNo())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Object No"));
}
if (StringUtils.isEmpty(estimateCopyRequest.getPlanNo())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Plan No"));
}
if (StringUtils.isEmpty(estimateCopyRequest.getUserId())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "User ID"));
}
@ -827,8 +813,8 @@ public class EstimateService {
ObjectRequest objectRequest = new ObjectRequest();
objectRequest.setSaleStoreId(estimateCopyRequest.getCopySaleStoreId());
objectRequest.setReceiveUser(
StringUtils.defaultString(estimateCopyRequest.getCopyReceiveUser()));
objectRequest
.setReceiveUser(StringUtils.defaultString(estimateCopyRequest.getCopyReceiveUser()));
objectRequest.setDelFlg("1");
objectRequest.setOrgDelFlg("0");
objectRequest.setTempFlg("0");
@ -859,6 +845,9 @@ public class EstimateService {
itemRequest.setDispOrder(itemResponse.getDispOrder());
itemRequest.setPaDispOrder(itemResponse.getPaDispOrder());
itemRequest.setItemId(itemResponse.getItemId());
itemRequest.setItemNo(itemResponse.getItemNo());
itemRequest.setItemName(itemResponse.getItemName());
itemRequest.setUnit(itemResponse.getUnit());
itemRequest.setAmount(itemResponse.getAmount());
itemRequest.setBomAmount(itemResponse.getBomAmount());
itemRequest.setSpecialNoteCd(itemResponse.getSpecialNoteCd());
@ -912,8 +901,7 @@ public class EstimateService {
itemRequest.setPartAdd(
!StringUtils.isEmpty(itemRequest.getPartAdd()) ? itemRequest.getPartAdd() : "0");
itemRequest.setItemChangeFlg(
!StringUtils.isEmpty(itemRequest.getItemChangeFlg())
? itemRequest.getItemChangeFlg()
!StringUtils.isEmpty(itemRequest.getItemChangeFlg()) ? itemRequest.getItemChangeFlg()
: "0");
itemRequest.setUserId(estimateCopyRequest.getUserId());
@ -960,26 +948,23 @@ public class EstimateService {
public EstimateResponse updateEstimateReset(EstimateRequest estimateRequest) throws Exception {
// Validation
if (StringUtils.isEmpty(estimateRequest.getObjectNo())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Object No"));
}
if (StringUtils.isEmpty(estimateRequest.getPlanNo())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Plan No"));
}
if (StringUtils.isEmpty(estimateRequest.getUserId())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "User ID"));
}
// 견적서 상세 조회
EstimateResponse estimateResponse = estimateMapper.selectEstimateDetail(estimateRequest);
if (estimateResponse == null) {
throw new QcastException(
ErrorCode.NOT_FOUND, message.getMessage("common.message.required.data", "Estimate Info"));
throw new QcastException(ErrorCode.NOT_FOUND,
message.getMessage("common.message.required.data", "Estimate Info"));
}
// 응답 객체
@ -996,8 +981,8 @@ public class EstimateService {
ObjectResponse objectResponse =
objectMapper.selectObjectDetail(estimateRequest.getObjectNo());
if (objectResponse != null) {
estimateRequest.setWeatherPoint(
objectResponse.getPrefName() + " - " + objectResponse.getAreaName());
estimateRequest
.setWeatherPoint(objectResponse.getPrefName() + " - " + objectResponse.getAreaName());
estimateRequest.setCharger(objectResponse.getReceiveUser());
}
@ -1070,10 +1055,8 @@ public class EstimateService {
bomItem.setUnit(itemResponse.getUnit());
bomItem.setPnowW(itemResponse.getPnowW());
bomItem.setSpecification(itemResponse.getPnowW());
bomItem.setAmount(
String.valueOf(
Integer.parseInt(itemResponse.getBomAmount())
* Integer.parseInt(itemRequest.getAmount())));
bomItem.setAmount(String.valueOf(Integer.parseInt(itemResponse.getBomAmount())
* Integer.parseInt(itemRequest.getAmount())));
bomItem.setBomAmount(itemResponse.getBomAmount());
bomItem.setUnitPrice(itemResponse.getSalePrice());
bomItem.setSalePrice(itemResponse.getSalePrice());
@ -1170,29 +1153,24 @@ public class EstimateService {
String pcTypeNo = "";
for (ItemRequest itemRequest : itemList) {
if (StringUtils.isEmpty(itemRequest.getDispOrder())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Display Order"));
}
if (StringUtils.isEmpty(itemRequest.getItemId())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Item ID"));
}
if (StringUtils.isEmpty(itemRequest.getAmount())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Item Amount"));
}
// 수량
BigDecimal amount =
new BigDecimal(
StringUtils.isEmpty(itemRequest.getAmount()) ? "0" : itemRequest.getAmount());
BigDecimal amount = new BigDecimal(
StringUtils.isEmpty(itemRequest.getAmount()) ? "0" : itemRequest.getAmount());
// 아이템용량
BigDecimal pnowW =
new BigDecimal(
StringUtils.isEmpty(itemRequest.getPnowW()) ? "0" : itemRequest.getPnowW());
BigDecimal pnowW = new BigDecimal(
StringUtils.isEmpty(itemRequest.getPnowW()) ? "0" : itemRequest.getPnowW());
// 모듈/PC 체크
if ("MODULE_".equals(itemRequest.getItemGroup())) {
@ -1233,8 +1211,7 @@ public class EstimateService {
itemRequest.setOpenFlg(
!StringUtils.isEmpty(itemRequest.getOpenFlg()) ? itemRequest.getOpenFlg() : "0");
itemRequest.setItemChangeFlg(
!StringUtils.isEmpty(itemRequest.getItemChangeFlg())
? itemRequest.getItemChangeFlg()
!StringUtils.isEmpty(itemRequest.getItemChangeFlg()) ? itemRequest.getItemChangeFlg()
: "0");
itemRequest.setUserId(estimateRequest.getUserId());
@ -1281,23 +1258,19 @@ public class EstimateService {
public void updateEstimateLock(EstimateRequest estimateRequest) throws Exception {
// Validation
if (StringUtils.isEmpty(estimateRequest.getObjectNo())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Object No"));
}
if (StringUtils.isEmpty(estimateRequest.getPlanNo())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Plan No"));
}
if (StringUtils.isEmpty(estimateRequest.getLockFlg())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Lock Flag"));
}
if (StringUtils.isEmpty(estimateRequest.getUserId())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "User ID"));
}
@ -1317,22 +1290,19 @@ public class EstimateService {
* @param estimateRequest 견적서 엑셀 다운로드 요청 정보
* @throws Exception
*/
public void excelDownload(
HttpServletRequest request, HttpServletResponse response, EstimateRequest estimateRequest)
throws Exception {
public void excelDownload(HttpServletRequest request, HttpServletResponse response,
EstimateRequest estimateRequest) throws Exception {
EstimateResponse estimateResponse = new EstimateResponse();
String splitStr = "";
// Validation
if (StringUtils.isEmpty(estimateRequest.getObjectNo())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Object No"));
}
if (StringUtils.isEmpty(estimateRequest.getPlanNo())) {
throw new QcastException(
ErrorCode.INVALID_INPUT_VALUE,
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Plan No"));
}
@ -1342,10 +1312,8 @@ public class EstimateService {
// file Name 명이 없는경우
if (estimateRequest.getFileName() == null || "".equals(estimateRequest.getFileName())) {
estimateRequest.setFileName(
estimateResponse.getObjectNo()
+ "_"
+ new SimpleDateFormat("yyyyMMdd").format(new Date()));
estimateRequest.setFileName(estimateResponse.getObjectNo() + "_"
+ new SimpleDateFormat("yyyyMMdd").format(new Date()));
}
if ("1".equals(estimateRequest.getSchDisplayFlg())) {
@ -1420,8 +1388,8 @@ public class EstimateService {
List<ItemResponse> estimateItemList = estimateMapper.selectEstimateItemList(estimateRequest);
// 합산금액 계산
this.selectTotalPriceInfo(
estimateResponse, estimateItemList, estimateRequest.getSchUnitPriceFlg());
this.selectTotalPriceInfo(estimateResponse, estimateItemList,
estimateRequest.getSchUnitPriceFlg());
int j = 1;
for (ItemResponse itemResponse : estimateItemList) {
@ -1430,8 +1398,8 @@ public class EstimateService {
// 문자열 통화로 변환 처리
itemResponse.setSalePrice(
String.format("%1$,.0f", Double.parseDouble(itemResponse.getSalePrice())));
itemResponse.setAmount(
String.format("%1$,.0f", Double.parseDouble(itemResponse.getAmount())));
itemResponse
.setAmount(String.format("%1$,.0f", Double.parseDouble(itemResponse.getAmount())));
itemResponse.setSaleTotPrice(
String.format("%1$,.0f", Double.parseDouble(itemResponse.getSaleTotPrice())));
@ -1445,14 +1413,14 @@ public class EstimateService {
// 합산 문자열 통화로 변환 처리
estimateResponse.setPkgYn("YJSS".equals(estimateResponse.getEstimateType()) ? "Y" : "N");
estimateResponse.setPkgNo(
"YJSS".equals(estimateResponse.getEstimateType()) ? String.valueOf(j++) : "");
estimateResponse
.setPkgNo("YJSS".equals(estimateResponse.getEstimateType()) ? String.valueOf(j++) : "");
if ("YJSS".equals(estimateResponse.getEstimateType())) {
estimateResponse.setPkgAsp(
String.format("%1$,.0f", Double.parseDouble(estimateResponse.getPkgAsp())));
estimateResponse
.setPkgAsp(String.format("%1$,.0f", Double.parseDouble(estimateResponse.getPkgAsp())));
}
estimateResponse.setTotVol(
String.format("%1$,.0f", Double.parseDouble(estimateResponse.getTotVol())));
estimateResponse
.setTotVol(String.format("%1$,.0f", Double.parseDouble(estimateResponse.getTotVol())));
estimateResponse.setPkgTotPrice(
String.format("%1$,.0f", Double.parseDouble(estimateResponse.getPkgTotPrice())));
estimateResponse.setSupplyPrice(
@ -1483,8 +1451,7 @@ public class EstimateService {
}
pwrGnrSimResponse.setIntFrcPwrGnrList(
Arrays.stream(pwrGnrSimResponse.getFrcPwrGnrList())
.map(s -> s.replace(",", "")) // , 제거
Arrays.stream(pwrGnrSimResponse.getFrcPwrGnrList()).map(s -> s.replace(",", "")) // , 제거
.mapToInt(Integer::parseInt) // 문자열을 int로 변환
.toArray());
@ -1574,12 +1541,8 @@ public class EstimateService {
ExcelUtil excelUtil = new ExcelUtil();
byte[] excelBytes =
excelUtil.download(
request,
response,
excelUtil.convertVoToMap(estimateResponse),
excelUtil.convertListToMap(estimateItemList),
excelTemplateNam);
excelUtil.download(request, response, excelUtil.convertVoToMap(estimateResponse),
excelUtil.convertListToMap(estimateItemList), excelTemplateNam);
InputStream in = new ByteArrayInputStream(excelBytes);
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();
workbook.write(byteArrayOutputStream);
excelBytes = byteArrayOutputStream.toByteArray();
response.setHeader(
"Content-Disposition",
response.setHeader("Content-Disposition",
"attachment; filename=\"" + estimateRequest.getFileName() + ".xlsx\"");
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.getOutputStream().write(excelBytes);
@ -1630,9 +1593,8 @@ public class EstimateService {
* @param unitPriceFlg 가격 표시 코드
* @throws Exception
*/
public void selectTotalPriceInfo(
EstimateResponse estimateResponse, List<ItemResponse> itemList, String unitPriceFlg)
throws Exception {
public void selectTotalPriceInfo(EstimateResponse estimateResponse, List<ItemResponse> itemList,
String unitPriceFlg) throws Exception {
BigDecimal totAmount = BigDecimal.ZERO;
BigDecimal totVol = BigDecimal.ZERO;
BigDecimal pkgTotPrice = BigDecimal.ZERO;
@ -1643,36 +1605,27 @@ public class EstimateService {
String estimateType = estimateResponse.getEstimateType();
// 주택패키지 단가
BigDecimal pkgAsp =
new BigDecimal(
StringUtils.isEmpty(estimateResponse.getPkgAsp()) ? "0" : estimateResponse.getPkgAsp());
BigDecimal pkgAsp = new BigDecimal(
StringUtils.isEmpty(estimateResponse.getPkgAsp()) ? "0" : estimateResponse.getPkgAsp());
for (ItemResponse itemResponse : itemList) {
// 수량
BigDecimal amount =
new BigDecimal(
StringUtils.isEmpty(itemResponse.getAmount()) ? "0" : itemResponse.getAmount());
BigDecimal amount = new BigDecimal(
StringUtils.isEmpty(itemResponse.getAmount()) ? "0" : itemResponse.getAmount());
// 판매가
BigDecimal salePrice = BigDecimal.ZERO;
if ("1".equals(unitPriceFlg)) {
salePrice =
new BigDecimal(
StringUtils.isEmpty(itemResponse.getUnitPrice())
? "0"
: itemResponse.getUnitPrice());
salePrice = new BigDecimal(
StringUtils.isEmpty(itemResponse.getUnitPrice()) ? "0" : itemResponse.getUnitPrice());
itemResponse.setSalePrice(String.valueOf(salePrice));
} else {
salePrice =
new BigDecimal(
StringUtils.isEmpty(itemResponse.getSalePrice())
? "0"
: itemResponse.getSalePrice());
salePrice = new BigDecimal(
StringUtils.isEmpty(itemResponse.getSalePrice()) ? "0" : itemResponse.getSalePrice());
}
// 아이템용량
BigDecimal pnowW =
new BigDecimal(
StringUtils.isEmpty(itemResponse.getPnowW()) ? "0" : itemResponse.getPnowW());
BigDecimal pnowW = new BigDecimal(
StringUtils.isEmpty(itemResponse.getPnowW()) ? "0" : itemResponse.getPnowW());
// 아이템 단가 합산
itemResponse.setSaleTotPrice(String.valueOf(salePrice.multiply(amount)));
@ -1716,11 +1669,10 @@ public class EstimateService {
estimateResponse.setPkgTotPrice(String.valueOf(pkgTotPrice));
estimateResponse.setTotAmount(String.valueOf(totAmount.setScale(0, BigDecimal.ROUND_HALF_UP)));
estimateResponse.setTotVol(String.valueOf(totVol));
estimateResponse.setTotVolKw(
String.valueOf(
totVol.multiply(new BigDecimal("0.001")).setScale(3, BigDecimal.ROUND_FLOOR)));
estimateResponse.setSupplyPrice(
String.valueOf(supplyPrice.setScale(0, BigDecimal.ROUND_HALF_UP)));
estimateResponse.setTotVolKw(String
.valueOf(totVol.multiply(new BigDecimal("0.001")).setScale(3, BigDecimal.ROUND_FLOOR)));
estimateResponse
.setSupplyPrice(String.valueOf(supplyPrice.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)));
}
@ -1776,9 +1728,8 @@ public class EstimateService {
EstimateApiResponse response = null;
/* [1]. QSP API CALL -> Response */
String strResponse =
interfaceQsp.callApi(
HttpMethod.POST, QSP_API_URL + "/api/order/qcastQuotationSave", estimateSendRequest);
String strResponse = interfaceQsp.callApi(HttpMethod.POST,
QSP_API_URL + "/api/order/qcastQuotationSave", estimateSendRequest);
if (!"".equals(strResponse)) {
com.fasterxml.jackson.databind.ObjectMapper om =
@ -1845,14 +1796,11 @@ public class EstimateService {
elm.text(StringUtils.defaultString(data.getObjectNameOmit()));
elm = doc.getElementById("objectNo1");
elm.text(
StringUtils.defaultString(data.getObjectNo())
+ " / "
+ StringUtils.defaultString(data.getPlanNo()));
elm.text(StringUtils.defaultString(data.getObjectNo()) + " / "
+ StringUtils.defaultString(data.getPlanNo()));
/*
elm = doc.getElementById("planNo");
elm.text(StringUtils.defaultString(data.getPlanNo()));
* elm = doc.getElementById("planNo"); elm.text(StringUtils.defaultString(data.getPlanNo()));
*/
elm = doc.getElementById("estimateDate");
@ -1887,28 +1835,18 @@ public class EstimateService {
sb.append("<tr>");
sb.append(
"<td style='width:60px;'>" + StringUtils.defaultString(itemResponse.getNo()) + "</td>");
sb.append(
"<td style='width:120px;text-align:left;'>"
+ StringUtils.defaultString(itemResponse.getItemName())
+ "</td>");
sb.append(
"<td style='width:120px;'>"
+ StringUtils.defaultString(itemResponse.getItemNo())
+ "</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("<td style='width:120px;text-align:left;'>"
+ StringUtils.defaultString(itemResponse.getItemName()) + "</td>");
sb.append("<td style='width:120px;'>" + StringUtils.defaultString(itemResponse.getItemNo())
+ "</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(
"<td style='width:60px;'>" + StringUtils.defaultString(itemResponse.getUnit()) + "</td>");
sb.append(
"<td style='width:80px;text-align:right;'>"
+ StringUtils.defaultString(itemResponse.getSaleTotPrice())
+ "</td>");
sb.append("<td style='width:80px;text-align:right;'>"
+ StringUtils.defaultString(itemResponse.getSaleTotPrice()) + "</td>");
sb.append("</tr>");
}
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:120px;text-align:left;'>住宅 PKG</td>");
sb.append("<td style='width:120px;'>-</td>");
sb.append(
"<td style='width:80px;text-align:right;'>"
+ StringUtils.defaultString(data.getPkgAsp())
+ "</td>");
sb.append(
"<td style='width:60px;text-align:right;'>"
+ StringUtils.defaultString(data.getTotVol())
+ "</td>");
sb.append("<td style='width:80px;text-align:right;'>"
+ StringUtils.defaultString(data.getPkgAsp()) + "</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:80px;text-align:right;'>"
+ StringUtils.defaultString(data.getPkgTotPrice())
+ "</td>");
sb.append("<td style='width:80px;text-align:right;'>"
+ StringUtils.defaultString(data.getPkgTotPrice()) + "</td>");
sb.append("</tr>");
}
elm = doc.getElementById("itemList_detail");
@ -1956,15 +1888,10 @@ public class EstimateService {
sb = new StringBuilder();
for (NoteResponse noteResponse : data.getNoteList()) {
sb.append("<tr>");
sb.append(
"<td style='text-align:left;'>"
+ StringUtils.defaultString(noteResponse.getCodeNm())
+ "</td>");
sb.append(
"<td style='text-align:left;'>"
+ StringUtils.defaultString(noteResponse.getRemarks())
.replaceAll("\r\n|\r|\n", "<br />")
+ "</td>");
sb.append("<td style='text-align:left;'>"
+ StringUtils.defaultString(noteResponse.getCodeNm()) + "</td>");
sb.append("<td style='text-align:left;'>" + StringUtils
.defaultString(noteResponse.getRemarks()).replaceAll("\r\n|\r|\n", "<br />") + "</td>");
sb.append("</tr>");
}
elm = doc.getElementById("noteList_detail");
@ -1973,11 +1900,8 @@ public class EstimateService {
// 도면 설정
elm = doc.getElementById("objectNo4");
elm.text(
StringUtils.defaultString(data.getObjectNo())
+ " (Plan No : "
+ StringUtils.defaultString(data.getPlanNo())
+ ")");
elm.text(StringUtils.defaultString(data.getObjectNo()) + " (Plan No : "
+ StringUtils.defaultString(data.getPlanNo()) + ")");
elm = doc.getElementById("objectName");
elm.text(StringUtils.defaultString(data.getObjectName()));
@ -2016,14 +1940,10 @@ public class EstimateService {
if (!"STAND_".equals(itemResponse.getItemGroup())) {
sb.append("<tr>");
sb.append("<td>" + (no++) + "</td>");
sb.append(
"<td style='text-align:left;'>"
+ StringUtils.defaultString(itemResponse.getItemNo())
+ "</td>");
sb.append(
"<td style='text-align:right;'>"
+ StringUtils.defaultString(itemResponse.getAmount())
+ "</td>");
sb.append("<td style='text-align:left;'>"
+ StringUtils.defaultString(itemResponse.getItemNo()) + "</td>");
sb.append("<td style='text-align:right;'>"
+ StringUtils.defaultString(itemResponse.getAmount()) + "</td>");
sb.append("</tr>");
}
}
@ -2037,12 +1957,8 @@ public class EstimateService {
sb.append("<tr>");
sb.append("<td>" + (no++) + "</td>");
sb.append(
"<td style='text-align:left;'>"
+ StringUtils.defaultString(itemResponse.getItemNo())
+ " ["
+ itemResponse.getCircuitCfg()
+ "]"
+ "</td>");
"<td style='text-align:left;'>" + StringUtils.defaultString(itemResponse.getItemNo())
+ " [" + itemResponse.getCircuitCfg() + "]" + "</td>");
sb.append("</tr>");
}
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.getClassTypeName()) + "</td>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getAmount()) + "</td>");
sb.append(
"<td style='text-align:right;'>"
+ StringUtils.defaultString(roofResponse.getVolKw())
+ "</td>");
sb.append("<td style='text-align:right;'>"
+ StringUtils.defaultString(roofResponse.getVolKw()) + "</td>");
sb.append("</tr>");
}
elm = doc.getElementById("surFaceList_detail");
@ -2077,19 +1991,13 @@ public class EstimateService {
for (RoofResponse roofResponse : data.getRoofInfo().getRoofList()) {
sb.append("<tr>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getRoofSurface()) + "</td>");
sb.append(
"<td style='text-align:left;'>"
+ StringUtils.defaultString(roofResponse.getRoofMaterialName())
+ "</td>");
sb.append("<td style='text-align:left;'>"
+ StringUtils.defaultString(roofResponse.getRoofMaterialName()) + "</td>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getSlope()) + "寸</td>");
sb.append(
"<td>"
+ StringUtils.defaultString(roofResponse.getConstructSpecificationName())
+ "</td>");
sb.append(
"<td style='text-align:left;'>"
+ StringUtils.defaultString(roofResponse.getSupportMethodName())
+ "</td>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getConstructSpecificationName())
+ "</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.getSetupHeight()) + "</td>");
sb.append("</tr>");
@ -2099,11 +2007,8 @@ public class EstimateService {
}
elm = doc.getElementById("objectNo5");
elm.text(
StringUtils.defaultString(data.getObjectNo())
+ " (Plan No : "
+ StringUtils.defaultString(data.getPlanNo())
+ ")");
elm.text(StringUtils.defaultString(data.getObjectNo()) + " (Plan No : "
+ StringUtils.defaultString(data.getPlanNo()) + ")");
elm = doc.getElementById("objectName5");
elm.text(StringUtils.defaultString(data.getObjectName()));
@ -2142,14 +2047,10 @@ public class EstimateService {
if ("STAND_".equals(itemResponse.getItemGroup())) {
sb.append("<tr>");
sb.append("<td>" + (no++) + "</td>");
sb.append(
"<td style='text-align:left;'>"
+ StringUtils.defaultString(itemResponse.getItemNo())
+ "</td>");
sb.append(
"<td style='text-align:right;'>"
+ StringUtils.defaultString(itemResponse.getAmount())
+ "</td>");
sb.append("<td style='text-align:left;'>"
+ StringUtils.defaultString(itemResponse.getItemNo()) + "</td>");
sb.append("<td style='text-align:right;'>"
+ StringUtils.defaultString(itemResponse.getAmount()) + "</td>");
sb.append("</tr>");
}
}
@ -2161,19 +2062,13 @@ public class EstimateService {
for (RoofResponse roofResponse : data.getRoofInfo().getRoofList()) {
sb.append("<tr>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getRoofSurface()) + "</td>");
sb.append(
"<td style='text-align:left;'>"
+ StringUtils.defaultString(roofResponse.getRoofMaterialName())
+ "</td>");
sb.append("<td style='text-align:left;'>"
+ StringUtils.defaultString(roofResponse.getRoofMaterialName()) + "</td>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getSlope()) + "寸</td>");
sb.append(
"<td>"
+ StringUtils.defaultString(roofResponse.getConstructSpecificationName())
+ "</td>");
sb.append(
"<td style='text-align:left;'>"
+ StringUtils.defaultString(roofResponse.getSupportMethodName())
+ "</td>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getConstructSpecificationName())
+ "</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.getSetupHeight()) + "</td>");
sb.append("</tr>");
@ -2281,14 +2176,14 @@ public class EstimateService {
* @param moduleList
* @return
*/
private List<ItemRequest> getPcsCircuitList(
List<ItemRequest> pcsItemList, List<ItemRequest> moduleList) {
private List<ItemRequest> getPcsCircuitList(List<ItemRequest> pcsItemList,
List<ItemRequest> moduleList) {
if (pcsItemList != null && pcsItemList.size() > 0) {
for (ItemRequest itemRequest : moduleList) {
itemRequest.setCircuit(
itemRequest.getCircuit().replaceAll("\\(", "").replaceAll("\\)", ""));
itemRequest
.setCircuit(itemRequest.getCircuit().replaceAll("\\(", "").replaceAll("\\)", ""));
}
if (pcsItemList.size() == 1) {
@ -2299,10 +2194,9 @@ public class EstimateService {
for (ItemRequest data : pcsItemList) {
String val = String.valueOf(j);
List<ItemRequest> resultList =
moduleList.stream()
.filter(t -> StringUtils.equals(val, t.getCircuit().split("-")[0]))
.collect(Collectors.toList());
List<ItemRequest> resultList = moduleList.stream()
.filter(t -> StringUtils.equals(val, t.getCircuit().split("-")[0]))
.collect(Collectors.toList());
data.setCircuitCfg(this.getPcsCircuitCtg(resultList));
j++;
}
@ -2334,19 +2228,18 @@ public class EstimateService {
Set<String> set = new HashSet<String>(list);
List<String> setList = new ArrayList<>(set);
Collections.sort(
setList,
new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
int first = Integer.parseInt(o1.split("-")[0]);
int second = Integer.parseInt(o2.split("-")[0]);
return second > first ? -1 : second < first ? 1 : 0; // 오름차순 정렬
}
});
Collections.sort(setList, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
int first = Integer.parseInt(o1.split("-")[0]);
int second = Integer.parseInt(o2.split("-")[0]);
return second > first ? -1 : second < first ? 1 : 0; // 오름차순 정렬
}
});
for (String str : setList) {
if (!StringUtils.isEmpty(circuitCfg)) circuitCfg += ", ";
if (!StringUtils.isEmpty(circuitCfg))
circuitCfg += ", ";
circuitCfg += Collections.frequency(list, str);
}
}

View File

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