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

    <select id="getHarmonicDetailMonthOne" resultType="com.njcn.harmonic.pojo.po.RMpPartHarmonicDetailM">
        select
        #{dataDate} dataDate,
        measurement_point_id measurementPointId,
        sum(is_harmonic) measurementOverDay,
        sum(is_freq) freqOverDay,
        sum(is_v_dev_up) vDevUpOverDay,
        sum(is_v_dev_low) vDevLowOverDay,
        sum(is_v_dev) vDevOverDay,
        sum(is_v_thd) vThdOverDay,
        sum(is_v) vOverDay,
        sum(is_i) iOverDay,
        sum(is_v_2) v2OverDay,
        sum(is_v_3) v3OverDay,
        sum(is_v_4) v4OverDay,
        sum(is_v_5) v5OverDay,
        sum(is_v_6) v6OverDay,
        sum(is_v_7) v7OverDay,
        sum(is_v_8) v8OverDay,
        sum(is_v_9) v9OverDay,
        sum(is_v_10) v10OverDay,
        sum(is_v_11) v11OverDay,
        sum(is_v_12) v12OverDay,
        sum(is_v_13) v13OverDay,
        sum(is_v_14) v14OverDay,
        sum(is_v_15) v15OverDay,
        sum(is_v_16) v16OverDay,
        sum(is_v_17) v17OverDay,
        sum(is_v_18) v18OverDay,
        sum(is_v_19) v19OverDay,
        sum(is_v_20) v20OverDay,
        sum(is_v_21) v21OverDay,
        sum(is_v_22) v22OverDay,
        sum(is_v_23) v23OverDay,
        sum(is_v_24) v24OverDay,
        sum(is_v_25) v25OverDay,
        sum(is_v_26) v26OverDay,
        sum(is_v_27) v27OverDay,
        sum(is_v_28) v28OverDay,
        sum(is_v_29) v29OverDay,
        sum(is_v_30) v30OverDay,
        sum(is_v_31) v31OverDay,
        sum(is_v_32) v32OverDay,
        sum(is_v_33) v33OverDay,
        sum(is_v_34) v34OverDay,
        sum(is_v_35) v35OverDay,
        sum(is_v_36) v36OverDay,
        sum(is_v_37) v37OverDay,
        sum(is_v_38) v38OverDay,
        sum(is_v_39) v39OverDay,
        sum(is_v_40) v40OverDay,
        sum(is_v_41) v41OverDay,
        sum(is_v_42) v42OverDay,
        sum(is_v_43) v43OverDay,
        sum(is_v_44) v44OverDay,
        sum(is_v_45) v45OverDay,
        sum(is_v_46) v46OverDay,
        sum(is_v_47) v47OverDay,
        sum(is_v_48) v48OverDay,
        sum(is_v_49) v49OverDay,
        sum(is_v_50) v50OverDay,
        sum(is_i_2) i2OverDay,
        sum(is_i_3) i3OverDay,
        sum(is_i_4) i4OverDay,
        sum(is_i_5) i5OverDay,
        sum(is_i_6) i6OverDay,
        sum(is_i_7) i7OverDay,
        sum(is_i_8) i8OverDay,
        sum(is_i_9) i9OverDay,
        sum(is_i_10) i10OverDay,
        sum(is_i_11) i11OverDay,
        sum(is_i_12) i12OverDay,
        sum(is_i_13) i13OverDay,
        sum(is_i_14) i14OverDay,
        sum(is_i_15) i15OverDay,
        sum(is_i_16) i16OverDay,
        sum(is_i_17) i17OverDay,
        sum(is_i_18) i18OverDay,
        sum(is_i_19) i19OverDay,
        sum(is_i_20) i20OverDay,
        sum(is_i_21) i21OverDay,
        sum(is_i_22) i22OverDay,
        sum(is_i_23) i23OverDay,
        sum(is_i_24) i24OverDay,
        sum(is_i_25) i25OverDay,
        sum(is_i_26) i26OverDay,
        sum(is_i_27) i27OverDay,
        sum(is_i_28) i28OverDay,
        sum(is_i_29) i29OverDay,
        sum(is_i_30) i30OverDay,
        sum(is_i_31) i31OverDay,
        sum(is_i_32) i32OverDay,
        sum(is_i_33) i33OverDay,
        sum(is_i_34) i34OverDay,
        sum(is_i_35) i35OverDay,
        sum(is_i_36) i36OverDay,
        sum(is_i_37) i37OverDay,
        sum(is_i_38) i38OverDay,
        sum(is_i_39) i39OverDay,
        sum(is_i_40) i40OverDay,
        sum(is_i_41) i41OverDay,
        sum(is_i_42) i42OverDay,
        sum(is_i_43) i43OverDay,
        sum(is_i_44) i44OverDay,
        sum(is_i_45) i45OverDay,
        sum(is_i_46) i46OverDay,
        sum(is_i_47) i47OverDay,
        sum(is_i_48) i48OverDay,
        sum(is_i_49) i49OverDay,
        sum(is_i_50) i50OverDay,
        sum(is_unbalance) unbalanceOverDay,
        sum(is_i_neg) iNegOverDay
        from
        r_mp_part_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="getPartSum" resultType="java.util.Map">
        SELECT
        count( CASE WHEN measurement_over_day > 0 THEN 1 END ) "measurementOverDayCount",
        count( CASE WHEN freq_over_day > 0 THEN 1 END ) "freqOverDayCount",
        count( CASE WHEN v_dev_over_day > 0 THEN 1 END ) "vDevOverDayCount",
        count( CASE WHEN v_over_day > 0 THEN 1 END ) "vOverDayCount",
        count( CASE WHEN i_over_day > 0 THEN 1 END ) "iOverDayCount",
        count( CASE WHEN unbalance_over_day > 0 THEN 1 END ) "unbalanceOverDayCount",
        count( CASE WHEN i_neg_over_day > 0 THEN 1 END ) "iNegOverDayCount"
        FROM
        r_mp_part_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>
