<?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.RStatLimitTargetDMapper">

    <select id="getSumV" resultType="com.njcn.harmonic.pojo.po.day.RStatLimitTargetDPO">
        SELECT
            my_index as lineId,
            sum( uaberrance_overtime ) +
            sum( uharm_2_overtime ) +
            sum( uharm_3_overtime ) +
            sum( uharm_4_overtime ) +
            sum( uharm_5_overtime ) +
            sum( uharm_6_overtime ) +
            sum( uharm_7_overtime ) +
            sum( uharm_8_overtime ) +
            sum( uharm_9_overtime ) +
            sum( uharm_10_overtime )+
            sum( uharm_11_overtime )+
            sum( uharm_12_overtime )+
            sum( uharm_13_overtime )+
            sum( uharm_14_overtime )+
            sum( uharm_15_overtime )+
            sum( uharm_16_overtime )+
            sum( uharm_17_overtime )+
            sum( uharm_18_overtime )+
            sum( uharm_19_overtime )+
            sum( uharm_20_overtime )+
            sum( uharm_21_overtime )+
            sum( uharm_22_overtime )+
            sum( uharm_23_overtime )+
            sum( uharm_24_overtime )+
            sum( uharm_25_overtime ) allTime,
            sum( uaberrance_overtime ) AS uaberrance_overtime,
            sum( uharm_2_overtime ) AS uharm_2_overtime,
            sum( uharm_3_overtime ) AS uharm_3_overtime,
            sum( uharm_4_overtime ) AS uharm_4_overtime,
            sum( uharm_5_overtime ) AS uharm_5_overtime,
            sum( uharm_6_overtime ) AS uharm_6_overtime,
            sum( uharm_7_overtime ) AS uharm_7_overtime,
            sum( uharm_8_overtime ) AS uharm_8_overtime,
            sum( uharm_9_overtime ) AS uharm_9_overtime,
            sum( uharm_10_overtime ) AS uharm_10_overtime,
            sum( uharm_11_overtime ) AS uharm_11_overtime,
            sum( uharm_12_overtime ) AS uharm_12_overtime,
            sum( uharm_13_overtime ) AS uharm_13_overtime,
            sum( uharm_14_overtime ) AS uharm_14_overtime,
            sum( uharm_15_overtime ) AS uharm_15_overtime,
            sum( uharm_16_overtime ) AS uharm_16_overtime,
            sum( uharm_17_overtime ) AS uharm_17_overtime,
            sum( uharm_18_overtime ) AS uharm_18_overtime,
            sum( uharm_19_overtime ) AS uharm_19_overtime,
            sum( uharm_20_overtime ) AS uharm_20_overtime,
            sum( uharm_21_overtime ) AS uharm_21_overtime,
            sum( uharm_22_overtime ) AS uharm_22_overtime,
            sum( uharm_23_overtime ) AS uharm_23_overtime,
            sum( uharm_24_overtime ) AS uharm_24_overtime,
            sum( uharm_25_overtime ) AS uharm_25_overtime
        FROM
            r_stat_limit_target_d
        <where>
            <if test=" ids != null and ids.size > 0">
                AND my_index IN
                <foreach collection='ids' item='item' index="index" open='(' separator=',' close=')'>
                    #{item}
                </foreach>
            </if>
            <if test=" startTime != null and startTime !=''">
                AND  time_id >= #{startTime}
            </if>
            <if test="endTime != null and endTime != ''">
                AND  time_id &lt;= #{endTime}
            </if>
        </where>
        GROUP BY
            my_index
    </select>
    <select id="getSumI" resultType="com.njcn.harmonic.pojo.po.day.RStatLimitTargetDPO">
        SELECT
        my_index as lineId,
        sum( iharm_2_overtime ) +
        sum( iharm_3_overtime ) +
        sum( iharm_4_overtime ) +
        sum( iharm_5_overtime ) +
        sum( iharm_6_overtime ) +
        sum( iharm_7_overtime ) +
        sum( iharm_8_overtime ) +
        sum( iharm_9_overtime ) +
        sum( iharm_10_overtime ) +
        sum( iharm_11_overtime ) +
        sum( iharm_12_overtime ) +
        sum( iharm_13_overtime ) +
        sum( iharm_14_overtime ) +
        sum( iharm_15_overtime ) +
        sum( iharm_16_overtime ) +
        sum( iharm_17_overtime ) +
        sum( iharm_18_overtime ) +
        sum( iharm_19_overtime ) +
        sum( iharm_20_overtime ) +
        sum( iharm_21_overtime ) +
        sum( iharm_22_overtime ) +
        sum( iharm_23_overtime ) +
        sum( iharm_24_overtime ) +
        sum( iharm_25_overtime ) allTime,
        sum( iharm_2_overtime ) AS iharm_2_overtime,
        sum( iharm_3_overtime ) AS iharm_3_overtime,
        sum( iharm_4_overtime ) AS iharm_4_overtime,
        sum( iharm_5_overtime ) AS iharm_5_overtime,
        sum( iharm_6_overtime ) AS iharm_6_overtime,
        sum( iharm_7_overtime ) AS iharm_7_overtime,
        sum( iharm_8_overtime ) AS iharm_8_overtime,
        sum( iharm_9_overtime ) AS iharm_9_overtime,
        sum( iharm_10_overtime ) AS iharm_10_overtime,
        sum( iharm_11_overtime ) AS iharm_11_overtime,
        sum( iharm_12_overtime ) AS iharm_12_overtime,
        sum( iharm_13_overtime ) AS iharm_13_overtime,
        sum( iharm_14_overtime ) AS iharm_14_overtime,
        sum( iharm_15_overtime ) AS iharm_15_overtime,
        sum( iharm_16_overtime ) AS iharm_16_overtime,
        sum( iharm_17_overtime ) AS iharm_17_overtime,
        sum( iharm_18_overtime ) AS iharm_18_overtime,
        sum( iharm_19_overtime ) AS iharm_19_overtime,
        sum( iharm_20_overtime ) AS iharm_20_overtime,
        sum( iharm_21_overtime ) AS iharm_21_overtime,
        sum( iharm_22_overtime ) AS iharm_22_overtime,
        sum( iharm_23_overtime ) AS iharm_23_overtime,
        sum( iharm_24_overtime ) AS iharm_24_overtime,
        sum( iharm_25_overtime ) AS iharm_25_overtime
        FROM
        r_stat_limit_target_d
        <where>
            <if test=" ids != null and ids.size > 0">
                AND my_index IN
                <foreach collection='ids' item='item' index="index" open='(' separator=',' close=')'>
                    #{item}
                </foreach>
            </if>
            <if test=" startTime != null and startTime !=''">
                AND  time_id >= #{startTime}
            </if>
            <if test="endTime != null and endTime != ''">
                AND  time_id &lt;= #{endTime}
            </if>
        </where>
        GROUP BY
        my_index
    </select>
    <select id="getSumAddV" resultType="java.lang.Integer">
        SELECT
        sum( uaberrance_overtime ) +
        sum( uharm_2_overtime ) +
        sum( uharm_3_overtime ) +
        sum( uharm_4_overtime ) +
        sum( uharm_5_overtime ) +
        sum( uharm_6_overtime ) +
        sum( uharm_7_overtime ) +
        sum( uharm_8_overtime ) +
        sum( uharm_9_overtime ) +
        sum( uharm_10_overtime )+
        sum( uharm_11_overtime )+
        sum( uharm_12_overtime )+
        sum( uharm_13_overtime )+
        sum( uharm_14_overtime )+
        sum( uharm_15_overtime )+
        sum( uharm_16_overtime )+
        sum( uharm_17_overtime )+
        sum( uharm_18_overtime )+
        sum( uharm_19_overtime )+
        sum( uharm_20_overtime )+
        sum( uharm_21_overtime )+
        sum( uharm_22_overtime )+
        sum( uharm_23_overtime )+
        sum( uharm_24_overtime )+
        sum( uharm_25_overtime )
        FROM
        r_stat_limit_target_d
        <where>
            <if test=" ids != null and ids.size > 0">
                AND my_index IN
                <foreach collection='ids' item='item' index="index" open='(' separator=',' close=')'>
                    #{item}
                </foreach>
            </if>
            <if test=" startTime != null and startTime !=''">
                AND  time_id >= #{startTime}
            </if>
            <if test="endTime != null and endTime != ''">
                AND  time_id &lt;= #{endTime}
            </if>
        </where>
    </select>
    <select id="getSumAddI" resultType="java.lang.Integer">
        SELECT
        sum( iharm_2_overtime ) +
        sum( iharm_3_overtime ) +
        sum( iharm_4_overtime ) +
        sum( iharm_5_overtime ) +
        sum( iharm_6_overtime ) +
        sum( iharm_7_overtime ) +
        sum( iharm_8_overtime ) +
        sum( iharm_9_overtime ) +
        sum( iharm_10_overtime ) +
        sum( iharm_11_overtime ) +
        sum( iharm_12_overtime ) +
        sum( iharm_13_overtime ) +
        sum( iharm_14_overtime ) +
        sum( iharm_15_overtime ) +
        sum( iharm_16_overtime ) +
        sum( iharm_17_overtime ) +
        sum( iharm_18_overtime ) +
        sum( iharm_19_overtime ) +
        sum( iharm_20_overtime ) +
        sum( iharm_21_overtime ) +
        sum( iharm_22_overtime ) +
        sum( iharm_23_overtime ) +
        sum( iharm_24_overtime ) +
        sum( iharm_25_overtime )
        FROM
        r_stat_limit_target_d
        <where>
            <if test=" ids != null and ids.size > 0">
                AND my_index IN
                <foreach collection='ids' item='item' index="index" open='(' separator=',' close=')'>
                    #{item}
                </foreach>
            </if>
            <if test=" startTime != null and startTime !=''">
                AND  time_id >= #{startTime}
            </if>
            <if test="endTime != null and endTime != ''">
                AND  time_id &lt;= #{endTime}
            </if>
        </where>
    </select>
    <select id="getLinesTarget" resultType="java.lang.String">
        select
            my_index
        from (
            SELECT
                my_index,
                sum( all_time ) AS allCount
            FROM
                r_stat_limit_target_d
            <where>
                <if test=" ids != null and ids.size > 0">
                    AND my_index IN
                    <foreach collection='ids' item='item' index="index" open='(' separator=',' close=')'>
                        #{item}
                    </foreach>
                </if>
                <if test=" startTime != null and startTime !=''">
                    AND  time_id >= #{startTime}
                </if>
                <if test="endTime != null and endTime != ''">
                    AND  time_id &lt;= #{endTime}
                </if>
            </where>
            GROUP BY
                my_index
            HAVING
            allCount >0) a
    </select>
</mapper>
