From 8df66cd591deb9826fec0b8fd135691d438a647b Mon Sep 17 00:00:00 2001 From: "LAPTOP-L3VE7KK2\\USER" Date: Fri, 1 Nov 2024 15:42:57 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=AC=EC=A0=81=EC=84=9C=20API=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/estimate/EstimateController.java | 5 +- .../qcast/biz/estimate/EstimateService.java | 21 ++++- .../biz/estimate/dto/EstimatePdfResponse.java | 85 +++++++++++++++++++ .../biz/estimate/dto/EstimateResponse.java | 9 ++ .../mappers/estimate/estimateMapper.xml | 45 +++++++++- 5 files changed, 157 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/interplug/qcast/biz/estimate/dto/EstimatePdfResponse.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 5df11dd3..a6ae6091 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/EstimateController.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/EstimateController.java @@ -53,7 +53,8 @@ public class EstimateController { @Operation(description = "견적서를 복사한다.") @PostMapping("/save-estimate-copy") @ResponseStatus(HttpStatus.CREATED) - public void insertEstimateCopy(@RequestBody EstimateRequest estimateRequest) throws Exception { - estimateService.insertEstimateCopy(estimateRequest); + public EstimateResponse insertEstimateCopy(@RequestBody EstimateRequest estimateRequest) + throws Exception { + return estimateService.insertEstimateCopy(estimateRequest); } } 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 ce714fbd..9f9c4685 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java @@ -49,6 +49,11 @@ public class EstimateService { 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, + message.getMessage("common.message.required.data", "Sap Sale Store Code")); + } if (StringUtils.isEmpty(priceRequest.getDocTpCd())) { throw new QcastException( ErrorCode.INVALID_INPUT_VALUE, @@ -61,6 +66,7 @@ public class EstimateService { String apiUrl = UriComponentsBuilder.fromHttpUrl(url) .queryParam("saleStoreId", priceRequest.getSaleStoreId()) + .queryParam("sapSalesStoreCd", priceRequest.getSapSalesStoreCd()) .queryParam("docTpCd", priceRequest.getDocTpCd()) .build() .toUriString(); @@ -412,7 +418,7 @@ public class EstimateService { } } - public void insertEstimateCopy(EstimateRequest estimateRequest) throws Exception { + public EstimateResponse insertEstimateCopy(EstimateRequest estimateRequest) throws Exception { // Validation if (StringUtils.isEmpty(estimateRequest.getObjectNo())) { throw new QcastException( @@ -425,6 +431,8 @@ public class EstimateService { message.getMessage("common.message.required.data", "Plan No")); } + EstimateResponse response = new EstimateResponse(); + // [1]. 총 플랜 목록 조회 및 제약조건 처리 (플랜 10개까지만 등록) PlanRequest planRequest = new PlanRequest(); planRequest.setObjectNo(estimateRequest.getObjectNo()); @@ -494,11 +502,17 @@ public class EstimateService { } // 도면 복사 (추후 개발 필요) + + // 리턴 + response.setObjectNo(estimateRequest.getObjectNo()); + response.setPlanNo(estimateRequest.getCopyPlanNo()); + return response; } public void selectTotalPriceInfo(EstimateResponse estimateResponse) throws Exception { BigDecimal totAmount = BigDecimal.ZERO; BigDecimal totVol = BigDecimal.ZERO; + BigDecimal pkgTotPrice = BigDecimal.ZERO; BigDecimal supplyPrice = BigDecimal.ZERO; BigDecimal vatPrice = BigDecimal.ZERO; BigDecimal totPrice = BigDecimal.ZERO; @@ -551,7 +565,9 @@ public class EstimateService { } if ("YJSS".equals(estimateType)) { - supplyPrice.add(pkgAsp.multiply(totVol)); + pkgTotPrice = pkgAsp.multiply(totVol); + pkgTotPrice = pkgTotPrice.setScale(0, BigDecimal.ROUND_HALF_UP); + supplyPrice = supplyPrice.add(pkgTotPrice); } // 부가세 계산 (10프로) @@ -559,6 +575,7 @@ public class EstimateService { // 총 가격 합산 (공급가 + 부가세) totPrice = totPrice.add(supplyPrice.add(vatPrice)); + estimateResponse.setPkgTotPrice(String.valueOf(pkgTotPrice)); estimateResponse.setTotAmount(String.valueOf(totAmount.setScale(0, BigDecimal.ROUND_HALF_UP))); estimateResponse.setTotVol(String.valueOf(totVol.setScale(0, BigDecimal.ROUND_HALF_UP))); estimateResponse.setSupplyPrice( diff --git a/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimatePdfResponse.java b/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimatePdfResponse.java new file mode 100644 index 00000000..1bdf5ff3 --- /dev/null +++ b/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimatePdfResponse.java @@ -0,0 +1,85 @@ +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 EstimatePdfResponse { + @Schema(description = "물건번호") + private String objectNo; + + @Schema(description = "플랜번호") + private String planNo; + + @Schema(description = "판매점ID") + private String saleStoreId; + + @Schema(description = "견적서 유효기간") + private String estimateValidityTerm; + + @Schema(description = "견적갱신일") + private String estimateDate; + + @Schema(description = "PKG 단가") + private String pkgAsp; + + @Schema(description = "비고") + private String remarks; + + // 가격 관련 정보 + @Schema(description = "총 수량") + private String totAmount; + + @Schema(description = "총 용량") + private String totVol; + + @Schema(description = "PKG 총액") + private String pkgTotPrice; + + @Schema(description = "공급가액") + private String supplyPrice; + + @Schema(description = "부가세") + private String vatPrice; + + @Schema(description = "총액") + private String totPrice; + + // 물건정보 정보 + @Schema(description = "물건명") + private String objectName; + + @Schema(description = "경칭") + private String objectNameOmit; + + // 판매점 정보 + @Schema(description = "고객 판매점명") + private String custSaleStoreName; + + @Schema(description = "판매점명") + private String saleStoreName; + + @Schema(description = "우편번호") + private String zipNo; + + @Schema(description = "주소") + private String address; + + @Schema(description = "전화번호") + private String tel; + + @Schema(description = "Fax번호") + private String fax; + + // PKG 정보 + @Schema(description = "주택패키지 여부") + private String pkgYn; + + @Schema(description = "주택패키지 번호") + private String pkgNo; + + // 데이터 목록 관련 정보 + @Schema(description = "아이템 목록") + List itemList; +} diff --git a/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateResponse.java b/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateResponse.java index f96ecaa8..1b2bbe1f 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateResponse.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/dto/EstimateResponse.java @@ -133,6 +133,9 @@ public class EstimateResponse { @Schema(description = "가격코드") private String priceCd; + @Schema(description = "비고") + private String remarks; + @Schema(description = "갱신일") private String lastEditDatetime; @@ -143,6 +146,9 @@ public class EstimateResponse { @Schema(description = "총 용량") private String totVol; + @Schema(description = "PKG 총액") + private String pkgTotPrice; + @Schema(description = "공급가액") private String supplyPrice; @@ -159,6 +165,9 @@ public class EstimateResponse { @Schema(description = "경칭") private String objectNameOmit; + @Schema(description = "물건정보 비고") + private String objectRemarks; + // 데이터 목록 관련 정보 @Schema(description = "아이템 목록") List itemList; diff --git a/src/main/resources/mappers/estimate/estimateMapper.xml b/src/main/resources/mappers/estimate/estimateMapper.xml index b16ba859..4aac47f7 100644 --- a/src/main/resources/mappers/estimate/estimateMapper.xml +++ b/src/main/resources/mappers/estimate/estimateMapper.xml @@ -45,15 +45,52 @@ , P.FILE_FLG , P.ESTIMATE_OPTION , P.PKG_ASP + , P.PRICE_CD + , P.REMARKS , P.LAST_EDIT_DATETIME , O.OBJECT_NAME , O.OBJECT_NAME_OMIT + , O.REMARKS AS OBJECT_REMARKS FROM T_PLAN P WITH (NOLOCK) INNER JOIN T_OBJECT O WITH (NOLOCK) - ON T.OBJECT_NO = O.OBJECT_NO - WHERE T.OBJECT_NO = #{objectNo} - AND T.PLAN_NO = #{planNo} - AND T.DEL_FLG = '0' + ON P.OBJECT_NO = O.OBJECT_NO + WHERE P.OBJECT_NO = #{objectNo} + AND P.PLAN_NO = #{planNo} + AND P.DEL_FLG = '0' + + +