From ea186f3f5a70103e54ffd292289fbc5696143dcd Mon Sep 17 00:00:00 2001 From: "DESKTOP-6E8S9S5\\LEE" Date: Thu, 18 Jun 2026 14:15:16 +0900 Subject: [PATCH] =?UTF-8?q?QSP=20=EC=97=91=EC=85=80=EB=8B=A4=EC=9A=B4?= =?UTF-8?q?=EB=A1=9C=EB=93=9C=20API=20=ED=8E=98=EC=9D=B4=EC=A7=95=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/excelDown/ExcelDownController.java | 27 +++++-- .../qcast/biz/excelDown/ExcelDownMapper.java | 20 +++++ .../qcast/biz/excelDown/ExcelDownService.java | 29 +++++++ .../qcast/biz/excelDown/dto/QuotRequest.java | 9 +++ .../qcast/biz/excelDown/dto/QuotResponse.java | 4 + .../mappers/excelDown/excelDownMapper.xml | 76 +++++++++++++++++++ 6 files changed, 160 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownController.java b/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownController.java index 461b1f3f..09b8d5ce 100644 --- a/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownController.java +++ b/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownController.java @@ -1,6 +1,8 @@ package com.interplug.qcast.biz.excelDown; import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -9,7 +11,6 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import com.interplug.qcast.biz.excelDown.dto.NtrCtsCmpRequest; import com.interplug.qcast.biz.excelDown.dto.NtrCtsCmpResponse; -import com.interplug.qcast.biz.excelDown.dto.QuotItemResponse; import com.interplug.qcast.biz.excelDown.dto.QuotPlanResponse; import com.interplug.qcast.biz.excelDown.dto.QuotRequest; import com.interplug.qcast.biz.excelDown.dto.QuotResponse; @@ -37,13 +38,29 @@ public class ExcelDownController { QuotResponse quotRes = new QuotResponse(); if ("1".equals(quotRequest.getSch_selectType())) { + boolean isPaged = quotRequest.getPageNo() != null && quotRequest.getPageSize() != null; + + if (isPaged) { + int totalCount = excelDownService.selectQuotPlanExclDownDataCount(quotRequest); + int totalPages = (int) Math.ceil((double) totalCount / quotRequest.getPageSize()); + quotRes.setTotalCount(totalCount); + quotRes.setTotalPages(totalPages); + } + List quotPlanExclDownData = excelDownService.selectQuotPlanExclDownData(quotRequest); - List quotItemExclDownData = - excelDownService.selectQuotItemExclDownData(quotRequest); - quotRes.setQuotPlanList(quotPlanExclDownData); - quotRes.setQuotItemList(quotItemExclDownData); + + if (isPaged) { + List objectNos = quotPlanExclDownData.stream() + .map(QuotPlanResponse::getObjectNo) + .filter(Objects::nonNull) + .distinct() + .collect(Collectors.toList()); + quotRes.setQuotItemList(excelDownService.selectQuotItemExclDownDataByObjectNos(objectNos)); + } else { + quotRes.setQuotItemList(excelDownService.selectQuotItemExclDownData(quotRequest)); + } } else { List quotPlanExclDownData = excelDownService.selectQuotPlanExclDownData2(quotRequest); diff --git a/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownMapper.java b/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownMapper.java index 72a13a5b..9784f458 100644 --- a/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownMapper.java +++ b/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownMapper.java @@ -10,6 +10,7 @@ import com.interplug.qcast.biz.excelDown.dto.WrntIsncCmplRequest; import com.interplug.qcast.biz.excelDown.dto.WrntIsncCmplResponse; import java.util.List; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; @Mapper interface ExcelDownMapper { @@ -32,6 +33,15 @@ interface ExcelDownMapper { */ List selectQuotPlanExclDownData2(QuotRequest quotRequest) throws Exception; + /** + * 과거데이터_견적 엑셀다운로드 플랜 건수 조회 (페이징용) + * + * @param quotRequest + * @return + * @throws Exception + */ + int selectQuotPlanExclDownDataCount(QuotRequest quotRequest) throws Exception; + /** * 과거데이터_견적 엑셀다운로드 조회(아이템) * @@ -41,6 +51,16 @@ interface ExcelDownMapper { */ List selectQuotItemExclDownData(QuotRequest quotRequest) throws Exception; + /** + * 과거데이터_견적 엑셀다운로드 조회(아이템) - 물건번호 목록으로 필터링 (페이징용) + * + * @param objectNos + * @return + * @throws Exception + */ + List selectQuotItemExclDownDataByObjectNos( + @Param("objectNos") List objectNos) throws Exception; + /** * 과거데이터_자연재해보상입력 엑셀다운로드 조회 * diff --git a/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownService.java b/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownService.java index eb8219e6..5fae4966 100644 --- a/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownService.java +++ b/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownService.java @@ -5,9 +5,12 @@ import com.interplug.qcast.config.message.Messages; import com.interplug.qcast.util.ZipFileManager; import jakarta.servlet.http.HttpServletResponse; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -62,6 +65,32 @@ public class ExcelDownService { return excelDownMapper.selectQuotItemExclDownData(quotRequest); } + /** + * 과거데이터_견적 엑셀다운로드 플랜 건수 조회 (페이징용) + * + * @param quotRequest + * @return + * @throws Exception + */ + public int selectQuotPlanExclDownDataCount(QuotRequest quotRequest) throws Exception { + return excelDownMapper.selectQuotPlanExclDownDataCount(quotRequest); + } + + /** + * 과거데이터_견적 엑셀다운로드 조회(아이템) - 물건번호 목록으로 필터링 (페이징용) + * + * @param objectNos + * @return + * @throws Exception + */ + public List selectQuotItemExclDownDataByObjectNos(List objectNos) + throws Exception { + if (objectNos == null || objectNos.isEmpty()) { + return Collections.emptyList(); + } + return excelDownMapper.selectQuotItemExclDownDataByObjectNos(objectNos); + } + /** * 과거데이터_자연재해보상입력 엑셀다운로드 조회 * diff --git a/src/main/java/com/interplug/qcast/biz/excelDown/dto/QuotRequest.java b/src/main/java/com/interplug/qcast/biz/excelDown/dto/QuotRequest.java index ea418012..cc4de9e6 100644 --- a/src/main/java/com/interplug/qcast/biz/excelDown/dto/QuotRequest.java +++ b/src/main/java/com/interplug/qcast/biz/excelDown/dto/QuotRequest.java @@ -21,4 +21,13 @@ public class QuotRequest { private String sch_saleStoreId; @Schema(description = "영업 담당자명") private String sch_businessChargerCd; + @Schema(description = "페이지 번호 (1부터 시작, null이면 전체 조회)") + private Integer pageNo; + @Schema(description = "페이지당 건수") + private Integer pageSize; + + public int getOffset() { + if (pageNo == null || pageSize == null) return 0; + return (pageNo - 1) * pageSize; + } } \ No newline at end of file diff --git a/src/main/java/com/interplug/qcast/biz/excelDown/dto/QuotResponse.java b/src/main/java/com/interplug/qcast/biz/excelDown/dto/QuotResponse.java index 14f78fa4..2799fc9a 100644 --- a/src/main/java/com/interplug/qcast/biz/excelDown/dto/QuotResponse.java +++ b/src/main/java/com/interplug/qcast/biz/excelDown/dto/QuotResponse.java @@ -15,4 +15,8 @@ public class QuotResponse { private List quotItemList; @Schema(description = "플랜정보 목록") private List quotPlanList; + @Schema(description = "전체 플랜 건수 (페이징 시에만 반환)") + private Integer totalCount; + @Schema(description = "전체 페이지 수 (페이징 시에만 반환)") + private Integer totalPages; } \ No newline at end of file diff --git a/src/main/resources/mappers/excelDown/excelDownMapper.xml b/src/main/resources/mappers/excelDown/excelDownMapper.xml index 143d2ca2..45c98315 100644 --- a/src/main/resources/mappers/excelDown/excelDownMapper.xml +++ b/src/main/resources/mappers/excelDown/excelDownMapper.xml @@ -180,6 +180,14 @@ ON G.FIRST_AGENT_ID = Y.SALE_STORE_ID /*1차점정보*/ WHERE A.DEL_FLG = 0 AND (B.DEL_FLG = 0 OR (OI.SOURCE_ORIGIN = 'QCAST_III' AND OI.ORG_DEL_FLG = '0')) + + + ORDER BY B.OBJECT_NO, A.PLAN_NO + OFFSET #{offset} ROWS FETCH NEXT #{pageSize} ROWS ONLY + + + + AND B.ESTIMATE_DETAIL_CREATE_DATE =]]> #{sch_startDt} + ' 00:00:00' AND B.ESTIMATE_DETAIL_CREATE_DATE #{sch_endDt} + ' 23:59:59' @@ -190,6 +198,22 @@ AND G.BUSINESS_CHARGER_CD = #{sch_businessChargerCd} + + + + /* sqlid : selectQuotItemExclDownDataByObjectNos (견적엑셀다운로드 품목단위 데이터 조회 - 페이징용) */ + SELECT + C.OBJECT_NO + , B.PLAN_NO + , C.OBJECT_NAME + , H.SALE_STORE_NAME AS SOLD_SALE_STORE_NAME + , D.SALE_STORE_NAME + , I.PREF_NAME + , K.BUSINESS_TEAM + , C.SALE_STORE_ID + , C.ESTIMATE_DETAIL_CREATE_DATE + , A.ITEM_NO + , A.ITEM_NAME + , A.AMOUNT + , ( + SELECT TOP 1 T.SALE_PRICE + FROM M_SALE_STORE_PRICE T + WHERE T.SALE_STORE_ID = D.SALE_STORE_ID + AND T.ITEM_ID = A.ITEM_ID + ) AS SALE_PRICE + FROM T_OBJECT C + LEFT OUTER JOIN T_OBJECT_INFO OI + ON OI.OBJECT_NO = C.OBJECT_NO + LEFT OUTER JOIN M_SALES_STORE D + ON C.SALE_STORE_ID = D.SALE_STORE_ID + LEFT OUTER JOIN T_PLAN B + ON C.OBJECT_NO = B.OBJECT_NO + LEFT OUTER JOIN T_PART_ESTIMATE A + ON A.OBJECT_NO = B.OBJECT_NO + AND A.PLAN_NO = B.PLAN_NO + LEFT OUTER JOIN M_SALES_STORE H + ON D.FIRST_AGENT_ID = H.SALE_STORE_ID + AND H.DEL_FLG = 0 + LEFT OUTER JOIN T_SIMULATION_PREFECTURE I + ON C.PREF_ID = I.PREF_ID + LEFT OUTER JOIN M_BUSINESS_CHARGER J + ON D.BUSINESS_CHARGER_CD = J.BUSINESS_CHARGER_CD + AND J.DEL_FLG = 0 + LEFT OUTER JOIN M_BUSINESS_TEAM K + ON J.BUSINESS_TEAM_CD = K.BUSINESS_TEAM_CD + AND K.DEL_FLG = 0 + WHERE (C.DEL_FLG = 0 OR (OI.SOURCE_ORIGIN = 'QCAST_III' AND OI.ORG_DEL_FLG = '0')) + AND D.DEL_FLG = 0 + AND B.DEL_FLG = 0 + AND C.OBJECT_NO IN + + #{objectNo} + + +