<?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.utic.center.utic.stat.server.dao.mapper.UticStatParamMapper">

    <select id="findStatTime" resultType="com.utic.center.utic.stat.server.dto.StatTimeDto">
        <![CDATA[
        SELECT TO_CHAR(currTime,  'YYYYMMDDHH24MISS') AS currTime,
               TO_CHAR(past05Min, 'YYYYMMDDHH24MISS') AS past05Min,
               TO_CHAR(past10Min, 'YYYYMMDDHH24MISS') AS past10Min,
               TO_CHAR(past30Min, 'YYYYMMDDHH24MISS') AS past30Min,
               TO_CHAR(prcs05Min, 'YYYYMMDDHH24MISS') AS prcs05Min,
               TO_CHAR(prcs15Min, 'YYYYMMDDHH24MISS') AS prcs15Min,
               TO_CHAR(prcs30Min, 'YYYYMMDDHH24MISS') AS prcs30Min,
               TO_CHAR(prcsHour,  'YYYYMMDDHH24MISS') AS prcsHour,
               TO_CHAR(prcsDay,   'YYYYMMDDHH24MISS') AS prcsDay
        FROM (SELECT SYSDATE                                                                 AS currTime,
                     SYSDATE -  5/1440                                                       AS past05Min,
                     SYSDATE - 10/1440                                                       AS past10Min,
                     SYSDATE - 30/1440                                                       AS past30Min,
                     TRUNC(SYSDATE, 'HH24') + FLOOR(TO_CHAR(SYSDATE, 'MI') /  5) *  5 / 1440 AS prcs05Min,
                     TRUNC(SYSDATE, 'HH24') + FLOOR(TO_CHAR(SYSDATE, 'MI') / 15) * 15 / 1440 AS prcs15Min,
                     TRUNC(SYSDATE, 'HH24') + FLOOR(TO_CHAR(SYSDATE, 'MI') / 30) * 30 / 1440 AS prcs30Min,
                     TRUNC(SYSDATE, 'HH24')                                                  AS prcsHour,
                     TRUNC(SYSDATE - 1, 'DD')                                                AS prcsDay
              FROM DUAL)
        ]]>
    </select>

    <select id="findAllCodeValue" resultType="com.utic.center.utic.stat.server.dto.CodeValueDto" timeout="30">
        <![CDATA[
        SELECT MAINCODE                      AS mainCode,
               NVL(SUBCODE,           '999') AS subCode,
               NVL(CODEVALUE,         '999') AS codeValue,
               NVL(TO_NUMBER(MINVALUE), 999) AS minValue,
               NVL(TO_NUMBER(MAXVALUE), 999) AS maxValue
        FROM CODEDEFINE
        WHERE MAINCODE in ('C01', 'C02')
          AND SUBCODE != 'T00'
        ORDER BY MAINCODE, SUBCODE
        ]]>
   </select>

</mapper>
