diff --git a/src/main/java/kr/co/uplus/ez/api/stats/StatsService.java b/src/main/java/kr/co/uplus/ez/api/stats/StatsService.java index b701bd6..e558f5c 100644 --- a/src/main/java/kr/co/uplus/ez/api/stats/StatsService.java +++ b/src/main/java/kr/co/uplus/ez/api/stats/StatsService.java @@ -4,12 +4,11 @@ import kr.co.uplus.ez.api.stats.dto.*; import kr.co.uplus.ez.common.data.ApiResponseCode; import kr.co.uplus.ez.common.data.ApiResponseMessage; import kr.co.uplus.ez.common.data.Paging; - +import kr.co.uplus.ez.common.utils.DateUtils; import org.mybatis.spring.SqlSessionTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -144,7 +143,12 @@ public class StatsService { public BsnmMonthListResDto bsnmMonthList(BsnmMonthListReqDto bsnmMonthListReqDto) { StatsMapper statsMapper = sqlSessionSlave.getMapper(StatsMapper.class); - + + //오늘 날짜 조회인지 확인 + if(DateUtils.date2strYM().equals(bsnmMonthListReqDto.getEndMon())) { + bsnmMonthListReqDto.setNowDiv("Y"); + } + String nowPage = String.valueOf(bsnmMonthListReqDto.getPage()); int totalCnt = statsMapper.selectCustMstatListTotalCnt(bsnmMonthListReqDto); @@ -188,7 +192,12 @@ public class StatsService { */ public BsnmMonthListExcelResDto bsnmMonthListExcel(BsnmMonthListExcelReqDto bsnmMonthListExcelReqDto) { StatsMapper statsMapper = sqlSessionSlave.getMapper(StatsMapper.class); - + + //오늘 날짜 조회인지 확인 + if(DateUtils.date2strYM().equals(bsnmMonthListExcelReqDto.getEndMon())) { + bsnmMonthListExcelReqDto.setNowDiv("Y"); + } + List bsnmMonthLists = statsMapper.selectCustMstatExcelList(bsnmMonthListExcelReqDto); BsnmMonthListExcelRes bsnmMonthListExcelRes = new BsnmMonthListExcelRes(); diff --git a/src/main/java/kr/co/uplus/ez/api/stats/dto/BsnmMonthListExcelReqDto.java b/src/main/java/kr/co/uplus/ez/api/stats/dto/BsnmMonthListExcelReqDto.java index 7b94a77..7786497 100644 --- a/src/main/java/kr/co/uplus/ez/api/stats/dto/BsnmMonthListExcelReqDto.java +++ b/src/main/java/kr/co/uplus/ez/api/stats/dto/BsnmMonthListExcelReqDto.java @@ -23,5 +23,8 @@ public class BsnmMonthListExcelReqDto implements Serializable { @ApiModelProperty(example = "사업자등록번호", name = "사업자등록번호", dataType = "String") private String bizrno; - + + @NotNull + @ApiModelProperty(example = "당일 조회 여부", name = "당일 조회 여부", dataType = "String") + private String nowDiv = "N"; } \ No newline at end of file diff --git a/src/main/java/kr/co/uplus/ez/api/stats/dto/BsnmMonthListReqDto.java b/src/main/java/kr/co/uplus/ez/api/stats/dto/BsnmMonthListReqDto.java index d8013b5..94df698 100644 --- a/src/main/java/kr/co/uplus/ez/api/stats/dto/BsnmMonthListReqDto.java +++ b/src/main/java/kr/co/uplus/ez/api/stats/dto/BsnmMonthListReqDto.java @@ -31,5 +31,9 @@ public class BsnmMonthListReqDto implements Serializable { @NotNull @ApiModelProperty(example = "현재 페이지", name = "현재 페이지", dataType = "int") private int page; + + @NotNull + @ApiModelProperty(example = "당일 조회 여부", name = "당일 조회 여부", dataType = "String") + private String nowDiv = "N"; } \ No newline at end of file diff --git a/src/main/java/kr/co/uplus/ez/common/utils/DateUtils.java b/src/main/java/kr/co/uplus/ez/common/utils/DateUtils.java index e0f164f..a4214ca 100644 --- a/src/main/java/kr/co/uplus/ez/common/utils/DateUtils.java +++ b/src/main/java/kr/co/uplus/ez/common/utils/DateUtils.java @@ -13,6 +13,7 @@ public class DateUtils { private static final String DF_FORMAT_STR = "yyyy-MM-dd HH:mm:ss"; private static final String DF_YMD_FORMAT_STR = "yyyy-MM-dd"; private static final DateTimeFormatter YMD = DateTimeFormat.forPattern("yyyyMMdd"); + private static final DateTimeFormatter YM = DateTimeFormat.forPattern("yyyyMM"); private static final DateTimeFormatter YMDHMS = DateTimeFormat.forPattern("yyyyMMddHHmmss"); private static final DateTimeFormatter dfFormat = DateTimeFormat.forPattern(DF_FORMAT_STR); @@ -36,6 +37,10 @@ public class DateUtils { public static String date2strYMD() { return dtime2str(DateTime.now(), YMD); } + + public static String date2strYM() { + return dtime2str(DateTime.now(), YM); + } public static String date2strYMDHMS() { return dtime2str(DateTime.now(), YMDHMS); diff --git a/src/main/resources/mapper/mysql/stats/stats-mapper.xml b/src/main/resources/mapper/mysql/stats/stats-mapper.xml index d9f8cb7..f92c29b 100644 --- a/src/main/resources/mapper/mysql/stats/stats-mapper.xml +++ b/src/main/resources/mapper/mysql/stats/stats-mapper.xml @@ -546,107 +546,52 @@ - - + + @@ -761,24 +804,60 @@ FROM ( SELECT - DATE_FORMAT(S1.SUM_YM, '%Y-%m') AS sumYm, S3.CUST_NM AS custNm, S3.BIZRNO AS bizrno, - (S1.sndCntS + S1.sndCntL + S1.sndCntM + S1.sndCntR) AS sndCnt, - (S1.succCntS + S1.succCntL +S1.succCntM +S1.succCntR + fbSuccCntS + fbSuccCntL+ fbSuccCntM) AS succCnt, - IFNULL(ROUND(((S1.succCntS + S1.succCntL +S1.succCntM +S1.succCntR + fbSuccCntS + fbSuccCntL+ fbSuccCntM) / (S1.sndCntS + S1.sndCntL + S1.sndCntM + S1.sndCntR)) * 100, 2), 0) AS succRt, - S1.sndCntS, S1.succCntS, IFNULL(ROUND((S1.succCntS/S1.sndCntS)*100,2),0) AS succRtS, - S1.sndCntL, S1.succCntL, IFNULL(ROUND((S1.succCntL/S1.sndCntL)*100,2),0) AS succRtL, - S1.sndCntM, S1.succCntM, IFNULL(ROUND((S1.succCntM/S1.sndCntM)*100,2),0) AS succRtM, - S1.sndCntR, S1.succCntR, IFNULL(ROUND((S1.succCntR/S1.sndCntR)*100,2),0) AS succRtR, - S1.fbSndCntS, S1.fbSuccCntS, IFNULL(ROUND((S1.fbSuccCntS/S1.fbSndCntS)*100,2),0) AS succFbRtS, - S1.fbSndCntL, S1.fbSuccCntL, IFNULL(ROUND((S1.fbSuccCntL/S1.fbSndCntL)*100,2),0) AS succFbRtL, - S1.fbSndCntM, S1.fbSuccCntM, IFNULL(ROUND((S1.fbSuccCntM/S1.fbSndCntM)*100,2),0) AS succFbRtM + DATE_FORMAT(A.SUM_YM, '%Y-%m') AS sumYm, C.CUST_NM AS custNm, C.BIZRNO AS bizrno, + A.sndCnt, A.succCnt, IFNULL(ROUND((A.succCnt/A.sndCnt)*100,2), 0) AS succRt, + A.sndCntS, A.succCntS, IFNULL(ROUND((A.succCntS/A.sndCntS)*100,2), 0) AS succRtS, + A.sndCntL, A.succCntL, IFNULL(ROUND((A.succCntL/A.sndCntL)*100,2), 0) AS succRtL, + A.sndCntM, A.succCntM, IFNULL(ROUND((A.succCntM/A.sndCntM)*100,2), 0) AS succRtM, + A.sndCntR, A.succCntR, IFNULL(ROUND((A.succCntR/A.sndCntR)*100,2), 0) AS succRtR, + A.fbSndCntS, A.fbSuccCntS, IFNULL(ROUND((A.fbSuccCntS/A.fbSndCntS)*100,2), 0) AS succFbRtS, + A.fbSndCntL, A.fbSuccCntL, IFNULL(ROUND((A.fbSuccCntL/A.fbSndCntL)*100,2), 0) AS succFbRtL, + A.fbSndCntM, A.fbSuccCntM, IFNULL(ROUND((A.fbSuccCntM/A.fbSndCntM)*100,2), 0) AS succFbRtM FROM ( SELECT - SUM_YM, USER_SEQ, - SUM(sndCntS) AS sndCntS, SUM(succCntS) AS succCntS, SUM(sndCntL) AS sndCntL, SUM(succCntL) AS succCntL, SUM(sndCntM) AS sndCntM, - SUM(succCntM) AS succCntM, SUM(sndCntR) AS sndCntR, SUM(succCntR) AS succCntR, SUM(fbSndCntS) AS fbSndCntS, SUM(fbSuccCntS) AS fbSuccCntS, - SUM(fbSndCntL) AS fbSndCntL, SUM(fbSuccCntL) AS fbSuccCntL, SUM(fbSndCntM) AS fbSndCntM, SUM(fbSuccCntM) AS fbSuccCntM + S1.SUM_YM, S1.USER_SEQ, + (SUM(S1.sndCntS) + SUM(S1.sndCntL) + SUM(S1.sndCntM) + SUM(S1.sndCntR)) AS sndCnt, + (SUM(S1.succCntS) + SUM(S1.succCntL) +SUM(S1.succCntM) +SUM(S1.succCntR) + SUM(fbSuccCntS) + SUM(fbSuccCntL)+ SUM(fbSuccCntM)) AS succCnt, + SUM(S1.sndCntS) AS sndCntS, SUM(S1.succCntS) AS succCntS, SUM(S1.sndCntL) AS sndCntL, SUM(S1.succCntL) AS succCntL, SUM(S1.sndCntM) AS sndCntM, + SUM(S1.succCntM) AS succCntM, SUM(S1.sndCntR) AS sndCntR, SUM(S1.succCntR) AS succCntR, SUM(S1.fbSndCntS) AS fbSndCntS, SUM(S1.fbSuccCntS) AS fbSuccCntS, + SUM(S1.fbSndCntL) AS fbSndCntL, SUM(S1.fbSuccCntL) AS fbSuccCntL, SUM(S1.fbSndCntM) AS fbSndCntM, SUM(S1.fbSuccCntM) AS fbSuccCntM + FROM + ( + SELECT + SUM_YM, USER_SEQ, + CASE WHEN SND_CH_CD = 'SMS' THEN IFNULL(SND_CNT, 0) ELSE 0 END AS sndCntS, + CASE WHEN SND_CH_CD = 'SMS' THEN IFNULL(SUCC_CNT, 0) ELSE 0 END AS succCntS, + CASE WHEN SND_CH_CD = 'LMS' THEN IFNULL(SND_CNT, 0) ELSE 0 END AS sndCntL, + CASE WHEN SND_CH_CD = 'LMS' THEN IFNULL(SUCC_CNT, 0) ELSE 0 END AS succCntL, + CASE WHEN SND_CH_CD = 'MMS' THEN IFNULL(SND_CNT, 0) ELSE 0 END AS sndCntM, + CASE WHEN SND_CH_CD = 'MMS' THEN IFNULL(SUCC_CNT, 0) ELSE 0 END AS succCntM, + CASE WHEN SND_CH_CD = 'ALIMTALK' THEN IFNULL(SND_CNT, 0) ELSE 0 END AS sndCntR, + CASE WHEN SND_CH_CD = 'ALIMTALK' THEN IFNULL(SUCC_CNT, 0) ELSE 0 END AS succCntR, + CASE WHEN RPLCSND_CH_CD = 'SMS' THEN IFNULL(FBACK_CNT, 0) ELSE 0 END AS fbSndCntS, + CASE WHEN RPLCSND_CH_CD = 'SMS' THEN IFNULL(FBACK_SUCC_CNT, 0) ELSE 0 END AS fbSuccCntS, + CASE WHEN RPLCSND_CH_CD = 'LMS' THEN IFNULL(FBACK_CNT, 0) ELSE 0 END AS fbSndCntL, + CASE WHEN RPLCSND_CH_CD = 'LMS' THEN IFNULL(FBACK_SUCC_CNT, 0) ELSE 0 END AS fbSuccCntL, + CASE WHEN RPLCSND_CH_CD = 'MMS' THEN IFNULL(FBACK_CNT, 0) ELSE 0 END AS fbSndCntM, + CASE WHEN RPLCSND_CH_CD = 'MMS' THEN IFNULL(FBACK_SUCC_CNT, 0) ELSE 0 END AS fbSuccCntM + FROM + hubez_common.EZ_CUST_MSTAT + WHERE + SUM_YM BETWEEN STR_TO_DATE(CONCAT(#{startMon},'01'),'%Y%m%d') AND STR_TO_DATE(CONCAT(#{endMon},'01'),'%Y%m%d') + AND BIZRNO != '1234567890' + ) S1 + WHERE + 1 = 1 + GROUP BY S1.SUM_YM, S1.USER_SEQ + + UNION ALL + SELECT + S2.SUM_YM, S2.USER_SEQ, + (SUM(S2.sndCntS) + SUM(S2.sndCntL) + SUM(S2.sndCntM) + SUM(S2.sndCntR)) AS sndCnt, + (SUM(S2.succCntS) + SUM(S2.succCntL) +SUM(S2.succCntM) +SUM(S2.succCntR) + SUM(fbSuccCntS) + SUM(fbSuccCntL)+ SUM(fbSuccCntM)) AS succCnt, + SUM(S2.sndCntS) AS sndCntS, SUM(S2.succCntS) AS succCntS, SUM(S2.sndCntL) AS sndCntL, SUM(S2.succCntL) AS succCntL, SUM(S2.sndCntM) AS sndCntM, + SUM(S2.succCntM) AS succCntM, SUM(S2.sndCntR) AS sndCntR, SUM(S2.succCntR) AS succCntR, SUM(S2.fbSndCntS) AS fbSndCntS, SUM(S2.fbSuccCntS) AS fbSuccCntS, + SUM(S2.fbSndCntL) AS fbSndCntL, SUM(S2.fbSuccCntL) AS fbSuccCntL, SUM(S2.fbSndCntM) AS fbSndCntM, SUM(S2.fbSuccCntM) AS fbSuccCntM FROM ( SELECT @@ -799,35 +878,6 @@ CASE WHEN SND_CH_CD = 'MMS' THEN SUM(FBACK_SUCC_CNT) ELSE 0 END AS fbSuccCntM FROM ( - SELECT - SUM_YM, - USER_SEQ, - SND_CH_CD, - IFNULL(SUM(SND_CNT), 0) AS SND_CNT, - IFNULL(SUM(SUCC_CNT), 0) AS SUCC_CNT, - 0 AS FBACK_CNT, - 0 AS FBACK_SUCC_CNT - FROM - hubez_common.EZ_CUST_MSTAT - WHERE - SUM_YM BETWEEN STR_TO_DATE(CONCAT(#{startMon},'01'),'%Y%m%d') AND STR_TO_DATE(CONCAT(#{endMon},'01'),'%Y%m%d') - GROUP BY SUM_YM, USER_SEQ, SND_CH_CD - UNION ALL - SELECT - SUM_YM, - USER_SEQ, - RPLCSND_CH_CD AS SND_CH_CD, - 0 AS SND_CNT, - 0 AS SUCC_CNT, - IFNULL(SUM(FBACK_CNT), 0) AS FBACK_CNT, - IFNULL(SUM(FBACK_SUCC_CNT), 0) AS FBACK_SUCC_CNT - FROM - hubez_common.EZ_CUST_MSTAT - WHERE - SUM_YM BETWEEN STR_TO_DATE(CONCAT(#{startMon},'01'),'%Y%m%d') AND STR_TO_DATE(CONCAT(#{endMon},'01'),'%Y%m%d') - AND RPLCSND_CH_CD IN ('SMS', 'LMS', 'MMS') - GROUP BY SUM_YM, USER_SEQ, RPLCSND_CH_CD - UNION ALL SELECT DATE_FORMAT(ewm.YMD, '%Y-%m-01') AS SUM_YM, esu.PRNTS_USER_SEQ AS USER_SEQ, @@ -862,17 +912,18 @@ WHERE 1 = 1 GROUP BY SUM_YM, USER_SEQ, SND_CH_CD - ) T2 + ) S2 WHERE 1 = 1 - GROUP BY SUM_YM, USER_SEQ - ) S1, - hubez_common.EZ_SUBS_INFO S2, - hubez_common.EZ_CUST_INFO S3 + GROUP BY S2.SUM_YM, S2.USER_SEQ + + ) A, + hubez_common.EZ_SUBS_INFO B, + hubez_common.EZ_CUST_INFO C WHERE - S1.USER_SEQ = S2.USER_SEQ - AND S2.CUST_SEQ = S3.CUST_SEQ - AND S3.BIZRNO != '1234567890' + A.USER_SEQ = B.USER_SEQ + AND B.CUST_SEQ = C.CUST_SEQ + AND C.BIZRNO != '1234567890' ) M WHERE