From 282fa9bfb0f06a97e47066b608c25be8dee4b3d3 Mon Sep 17 00:00:00 2001 From: "LAPTOP-L3VE7KK2\\USER" Date: Mon, 11 Nov 2024 17:37:09 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=AC=EC=A0=81=EC=84=9C=20QSP=20=EC=97=B0?= =?UTF-8?q?=EB=8F=99=20API=20=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/estimate/EstimateController.java | 4 +- .../qcast/biz/estimate/EstimateMapper.java | 7 +- .../qcast/biz/estimate/EstimateService.java | 122 ++++++++++++++++-- ...Response.java => EstimateApiResponse.java} | 2 +- .../biz/estimate/dto/EstimateRequest.java | 3 + .../biz/estimate/dto/EstimateSendRequest.java | 11 ++ .../estimate/dto/EstimateSendResponse.java | 115 +++++++++++++++++ .../qcast/biz/object/dto/ObjectRequest.java | 5 +- .../mappers/estimate/estimateMapper.xml | 52 ++++++++ .../resources/mappers/object/objectMapper.xml | 13 +- 10 files changed, 317 insertions(+), 17 deletions(-) rename src/main/java/com/interplug/qcast/biz/estimate/dto/{PriceResponse.java => EstimateApiResponse.java} (86%) create mode 100644 src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateSendRequest.java create mode 100644 src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateSendResponse.java diff --git a/src/main/java/com/interplug/qcast/biz/estimate/EstimateController.java b/src/main/java/com/interplug/qcast/biz/estimate/EstimateController.java index 2440cd7d..4552609b 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/EstimateController.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/EstimateController.java @@ -22,14 +22,14 @@ public class EstimateController { @Operation(description = "1차점 가격 관리 목록을 조회한다.") @GetMapping("/price/store-price-list") @ResponseStatus(HttpStatus.OK) - public PriceResponse selectStorePriceList(PriceRequest priceRequest) throws Exception { + public EstimateApiResponse selectStorePriceList(PriceRequest priceRequest) throws Exception { return estimateService.selectStorePriceList(priceRequest); } @Operation(description = "아이템 가격 목록을 조회한다.") @PostMapping("/price/item-price-list") @ResponseStatus(HttpStatus.OK) - public PriceResponse selectItemPriceList(@RequestBody PriceRequest priceRequest) + public EstimateApiResponse selectItemPriceList(@RequestBody PriceRequest priceRequest) throws Exception { return estimateService.selectItemPriceList(priceRequest); } diff --git a/src/main/java/com/interplug/qcast/biz/estimate/EstimateMapper.java b/src/main/java/com/interplug/qcast/biz/estimate/EstimateMapper.java index 1f73781f..5e169ed3 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/EstimateMapper.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/EstimateMapper.java @@ -1,7 +1,6 @@ package com.interplug.qcast.biz.estimate; import com.interplug.qcast.biz.estimate.dto.*; -import com.interplug.qcast.biz.object.dto.*; import java.util.List; import org.apache.ibatis.annotations.Mapper; @@ -13,6 +12,9 @@ public interface EstimateMapper { // 견적서 PDF 상세 확인 public EstimateResponse selectEstimatePdfDetail(EstimateRequest estimateRequest); + // 견적서 API 상세 확인 + public EstimateSendResponse selectEstimateApiDetail(EstimateRequest estimateRequest); + // 견적서 아이템 목록 조회 public List selectEstimateItemList(EstimateRequest estimateRequest); @@ -31,6 +33,9 @@ public interface EstimateMapper { // 견적서 정보 수정 public int updateEstimate(EstimateRequest estimateRequest); + // 견적서 API 정보 수정 + public int updateEstimateApi(EstimateRequest estimateRequest); + // 견적서 지붕재 등록 public int insertEstimateRoof(RoofRequest roofRequest); diff --git a/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java b/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java index c8a7a857..3f2dada3 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java @@ -21,7 +21,6 @@ import com.interplug.qcast.util.InterfaceQsp; import io.micrometer.common.util.StringUtils; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import java.awt.*; import java.beans.BeanInfo; import java.beans.Introspector; import java.beans.PropertyDescriptor; @@ -62,13 +61,13 @@ public class EstimateService { @Autowired private PwrGnrSimService pwrGnrSimService; /** - * 1차점 price 관리 목록 조회 + * QSP 1차점 price 관리 목록 조회 * * @param priceRequest 1차점 price 관련 정보 * @return PriceResponse 1차점 price 목록 * @throws Exception */ - public PriceResponse selectStorePriceList(PriceRequest priceRequest) throws Exception { + public EstimateApiResponse selectStorePriceList(PriceRequest priceRequest) throws Exception { // Validation if (StringUtils.isEmpty(priceRequest.getSaleStoreId())) { throw new QcastException( @@ -86,7 +85,7 @@ public class EstimateService { message.getMessage("common.message.required.data", "Estimate Type")); } - PriceResponse response = null; + EstimateApiResponse response = null; /* [1]. QSP API (url + param) Setting */ String url = QSP_API_URL + "/api/price/storePriceList"; String apiUrl = @@ -104,7 +103,7 @@ public class EstimateService { com.fasterxml.jackson.databind.ObjectMapper om = new com.fasterxml.jackson.databind.ObjectMapper() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - response = om.readValue(strResponse, PriceResponse.class); + response = om.readValue(strResponse, EstimateApiResponse.class); } else { // [msg] No data throw new QcastException(ErrorCode.NOT_FOUND, message.getMessage("common.message.no.data")); @@ -114,11 +113,13 @@ public class EstimateService { } /** + * QSP 아이템 가격 목록 조회 + * * @param priceRequest * @return PriceResponse * @throws Exception */ - public PriceResponse selectItemPriceList(PriceRequest priceRequest) throws Exception { + public EstimateApiResponse selectItemPriceList(PriceRequest priceRequest) throws Exception { // Validation if (StringUtils.isEmpty(priceRequest.getSaleStoreId())) { throw new QcastException( @@ -136,7 +137,7 @@ public class EstimateService { message.getMessage("common.message.required.data", "Price Code")); } - PriceResponse response = null; + EstimateApiResponse response = null; /* [1]. QSP API CALL -> Response */ String strResponse = interfaceQsp.callApi( @@ -146,7 +147,7 @@ public class EstimateService { com.fasterxml.jackson.databind.ObjectMapper om = new com.fasterxml.jackson.databind.ObjectMapper() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - response = om.readValue(strResponse, PriceResponse.class); + response = om.readValue(strResponse, EstimateApiResponse.class); } else { // [msg] No data throw new QcastException(ErrorCode.NOT_FOUND, message.getMessage("common.message.no.data")); @@ -488,9 +489,11 @@ public class EstimateService { estimateMapper.deleteEstimateItemList(estimateRequest); // 견적서 아이템 신규 추가 + int j = 1; for (ItemRequest itemRequest : itemList) { itemRequest.setObjectNo(estimateRequest.getObjectNo()); itemRequest.setPlanNo(estimateRequest.getPlanNo()); + itemRequest.setDispOrder(String.valueOf(j++)); itemRequest.setPartAdd( !StringUtils.isEmpty(itemRequest.getPartAdd()) ? itemRequest.getPartAdd() : "0"); itemRequest.setItemChangeFlg( @@ -501,6 +504,19 @@ public class EstimateService { estimateMapper.insertEstimateItem(itemRequest); } + + // QSP Q.CAST SEND API + List resultList = new ArrayList(); + resultList = this.sendEstimateApi(estimateRequest); + // API에서 받은 문서번호 업데이트 + for (EstimateSendResponse result : resultList) { + estimateRequest.setObjectNo(result.getObjectNo()); + estimateRequest.setPlanNo(result.getPlanNo()); + estimateRequest.setDocNo(result.getDocNo()); + estimateRequest.setSyncFlg(result.getSyncFlg()); + + estimateMapper.updateEstimateApi(estimateRequest); + } } catch (Exception e) { e.printStackTrace(); } @@ -717,6 +733,14 @@ public class EstimateService { } } + /** + * 아이템 목록을 통한 견적서 가격 자동계산 + * + * @param estimateResponse 견적서 정보 + * @param itemList 아이템 정보 목록 + * @param unitPriceFlg 가격 표시 코드 + * @throws Exception + */ public void selectTotalPriceInfo( EstimateResponse estimateResponse, List itemList, String unitPriceFlg) throws Exception { @@ -791,7 +815,7 @@ public class EstimateService { } // 부가세 계산 (10프로) - vatPrice = supplyPrice.multiply(new BigDecimal("0.01")); + vatPrice = supplyPrice.multiply(new BigDecimal("0.1")); // 총 가격 합산 (공급가 + 부가세) totPrice = totPrice.add(supplyPrice.add(vatPrice)); @@ -807,6 +831,86 @@ public class EstimateService { estimateResponse.setTotPrice(String.valueOf(totPrice.setScale(0, BigDecimal.ROUND_HALF_UP))); } + /** + * QSP Q.CAST 견적서 전송 API + * + * @param estimateRequest 견적서 요청 정보 + * @return String 문서번호 + * @throws Exception + */ + public List sendEstimateApi(EstimateRequest estimateRequest) + throws Exception { + EstimateSendRequest estimateSendRequest = new EstimateSendRequest(); + List quoteList = new ArrayList(); + String docNo = ""; + + // 견적서 상세 조회 + EstimateSendResponse estimateSendResponse = + estimateMapper.selectEstimateApiDetail(estimateRequest); + + if (estimateSendResponse == null) { + throw new QcastException(ErrorCode.NOT_FOUND, message.getMessage("common.message.no.data")); + } else { + estimateSendResponse.setSaveType("3"); + estimateSendResponse.setSyncFlg("0"); + estimateSendResponse.setConstructSpecification( + !StringUtils.isEmpty(estimateRequest.getConstructSpecification()) + ? estimateRequest.getConstructSpecification().split("、")[0] + : ""); + estimateSendResponse.setDelFlg("1".equals(estimateSendResponse.getDelFlg()) ? "Y" : "N"); + + // 아이템 목록 조회 + List estimateItemList = estimateMapper.selectEstimateItemList(estimateRequest); + estimateSendResponse.setItemList(estimateItemList); + + // 첨부파일 목록 조회 + FileRequest fileDeleteReq = new FileRequest(); + fileDeleteReq.setObjectNo(estimateRequest.getObjectNo()); + fileDeleteReq.setPlanNo(estimateRequest.getPlanNo()); + fileDeleteReq.setCategory("10"); + + List fileList = fileMapper.selectFileList(fileDeleteReq); + estimateSendResponse.setFileList(fileList); + + quoteList.add(estimateSendResponse); + estimateSendRequest.setQuoteList(quoteList); + } + + EstimateApiResponse response = null; + /* [1]. QSP API CALL -> Response */ + String strResponse = + interfaceQsp.callApi( + HttpMethod.POST, QSP_API_URL + "/api/master/qcastQuotationSave", estimateSendRequest); + + if (!"".equals(strResponse)) { + com.fasterxml.jackson.databind.ObjectMapper om = + new com.fasterxml.jackson.databind.ObjectMapper() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + response = om.readValue(strResponse, EstimateApiResponse.class); + + Map result = (Map) response.getData(); + + if (result != null) { + List> succList = (List>) result.get("successList"); + for (Map succ : succList) { + if (succ != null) { + for (EstimateSendResponse data : quoteList) { + if (data.getObjectNo().equals(succ.get("objectNo")) + && data.getPlanNo().equals(succ.get("planNo"))) { + data.setSyncFlg("1"); + data.setDocNo(String.valueOf(succ.get("docNo"))); + } + } + } + } + } + } else { + log.error("sendEstimateApi >>> " + message.getMessage("common.message.no.data")); + } + + return quoteList; + } + public Map convertVoToMap(Object vo) { Map result = new HashMap(); diff --git a/src/main/java/com/interplug/qcast/biz/estimate/dto/PriceResponse.java b/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateApiResponse.java similarity index 86% rename from src/main/java/com/interplug/qcast/biz/estimate/dto/PriceResponse.java rename to src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateApiResponse.java index 01fbde27..a797b93a 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/dto/PriceResponse.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateApiResponse.java @@ -3,7 +3,7 @@ package com.interplug.qcast.biz.estimate.dto; import lombok.Data; @Data -public class PriceResponse { +public class EstimateApiResponse { /** API response result */ private Object result; diff --git a/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateRequest.java b/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateRequest.java index 6c86de57..daee7689 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateRequest.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateRequest.java @@ -150,6 +150,9 @@ public class EstimateRequest { @Schema(description = "가격코드") private String priceCd; + @Schema(description = "QSP 동기화 여부") + private String syncFlg; + @Schema(description = "비고") private String remarks; diff --git a/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateSendRequest.java b/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateSendRequest.java new file mode 100644 index 00000000..173b06c3 --- /dev/null +++ b/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateSendRequest.java @@ -0,0 +1,11 @@ +package com.interplug.qcast.biz.estimate.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.List; +import lombok.Data; + +@Data +public class EstimateSendRequest { + @Schema(description = "견적서 목록 정보") + List quoteList; +} diff --git a/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateSendResponse.java b/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateSendResponse.java new file mode 100644 index 00000000..50955725 --- /dev/null +++ b/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateSendResponse.java @@ -0,0 +1,115 @@ +package com.interplug.qcast.biz.estimate.dto; + +import com.interplug.qcast.biz.file.dto.FileResponse; +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.List; +import lombok.Data; + +@Data +public class EstimateSendResponse { + @Schema(description = "물건번호") + private String objectNo; + + @Schema(description = "플랜번호") + private String planNo; + + @Schema(description = "판매점 ID") + private String saleStoreId; + + @Schema(description = "물건명") + private String objectName; + + @Schema(description = "견적서 등록일") + private String estimateDetailCreateDate; + + @Schema(description = "수취회사명") + private String receiveCompanyName; + + @Schema(description = "수취자명") + private String receiveUser; + + @Schema(description = "배송지 우편번호") + private String deliveryZipNo; + + @Schema(description = "배송지 주소") + private String deliveryTarget; + + @Schema(description = "배송지 연락처") + private String deliveryTel; + + @Schema(description = "배송 희망일") + private String deliveryHopeDate; + + @Schema(description = "사양확장일") + private String specificationConfirmDate; + + @Schema(description = "결제기간일") + private String paymentTerms; + + @Schema(description = "차종류 코드") + private String carKindCd; + + @Schema(description = "Track 종류 코드") + private String trackKind; + + @Schema(description = "Track 10톤 배송일") + private String track10tDelivery; + + @Schema(description = "Track 무게 코드") + private String trackWeight; + + @Schema(description = "Track 시간 지정") + private String trackTimeSpecify; + + @Schema(description = "Track 시간") + private String trackTime; + + @Schema(description = "포리프트 여부") + private String forklift; + + @Schema(description = "전압여부 (주택:0, 저압:1)") + private String houseClassCd; + + @Schema(description = "영업사원 코드") + private String businessChargerCd; + + @Schema(description = "영업사원 그룹 코드") + private String businessGroupCd; + + @Schema(description = "시공방법") + private String constructSpecification; + + @Schema(description = "북면설치여부") + private String northArrangement; + + @Schema(description = "견적서 타입 (YJSS, YJOD)") + private String estimateType; + + @Schema(description = "주택패키지 단가") + private String pkgAsp; + + @Schema(description = "삭제여부") + private String delFlg; + + @Schema(description = "마지막 수정일") + private String lastEditDatetime; + + @Schema(description = "마지막 수정자") + private String lastEditUser; + + @Schema(description = "저장타입(3:Q.CAST III)") + private String saveType; + + @Schema(description = "문서번호") + private String docNo; + + @Schema(description = "동기화 처리여부") + private String syncFlg; + + // 데이터 목록 관련 정보 + @Schema(description = "아이템 목록") + List itemList; + + @Schema(description = "첨부파일 목록") + List fileList; +} diff --git a/src/main/java/com/interplug/qcast/biz/object/dto/ObjectRequest.java b/src/main/java/com/interplug/qcast/biz/object/dto/ObjectRequest.java index 819c7ed1..d9a36cbe 100644 --- a/src/main/java/com/interplug/qcast/biz/object/dto/ObjectRequest.java +++ b/src/main/java/com/interplug/qcast/biz/object/dto/ObjectRequest.java @@ -116,9 +116,12 @@ public class ObjectRequest { @Schema(description = "검색 - 판매점ID") private String schSaleStoreId; - @Schema(description = "검색 - 선택판매점ID") + @Schema(description = "검색 - 선택판매점 1차점 ID") private String schSelSaleStoreId; + @Schema(description = "검색 - 선택판매점 2차점 ID") + private String schOtherSelSaleStoreId; + @Schema(description = "검색 - 주소") private String schAddress; diff --git a/src/main/resources/mappers/estimate/estimateMapper.xml b/src/main/resources/mappers/estimate/estimateMapper.xml index 336a6bf3..f2c9f9af 100644 --- a/src/main/resources/mappers/estimate/estimateMapper.xml +++ b/src/main/resources/mappers/estimate/estimateMapper.xml @@ -106,6 +106,48 @@ ON T.CREATE_SALE_STORE_ID = SS2.SALE_STORE_ID + +