Compare commits

..

3 Commits

6 changed files with 160 additions and 5 deletions

View File

@ -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<QuotPlanResponse> quotPlanExclDownData =
excelDownService.selectQuotPlanExclDownData(quotRequest);
List<QuotItemResponse> quotItemExclDownData =
excelDownService.selectQuotItemExclDownData(quotRequest);
quotRes.setQuotPlanList(quotPlanExclDownData);
quotRes.setQuotItemList(quotItemExclDownData);
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));
}
} else {
List<QuotPlanResponse> quotPlanExclDownData =
excelDownService.selectQuotPlanExclDownData2(quotRequest);

View File

@ -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<QuotPlanResponse> selectQuotPlanExclDownData2(QuotRequest quotRequest) throws Exception;
/**
* 과거데이터_견적 엑셀다운로드 플랜 건수 조회 (페이징용)
*
* @param quotRequest
* @return
* @throws Exception
*/
int selectQuotPlanExclDownDataCount(QuotRequest quotRequest) throws Exception;
/**
* 과거데이터_견적 엑셀다운로드 조회(아이템)
*
@ -41,6 +51,16 @@ interface ExcelDownMapper {
*/
List<QuotItemResponse> selectQuotItemExclDownData(QuotRequest quotRequest) throws Exception;
/**
* 과거데이터_견적 엑셀다운로드 조회(아이템) - 물건번호 목록으로 필터링 (페이징용)
*
* @param objectNos
* @return
* @throws Exception
*/
List<QuotItemResponse> selectQuotItemExclDownDataByObjectNos(
@Param("objectNos") List<String> objectNos) throws Exception;
/**
* 과거데이터_자연재해보상입력 엑셀다운로드 조회
*

View File

@ -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<QuotItemResponse> selectQuotItemExclDownDataByObjectNos(List<String> objectNos)
throws Exception {
if (objectNos == null || objectNos.isEmpty()) {
return Collections.emptyList();
}
return excelDownMapper.selectQuotItemExclDownDataByObjectNos(objectNos);
}
/**
* 과거데이터_자연재해보상입력 엑셀다운로드 조회
*

View File

@ -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;
}
}

View File

@ -15,4 +15,8 @@ public class QuotResponse {
private List<QuotItemResponse> quotItemList;
@Schema(description = "플랜정보 목록")
private List<QuotPlanResponse> quotPlanList;
@Schema(description = "전체 플랜 건수 (페이징 시에만 반환)")
private Integer totalCount;
@Schema(description = "전체 페이지 수 (페이징 시에만 반환)")
private Integer totalPages;
}

View File

@ -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'))
<include refid="quotPlanSearchConditions"/>
<if test="pageNo != null and pageSize != null">
ORDER BY B.OBJECT_NO, A.PLAN_NO
OFFSET #{offset} ROWS FETCH NEXT #{pageSize} ROWS ONLY
</if>
</select>
<sql id="quotPlanSearchConditions">
<if test="sch_startDt != null and sch_startDt != '' and sch_endDt != null and sch_endDt != ''"> <!-- 견적일 -->
AND B.ESTIMATE_DETAIL_CREATE_DATE <![CDATA[>=]]> #{sch_startDt} + ' 00:00:00'
AND B.ESTIMATE_DETAIL_CREATE_DATE <![CDATA[<=]]> #{sch_endDt} + ' 23:59:59'
@ -190,6 +198,22 @@
<if test="sch_businessChargerCd != null and sch_businessChargerCd != ''"> <!-- 영업담당자 -->
AND G.BUSINESS_CHARGER_CD = #{sch_businessChargerCd}
</if>
</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"
@ -311,6 +335,58 @@
</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">
/* sqlid : com.interplug.qcast.api.excelDown.selectNtrCtsCmpExclDownData (자연재해보상입력 엑셀 다운로드 데이터 조회)*/
SELECT