<?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.prepare.harmonic.mapper.mysql.line.RMpSurplusHarmonicDetailMMapper">

    <select id="getHarmonicDetailMonthTwo" resultType="com.njcn.harmonic.pojo.po.RMpSurplusHarmonicDetailM">
        select
            #{dataDate} dataDate,
            measurement_point_id measurementPointId,
            sum(is_flicker) flickerOverDay,
            sum(is_inuharm) inuharmOverDay,
            sum(is_inuharm_1) inuharm1OverDay,
            sum(is_inuharm_2) inuharm2OverDay,
            sum(is_inuharm_3) inuharm3OverDay,
            sum(is_inuharm_4) inuharm4OverDay,
            sum(is_inuharm_5) inuharm5OverDay,
            sum(is_inuharm_6) inuharm6OverDay,
            sum(is_inuharm_7) inuharm7OverDay,
            sum(is_inuharm_8) inuharm8OverDay,
            sum(is_inuharm_9) inuharm9OverDay,
            sum(is_inuharm_10) inuharm10OverDay,
            sum(is_inuharm_11) inuharm11OverDay,
            sum(is_inuharm_12) inuharm12OverDay,
            sum(is_inuharm_13) inuharm13OverDay,
            sum(is_inuharm_14) inuharm14OverDay,
            sum(is_inuharm_15) inuharm15OverDay,
            sum(is_inuharm_16) inuharm16OverDay,
            sum(is_inuharm_17) inuharm17OverDay,
            sum(is_inuharm_18) inuharm18OverDay,
            sum(is_inuharm_19) inuharm19OverDay,
            sum(is_inuharm_20) inuharm20OverDay,
            sum(is_inuharm_21) inuharm21OverDay,
            sum(is_inuharm_22) inuharm22OverDay,
            sum(is_inuharm_23) inuharm23OverDay,
            sum(is_inuharm_24) inuharm24OverDay,
            sum(is_inuharm_25) inuharm25OverDay,
            sum(is_inuharm_26) inuharm26OverDay,
            sum(is_inuharm_27) inuharm27OverDay,
            sum(is_inuharm_28) inuharm28OverDay,
            sum(is_inuharm_29) inuharm29OverDay,
            sum(is_inuharm_30) inuharm30OverDay,
            sum(is_inuharm_31) inuharm31OverDay,
            sum(is_inuharm_32) inuharm32OverDay,
            sum(is_inuharm_33) inuharm33OverDay,
            sum(is_inuharm_34) inuharm34OverDay,
            sum(is_inuharm_35) inuharm35OverDay,
            sum(is_inuharm_36) inuharm36OverDay,
            sum(is_inuharm_37) inuharm37OverDay,
            sum(is_inuharm_38) inuharm38OverDay,
            sum(is_inuharm_39) inuharm39OverDay,
            sum(is_inuharm_40) inuharm40OverDay,
            sum(is_inuharm_41) inuharm41OverDay,
            sum(is_inuharm_42) inuharm42OverDay,
            sum(is_inuharm_43) inuharm43OverDay,
            sum(is_inuharm_44) inuharm44OverDay,
            sum(is_inuharm_45) inuharm45OverDay,
            sum(is_inuharm_46) inuharm46OverDay,
            sum(is_inuharm_47) inuharm47OverDay,
            sum(is_inuharm_48) inuharm48OverDay,
            sum(is_inuharm_49) inuharm49OverDay,
            sum(is_inuharm_50) inuharm50OverDay
        from
            r_mp_surplus_harmonic_detail_d
        where
            data_date between #{startTime} and #{endTime}
            <if test="lineList != null and lineList.size() > 0">
                and measurement_point_id in
                <foreach collection="lineList" item="item" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
        group by
            measurement_point_id
    </select>

    <select id="getSurplusSum" resultType="java.util.Map">
        SELECT
            count( CASE WHEN flicker_over_day > 0 THEN 1 END ) "flickerOverDayCount",
            count( CASE WHEN inuharm_over_day > 0 THEN 1 END ) "inuharmOverDayCount"
        FROM
            r_mp_surplus_harmonic_detail_m
        WHERE
        measurement_point_id in
        <foreach collection="lineIds" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        AND data_date between #{startTime} and #{endTime}
    </select>

</mapper>
