QSP 엑셀다운로드 API 페이징 처리
This commit is contained in:
parent
8c99e79a07
commit
d8ee216dd2
@ -1,8 +1,6 @@
|
|||||||
package com.interplug.qcast.biz.excelDown;
|
package com.interplug.qcast.biz.excelDown;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@ -38,29 +36,8 @@ public class ExcelDownController {
|
|||||||
QuotResponse quotRes = new QuotResponse();
|
QuotResponse quotRes = new QuotResponse();
|
||||||
|
|
||||||
if ("1".equals(quotRequest.getSch_selectType())) {
|
if ("1".equals(quotRequest.getSch_selectType())) {
|
||||||
boolean isPaged = quotRequest.getPageNo() != null && quotRequest.getPageSize() != null;
|
quotRes.setQuotPlanList(excelDownService.selectQuotPlanExclDownData(quotRequest));
|
||||||
|
|
||||||
if (isPaged) {
|
|
||||||
int totalCount = excelDownService.selectQuotPlanExclDownDataCount(quotRequest);
|
|
||||||
int totalPages = (int) Math.ceil((double) totalCount / quotRequest.getPageSize());
|
|
||||||
quotRes.setTotalCount(totalCount);
|
|
||||||
quotRes.setTotalPages(totalPages);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<QuotPlanResponse> quotPlanExclDownData =
|
|
||||||
excelDownService.selectQuotPlanExclDownData(quotRequest);
|
|
||||||
quotRes.setQuotPlanList(quotPlanExclDownData);
|
|
||||||
|
|
||||||
if (isPaged) {
|
|
||||||
List<String> objectNos = quotPlanExclDownData.stream()
|
|
||||||
.map(QuotPlanResponse::getObjectNo)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.distinct()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
quotRes.setQuotItemList(excelDownService.selectQuotItemExclDownDataByObjectNos(objectNos));
|
|
||||||
} else {
|
|
||||||
quotRes.setQuotItemList(excelDownService.selectQuotItemExclDownData(quotRequest));
|
quotRes.setQuotItemList(excelDownService.selectQuotItemExclDownData(quotRequest));
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
List<QuotPlanResponse> quotPlanExclDownData =
|
List<QuotPlanResponse> quotPlanExclDownData =
|
||||||
excelDownService.selectQuotPlanExclDownData2(quotRequest);
|
excelDownService.selectQuotPlanExclDownData2(quotRequest);
|
||||||
|
|||||||
@ -33,15 +33,6 @@ interface ExcelDownMapper {
|
|||||||
*/
|
*/
|
||||||
List<QuotPlanResponse> selectQuotPlanExclDownData2(QuotRequest quotRequest) throws Exception;
|
List<QuotPlanResponse> selectQuotPlanExclDownData2(QuotRequest quotRequest) throws Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* 과거데이터_견적 엑셀다운로드 플랜 건수 조회 (페이징용)
|
|
||||||
*
|
|
||||||
* @param quotRequest
|
|
||||||
* @return
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
int selectQuotPlanExclDownDataCount(QuotRequest quotRequest) throws Exception;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 과거데이터_견적 엑셀다운로드 조회(아이템)
|
* 과거데이터_견적 엑셀다운로드 조회(아이템)
|
||||||
*
|
*
|
||||||
@ -51,15 +42,6 @@ interface ExcelDownMapper {
|
|||||||
*/
|
*/
|
||||||
List<QuotItemResponse> selectQuotItemExclDownData(QuotRequest quotRequest) throws Exception;
|
List<QuotItemResponse> selectQuotItemExclDownData(QuotRequest quotRequest) throws Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* 과거데이터_견적 엑셀다운로드 조회(아이템) - 물건번호 목록으로 필터링 (페이징용)
|
|
||||||
*
|
|
||||||
* @param objectNos
|
|
||||||
* @return
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
List<QuotItemResponse> selectQuotItemExclDownDataByObjectNos(
|
|
||||||
@Param("objectNos") List<String> objectNos) throws Exception;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 과거데이터_자연재해보상입력 엑셀다운로드 조회
|
* 과거데이터_자연재해보상입력 엑셀다운로드 조회
|
||||||
|
|||||||
@ -65,32 +65,6 @@ public class ExcelDownService {
|
|||||||
return excelDownMapper.selectQuotItemExclDownData(quotRequest);
|
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<QuotItemResponse> selectQuotItemExclDownDataByObjectNos(List<String> objectNos)
|
|
||||||
throws Exception {
|
|
||||||
if (objectNos == null || objectNos.isEmpty()) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
return excelDownMapper.selectQuotItemExclDownDataByObjectNos(objectNos);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 과거데이터_자연재해보상입력 엑셀다운로드 조회
|
* 과거데이터_자연재해보상입력 엑셀다운로드 조회
|
||||||
*
|
*
|
||||||
|
|||||||
@ -26,8 +26,4 @@ public class QuotRequest {
|
|||||||
@Schema(description = "페이지당 건수")
|
@Schema(description = "페이지당 건수")
|
||||||
private Integer pageSize;
|
private Integer pageSize;
|
||||||
|
|
||||||
public int getOffset() {
|
|
||||||
if (pageNo == null || pageSize == null) return 0;
|
|
||||||
return (pageNo - 1) * pageSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -15,8 +15,4 @@ public class QuotResponse {
|
|||||||
private List<QuotItemResponse> quotItemList;
|
private List<QuotItemResponse> quotItemList;
|
||||||
@Schema(description = "플랜정보 목록")
|
@Schema(description = "플랜정보 목록")
|
||||||
private List<QuotPlanResponse> quotPlanList;
|
private List<QuotPlanResponse> quotPlanList;
|
||||||
@Schema(description = "전체 플랜 건수 (페이징 시에만 반환)")
|
|
||||||
private Integer totalCount;
|
|
||||||
@Schema(description = "전체 페이지 수 (페이징 시에만 반환)")
|
|
||||||
private Integer totalPages;
|
|
||||||
}
|
}
|
||||||
@ -6,8 +6,10 @@
|
|||||||
<select id="selectQuotPlanExclDownData" parameterType="com.interplug.qcast.biz.excelDown.dto.QuotRequest"
|
<select id="selectQuotPlanExclDownData" parameterType="com.interplug.qcast.biz.excelDown.dto.QuotRequest"
|
||||||
resultType="com.interplug.qcast.biz.excelDown.dto.QuotPlanResponse">
|
resultType="com.interplug.qcast.biz.excelDown.dto.QuotPlanResponse">
|
||||||
/* sqlid : com.interplug.qcast.api.excelDown.selectQuotPlanExclDownData (견적엑셀다운로드 플랜정보 데이터 조회) */
|
/* sqlid : com.interplug.qcast.api.excelDown.selectQuotPlanExclDownData (견적엑셀다운로드 플랜정보 데이터 조회) */
|
||||||
|
SELECT * FROM (
|
||||||
SELECT
|
SELECT
|
||||||
B.OBJECT_NO /* 물건번호 物件番号 */
|
ROW_NUMBER() OVER (ORDER BY B.OBJECT_NO, A.PLAN_NO) AS RN
|
||||||
|
, B.OBJECT_NO /* 물건번호 物件番号 */
|
||||||
, A.PLAN_NO /* 플랜 案件番号 */
|
, A.PLAN_NO /* 플랜 案件番号 */
|
||||||
, CONVERT(varchar, A.LAST_EDIT_DATETIME, 120) AS LAST_EDIT_DATETIME /* 플랜정보 최신 갱신일시 プラン情報最新更新日時 */
|
, CONVERT(varchar, A.LAST_EDIT_DATETIME, 120) AS LAST_EDIT_DATETIME /* 플랜정보 최신 갱신일시 プラン情報最新更新日時 */
|
||||||
, G.SALE_STORE_NAME /* 판매대리점 販売代理店 */
|
, G.SALE_STORE_NAME /* 판매대리점 販売代理店 */
|
||||||
@ -181,9 +183,9 @@
|
|||||||
WHERE A.DEL_FLG = 0
|
WHERE A.DEL_FLG = 0
|
||||||
AND (B.DEL_FLG = 0 OR (OI.SOURCE_ORIGIN = 'QCAST_III' AND OI.ORG_DEL_FLG = '0'))
|
AND (B.DEL_FLG = 0 OR (OI.SOURCE_ORIGIN = 'QCAST_III' AND OI.ORG_DEL_FLG = '0'))
|
||||||
<include refid="quotPlanSearchConditions"/>
|
<include refid="quotPlanSearchConditions"/>
|
||||||
|
) AS PAGED
|
||||||
<if test="pageNo != null and pageSize != null">
|
<if test="pageNo != null and pageSize != null">
|
||||||
ORDER BY B.OBJECT_NO, A.PLAN_NO
|
WHERE RN BETWEEN (#{pageNo} - 1) * #{pageSize} + 1 AND #{pageNo} * #{pageSize}
|
||||||
OFFSET #{offset} ROWS FETCH NEXT #{pageSize} ROWS ONLY
|
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@ -200,22 +202,6 @@
|
|||||||
</if>
|
</if>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectQuotPlanExclDownDataCount" parameterType="com.interplug.qcast.biz.excelDown.dto.QuotRequest"
|
|
||||||
resultType="int">
|
|
||||||
/* sqlid : selectQuotPlanExclDownDataCount (견적엑셀다운로드 플랜 건수 조회 - 페이징용) */
|
|
||||||
SELECT COUNT(*)
|
|
||||||
FROM T_OBJECT B
|
|
||||||
LEFT OUTER JOIN T_OBJECT_INFO OI
|
|
||||||
ON OI.OBJECT_NO = B.OBJECT_NO
|
|
||||||
LEFT OUTER JOIN T_PLAN A
|
|
||||||
ON A.OBJECT_NO = B.OBJECT_NO
|
|
||||||
LEFT OUTER JOIN M_SALES_STORE G
|
|
||||||
ON B.SALE_STORE_ID = G.SALE_STORE_ID
|
|
||||||
WHERE A.DEL_FLG = 0
|
|
||||||
AND (B.DEL_FLG = 0 OR (OI.SOURCE_ORIGIN = 'QCAST_III' AND OI.ORG_DEL_FLG = '0'))
|
|
||||||
<include refid="quotPlanSearchConditions"/>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectQuotPlanExclDownData2" parameterType="com.interplug.qcast.biz.excelDown.dto.QuotRequest"
|
<select id="selectQuotPlanExclDownData2" parameterType="com.interplug.qcast.biz.excelDown.dto.QuotRequest"
|
||||||
resultType="com.interplug.qcast.biz.excelDown.dto.QuotPlanResponse">
|
resultType="com.interplug.qcast.biz.excelDown.dto.QuotPlanResponse">
|
||||||
/* sqlid : com.interplug.qcast.api.excelDown.selectQuotPlanExclDownData2 (견적엑셀다운로드 플랜정보 데이터 조회) */
|
/* sqlid : com.interplug.qcast.api.excelDown.selectQuotPlanExclDownData2 (견적엑셀다운로드 플랜정보 데이터 조회) */
|
||||||
@ -258,7 +244,11 @@
|
|||||||
resultType="com.interplug.qcast.biz.excelDown.dto.QuotItemResponse">
|
resultType="com.interplug.qcast.biz.excelDown.dto.QuotItemResponse">
|
||||||
/* sqlid : com.interplug.qcast.api.excelDown.selectQuotItemExclDownData (견적엑셀다운로드 품목단위 데이터 조회) */
|
/* sqlid : com.interplug.qcast.api.excelDown.selectQuotItemExclDownData (견적엑셀다운로드 품목단위 데이터 조회) */
|
||||||
SELECT
|
SELECT
|
||||||
C.OBJECT_NO /* 물건번호 物件番号 */
|
*
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
ROW_NUMBER() OVER (ORDER BY C.OBJECT_NO, B.PLAN_NO, A.ITEM_NO) AS RN
|
||||||
|
, C.OBJECT_NO /* 물건번호 物件番号 */
|
||||||
, B.PLAN_NO /* 플랜 案件番号 */
|
, B.PLAN_NO /* 플랜 案件番号 */
|
||||||
, C.OBJECT_NAME /* 물건명 案件名 */
|
, C.OBJECT_NAME /* 물건명 案件名 */
|
||||||
, H.SALE_STORE_NAME AS SOLD_SALE_STORE_NAME /* 1차 판매점명 一次販売店名 */
|
, H.SALE_STORE_NAME AS SOLD_SALE_STORE_NAME /* 1차 판매점명 一次販売店名 */
|
||||||
@ -332,61 +322,13 @@
|
|||||||
<if test="sch_businessChargerCd != null and sch_businessChargerCd != ''"> <!-- 영업담당자 -->
|
<if test="sch_businessChargerCd != null and sch_businessChargerCd != ''"> <!-- 영업담당자 -->
|
||||||
AND C.BUSINESS_CHARGER_CD = #{sch_businessChargerCd}
|
AND C.BUSINESS_CHARGER_CD = #{sch_businessChargerCd}
|
||||||
</if>
|
</if>
|
||||||
|
) AS PAGED
|
||||||
|
<if test="pageNo != null and pageSize != null">
|
||||||
|
WHERE RN BETWEEN (#{pageNo} - 1) * #{pageSize} + 1 AND #{pageNo} * #{pageSize}
|
||||||
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<select id="selectQuotItemExclDownDataByObjectNos" parameterType="java.util.List"
|
|
||||||
resultType="com.interplug.qcast.biz.excelDown.dto.QuotItemResponse">
|
|
||||||
/* 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
|
|
||||||
<foreach collection="list" item="objectNo" open="(" separator="," close=")">
|
|
||||||
#{objectNo}
|
|
||||||
</foreach>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectNtrCtsCmpExclDownData" parameterType="com.interplug.qcast.biz.excelDown.dto.NtrCtsCmpRequest" resultType="com.interplug.qcast.biz.excelDown.dto.NtrCtsCmpResponse">
|
<select id="selectNtrCtsCmpExclDownData" parameterType="com.interplug.qcast.biz.excelDown.dto.NtrCtsCmpRequest" resultType="com.interplug.qcast.biz.excelDown.dto.NtrCtsCmpResponse">
|
||||||
/* sqlid : com.interplug.qcast.api.excelDown.selectNtrCtsCmpExclDownData (자연재해보상입력 엑셀 다운로드 데이터 조회)*/
|
/* sqlid : com.interplug.qcast.api.excelDown.selectNtrCtsCmpExclDownData (자연재해보상입력 엑셀 다운로드 데이터 조회)*/
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user