<?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.njcn.harmonic.mapper.report.QualifiedReportMapper">

    <select id="getLimitRateData" resultType="map">
        select my_index,
        SUM( UHARM_2_OVERTIME ) UHARM_2_OVERTIME,
        SUM( IHARM_2_OVERTIME ) IHARM_2_OVERTIME,
        SUM( UHARM_3_OVERTIME ) UHARM_3_OVERTIME,
        SUM( IHARM_3_OVERTIME ) IHARM_3_OVERTIME,
        SUM( UHARM_4_OVERTIME ) UHARM_4_OVERTIME,
        SUM( IHARM_4_OVERTIME ) IHARM_4_OVERTIME,
        SUM( UHARM_5_OVERTIME ) UHARM_5_OVERTIME,
        SUM( IHARM_5_OVERTIME ) IHARM_5_OVERTIME,
        SUM( UHARM_6_OVERTIME ) UHARM_6_OVERTIME,
        SUM( IHARM_6_OVERTIME ) IHARM_6_OVERTIME,
        SUM( UHARM_7_OVERTIME ) UHARM_7_OVERTIME,
        SUM( IHARM_7_OVERTIME ) IHARM_7_OVERTIME,
        SUM( UHARM_8_OVERTIME ) UHARM_8_OVERTIME,
        SUM( IHARM_8_OVERTIME ) IHARM_8_OVERTIME,
        SUM( UHARM_9_OVERTIME ) UHARM_9_OVERTIME,
        SUM( IHARM_9_OVERTIME ) IHARM_9_OVERTIME,
        SUM( UHARM_10_OVERTIME ) UHARM_10_OVERTIME,
        SUM( IHARM_10_OVERTIME ) IHARM_10_OVERTIME,
        SUM( UHARM_11_OVERTIME ) UHARM_11_OVERTIME,
        SUM( IHARM_11_OVERTIME ) IHARM_11_OVERTIME,
        SUM( UHARM_12_OVERTIME ) UHARM_12_OVERTIME,
        SUM( IHARM_12_OVERTIME ) IHARM_12_OVERTIME,
        SUM( UHARM_13_OVERTIME ) UHARM_13_OVERTIME,
        SUM( IHARM_13_OVERTIME ) IHARM_13_OVERTIME,
        SUM( UHARM_14_OVERTIME ) UHARM_14_OVERTIME,
        SUM( IHARM_14_OVERTIME ) IHARM_14_OVERTIME,
        SUM( UHARM_15_OVERTIME ) UHARM_15_OVERTIME,
        SUM( IHARM_15_OVERTIME ) IHARM_15_OVERTIME,
        SUM( UHARM_16_OVERTIME ) UHARM_16_OVERTIME,
        SUM( IHARM_16_OVERTIME ) IHARM_16_OVERTIME,
        SUM( UHARM_17_OVERTIME ) UHARM_17_OVERTIME,
        SUM( IHARM_17_OVERTIME ) IHARM_17_OVERTIME,
        SUM( UHARM_18_OVERTIME ) UHARM_18_OVERTIME,
        SUM( IHARM_18_OVERTIME ) IHARM_18_OVERTIME,
        SUM( UHARM_19_OVERTIME ) UHARM_19_OVERTIME,
        SUM( IHARM_19_OVERTIME ) IHARM_19_OVERTIME,
        SUM( UHARM_20_OVERTIME ) UHARM_20_OVERTIME,
        SUM( IHARM_20_OVERTIME ) IHARM_20_OVERTIME,
        SUM( UHARM_21_OVERTIME ) UHARM_21_OVERTIME,
        SUM( IHARM_21_OVERTIME ) IHARM_21_OVERTIME,
        SUM( UHARM_22_OVERTIME ) UHARM_22_OVERTIME,
        SUM( IHARM_22_OVERTIME ) IHARM_22_OVERTIME,
        SUM( UHARM_23_OVERTIME ) UHARM_23_OVERTIME,
        SUM( IHARM_23_OVERTIME ) IHARM_23_OVERTIME,
        SUM( UHARM_24_OVERTIME ) UHARM_24_OVERTIME,
        SUM( IHARM_24_OVERTIME ) IHARM_24_OVERTIME,
        SUM( UHARM_25_OVERTIME ) UHARM_25_OVERTIME,
        SUM( IHARM_25_OVERTIME ) IHARM_25_OVERTIME,
        SUM( VOLTAGE_DEV_OVERTIME ) VOLTAGE_DEV_OVERTIME,
        SUM( UABERRANCE_OVERTIME ) UABERRANCE_OVERTIME,
        SUM( UBALANCE_OVERTIME ) UBALANCE_OVERTIME,
        SUM( FLICKER_OVERTIME ) FLICKER_OVERTIME,
        SUM( flicker_all_time ) FLICKET_ALL_TIME,
        sum( Freq_Dev_OverTime ) FREQ_DEV_OVERTIME,
        SUM( ALL_TIME ) ALLTIME
        FROM
        r_stat_limit_target_d
        WHERE
        my_index in
        <foreach collection="lineIds" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        and time_id BETWEEN #{startTime} AND #{endTime}
        AND Phasic_Type = 'T'
        group by MY_INDEX
    </select>


    <select id="getLimitRateDataIHarm" resultType="map">
        select line_id MYINDEX,
        max( I_2 ) IHARM_2_OVERTIME,
        max( I_3 ) IHARM_3_OVERTIME,
        max( I_4 ) IHARM_4_OVERTIME,
        max( I_5 ) IHARM_5_OVERTIME,
        max( I_6 ) IHARM_6_OVERTIME,
        max( I_7 ) IHARM_7_OVERTIME,
        max( I_8 ) IHARM_8_OVERTIME,
        max( I_9 ) IHARM_9_OVERTIME,
        max( I_10 ) IHARM_10_OVERTIME,
        max( I_11 ) IHARM_11_OVERTIME,
        max( I_12 ) IHARM_12_OVERTIME,
        max( I_13 ) IHARM_13_OVERTIME,
        max( I_14 ) IHARM_14_OVERTIME,
        max( I_15 ) IHARM_15_OVERTIME,
        max( I_16 ) IHARM_16_OVERTIME,
        max( I_17 ) IHARM_17_OVERTIME,
        max( I_18 ) IHARM_18_OVERTIME,
        max( I_19 ) IHARM_19_OVERTIME,
        max( I_20 ) IHARM_20_OVERTIME,
        max( I_21 ) IHARM_21_OVERTIME,
        max( I_22 ) IHARM_22_OVERTIME,
        max( I_23 ) IHARM_23_OVERTIME,
        max( I_24 ) IHARM_24_OVERTIME,
        max( I_25 ) IHARM_25_OVERTIME
        FROM r_stat_data_i_d
        WHERE line_id in
        <foreach collection="lineIds" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        and time BETWEEN #{startTime} AND #{endTime}
        group by line_id
    </select>

</mapper>
