<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.tsi.monitoring.mapper.utis.UtisMapper">
    <!--  DB1.센터/민간 로그 정보조회-센터목록  -->
    <!--  프로세스 정보조회  -->
    <select id="getProcessInfo"  resultType="com.tsi.monitoring.vo.ProcessVo">
        SELECT A.PROCESSID AS PROCESS_ID,
               A.SERVERID AS SERVER_ID,
               A.USERGROUPID AS USER_GROUP_ID,
               A.INFO,
               A.KIND,
               A.PROCESSNAME AS PROCESS_NAME,
               A.LOCATE,
               A.VERSION,
               A.PORTNUM AS PORT_NUM,
               B.SERVERNAME AS SERVER_NAME,
               B.SERVERIP AS SERVER_IP
        FROM PROCESS A, SERVER B
        WHERE A.KIND = '4'
          AND A.SERVERID = B.SERVERID
    </select>

    <!--  프로세스 상태조회  -->
    <select id="getProcessCommState"  resultType="com.tsi.monitoring.vo.ProcessStatusVo">
        SELECT A.PROCESSID AS PROCESS_ID,
               DECODE(B.REGDATE, NULL, '1', NVL(B.RUNSTATE, '1')) AS RUN_STATE,
               B.RCVCNT AS RCV_CNT,
               B.SNDCNT AS SND_CNT,
               B.ETCCNT AS ETC_CNT,
               B.ERRDESC AS ERR_DESC,
               B.ERRTIMEGAP AS ERR_TIME_GAP,
               DECODE(B.REGDATE, NULL, 9000, ROUND((SYSDATE-B.REGDATE)*24*60*60)) AS REG_TIME_GAP,
               TO_CHAR(B.REGDATE, 'YYYY-MM-DD HH24:MI:SS') AS LAST_REG_DATE
        FROM PROCESS A, PROCESS_STATE B
        WHERE A.KIND = '4'
          AND A.PROCESSID = B.PROCESSID(+)
    </select>

    <!--  국토부 교통정보 제공 이력  -->
    <select id="getMolSendHistory" resultType="com.tsi.monitoring.vo.SendRcvHistVo">
        SELECT TO_CHAR(A.LOGDATE, 'YYYY-MM-DD HH24:MI:SS') AS REG_DATE,
               SUM(DATACNT) AS CNT
        FROM CURLINKST_POLICE_HIST_TCP@PTDBSDB A
        WHERE A.LOGDATE > TRUNC(SYSDATE)
        GROUP BY A.LOGDATE
        ORDER BY A.LOGDATE DESC
    </select>

    <!--  DB2.도로공사 돌발정보 수집 이력 -->
    <select id="getRecIncdHistory" resultType="com.tsi.monitoring.vo.SendRcvHistVo">
        SELECT TO_CHAR(A.REGDATE, 'YYYY-MM-DD HH24:MI:SS') AS REG_DATE,
                 NVL(A.INC_RCVCNT, 0) + NVL(A.EVT_RCVCNT, 0) AS CNT
          FROM LOG_RCV_INCIDENT_MOCT A
          WHERE A.REGDATE > TRUNC(SYSDATE)
          ORDER BY A.REGDATE DESC
    </select>

    <!--  DB2.도로공사 기간별 돌발정보 수집 이력 -->
    <select id="getPeriodRecIncdHistory" parameterType="java.util.HashMap" resultType="com.tsi.monitoring.vo.RcvIncdMoctVo">
        SELECT TO_CHAR(A.REGDATE, 'YYYY-MM-DD HH24:MI:SS') AS REG_DATE,
               NVL(A.INC_RCVCNT, 0) AS INCD_CNT,
               NVL(A.EVT_RCVCNT, 0) AS EVT_CNT,
               NVL(A.INC_RCVCNT, 0) + NVL(A.EVT_RCVCNT, 0) AS SUM_CNT
          FROM LOG_RCV_INCIDENT_MOCT A
          WHERE A.REGDATE
        BETWEEN TO_DATE(#{fromDt}, 'YYYY-MM-DD HH24:MI:SS')
            AND TO_DATE(#{toDt}, 'YYYY-MM-DD HH24:MI:SS')
          ORDER BY A.REGDATE
    </select>

    <!--  DB2.동부NTS 교통정보 수집 이력 -->
    <select id="getNtsRecHistory" resultType="com.tsi.monitoring.vo.SendRcvHistVo">
        SELECT TO_CHAR(A.REGDATE, 'YYYY-MM-DD HH24:MI:SS') AS REG_DATE,
               A.DONGBU AS CNT
        FROM LOG_RCV_TRAFFIC_PRIVATE A
        WHERE A.REGDATE > TRUNC(SYSDATE)
        ORDER BY A.REGDATE DESC
    </select>
    <!--  DB2.민간 교통정보 제공 이력 -->
    <select id="getMocSendTrafficHistory" resultType="com.tsi.monitoring.vo.SendRcvHistVo">
        SELECT TO_CHAR(A.REGDATE, 'YYYY-MM-DD HH24:MI:SS') AS REG_DATE,
               A.TRAF AS CNT
        FROM LOG_SND_TRAFFIC_PRIVATE A
        WHERE A.REGDATE > TRUNC(SYSDATE)
        ORDER BY A.REGDATE DESC
    </select>
    <!--  DB2.국토부 교통정보 수집이력 -->
    <select id="getMocRcvTrafficHistory" resultType="com.tsi.monitoring.vo.SendRcvHistVo">
        SELECT TO_CHAR(A.LOGDATE, 'YYYY-MM-DD HH24:MI:SS') AS REG_DATE,
               SUM(DATACNT) AS CNT
          FROM CURLINKST_MOCT_HIST@PTDBSDB A
         WHERE A.LOGDATE > TRUNC(SYSDATE)
         GROUP BY A.LOGDATE
         ORDER BY A.LOGDATE DESC
    </select>
    <!--  DB2.국토부 민간교통정보 수집 이력 -->
    <select id="getMocPrivateRcvTrafficHistory" resultType="com.tsi.monitoring.vo.SendRcvHistVo">
        SELECT TO_CHAR(A.LOGDATE, 'YYYY-MM-DD HH24:MI:SS') AS REG_DATE,
               SUM(DATACNT) AS CNT
          FROM CURLINKST_MOCT_PRIVATE_HIST@PTDBSDB A
         WHERE A.LOGDATE > TRUNC(SYSDATE)
         GROUP BY A.LOGDATE
         ORDER BY A.LOGDATE DESC
    </select>
    <!--  DB2.경찰 돌발정보 수집 이력 -->
    <select id="getPoliceOccurHistory" resultType="com.tsi.monitoring.vo.SendRcvHistVo">
        SELECT TO_CHAR(A.EXEC_DATE, 'YYYY-MM-DD HH24:MI:SS') AS REG_DATE,
               TO_NUMBER(NVL(IMS_TO_UTIS_CNT,'0')) AS CNT
          FROM UTISINCI.TB_BATCH_LOG A
         WHERE A.EXEC_DATE > TRUNC(SYSDATE)
         ORDER BY A.EXEC_DATE DESC
    </select>

    <!-- DB2.중앙센터돌발건수 조회 -->
    <select id="getCentralOccurCount" resultType="java.lang.Long">
        SELECT COUNT(1) AS DATA_CNT
        FROM INCIDENT_CENTER A
        WHERE A.REPORTDATE > (SYSDATE - 30/1440);
    </select>

    <select id="getProcessLinkedCountHistory" resultType="com.tsi.monitoring.vo.SendRcvHistVo">
        SELECT 70010 AS PROCESS_ID,
               TO_CHAR(A.REGDATE, 'YYYY-MM-DD HH24:MI:SS') AS REG_DATE,
               NVL(A.INC_RCVCNT, 0) + NVL(A.EVT_RCVCNT, 0) AS CNT
          FROM LOG_RCV_INCIDENT_MOCT A
         WHERE A.REGDATE > TRUNC(SYSDATE)
         UNION ALL
        SELECT 70020 AS PROCESS_ID,
               TO_CHAR(A.REGDATE, 'YYYY-MM-DD HH24:MI:SS') AS REG_DATE,
               A.TRAF AS CNT
          FROM LOG_SND_TRAFFIC_PRIVATE A
         WHERE A.REGDATE > TRUNC(SYSDATE)
         UNION ALL
        SELECT 50103 AS PROCESS_ID,
               TO_CHAR(A.LOGDATE, 'YYYY-MM-DD HH24:MI:SS') AS REG_DATE,
               SUM(DATACNT) AS CNT
          FROM CURLINKST_MOCT_PRIVATE_HIST@PTDBSDB A
         WHERE A.LOGDATE > TRUNC(SYSDATE)
         GROUP BY A.LOGDATE
         UNION ALL
        SELECT 80010 AS PROCESS_ID,
               TO_CHAR(A.EXEC_DATE, 'YYYY-MM-DD HH24:MI:SS') AS REG_DATE,
               TO_NUMBER(NVL(IMS_TO_UTIS_CNT,'0')) AS CNT
          FROM UTISINCI.TB_BATCH_LOG A
         WHERE A.EXEC_DATE > TRUNC(SYSDATE)
         ORDER BY PROCESS_ID, REG_DATE DESC
    </select>

    <select id="getProcessLinkInfo" resultType="com.tsi.monitoring.vo.ProcessStatusVo">
        SELECT A.PROCESSID AS PROCESS_ID,
               A.INFO AS PROCESS_NM,
               C.SERVERIP AS SERVER_IP,
               C.SERVERNAME AS SERVER_NM,
               CASE
                   WHEN B.REGDATE IS NULL
                     OR B.RUNSTATE IS NULL
                     OR B.REGDATE <![CDATA[<]]> SYSDATE - B.ERRTIMEGAP/(24*60*60)
                   THEN '1'
                   ELSE B.RUNSTATE
                END RUN_STATE,
               B.ERRDESC AS ERR_DESC,
               B.RCVCNT AS RCV_CNT,
               B.SNDCNT AS SND_CNT,
               B.ETCCNT AS ETC_CNT,
               B.ERRDESC AS ERR_DESC,
               B.ERRTIMEGAP AS ERR_TIME_GAP,
               DECODE(B.REGDATE, NULL, 9000, ROUND((SYSDATE-B.REGDATE)*24*60*60)) AS REG_TIME_GAP,
               TO_CHAR(B.REGDATE, 'YYYY-MM-DD HH24:MI:SS') AS LAST_REG_DATE
        FROM PROCESS A, PROCESS_STATE B, SERVER C
        WHERE A.KIND = '4'
          AND A.SERVERID = C.SERVERID
          AND A.PROCESSID = B.PROCESSID(+)
--           AND A.PROCESSID NOT IN ('70021', '50102', '50101')
--           AND A.PROCESSID IN ('50103', '70020')
        ORDER BY PROCESS_NM
    </select>
    <select id="getAllProcessLinkInfo" resultType="com.tsi.monitoring.vo.ProcessStatusVo">
        SELECT A.PROCESSID AS PROCESS_ID,
               A.INFO AS PROCESS_NM,
               C.SERVERIP AS SERVER_IP,
               C.SERVERNAME AS SERVER_NM,
               CASE
                   WHEN B.REGDATE IS NULL
                     OR B.RUNSTATE IS NULL
                     OR B.REGDATE <![CDATA[<]]> SYSDATE - B.ERRTIMEGAP/(24*60*60)
                   THEN '1'
                   ELSE B.RUNSTATE
                END RUN_STATE,
               B.ERRDESC AS ERR_DESC,
               B.RCVCNT AS RCV_CNT,
               B.SNDCNT AS SND_CNT,
               B.ETCCNT AS ETC_CNT,
               B.ERRDESC AS ERR_DESC,
               B.ERRTIMEGAP AS ERR_TIME_GAP,
               DECODE(B.REGDATE, NULL, 9000, ROUND((SYSDATE-B.REGDATE)*24*60*60)) AS REG_TIME_GAP,
               TO_CHAR(B.REGDATE, 'YYYY-MM-DD HH24:MI:SS') AS LAST_REG_DATE
        FROM PROCESS A, PROCESS_STATE B, SERVER C
        WHERE A.KIND = '4'
          AND A.SERVERID = C.SERVERID
          AND A.PROCESSID = B.PROCESSID(+)
--           AND A.PROCESSID NOT IN (50101, 50102, 70021, 80010, 70010)
        ORDER BY PROCESS_ID
    </select>

    <!--  도로공사 돌발정보 수집 이력  -->
    <select id="getRcvIncidentHistory" resultType="com.tsi.monitoring.vo.StatisticsVo">
        <![CDATA[
            WITH HOURS AS (
                SELECT TO_CHAR(LEVEL - 1, 'FM00') AS HH
                  FROM DUAL
               CONNECT BY LEVEL <= 24
            ),
            RAW_DATA AS (
                SELECT TO_CHAR(REGDATE, 'HH24') AS HH,
                       LPAD(FLOOR(TO_NUMBER(TO_CHAR(REGDATE, 'MI')) / 5) * 5, 2, '0') AS MIN_GROUP,
                       SUM(NVL(INC_RCVCNT, 0) + NVL(EVT_RCVCNT, 0)) AS SUM_DATACNT
                  FROM LOG_RCV_INCIDENT_MOCT
                 WHERE REGDATE >= TRUNC(SYSDATE)
                   AND REGDATE < TRUNC(SYSDATE + 1)
                 GROUP BY TO_CHAR(REGDATE, 'HH24'), FLOOR(TO_NUMBER(TO_CHAR(REGDATE, 'MI')) / 5)
            ),
            PIVOTED AS (
                SELECT * FROM RAW_DATA
                PIVOT (
                    SUM(SUM_DATACNT)
                    FOR MIN_GROUP IN (
                    '00' AS M00, '05' AS M05, '10' AS M10, '15' AS M15,
                    '20' AS M20, '25' AS M25, '30' AS M30, '35' AS M35,
                    '40' AS M40, '45' AS M45, '50' AS M50, '55' AS M55
                    )
                )
            )
            SELECT H.HH,
                   NVL(P.M00, 0) AS M00,
                   NVL(P.M05, 0) AS M05,
                   NVL(P.M10, 0) AS M10,
                   NVL(P.M15, 0) AS M15,
                   NVL(P.M20, 0) AS M20,
                   NVL(P.M25, 0) AS M25,
                   NVL(P.M30, 0) AS M30,
                   NVL(P.M35, 0) AS M35,
                   NVL(P.M40, 0) AS M40,
                   NVL(P.M45, 0) AS M45,
                   NVL(P.M50, 0) AS M50,
                   NVL(P.M55, 0) AS M55,
                   NVL(P.M00, 0) + NVL(P.M05, 0) + NVL(P.M10, 0) + NVL(P.M15, 0) + NVL(P.M20, 0) + NVL(P.M25, 0) +
                   NVL(P.M30, 0) + NVL(P.M35, 0) + NVL(P.M40, 0) + NVL(P.M45, 0) + NVL(P.M50, 0) + NVL(P.M55, 0) AS TOTAL
            FROM HOURS H
            LEFT JOIN PIVOTED P ON H.HH = P.HH
           ORDER BY H.HH
        ]]>
    </select>

    <!--  국토교통부 민간 교통정보 수집이력  -->
    <select id="getRcvPoliceMoctTrafficHistory" resultType="com.tsi.monitoring.vo.StatisticsVo">
        <![CDATA[
            WITH HOURS AS (
                SELECT TO_CHAR(LEVEL - 1, 'FM00') AS HH
                  FROM DUAL
               CONNECT BY LEVEL <= 24
            ),
            RAW_DATA AS (
                SELECT TO_CHAR(LOGDATE, 'HH24') AS HH,
                       LPAD(FLOOR(TO_NUMBER(TO_CHAR(LOGDATE, 'MI')) / 5) * 5, 2, '0') AS MIN_GROUP,
                       SUM(DATACNT) AS SUM_DATACNT
                  FROM CURLINKST_MOCT_PRIVATE_HIST@PTDBSDB
                 WHERE LOGDATE >= TRUNC(SYSDATE)
                   AND LOGDATE < TRUNC(SYSDATE + 1)
                 GROUP BY TO_CHAR(LOGDATE, 'HH24'), FLOOR(TO_NUMBER(TO_CHAR(LOGDATE, 'MI')) / 5)
            ),
            PIVOTED AS (
                SELECT * FROM RAW_DATA
                PIVOT (
                    SUM(SUM_DATACNT)
                    FOR MIN_GROUP IN (
                    '00' AS M00, '05' AS M05, '10' AS M10, '15' AS M15,
                    '20' AS M20, '25' AS M25, '30' AS M30, '35' AS M35,
                    '40' AS M40, '45' AS M45, '50' AS M50, '55' AS M55
                    )
                )
            )
            SELECT H.HH,
                   NVL(P.M00, 0) AS M00,
                   NVL(P.M05, 0) AS M05,
                   NVL(P.M10, 0) AS M10,
                   NVL(P.M15, 0) AS M15,
                   NVL(P.M20, 0) AS M20,
                   NVL(P.M25, 0) AS M25,
                   NVL(P.M30, 0) AS M30,
                   NVL(P.M35, 0) AS M35,
                   NVL(P.M40, 0) AS M40,
                   NVL(P.M45, 0) AS M45,
                   NVL(P.M50, 0) AS M50,
                   NVL(P.M55, 0) AS M55,
                   NVL(P.M00, 0) + NVL(P.M05, 0) + NVL(P.M10, 0) + NVL(P.M15, 0) + NVL(P.M20, 0) + NVL(P.M25, 0) +
                   NVL(P.M30, 0) + NVL(P.M35, 0) + NVL(P.M40, 0) + NVL(P.M45, 0) + NVL(P.M50, 0) + NVL(P.M55, 0) AS TOTAL
            FROM HOURS H
            LEFT JOIN PIVOTED P ON H.HH = P.HH
           ORDER BY H.HH
        ]]>
    </select>
 <!--  국토교통부 제공이력  -->
    <select id="getSndPoliceTrafficHistory" resultType="com.tsi.monitoring.vo.StatisticsVo">
        <![CDATA[
            WITH HOURS AS (
                SELECT TO_CHAR(LEVEL - 1, 'FM00') AS HH
                  FROM DUAL
               CONNECT BY LEVEL <= 24
            ),
            RAW_DATA AS (
                SELECT TO_CHAR(LOGDATE, 'HH24') AS HH,
                       LPAD(FLOOR(TO_NUMBER(TO_CHAR(LOGDATE, 'MI')) / 5) * 5, 2, '0') AS MIN_GROUP,
                       SUM(DATACNT) AS SUM_DATACNT
                  FROM CURLINKST_POLICE_HIST_TCP@PTDBSDB
                 WHERE LOGDATE >= TRUNC(SYSDATE)
                   AND LOGDATE < TRUNC(SYSDATE + 1)
                 GROUP BY TO_CHAR(LOGDATE, 'HH24'), FLOOR(TO_NUMBER(TO_CHAR(LOGDATE, 'MI')) / 5)
            ),
            PIVOTED AS (
                SELECT * FROM RAW_DATA
                PIVOT (
                    SUM(SUM_DATACNT)
                    FOR MIN_GROUP IN (
                    '00' AS M00, '05' AS M05, '10' AS M10, '15' AS M15,
                    '20' AS M20, '25' AS M25, '30' AS M30, '35' AS M35,
                    '40' AS M40, '45' AS M45, '50' AS M50, '55' AS M55
                    )
                )
            )
            SELECT H.HH,
                   NVL(P.M00, 0) AS M00,
                   NVL(P.M05, 0) AS M05,
                   NVL(P.M10, 0) AS M10,
                   NVL(P.M15, 0) AS M15,
                   NVL(P.M20, 0) AS M20,
                   NVL(P.M25, 0) AS M25,
                   NVL(P.M30, 0) AS M30,
                   NVL(P.M35, 0) AS M35,
                   NVL(P.M40, 0) AS M40,
                   NVL(P.M45, 0) AS M45,
                   NVL(P.M50, 0) AS M50,
                   NVL(P.M55, 0) AS M55,
                   NVL(P.M00, 0) + NVL(P.M05, 0) + NVL(P.M10, 0) + NVL(P.M15, 0) + NVL(P.M20, 0) + NVL(P.M25, 0) +
                   NVL(P.M30, 0) + NVL(P.M35, 0) + NVL(P.M40, 0) + NVL(P.M45, 0) + NVL(P.M50, 0) + NVL(P.M55, 0) AS TOTAL
            FROM HOURS H
            LEFT JOIN PIVOTED P ON H.HH = P.HH
           ORDER BY H.HH
        ]]>
    </select>

    <!--  국토 교통부 수집 이력  -->
    <select id="getRcvPoliceTrafficHistory" resultType="com.tsi.monitoring.vo.StatisticsVo">
        <![CDATA[
            WITH HOURS AS (
                SELECT TO_CHAR(LEVEL - 1, 'FM00') AS HH
                  FROM DUAL
               CONNECT BY LEVEL <= 24
            ),
            RAW_DATA AS (
                SELECT TO_CHAR(LOGDATE, 'HH24') AS HH,
                       LPAD(FLOOR(TO_NUMBER(TO_CHAR(LOGDATE, 'MI')) / 5) * 5, 2, '0') AS MIN_GROUP,
                       SUM(DATACNT) AS SUM_DATACNT
                  FROM CURLINKST_MOCT_HIST@PTDBSDB
                 WHERE LOGDATE >= TRUNC(SYSDATE)
                   AND LOGDATE < TRUNC(SYSDATE + 1)
                 GROUP BY TO_CHAR(LOGDATE, 'HH24'), FLOOR(TO_NUMBER(TO_CHAR(LOGDATE, 'MI')) / 5)
            ),
            PIVOTED AS (
                SELECT * FROM RAW_DATA
                PIVOT (
                    SUM(SUM_DATACNT)
                    FOR MIN_GROUP IN (
                    '00' AS M00, '05' AS M05, '10' AS M10, '15' AS M15,
                    '20' AS M20, '25' AS M25, '30' AS M30, '35' AS M35,
                    '40' AS M40, '45' AS M45, '50' AS M50, '55' AS M55
                    )
                )
            )
            SELECT H.HH,
                   NVL(P.M00, 0) AS M00,
                   NVL(P.M05, 0) AS M05,
                   NVL(P.M10, 0) AS M10,
                   NVL(P.M15, 0) AS M15,
                   NVL(P.M20, 0) AS M20,
                   NVL(P.M25, 0) AS M25,
                   NVL(P.M30, 0) AS M30,
                   NVL(P.M35, 0) AS M35,
                   NVL(P.M40, 0) AS M40,
                   NVL(P.M45, 0) AS M45,
                   NVL(P.M50, 0) AS M50,
                   NVL(P.M55, 0) AS M55,
                   NVL(P.M00, 0) + NVL(P.M05, 0) + NVL(P.M10, 0) + NVL(P.M15, 0) + NVL(P.M20, 0) + NVL(P.M25, 0) +
                   NVL(P.M30, 0) + NVL(P.M35, 0) + NVL(P.M40, 0) + NVL(P.M45, 0) + NVL(P.M50, 0) + NVL(P.M55, 0) AS TOTAL
            FROM HOURS H
            LEFT JOIN PIVOTED P ON H.HH = P.HH
           ORDER BY H.HH
        ]]>
    </select>

    <!--  동부 NTS 수집 이력  -->
    <select id="getRcvNtsTrafficHistory" resultType="com.tsi.monitoring.vo.StatisticsVo">
        <![CDATA[
            WITH HOURS AS (
                SELECT TO_CHAR(LEVEL - 1, 'FM00') AS HH
                  FROM DUAL
               CONNECT BY LEVEL <= 24
            ),
            RAW_DATA AS (
                SELECT TO_CHAR(REGDATE, 'HH24') AS HH,
                       LPAD(FLOOR(TO_NUMBER(TO_CHAR(REGDATE, 'MI')) / 5) * 5, 2, '0') AS MIN_GROUP,
                       SUM(DONGBU) AS SUM_DATACNT
                  FROM LOG_RCV_TRAFFIC_PRIVATE
                 WHERE REGDATE >= TRUNC(SYSDATE)
                   AND REGDATE < TRUNC(SYSDATE + 1)
                 GROUP BY TO_CHAR(REGDATE, 'HH24'), FLOOR(TO_NUMBER(TO_CHAR(REGDATE, 'MI')) / 5)
            ),
            PIVOTED AS (
                SELECT * FROM RAW_DATA
                PIVOT (
                    SUM(SUM_DATACNT)
                    FOR MIN_GROUP IN (
                    '00' AS M00, '05' AS M05, '10' AS M10, '15' AS M15,
                    '20' AS M20, '25' AS M25, '30' AS M30, '35' AS M35,
                    '40' AS M40, '45' AS M45, '50' AS M50, '55' AS M55
                    )
                )
            )
            SELECT H.HH,
                   NVL(P.M00, 0) AS M00,
                   NVL(P.M05, 0) AS M05,
                   NVL(P.M10, 0) AS M10,
                   NVL(P.M15, 0) AS M15,
                   NVL(P.M20, 0) AS M20,
                   NVL(P.M25, 0) AS M25,
                   NVL(P.M30, 0) AS M30,
                   NVL(P.M35, 0) AS M35,
                   NVL(P.M40, 0) AS M40,
                   NVL(P.M45, 0) AS M45,
                   NVL(P.M50, 0) AS M50,
                   NVL(P.M55, 0) AS M55,
                   NVL(P.M00, 0) + NVL(P.M05, 0) + NVL(P.M10, 0) + NVL(P.M15, 0) + NVL(P.M20, 0) + NVL(P.M25, 0) +
                   NVL(P.M30, 0) + NVL(P.M35, 0) + NVL(P.M40, 0) + NVL(P.M45, 0) + NVL(P.M50, 0) + NVL(P.M55, 0) AS TOTAL
            FROM HOURS H
            LEFT JOIN PIVOTED P ON H.HH = P.HH
           ORDER BY H.HH
        ]]>
    </select>

   <!--  민간 교통정보 제공 이력  -->
    <select id="getSndMoctTrafficHistory" resultType="com.tsi.monitoring.vo.StatisticsVo">
        <![CDATA[
            WITH HOURS AS (
                SELECT TO_CHAR(LEVEL - 1, 'FM00') AS HH
                  FROM DUAL
               CONNECT BY LEVEL <= 24
            ),
            RAW_DATA AS (
                SELECT TO_CHAR(REGDATE, 'HH24') AS HH,
                       LPAD(FLOOR(TO_NUMBER(TO_CHAR(REGDATE, 'MI')) / 5) * 5, 2, '0') AS MIN_GROUP,
                       SUM(TRAF) AS SUM_DATACNT
                  FROM LOG_SND_TRAFFIC_PRIVATE
                 WHERE REGDATE >= TRUNC(SYSDATE)
                   AND REGDATE < TRUNC(SYSDATE + 1)
                 GROUP BY TO_CHAR(REGDATE, 'HH24'), FLOOR(TO_NUMBER(TO_CHAR(REGDATE, 'MI')) / 5)
            ),
            PIVOTED AS (
                SELECT * FROM RAW_DATA
                PIVOT (
                    SUM(SUM_DATACNT)
                    FOR MIN_GROUP IN (
                    '00' AS M00, '05' AS M05, '10' AS M10, '15' AS M15,
                    '20' AS M20, '25' AS M25, '30' AS M30, '35' AS M35,
                    '40' AS M40, '45' AS M45, '50' AS M50, '55' AS M55
                    )
                )
            )
            SELECT H.HH,
                   NVL(P.M00, 0) AS M00,
                   NVL(P.M05, 0) AS M05,
                   NVL(P.M10, 0) AS M10,
                   NVL(P.M15, 0) AS M15,
                   NVL(P.M20, 0) AS M20,
                   NVL(P.M25, 0) AS M25,
                   NVL(P.M30, 0) AS M30,
                   NVL(P.M35, 0) AS M35,
                   NVL(P.M40, 0) AS M40,
                   NVL(P.M45, 0) AS M45,
                   NVL(P.M50, 0) AS M50,
                   NVL(P.M55, 0) AS M55,
                   NVL(P.M00, 0) + NVL(P.M05, 0) + NVL(P.M10, 0) + NVL(P.M15, 0) + NVL(P.M20, 0) + NVL(P.M25, 0) +
                   NVL(P.M30, 0) + NVL(P.M35, 0) + NVL(P.M40, 0) + NVL(P.M45, 0) + NVL(P.M50, 0) + NVL(P.M55, 0) AS TOTAL
            FROM HOURS H
            LEFT JOIN PIVOTED P ON H.HH = P.HH
           ORDER BY H.HH
        ]]>
    </select>

   <!--  경찰 돌발정보 수집 이력  -->
    <select id="getRcvPoliceIncidentHistory" resultType="com.tsi.monitoring.vo.StatisticsVo">
        <![CDATA[
            WITH HOURS AS (
                SELECT TO_CHAR(LEVEL - 1, 'FM00') AS HH
                  FROM DUAL
               CONNECT BY LEVEL <= 24
            ),
            RAW_DATA AS (
                SELECT TO_CHAR(EXEC_DATE, 'HH24') AS HH,
                       LPAD(FLOOR(TO_NUMBER(TO_CHAR(EXEC_DATE, 'MI')) / 5) * 5, 2, '0') AS MIN_GROUP,
                       SUM(TO_NUMBER(NVL(IMS_TO_UTIS_CNT,'0'))) AS SUM_DATACNT
                  FROM UTISINCI.TB_BATCH_LOG
                 WHERE EXEC_DATE >= TRUNC(SYSDATE)
                   AND EXEC_DATE < TRUNC(SYSDATE + 1)
                 GROUP BY TO_CHAR(EXEC_DATE, 'HH24'), FLOOR(TO_NUMBER(TO_CHAR(EXEC_DATE, 'MI')) / 5)
            ),
            PIVOTED AS (
                SELECT * FROM RAW_DATA
                PIVOT (
                    SUM(SUM_DATACNT)
                    FOR MIN_GROUP IN (
                    '00' AS M00, '05' AS M05, '10' AS M10, '15' AS M15,
                    '20' AS M20, '25' AS M25, '30' AS M30, '35' AS M35,
                    '40' AS M40, '45' AS M45, '50' AS M50, '55' AS M55
                    )
                )
            )
            SELECT H.HH,
                   NVL(P.M00, 0) AS M00,
                   NVL(P.M05, 0) AS M05,
                   NVL(P.M10, 0) AS M10,
                   NVL(P.M15, 0) AS M15,
                   NVL(P.M20, 0) AS M20,
                   NVL(P.M25, 0) AS M25,
                   NVL(P.M30, 0) AS M30,
                   NVL(P.M35, 0) AS M35,
                   NVL(P.M40, 0) AS M40,
                   NVL(P.M45, 0) AS M45,
                   NVL(P.M50, 0) AS M50,
                   NVL(P.M55, 0) AS M55,
                   NVL(P.M00, 0) + NVL(P.M05, 0) + NVL(P.M10, 0) + NVL(P.M15, 0) + NVL(P.M20, 0) + NVL(P.M25, 0) +
                   NVL(P.M30, 0) + NVL(P.M35, 0) + NVL(P.M40, 0) + NVL(P.M45, 0) + NVL(P.M50, 0) + NVL(P.M55, 0) AS TOTAL
            FROM HOURS H
            LEFT JOIN PIVOTED P ON H.HH = P.HH
           ORDER BY H.HH
        ]]>
    </select>

    <!--  동부 NTS 수집 이력  -->
    <select id="getPeriodRcvNtsStatistics" parameterType="java.util.HashMap" resultType="com.tsi.monitoring.vo.SendRcvHistVo">
        SELECT REGDATE AS REG_DATE,
               DONGBU AS CNT
          FROM LOG_RCV_TRAFFIC_PRIVATE
         WHERE REGDATE BETWEEN TO_DATE(#{fromDt}, 'YYYY-MM-DD HH24:MI:SS') and TO_DATE(#{toDt} , 'YYYY-MM-DD HH24:MI:SS')
    </select>

    <!--  민간연계 수집 이력  -->
    <select id="getPeriodSndMoctStatistics" parameterType="java.util.HashMap" resultType="com.tsi.monitoring.vo.SndMoctVo">
        SELECT TO_CHAR(A.REGDATE, 'YYYY-MM-DD HH24:MI:SS') AS REG_DATE,
               A.TRAF AS TRAF,
               A.KBS AS KBS,
               A.SK AS SK,
               A.DONGBU AS DONGBU,
               A.INCD AS INCD,
               A.KBSINCD AS KBS_INCD,
               A.SKINCD AS SK_INCD,
               A.DONGBUINCD AS DONGBU_INCD,
               A.KBSCTRL AS KBS_CTRL
        FROM LOG_SND_TRAFFIC_PRIVATE A
        WHERE A.REGDATE
      BETWEEN TO_DATE(#{fromDt}, 'YYYY-MM-DD HH24:MI:SS')
          AND TO_DATE(#{toDt}, 'YYYY-MM-DD HH24:MI:SS')
        ORDER BY A.REGDATE
    </select>
    <!--  국토부 교통정보 제공 이력  -->
    <select id="getPeriodSndMolitTraffStatistics" parameterType="java.util.HashMap" resultType="com.tsi.monitoring.vo.SndMolitTraffVo">
    <![CDATA[
        SELECT X.LOGDATE AS LOG_DATE,
               NVL(X.RCVCNT, 0) AS RCV_CNT,
               NVL(Y.SNDCNT, 0) AS SND_CNT,
               NVL(Z.SELCNT, 0) AS SEL_CNT,
               NVL(X.RCVCNT - Z.SELCNT, 0) AS SEL_GAP,
               NVL(X.RCVCNT - Y.SNDCNT, 0) AS SND_GAP,
               NVL(Z.SELCNT - Y.SNDCNT, 0) AS ASN_GAP
         FROM (
             SELECT TO_CHAR(A.LOGDATE, ${format}) AS LOGDATE, SUM(DATACNT) AS RCVCNT
               FROM CENTER_RECEIVE A
              WHERE A.LOGDATE BETWEEN TO_DATE(#{fromDt}, 'YYYY-MM-DD HH24:MI:SS')
                AND TO_DATE(#{toDt}, 'YYYY-MM-DD HH24:MI:SS')
                AND A.INFOTYPE = 'R1'
                AND A.CENTERID <> 'L00'
              GROUP BY TO_CHAR(A.LOGDATE, ${format})
        ) X,(
            SELECT TO_CHAR(A.LOGDATE, ${format}) AS LOGDATE, SUM(DATACNT) AS SNDCNT
              FROM CURLINKST_POLICE_HIST_TCP@PTDBSDB A
             WHERE A.LOGDATE BETWEEN TO_DATE(#{fromDt}, 'YYYY-MM-DD HH24:MI:SS')
               AND TO_DATE(#{toDt}, 'YYYY-MM-DD HH24:MI:SS')
             GROUP BY TO_CHAR(A.LOGDATE, ${format})
        ) Y, (
            SELECT TO_CHAR(A.LOGDATE, ${format}) AS LOGDATE, SUM(DATACNT) AS SELCNT
              FROM CURLINKST_POLICE_HIST@PTDBSDB A
             WHERE A.LOGDATE BETWEEN TO_DATE(#{fromDt}, 'YYYY-MM-DD HH24:MI:SS')
               AND TO_DATE(#{toDt}, 'YYYY-MM-DD HH24:MI:SS')
             GROUP BY TO_CHAR(A.LOGDATE, ${format})
        ) z
         WHERE X.LOGDATE = Y.LOGDATE(+)
           AND X.LOGDATE = Z.LOGDATE(+)
         ORDER BY X.LOGDATE
        ]]>
    </select>
    <!--  국토부 교통정보 수집 이력 통계 -->
    <select id="getPeriodRcvMolitTraffStatistics" parameterType="java.util.HashMap" resultType="com.tsi.monitoring.vo.SndMolitTraffVo">
        SELECT X.LOG_DATE, NVL(X.RCV_CNT, 0) AS RCV_CNT
        FROM (
            SELECT TO_CHAR(A.LOGDATE, ${format}) AS LOG_DATE, SUM(DATACNT) AS RCV_CNT
              FROM CURLINKST_MOCT_HIST@PTDBSDB A
             WHERE A.LOGDATE BETWEEN TO_DATE(#{fromDt}, 'YYYY-MM-DD HH24:MI:SS')
                                 AND TO_DATE(#{toDt}, 'YYYY-MM-DD HH24:MI:SS')
             GROUP BY TO_CHAR(A.LOGDATE, ${format})
             ) X
        ORDER BY X.LOG_DATE
    </select>

    <!--  국토부 교통정보 수집 이력  -->
    <select id="getPeriodRcvMolitTraffHist" parameterType="java.util.HashMap" resultType="com.tsi.monitoring.vo.SndMolitTraffVo">
        SELECT TO_CHAR(A.LOGDATE, 'YYYY-MM-DD HH24:MI:SS') AS LOG_DATE, NVL(DATACNT, 0) AS RCV_CNT
          FROM CURLINKST_MOCT_HIST@PTDBSDB A
         WHERE A.LOGDATE BETWEEN TO_DATE(#{fromDt}, 'YYYY-MM-DD HH24:MI:SS')
                             AND TO_DATE(#{toDt}, 'YYYY-MM-DD HH24:MI:SS')
         ORDER BY A.LOGDATE, A.DATACNT DESC
    </select>

    <!--  국토부 민간 교통정보 수집 이력  -->
    <select id="getPeriodRcvMoctTraffStatistics" parameterType="java.util.HashMap" resultType="com.tsi.monitoring.vo.SndMolitTraffVo">
        SELECT X.LOG_DATE, NVL(X.RCV_CNT, 0) AS RCV_CNT
        FROM (
                 SELECT TO_CHAR(A.LOGDATE, ${format}) AS LOG_DATE, SUM(DATACNT) AS RCV_CNT
                 FROM CURLINKST_MOCT_PRIVATE_HIST@PTDBSDB A
                 WHERE A.LOGDATE BETWEEN TO_DATE(#{fromDt}, 'YYYY-MM-DD HH24:MI:SS')
                           AND TO_DATE(#{toDt}, 'YYYY-MM-DD HH24:MI:SS')
                 GROUP BY TO_CHAR(A.LOGDATE, ${format})
             ) X
        ORDER BY X.LOG_DATE
    </select>

    <!--  국토부 교통정보 수집 이력  -->
    <select id="getPeriodRcvMoctTraffHist" parameterType="java.util.HashMap" resultType="com.tsi.monitoring.vo.SndMolitTraffVo">
        SELECT TO_CHAR(A.LOGDATE, 'YYYY-MM-DD HH24:MI:SS') AS LOG_DATE, NVL(DATACNT, 0) AS RCV_CNT
          FROM CURLINKST_MOCT_PRIVATE_HIST@PTDBSDB A
         WHERE A.LOGDATE BETWEEN TO_DATE(#{fromDt}, 'YYYY-MM-DD HH24:MI:SS')
                             AND TO_DATE(#{toDt}, 'YYYY-MM-DD HH24:MI:SS')
         ORDER BY A.LOGDATE, A.DATACNT DESC
    </select>

    <!--소통정보 가중치 설정 정보 -->
    <select id="getTrafficWeightInfos" resultType="com.tsi.monitoring.vo.TrafficWeightVo">
        SELECT WEIGHTCODE, DECODE(SUBSTR(WEIGHTCODE, 1, 1), '1', 8, 0) +
                           DECODE(SUBSTR(WEIGHTCODE, 2, 1), '1', 4, 0) +
                           DECODE(SUBSTR(WEIGHTCODE, 3, 1), '1', 2, 0) +
                           DECODE(SUBSTR(WEIGHTCODE, 4, 1), '1', 1, 0) AS VALIDX,
               NVL(GPS, 0) AS GPS, NVL(UTIS,   0) AS UTIS,
               NVL(LOC, 0) AS LOC, NVL(DONGBU, 0) AS DONGBU,
               SUBSTR(WEIGHTCODE, 1, 1) AS GPS_CODE,
               SUBSTR(WEIGHTCODE, 2, 1) AS UTIS_CODE,
               SUBSTR(WEIGHTCODE, 3, 1) AS LOC_CODE,
               SUBSTR(WEIGHTCODE, 4, 1) AS DONGBU_CODE,
               DATARESTYPE AS DATA_RES_TYPE
        FROM TRAFFIC_WEIGHT
        ORDER BY VALIDX
    </select>

    <update id="updateTrafficWeightInfo" parameterType="com.tsi.monitoring.vo.TrafficWeightVo">
        UPDATE TRAFFIC_WEIGHT
           SET GPS = #{gps},
               UTIS = #{utis},
               LOC = #{loc},
               DONGBU = #{dongbu},
               DATARESTYPE = #{dataResType}
         WHERE WEIGHTCODE = #{weightCode}
    </update>

    <select id="getPeriodSigCommStatistics" resultType="com.tsi.monitoring.vo.SigCommStatisticsVo" parameterType="java.util.HashMap">
        SELECT A.REGION_CD, TO_CHAR(A.COLLCT_DTIME, 'YYYY-MM-DD HH24:MI:SS') AS COLDATE,
               NVL(A.COLLCT_SN, 0) AS COLLCT_SN, A.COMM_CD, NVL(B.CD_NM, 'Unknown Comm Code') AS COM_NM
          FROM ${schema}TB_COMM_HIST${dblnk} A,
              (SELECT TO_NUMBER(SUB_CD, 'XX') AS COM_CD, CD_NM
                 FROM ${schema}TB_SIG_CODE${dblnk}
                WHERE MAIN_CD = 'COMCD') B
         WHERE A.COLLCT_DTIME BETWEEN TO_DATE(#{fromDt}, 'YYYY-MM-DD HH24:MI:SS')
                                  AND TO_DATE(#{toDt}, 'YYYY-MM-DD HH24:MI:SS')
           AND A.REGION_CD = #{centerId}
           AND A.COMM_CD = B.COM_CD(+)
         ORDER BY A.COLLCT_DTIME, A.COLLCT_SN
    </select>
    <select id="getAnalysisType" resultType="java.lang.Integer">
        SELECT TO_NUMBER(NVL(codevalue, '0')) AS analysis_type
          FROM CODEDEFINE
         WHERE maincode = 'C04'
           AND subcode  = 'T00'
    </select>

    <update id="setUtisAnalysisType" parameterType="java.lang.String">
        UPDATE CODEDEFINE
           SET codevalue = #{codeValue}
         WHERE maincode = 'C04'
           AND subcode  = 'T00'
    </update>

    <update id="setDwAnalysisType" parameterType="java.lang.String">
        UPDATE CODEDEFINE@DWDB
           SET codevalue = #{codeValue}
         WHERE maincode = 'C04'
           AND subcode  = 'T00'
    </update>

    <select id="getPeriodCenterRcvSendStatistics" parameterType="java.util.HashMap" resultType="com.tsi.monitoring.vo.PeriodCenterRcvSendStatisticsVo">
        <![CDATA[
        WITH
            params AS (
                SELECT TO_DATE(CONCAT(#{searchDt}, ' 00:00:00'), 'YYYY-MM-DD HH24:MI:SS') AS start_dt,
                       TO_DATE(CONCAT(#{searchDt}, ' 23:55:00'), 'YYYY-MM-DD HH24:MI:SS') AS end_dt
                FROM dual
            ),
            slots AS (
                SELECT params.start_dt + (LEVEL - 1) * (5/1440) AS slot_dt
                  FROM params
               CONNECT BY params.start_dt + (LEVEL - 1) * (5/1440) <= params.end_dt
            ),
            logs_rcv AS (
                SELECT * FROM CENTER_RECEIVE WHERE CENTERID = #{centerId}
            ),
            logs_snd AS (
                SELECT * FROM CENTER_SEND WHERE CENTERID = #{centerId}
            ),
            agg_rcv AS (
                SELECT TRUNC(LOGDATE, 'HH24') + FLOOR(TO_NUMBER(TO_CHAR(LOGDATE, 'MI')) / 5) * (5/1440) AS slot_dt,
                       SUM(CASE WHEN INFOTYPE = 'R1' THEN DATACNT ELSE 0 END) AS T_CNT,
                       SUM(CASE WHEN INFOTYPE = 'E1' THEN DATACNT ELSE 0 END) AS I_CNT
                  FROM logs_rcv, params
                 WHERE LOGDATE BETWEEN params.start_dt AND params.end_dt + (5/1440)
                 GROUP BY TRUNC(LOGDATE, 'HH24') + FLOOR(TO_NUMBER(TO_CHAR(LOGDATE, 'MI')) / 5) * (5/1440)
            ),
            agg_snd AS (
                SELECT TRUNC(LOGDATE, 'HH24') + FLOOR(TO_NUMBER(TO_CHAR(LOGDATE, 'MI')) / 5) * (5/1440) AS slot_dt,
                    SUM(CASE WHEN INFOTYPE = 'R1' THEN DATACNT ELSE 0 END) AS T_CNT,
                    SUM(CASE WHEN INFOTYPE = 'E1' THEN DATACNT ELSE 0 END) AS I_CNT,
                    SUM(CASE WHEN INFOTYPE = 'M1' THEN DATACNT ELSE 0 END) AS M_CNT
                  FROM logs_snd, params
                 WHERE LOGDATE BETWEEN params.start_dt AND params.end_dt + (5/1440)
                 GROUP BY TRUNC(LOGDATE, 'HH24') + FLOOR(TO_NUMBER(TO_CHAR(LOGDATE, 'MI')) / 5) * (5/1440)
            ),
            rcv_final AS (
                SELECT s.slot_dt,
                       NVL(r.T_CNT, 0) AS R_T_CNT,
                       NVL(r.I_CNT, 0) AS R_I_CNT
                  FROM slots s
                  LEFT JOIN agg_rcv r ON s.slot_dt = r.slot_dt
            ),
            snd_final AS (
                SELECT s.slot_dt,
                       NVL(snd.T_CNT, 0) AS S_T_CNT,
                       NVL(snd.I_CNT, 0) AS S_I_CNT,
                       NVL(snd.M_CNT, 0) AS S_M_CNT
                  FROM slots s
                  LEFT JOIN agg_snd snd ON s.slot_dt = snd.slot_dt
            )
            SELECT TO_CHAR(r.slot_dt, 'YYYY-MM-DD HH24:MI:SS') AS LOG_DATE,
                   r.R_T_CNT,
                   r.R_I_CNT,
                   s.S_T_CNT,
                   s.S_I_CNT,
                   s.S_M_CNT
              FROM rcv_final r
              JOIN snd_final s ON r.slot_dt = s.slot_dt
             ORDER BY r.slot_dt
        ]]>
    </select>

    <select id="getCenterSendRecCount" parameterType="java.util.HashMap" resultType="com.tsi.monitoring.vo.CenterSendRecCountVo">
        <![CDATA[
        WITH time_tbl AS (
                SELECT
                    LEVEL AS seq,
                    TO_DATE(#{fromDt}, 'YYYY-MM-DD') + (LEVEL - 1) * INTERVAL '5' MINUTE AS start_time,
                    TO_DATE(#{fromDt}, 'YYYY-MM-DD') + (LEVEL - 1) * INTERVAL '5' MINUTE + INTERVAL '4' MINUTE + INTERVAL '59' SECOND AS end_time
                FROM dual
             CONNECT BY LEVEL <= 288
            ),
            recv AS (
                SELECT
                    TRUNC(LOGDATE, 'MI') - MOD(TO_CHAR(LOGDATE, 'MI'), 5)/1440 AS slot_time,
                    COUNT(*) AS recv_count,
                    SUM(datacnt) AS recv_datacnt
                FROM CENTER_RECEIVE
                WHERE LOGDATE BETWEEN TO_DATE(#{fromDt} || '00:00:00', 'YYYY-MM-DD HH24:MI:SS') AND TO_DATE(#{fromDt} || '23:59:59', 'YYYY-MM-DD HH24:MI:SS')
                  AND INFOTYPE = 'R1'
                  AND CENTERID = #{centerId}
                GROUP BY TRUNC(LOGDATE, 'MI') - MOD(TO_CHAR(LOGDATE, 'MI'), 5)/1440
            ),
            send AS (
                SELECT
                    TRUNC(LOGDATE, 'MI') - MOD(TO_CHAR(LOGDATE, 'MI'), 5)/1440 AS slot_time,
                    COUNT(*) AS send_count,
                    SUM(datacnt) AS send_datacnt
                FROM CENTER_SEND
                WHERE LOGDATE BETWEEN TO_DATE(#{fromDt} || '00:00:00', 'YYYY-MM-DD HH24:MI:SS') AND TO_DATE(#{fromDt} || '23:59:59', 'YYYY-MM-DD HH24:MI:SS')
                  AND INFOTYPE = 'R1'
                  AND CENTERID = #{centerId}
                GROUP BY TRUNC(LOGDATE, 'MI') - MOD(TO_CHAR(LOGDATE, 'MI'), 5)/1440
            ),
            moct AS (
                SELECT
                    TRUNC(LOGDATE, 'MI') - MOD(TO_CHAR(LOGDATE, 'MI'), 5)/1440 AS slot_time,
                    COUNT(*) AS moct_count,
                    SUM(datacnt) AS moct_datacnt
                FROM CENTER_SEND
                WHERE LOGDATE BETWEEN TO_DATE(#{fromDt} || '00:00:00', 'YYYY-MM-DD HH24:MI:SS') AND TO_DATE(#{fromDt} || '23:59:59', 'YYYY-MM-DD HH24:MI:SS')
                  AND INFOTYPE = 'M1'
                  AND CENTERID = #{centerId}
                GROUP BY TRUNC(LOGDATE, 'MI') - MOD(TO_CHAR(LOGDATE, 'MI'), 5)/1440
            )
            SELECT
                ts.seq,
                ts.start_time,
                ts.end_time,
                NVL(r.recv_count, 0) AS recv_count,
                NVL(r.recv_datacnt, 0) AS recv_datacnt,
                NVL(s.send_count, 0) AS send_count,
                NVL(s.send_datacnt, 0) AS send_datacnt,
                NVL(m.moct_count, 0) AS moct_count,
                NVL(m.moct_datacnt, 0) AS moct_datacnt
            FROM time_tbl ts
                     LEFT JOIN recv r ON r.slot_time BETWEEN ts.start_time AND ts.end_time
                     LEFT JOIN send s ON s.slot_time BETWEEN ts.start_time AND ts.end_time
                     LEFT JOIN moct m ON m.slot_time BETWEEN ts.start_time AND ts.end_time
            ORDER BY ts.seq
        ]]>
    </select>
</mapper>