Compare commits

..

No commits in common. "a68a0210b89c6b972b864b4e07cc5f5e41d63a6e" and "ca8c239e8bfcc97ce2acb7f69d65d809da9c4b2f" have entirely different histories.

16 changed files with 511 additions and 821 deletions

View File

@ -1,15 +1,15 @@
package com.interplug.qcast.biz.commCode;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Service;
import com.interplug.qcast.biz.commCode.dto.CodeReq;
import com.interplug.qcast.biz.commCode.dto.CodeRes;
import com.interplug.qcast.biz.commCode.dto.CommCodeRes;
import com.interplug.qcast.biz.commCode.dto.DetailCodeRequest;
import com.interplug.qcast.biz.commCode.dto.HeadCodeRequest;
import java.util.ArrayList;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
@ -53,10 +53,16 @@ public class CommCodeService {
public List<CommCodeRes> selectQcastCommCode() {
List<CodeRes> result = commCodeMapper.selectQcastCommCode();
List<CommCodeRes> commCodeList = new ArrayList<>();
result.forEach(cr -> {
commCodeList.add(CommCodeRes.builder().clHeadCd(cr.getClHeadCd()).clCode(cr.getClCode())
.clCodeNm(cr.getClCodeNm()).clCodeJp(cr.getClCodeJp()).clPriority(cr.getClPriority())
.clRefChr1(cr.getClRefChr1()).clRefChr2(cr.getClRefChr2()).build());
result.forEach(
cr -> {
commCodeList.add(
CommCodeRes.builder()
.clHeadCd(cr.getClHeadCd())
.clCode(cr.getClCode())
.clCodeNm(cr.getClCodeNm())
.clCodeJp(cr.getClCodeJp())
.clPriority(cr.getClPriority())
.build());
});
return commCodeList;
}

View File

@ -11,6 +11,4 @@ public class CommCodeRes {
private String clCodeNm;
private String clCodeJp;
private Integer clPriority;
private String clRefChr1;
private String clRefChr2;
}

View File

@ -1,35 +1,5 @@
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;
@ -66,8 +36,24 @@ 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
@ -75,8 +61,7 @@ import lombok.extern.slf4j.Slf4j;
public class EstimateService {
private final InterfaceQsp interfaceQsp;
@Autowired
Messages message;
@Autowired Messages message;
@Value("${file.ini.root.path}")
private String baseDirPath;
@ -93,11 +78,9 @@ 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 관리 목록 조회
@ -109,25 +92,31 @@ 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)
String apiUrl =
UriComponentsBuilder.fromHttpUrl(url)
.queryParam("saleStoreId", priceRequest.getSaleStoreId())
.queryParam("sapSalesStoreCd", priceRequest.getSapSalesStoreCd())
.queryParam("docTpCd", priceRequest.getDocTpCd()).build().toUriString();
.queryParam("docTpCd", priceRequest.getDocTpCd())
.build()
.toUriString();
/* [2]. QSP API CALL -> Response */
String strResponse = interfaceQsp.callApi(HttpMethod.GET, apiUrl, null);
@ -155,22 +144,26 @@ 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 =
@ -218,11 +211,13 @@ 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"));
}
@ -257,9 +252,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)
constructSpecificationMultis +=
StringUtils.isEmpty(constructSpecificationMultis)
? arrOrgConstructSpecificationMultis[i]
: splitStr + arrOrgConstructSpecificationMultis[i];
}
@ -306,19 +303,23 @@ 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"));
}
@ -344,8 +345,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());
}
@ -448,7 +449,6 @@ public class EstimateService {
itemRequest.setFileUploadFlg(itemResponse.getFileUploadFlg());
itemRequest.setPkgMaterialFlg(itemResponse.getPkgMaterialFlg());
itemRequest.setOpenFlg(itemResponse.getOpenFlg());
itemRequest.setDispCableFlg("CABLE_".equals(itemResponse.getItemGroup()) ? "1" : "0");
itemRequest.setItemGroup(itemResponse.getItemGroup());
itemRequest.setItemCtgGr(itemResponse.getItemCtgGr());
itemRequest.setPartAdd("0");
@ -474,15 +474,15 @@ public class EstimateService {
bomItem.setUnit(itemResponse.getUnit());
bomItem.setPnowW(itemResponse.getPnowW());
bomItem.setSpecification(itemResponse.getPnowW());
bomItem.setAmount(String.valueOf(Integer.parseInt(itemResponse.getBomAmount())
bomItem.setAmount(
String.valueOf(
Integer.parseInt(itemResponse.getBomAmount())
* Integer.parseInt(itemRequest.getAmount())));
bomItem.setBomAmount(itemResponse.getBomAmount());
bomItem.setUnitPrice(itemResponse.getSalePrice());
bomItem.setSalePrice(itemResponse.getSalePrice());
bomItem.setFileUploadFlg(itemResponse.getFileUploadFlg());
bomItem.setPkgMaterialFlg(itemResponse.getPkgMaterialFlg());
bomItem.setOpenFlg("0");
bomItem.setDispCableFlg("0");
bomItem.setItemGroup(itemResponse.getItemGroup());
bomItem.setItemCtgGr(itemResponse.getItemCtgGr());
bomItem.setPartAdd("0");
@ -575,23 +575,28 @@ 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(
BigDecimal amount =
new BigDecimal(
StringUtils.isEmpty(itemRequest.getAmount()) ? "0" : itemRequest.getAmount());
// 아이템용량
BigDecimal pnowW = new BigDecimal(
BigDecimal pnowW =
new BigDecimal(
StringUtils.isEmpty(itemRequest.getPnowW()) ? "0" : itemRequest.getPnowW());
// 모듈/PC 체크
@ -624,7 +629,8 @@ 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);
@ -654,8 +660,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;
}
@ -730,10 +736,8 @@ public class EstimateService {
itemRequest.setOpenFlg(
!StringUtils.isEmpty(itemRequest.getOpenFlg()) ? itemRequest.getOpenFlg() : "0");
itemRequest.setItemChangeFlg(
!StringUtils.isEmpty(itemRequest.getItemChangeFlg()) ? itemRequest.getItemChangeFlg()
: "0");
itemRequest.setDispCableFlg(
!StringUtils.isEmpty(itemRequest.getDispCableFlg()) ? itemRequest.getDispCableFlg()
!StringUtils.isEmpty(itemRequest.getItemChangeFlg())
? itemRequest.getItemChangeFlg()
: "0");
itemRequest.setUserId(estimateRequest.getUserId());
@ -794,15 +798,18 @@ 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"));
}
@ -813,8 +820,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");
@ -845,14 +852,10 @@ 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());
itemRequest.setItemChangeFlg("0");
itemRequest.setDispCableFlg(itemResponse.getDispCableFlg());
itemList.add(itemRequest);
}
@ -901,7 +904,8 @@ 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());
@ -948,23 +952,26 @@ 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"));
}
// 응답 객체
@ -981,8 +988,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());
}
@ -1029,7 +1036,6 @@ public class EstimateService {
itemRequest.setFileUploadFlg(itemResponse.getFileUploadFlg());
itemRequest.setPkgMaterialFlg(itemResponse.getPkgMaterialFlg());
itemRequest.setOpenFlg(itemResponse.getOpenFlg());
itemRequest.setDispCableFlg("CABLE_".equals(itemResponse.getItemGroup()) ? "1" : "0");
itemRequest.setItemGroup(itemResponse.getItemGroup());
itemRequest.setItemCtgGr(itemResponse.getItemCtgGr());
itemRequest.setPartAdd("0");
@ -1055,15 +1061,15 @@ public class EstimateService {
bomItem.setUnit(itemResponse.getUnit());
bomItem.setPnowW(itemResponse.getPnowW());
bomItem.setSpecification(itemResponse.getPnowW());
bomItem.setAmount(String.valueOf(Integer.parseInt(itemResponse.getBomAmount())
bomItem.setAmount(
String.valueOf(
Integer.parseInt(itemResponse.getBomAmount())
* Integer.parseInt(itemRequest.getAmount())));
bomItem.setBomAmount(itemResponse.getBomAmount());
bomItem.setUnitPrice(itemResponse.getSalePrice());
bomItem.setSalePrice(itemResponse.getSalePrice());
bomItem.setFileUploadFlg(itemResponse.getFileUploadFlg());
bomItem.setPkgMaterialFlg(itemResponse.getPkgMaterialFlg());
bomItem.setOpenFlg("0");
bomItem.setDispCableFlg("0");
bomItem.setItemGroup(itemResponse.getItemGroup());
bomItem.setItemCtgGr(itemResponse.getItemCtgGr());
bomItem.setPartAdd("0");
@ -1153,23 +1159,28 @@ 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(
BigDecimal amount =
new BigDecimal(
StringUtils.isEmpty(itemRequest.getAmount()) ? "0" : itemRequest.getAmount());
// 아이템용량
BigDecimal pnowW = new BigDecimal(
BigDecimal pnowW =
new BigDecimal(
StringUtils.isEmpty(itemRequest.getPnowW()) ? "0" : itemRequest.getPnowW());
// 모듈/PC 체크
@ -1211,7 +1222,8 @@ 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());
@ -1258,19 +1270,23 @@ 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"));
}
@ -1290,19 +1306,22 @@ 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"));
}
@ -1312,7 +1331,9 @@ public class EstimateService {
// file Name 명이 없는경우
if (estimateRequest.getFileName() == null || "".equals(estimateRequest.getFileName())) {
estimateRequest.setFileName(estimateResponse.getObjectNo() + "_"
estimateRequest.setFileName(
estimateResponse.getObjectNo()
+ "_"
+ new SimpleDateFormat("yyyyMMdd").format(new Date()));
}
@ -1388,8 +1409,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) {
@ -1398,8 +1419,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())));
@ -1413,14 +1434,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(
@ -1451,7 +1472,8 @@ 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());
@ -1541,8 +1563,12 @@ 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 엑셀로 재변환
@ -1566,14 +1592,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);
@ -1593,8 +1619,9 @@ 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;
@ -1605,26 +1632,35 @@ public class EstimateService {
String estimateType = estimateResponse.getEstimateType();
// 주택패키지 단가
BigDecimal pkgAsp = new BigDecimal(
BigDecimal pkgAsp =
new BigDecimal(
StringUtils.isEmpty(estimateResponse.getPkgAsp()) ? "0" : estimateResponse.getPkgAsp());
for (ItemResponse itemResponse : itemList) {
// 수량
BigDecimal amount = new BigDecimal(
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(
BigDecimal pnowW =
new BigDecimal(
StringUtils.isEmpty(itemResponse.getPnowW()) ? "0" : itemResponse.getPnowW());
// 아이템 단가 합산
@ -1669,10 +1705,11 @@ 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)));
}
@ -1728,8 +1765,9 @@ 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 =
@ -1796,11 +1834,14 @@ public class EstimateService {
elm.text(StringUtils.defaultString(data.getObjectNameOmit()));
elm = doc.getElementById("objectNo1");
elm.text(StringUtils.defaultString(data.getObjectNo()) + " / "
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");
@ -1835,18 +1876,28 @@ 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())
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: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())) {
@ -1854,13 +1905,19 @@ 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");
@ -1888,10 +1945,15 @@ 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");
@ -1900,8 +1962,11 @@ 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()));
@ -1940,10 +2005,14 @@ 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>");
}
}
@ -1957,8 +2026,12 @@ 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");
@ -1972,8 +2045,10 @@ 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");
@ -1991,13 +2066,19 @@ 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>" + StringUtils.defaultString(roofResponse.getSlope()) + "寸</td>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getConstructSpecificationName())
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 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>");
@ -2007,8 +2088,11 @@ 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()));
@ -2047,10 +2131,14 @@ 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>");
}
}
@ -2062,13 +2150,19 @@ 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>" + StringUtils.defaultString(roofResponse.getSlope()) + "寸</td>");
sb.append("<td>" + StringUtils.defaultString(roofResponse.getConstructSpecificationName())
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 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>");
@ -2176,14 +2270,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) {
@ -2194,7 +2288,8 @@ public class EstimateService {
for (ItemRequest data : pcsItemList) {
String val = String.valueOf(j);
List<ItemRequest> resultList = moduleList.stream()
List<ItemRequest> resultList =
moduleList.stream()
.filter(t -> StringUtils.equals(val, t.getCircuit().split("-")[0]))
.collect(Collectors.toList());
data.setCircuitCfg(this.getPcsCircuitCtg(resultList));
@ -2228,7 +2323,9 @@ public class EstimateService {
Set<String> set = new HashSet<String>(list);
List<String> setList = new ArrayList<>(set);
Collections.sort(setList, new Comparator<String>() {
Collections.sort(
setList,
new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
int first = Integer.parseInt(o1.split("-")[0]);
@ -2238,8 +2335,7 @@ public class EstimateService {
});
for (String str : setList) {
if (!StringUtils.isEmpty(circuitCfg))
circuitCfg += ", ";
if (!StringUtils.isEmpty(circuitCfg)) circuitCfg += ", ";
circuitCfg += Collections.frequency(list, str);
}
}

View File

@ -74,9 +74,6 @@ public class ItemRequest {
@Schema(description = "아이템 변경 여부")
private String itemChangeFlg;
@Schema(description = "대표 케이블 여부")
private String dispCableFlg;
@Schema(description = "PC 아이템 ID")
private String pcItemId;

View File

@ -68,9 +68,6 @@ public class ItemResponse {
@Schema(description = "아이템 변경 여부")
private String itemChangeFlg;
@Schema(description = "대표 케이블 여부")
private String dispCableFlg;
@Schema(description = "W")
private String pnowW;

View File

@ -1,7 +1,6 @@
package com.interplug.qcast.biz.master.dto.pcs.connoption;
import com.interplug.qcast.biz.master.dto.pcs.ApiPcsConnResponse;
import com.interplug.qcast.biz.master.dto.pcs.ApiPcsOptionResponse;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import lombok.Getter;
@ -29,7 +28,4 @@ public class ApiPcsConnOptionPcsItemResponse {
@Schema(description = "연결함목록")
private List<ApiPcsConnResponse> connList;
@Schema(description = "옵션목록(모니터선택)")
private List<ApiPcsOptionResponse> optionList;
}

View File

@ -1,7 +1,6 @@
package com.interplug.qcast.biz.master.dto.pcs.voltagestepup;
import com.interplug.qcast.biz.master.dto.pcs.ApiPcsConnResponse;
import com.interplug.qcast.biz.master.dto.pcs.ApiPcsOptionResponse;
import com.interplug.qcast.biz.master.dto.pcs.ApiPcsSerQtyDto;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
@ -33,7 +32,4 @@ public class ApiPcsVoltageStepUpPcsItemResponse {
@Schema(description = "연결함목록")
private List<ApiPcsConnResponse> connList;
@Schema(description = "옵션목록(모니터선택)")
private List<ApiPcsOptionResponse> optionList;
}

View File

@ -1,28 +1,11 @@
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.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.estimate.dto.*;
import com.interplug.qcast.biz.object.dto.ObjectRequest;
import com.interplug.qcast.biz.object.dto.ObjectResponse;
import com.interplug.qcast.biz.object.dto.PlanReqRequest;
@ -38,8 +21,18 @@ 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
@ -47,8 +40,7 @@ import lombok.extern.slf4j.Slf4j;
public class ObjectService {
private final InterfaceQsp interfaceQsp;
@Autowired
Messages message;
@Autowired Messages message;
@Value("${file.ini.root.path}")
private String baseDirPath;
@ -62,8 +54,7 @@ public class ObjectService {
private final StoreFavoriteService storeFavoriteService;
@Autowired
private CanvasStatusService canvasStatusService;
@Autowired private CanvasStatusService canvasStatusService;
/**
* 도도부현 목록 조회
@ -109,11 +100,13 @@ 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"));
}
@ -136,15 +129,17 @@ 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"));
}
@ -175,7 +170,8 @@ 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"));
}
@ -191,7 +187,8 @@ 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"));
}
@ -243,9 +240,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)
constructSpecificationMultis +=
StringUtils.isEmpty(constructSpecificationMultis)
? arrOrgConstructSpecificationMultis[i]
: splitStr + arrOrgConstructSpecificationMultis[i];
}
@ -298,15 +297,18 @@ 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"));
}
@ -351,12 +353,18 @@ 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);
*/
// 설계의뢰번호 존재 물건번호 업데이트
@ -370,8 +378,9 @@ 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()
@ -380,8 +389,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")));
}
}
}
@ -405,15 +414,18 @@ 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"));
}
@ -435,7 +447,9 @@ public class ObjectService {
objectRequest.setAddresseeCompanyName(
objectRequest.getObjectName() + ' ' + objectRequest.getObjectNameOmit());
objectRequest.setAddresseeCompanyNameOmit(objectRequest.getObjectNameOmit());
objectRequest.setContentsPath(baseDirPath + "\\\\"
objectRequest.setContentsPath(
baseDirPath
+ "\\\\"
+ (tempChgFlg ? objectRequest.getNewObjectNo() : objectRequest.getObjectNo()));
result += objectMapper.updateObject(objectRequest);
result += objectMapper.updateObjectInfo(objectRequest);
@ -456,8 +470,9 @@ 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()
@ -466,8 +481,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")));
}
}
}
@ -475,7 +490,8 @@ public class ObjectService {
}
// 모든 변경 완료 재호출
objectResponse = objectMapper.selectObjectDetail(
objectResponse =
objectMapper.selectObjectDetail(
(tempChgFlg ? objectRequest.getNewObjectNo() : objectRequest.getObjectNo()));
return objectResponse;
}
@ -489,11 +505,13 @@ 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"));
}
@ -518,7 +536,8 @@ 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"));
}
@ -537,8 +556,9 @@ 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()
@ -547,8 +567,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")));
}
}
}
@ -574,24 +594,27 @@ 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 {
@ -616,14 +639,10 @@ 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());
itemRequest.setItemChangeFlg("0");
itemRequest.setDispCableFlg(itemResponse.getDispCableFlg());
itemList.add(itemRequest);
}
@ -675,8 +694,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(
@ -754,23 +773,26 @@ 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 삭제
@ -788,11 +810,13 @@ 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"));
}
@ -800,28 +824,43 @@ 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(
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(),
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)
String apiUrl =
UriComponentsBuilder.fromHttpUrl(url)
.queryParam("saleStoreId", planReqRequest.getSaleStoreId())
.queryParam("saleStoreLevel", planReqRequest.getSaleStoreLevel())
.queryParam("schPlanReqNo", encodedSchPlanReqNo).queryParam("schTitle", encodedSchTitle)
.queryParam("schPlanReqNo", encodedSchPlanReqNo)
.queryParam("schTitle", encodedSchTitle)
.queryParam("schAddress", encodedSchAddress)
.queryParam("schSaleStoreName", encodedSchSaleStoreName)
.queryParam("schPlanReqName", encodedSchPlanReqName)
@ -830,7 +869,9 @@ public class ObjectService {
.queryParam("schStartDt", planReqRequest.getSchStartDt())
.queryParam("schEndDt", planReqRequest.getSchEndDt())
.queryParam("startRow", planReqRequest.getStartRow())
.queryParam("endRow", planReqRequest.getEndRow()).build().toUriString();
.queryParam("endRow", planReqRequest.getEndRow())
.build()
.toUriString();
/* [2]. QSP API CALL -> Response */
String strResponse = interfaceQsp.callApi(HttpMethod.GET, apiUrl, null);

View File

@ -1,17 +1,17 @@
package com.interplug.qcast.biz.pwrGnrSimulation;
import com.interplug.qcast.biz.estimate.dto.EstimateRequest;
import com.interplug.qcast.biz.pwrGnrSimulation.dto.PwrGnrSimGuideResponse;
import com.interplug.qcast.biz.pwrGnrSimulation.dto.PwrGnrSimRequest;
import com.interplug.qcast.biz.pwrGnrSimulation.dto.PwrGnrSimResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@ -36,15 +36,4 @@ public class PwrGnrSimController {
public PwrGnrSimGuideResponse selectPwrGnrSimulationGuideInfo() throws Exception {
return pwrGnrSimService.selectPwrGnrSimulationGuideInfo();
}
@Operation(description = "견적서를 엑셀로 다운로드한다.")
@PostMapping("/excel-download")
@ResponseStatus(HttpStatus.OK)
public void excelDownload(
HttpServletRequest request,
HttpServletResponse response,
@RequestBody EstimateRequest estimateRequest)
throws Exception {
pwrGnrSimService.excelDownload(request, response, estimateRequest);
}
}

View File

@ -2,28 +2,23 @@ package com.interplug.qcast.biz.pwrGnrSimulation;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.interplug.qcast.biz.estimate.dto.*;
import com.interplug.qcast.biz.pwrGnrSimulation.dto.*;
import com.interplug.qcast.config.Exception.ErrorCode;
import com.interplug.qcast.config.Exception.QcastException;
import com.interplug.qcast.config.message.Messages;
import com.interplug.qcast.util.ExcelUtil;
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.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
@ -34,8 +29,6 @@ import org.springframework.stereotype.Service;
public class PwrGnrSimService {
private final InterfaceQsp interfaceQsp;
@Autowired Messages message;
@Value("${qsp.url}")
private String qspUrl;
@ -78,19 +71,19 @@ public class PwrGnrSimService {
// 태양 적위
double[] taiyousekii = readValuesFromFile("template/pwrGnrSimulation/taiyousekii.txt");
double[][] peakcut_by_pcs_data =
static double[][] peakcut_by_pcs_data =
readValuesFromFile2("template/pwrGnrSimulation/peakcut_by_pcs_data.txt");
double[][] tashounen_data_deg0 =
static double[][] tashounen_data_deg0 =
readValuesFromFile2("template/pwrGnrSimulation/tashounen_data_deg0.txt");
double[][] tashounen_data_deg90 =
static double[][] tashounen_data_deg90 =
readValuesFromFile2("template/pwrGnrSimulation/tashounen_data_deg90.txt");
double[][] amp_peakcut_data_deg0 =
static double[][] amp_peakcut_data_deg0 =
readValuesFromFile2("template/pwrGnrSimulation/amp_peakcut_data_deg0.txt");
double[][] amp_peakcut_data_deg90 =
static double[][] amp_peakcut_data_deg90 =
readValuesFromFile2("template/pwrGnrSimulation/amp_peakcut_data_deg90.txt");
/**
@ -515,7 +508,7 @@ public class PwrGnrSimService {
}
// 배열 변환 포맷 처리 메서드
private String[] formatAndPrintArray(double[] doubleArray) {
private static String[] formatAndPrintArray(double[] doubleArray) {
return Arrays.stream(doubleArray)
.mapToInt(d -> (int) d) // double -> int 변환
.mapToObj(i -> String.format("%,d", i))
@ -523,7 +516,7 @@ public class PwrGnrSimService {
}
// 설치면의 사면 일사량 계산
public double[] peakcut(
public static double[] peakcut(
int simulationPointNumber,
double koubai,
double houi,
@ -620,7 +613,7 @@ public class PwrGnrSimService {
}
/** 0도 방위 전력 피크 컷을 계산하는 방법 */
private double computePowerPeakCutDeg0(
private static double computePowerPeakCutDeg0(
int simulationPointNumber, double sekisairitsu, double koubai) {
// 0度近似曲線係数
double[] x = {1, 5, 15, 20, 30, 40};
@ -715,7 +708,7 @@ public class PwrGnrSimService {
}
/** 전류 피크 컷(5차) 90도 근사 곡선 계수 */
private double computeAmpPeakCutDeg90(
private static double computeAmpPeakCutDeg90(
int simulationPointNumber, double koubai, double amp_delta) {
// 초기 설정
@ -816,7 +809,8 @@ public class PwrGnrSimService {
}
/** 전류 피크 컷(5차) 0도 근사 곡선 계수 */
private double computeAmpPeakCutDeg0(int simulationPointNumber, double koubai, double amp_delta) {
private static double computeAmpPeakCutDeg0(
int simulationPointNumber, double koubai, double amp_delta) {
double[] x = {5, 15, 20, 30, 40, 50};
double[] z2 = new double[6];
@ -906,7 +900,7 @@ public class PwrGnrSimService {
}
/** 0도 방위 전력 피크 컷을 계산하는 방법 */
private double computePowerPeakCutDeg90(
private static double computePowerPeakCutDeg90(
int simulationPointNumber, double sekisairitsu, double koubai) {
// 데이터 초기화
double[] x = {1, 5, 15, 20, 30, 40};
@ -1193,7 +1187,7 @@ public class PwrGnrSimService {
return shamenNissha;
}
public double[] readValuesFromFile(String fileName) {
public static double[] readValuesFromFile(String fileName) {
List<Double> values = new ArrayList<>();
try (InputStream inputStream =
@ -1216,7 +1210,7 @@ public class PwrGnrSimService {
return values.stream().mapToDouble(Double::doubleValue).toArray();
}
public String[][] readValuesFromFileString2(String fileName) {
public static String[][] readValuesFromFileString2(String fileName) {
List<String[]> values = new ArrayList<>();
StringBuilder sb = new StringBuilder();
@ -1254,7 +1248,7 @@ public class PwrGnrSimService {
return values.toArray(new String[0][]);
}
public double[][] readValuesFromFile2(String fileName) {
public static double[][] readValuesFromFile2(String fileName) {
List<double[]> values = new ArrayList<>();
StringBuilder sb = new StringBuilder();
@ -1312,7 +1306,7 @@ public class PwrGnrSimService {
return guideResponse;
}
public Document pwrGnrSimPdfHtml(Document doc, PwrGnrSimResponse data)
public static Document pwrGnrSimPdfHtml(Document doc, PwrGnrSimResponse data)
throws IOException, QcastException {
String[] pwrGnrSimList = data.getFrcPwrGnrList();
@ -1484,111 +1478,10 @@ public class PwrGnrSimService {
return doc;
}
public int roundUpAuto(double value) {
public static int roundUpAuto(double value) {
int length = (int) Math.log10(value) + 1; // 숫자의 자리수를 계산
int place = (int) Math.pow(10, length - 1); // 자리수에 따른 올림 기준(10, 100, 1000 )
return (int) Math.ceil(value / place) * place;
}
public void excelDownload(
HttpServletRequest request, HttpServletResponse response, EstimateRequest estimateRequest)
throws Exception {
// Validation
if (StringUtils.isEmpty(estimateRequest.getObjectNo())) {
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,
message.getMessage("common.message.required.data", "Plan No"));
}
try {
EstimateResponse estimateResponse = new EstimateResponse();
estimateResponse.setObjectNo(estimateRequest.getObjectNo());
estimateResponse.setPlanNo(estimateRequest.getPlanNo());
// file Name 명이 없는경우
if (estimateRequest.getFileName() == null || "".equals(estimateRequest.getFileName())) {
estimateRequest.setFileName(
estimateResponse.getObjectNo()
+ "_"
+ new SimpleDateFormat("yyyyMMdd").format(new Date()));
}
// 발전시뮬레이션 계산
PwrGnrSimRequest pwrGnrSimRequest = new PwrGnrSimRequest();
pwrGnrSimRequest.setObjectNo(estimateResponse.getObjectNo());
pwrGnrSimRequest.setPlanNo(estimateResponse.getPlanNo());
PwrGnrSimResponse pwrGnrSimResponse = this.selectPwrGnrSimulation(pwrGnrSimRequest);
pwrGnrSimResponse.setPwrGnrSimType(estimateRequest.getPwrGnrSimType());
// 발전시뮬레이션 타입에 따른 list 셋팅
if ("A".equals(estimateRequest.getPwrGnrSimType())) {
pwrGnrSimResponse.setFrcPwrGnrList(pwrGnrSimResponse.getHatsudenryouAll());
} else if ("B".equals(estimateRequest.getPwrGnrSimType())) {
pwrGnrSimResponse.setFrcPwrGnrList(pwrGnrSimResponse.getHatsudenryouAllSnow());
} else if ("C".equals(estimateRequest.getPwrGnrSimType())) {
pwrGnrSimResponse.setFrcPwrGnrList(pwrGnrSimResponse.getHatsudenryouPeakcutAll());
} else if ("D".equals(estimateRequest.getPwrGnrSimType())) {
pwrGnrSimResponse.setFrcPwrGnrList(pwrGnrSimResponse.getHatsudenryouPeakcutAllSnow());
}
pwrGnrSimResponse.setIntFrcPwrGnrList(
Arrays.stream(pwrGnrSimResponse.getFrcPwrGnrList())
.map(s -> s.replace(",", "")) // , 제거
.mapToInt(Integer::parseInt) // 문자열을 int로 변환
.toArray());
if (pwrGnrSimResponse != null) {
try {
// 발전시뮬레이션 안내사항 조회
PwrGnrSimGuideResponse pwrGnrSimGuideInfo = this.selectPwrGnrSimulationGuideInfo();
if (pwrGnrSimGuideInfo != null) {
pwrGnrSimResponse.setGuideInfo(pwrGnrSimGuideInfo.getData());
}
} catch (Exception e) {
}
}
estimateResponse.setPwrGnrSim(pwrGnrSimResponse);
if ("PDF".equals(estimateRequest.getSchDownload())) { // PDF 다운로드
String[] arrSection = {"div.section3"};
String templateFilePath = "pdf_download_simulation_detail_template.html";
// 템플릿 html 조회
Document doc = PdfUtil.getPdfDoc(request, templateFilePath);
// 발전시뮬레이션 pdf Html 생성
doc = this.pwrGnrSimPdfHtml(doc, pwrGnrSimResponse);
// pdf 다운로드
PdfUtil.pdfDownload(request, response, doc, estimateRequest.getFileName(), null, true);
} else {
String excelTemplateName = "excel_download_simulation_detail_template.xlsx";
ExcelUtil excelUtil = new ExcelUtil();
excelUtil.download(
request,
response,
excelUtil.convertVoToMap(estimateResponse),
null,
estimateRequest.getFileName(),
excelTemplateName);
}
} catch (Exception e) {
e.printStackTrace();
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR);
}
}
}

View File

@ -3,7 +3,6 @@ package com.interplug.qcast.util;
import com.itextpdf.html2pdf.ConverterProperties;
import com.itextpdf.html2pdf.HtmlConverter;
import com.itextpdf.html2pdf.resolver.font.DefaultFontProvider;
import com.itextpdf.kernel.geom.PageSize;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.kernel.pdf.PdfWriter;
@ -61,7 +60,6 @@ public class PdfUtil {
* @param doc
* @param pdfFileName 파일명
* @param arrSection 노출 Section
* @param isLandscape 가로/세로 설정
* @throws IOException
*/
public static void pdfDownload(
@ -69,13 +67,9 @@ public class PdfUtil {
HttpServletResponse response,
Document doc,
String pdfFileName,
String[] arrSection,
boolean isLandscape)
String[] arrSection)
throws IOException {
// 가로 세로 설정
PageSize pageSize = isLandscape ? PageSize.A4.rotate() : PageSize.A4;
// 응답에 PDF 설정
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment; filename=\"" + pdfFileName + "\".pdf");
@ -85,8 +79,6 @@ public class PdfUtil {
PdfWriter writer = new PdfWriter(os);
PdfDocument pdfDoc = new PdfDocument(writer)) {
pdfDoc.setDefaultPageSize(pageSize);
// 폰트 설정
ConverterProperties properties = new ConverterProperties();
String fontPath = "template/pdf/BIZUDPGothic-Regular.ttf";
@ -96,9 +88,7 @@ public class PdfUtil {
if (arrSection == null || arrSection.length == 0) {
// HTML 전체를 pdfDoc에 직접 변환
HtmlConverter.convertToPdf(
new ByteArrayInputStream(doc.html().getBytes(StandardCharsets.UTF_8)),
pdfDoc,
properties);
new ByteArrayInputStream(doc.html().getBytes(StandardCharsets.UTF_8)), os, properties);
os.flush();
} else {
// arrSection이 있는 경우 섹션을 개별적으로 변환 병합
@ -118,8 +108,6 @@ public class PdfUtil {
PdfWriter tempWriter = new PdfWriter(tempOutputStream);
PdfDocument tempPdfDoc = new PdfDocument(tempWriter)) {
tempPdfDoc.setDefaultPageSize(pageSize);
HtmlConverter.convertToPdf(
new ByteArrayInputStream(sectionHtml.getBytes(StandardCharsets.UTF_8)),
tempPdfDoc,
@ -173,15 +161,4 @@ public class PdfUtil {
}
return fontProvider;
}
public static void pdfDownload(
HttpServletRequest request,
HttpServletResponse response,
Document doc,
String pdfFileName,
String[] arrSection)
throws IOException {
pdfDownload(request, response, doc, pdfFileName, arrSection, false); // 기본값은 세로
}
}

View File

@ -159,8 +159,6 @@
, CL.CODE_NM AS CL_CODE_NM
, CL.CODE_JP AS CL_CODE_JP
, CL.PRIORITY AS CL_PRIORITY
, CL.REF_CHR1 AS CL_REF_CHR1
, CL.REF_CHR2 AS CL_REF_CHR2
FROM
M_COMM_H (NOLOCK) CH
INNER JOIN

View File

@ -150,16 +150,13 @@
WHEN MI.ITEM_GROUP = 'PC_' AND MI.POWER_COM_FLG = '0' THEN 'STORAGE_BATTERY'
ELSE MI.ITEM_GROUP END AS ITEM_GROUP
, MI.MODULE_FLG
, MII.PKG_MATERIAL_FLG
, MII.FILE_UPLOAD_FLG
, MII.ITEM_CTG_GR
, MI.PKG_MATERIAL_FLG
, MI.FILE_UPLOAD_FLG
, MI.ITEM_CTG_GR
, '0' AS SALE_PRICE
, '0' AS OPEN_FLG
FROM M_PACKAGE_ITEM PI WITH (NOLOCK)
INNER JOIN M_ITEM MI WITH (NOLOCK)
ON PI.ITEM_ID = MI.ITEM_ID
LEFT OUTER JOIN M_ITEM_INFO MII
ON MI.ITEM_ID = MII.ITEM_ID
WHERE PI.PACKAGE_ITEM_ID = #{itemId}
AND MI.DEL_FLG = 0
</select>

View File

@ -269,7 +269,6 @@
, PEI.FILE_UPLOAD_FLG
, PEI.OPEN_FLG
, PEI.ITEM_CHANGE_FLG
, PEI.DISP_CABLE_FLG
, I.PNOW_W
, CASE WHEN I.POWER_COM_FLG = '1' THEN 'PC_'
WHEN I.ITEM_GROUP = 'PC_' AND I.POWER_COM_FLG = '0' THEN 'STORAGE_BATTERY'
@ -822,7 +821,6 @@
, FILE_UPLOAD_FLG
, OPEN_FLG
, ITEM_CHANGE_FLG
, DISP_CABLE_FLG
) VALUES (
#{objectNo}
, #{planNo}
@ -840,7 +838,6 @@
, #{fileUploadFlg}
, #{openFlg}
, #{itemChangeFlg}
, #{dispCableFlg}
)
</insert>

View File

@ -1,288 +0,0 @@
<!doctype html>
<html lang="ja">
<head>
<style>
@media print {
body {
print-color-adjust: exact;
-webkit-print-color-adjust: exact;
}
}
table {
width: 100%;
table-layout: fixed;
font-family: M-Gothic;
font-size: 11px;
border-collapse: collapse;
margin: 0 auto;
line-height: 150%;
color: #333
}
.month-table td {
word-break: break-all;
}
th, td {
padding: 5px 5px 3px;
text-align: center;
font-size: 8px;
border: 1px solid #000
}
th {
background-color: #eee;
font-weight: bold
}
td {
background-color: white
}
.col-20 {
width: 20%
}
.col-15 {
width: 15%
}
.col-10 {
width: 10%
}
.col-13 {
width: 13%
}
body {
max-width: 1040px;
margin: 0 auto
}
.mb20 {
margin-bottom: 20px
}
/* 가이드박스 */
.guide-box {
border: 1px solid #000;
padding: 15px;
}
.guide-content {
white-space: pre-line;
line-height: 1.4;
font-size: 12px;
margin: 0;
}
/* 차트퍼블 */
.chart-wrapper {
width: 100%;
table-layout: fixed;
margin: 20px 0;
height: 324.3px;
}
.chart-wrapper td {
padding: 0;
border: none
}
.chart-wrapper td.y-axis-wrap {
vertical-align: bottom
}
.y-axis {
margin-top: -5px
}
.y-axis td {
font-size: 12px;
line-height: 1;
vertical-align: bottom;
padding: 12.3px 0
}
.y-axis td.zero {
padding-bottom: 0
}
.y-axis td.top {
padding-top: 0
}
.chart-wrapper td.bar-cell {
position: relative;
vertical-align: bottom;
border-bottom: 1px solid #ddd;
background-color: transparent
}
.chart-wrapper td.bar-cell .bar {
position: absolute;
bottom: 0;
left: 13.4px;
width: 18px;
margin: 0 auto
}
.chart-wrapper td.month-cell {
font-size: 11px;
padding-top: 7px
}
.chart-line td {
background-color: transparent;
padding: 18.2px 0;
border-bottom: 1px solid #ddd !important
}
.chart-line td.top {
padding: 1px
}
.chart-wrap {
overflow: hidden;
}
.left-side {
margin-right: 20px;
width: 570px;
float: left;
}
.right-side {
width: 430px;
float: right;
}
.tit {
font-size: 14px;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="section3">
<table class="mb20">
<tbody>
<tr>
<th class="col-10">物件番号</th>
<td id="objectNo"></td>
<th class="col-10">作成日</th>
<td class="col-13" id="drawingEstimateCreateDate"></td>
<th class="col-10">都道府県</th>
<td class="col-13" id="prefName"></td>
<th class="col-10">日射量観測地点</th>
<td class="col-13" id="areaName"></td>
</tr>
<tr>
<th class="col-10">システム容量</th>
<td id="capacity"></td>
<th class="col-10">年間予測発電量</th>
<td id="anlFrcsGnrt"></td>
<th class="col-10">積雪条件</th>
<td id="snowfall"></td>
<th class="col-10">風速条件</th>
<td id="standardWindSpeedId"></td>
</tr>
</tbody>
</table>
<div class="chart-wrap">
<div class="left-side">
<div id="pwrGnrChartImg">
<table class="chart-wrapper">
<tbody>
<tr id="htmlX">
<td class="y-axis-wrap">
<table class="y-axis">
<tbody id="htmlY">
</tbody>
</table>
</td>
</tr>
<tr>
<td class="month-cell"></td>
<td class="month-cell">1月</td>
<td class="month-cell">2月</td>
<td class="month-cell">3月</td>
<td class="month-cell">4月</td>
<td class="month-cell">5月</td>
<td class="month-cell">6月</td>
<td class="month-cell">7月</td>
<td class="month-cell">8月</td>
<td class="month-cell">9月</td>
<td class="month-cell">10月</td>
<td class="month-cell">11月</td>
<td class="month-cell">12月</td>
</tr>
</tbody>
</table>
</div>
<div class="tit">
● 予測発電量kWh
</div>
<table class="mb20 month-table">
<thead>
<tr>
<th>1月</th>
<th>2月</th>
<th>3月</th>
<th>4月</th>
<th>5月</th>
<th>6月</th>
<th>7月</th>
<th>8月</th>
<th>9月</th>
<th>10月</th>
<th>11月</th>
<th>12月</th>
<th>合計</th>
</tr>
</thead>
<tbody>
<tr id="frcPwrGnrList_detail">
</tr>
</tbody>
</table>
</div>
<div class="right-side">
<table class="mb20">
<thead>
<tr>
<th class="col-15">屋根面</th>
<th class="col-15">傾斜角度</th>
<th class="col-15">方位角(度)</th>
<th>太陽電池モジュール</th>
<th class="col-15">枚数(枚)</th>
</tr>
</thead>
<tbody id="roofModuleList_detail">
</tbody>
</table>
<table class="mb20">
<thead>
<tr>
<th>パワーコンディショナー</th>
<th class="col-20"></th>
</tr>
</thead>
<tbody id="pcsList_detail">
</tbody>
</table>
</div>
</div>
<div class="tit">
● Hanwha Japan 年間発電量シミュレーション案内事項
</div>
<div class="guide-box">
<pre class="guide-content" id="guideInfo"></pre>
</div>
</div>
</body>
</html>