<?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.HistoryDataMapper'>

    <select id="getDataV" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
            TIMEID as timeId,
            PHASIC_TYPE as phasicType,
            <if test="param.valueTypeName == ''">
                sum(RMS) as aValue
            </if>
            <if test="param.valueTypeName == 'MAX'">
                sum(RMS_MAX) as aValue
            </if>
            <if test="param.valueTypeName == 'MIN'">
                sum(RMS_MIN) as aValue
            </if>
            <if test="param.valueTypeName == 'CP95'">
                sum(RMS_CP95) as aValue
            </if>
        from
            data_v
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type!='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>

    </select>
    <select id="getDataV_lvr" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
            TIMEID as timeId,
            PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(RMSAB) as aValue,
            sum(RMSBC) as bValue,
            sum(RMSCA) as cValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(RMSAB_MAX) as aValue,
            sum(RMSBC_MAX) as bValue,
            sum(RMSCA_MAX) as cValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(RMSAB_MIN) as aValue,
            sum(RMSBC_MIN) as bValue,
            sum(RMSCA_MIN) as cValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(RMSAB_CP95) as aValue,
            sum(RMSBC_CP95) as bValue,
            sum(RMSCA_CP95) as cValue
        </if>
        from
            data_v
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type!='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataV_vu_dev" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
            TIMEID as timeId,
            PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(VU_Dev) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(VU_Dev_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(VU_Dev_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(VU_Dev_CP95) as aValue
        </if>
        from
            data_v
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type!='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataV_v_unbalance" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
            TIMEID as timeId,
            PHASIC_TYPE as phasicType,
            <if test="param.valueTypeName == ''">
                sum(V_Unbalance) as aValue
            </if>
            <if test="param.valueTypeName == 'MAX'">
                sum(V_Unbalance_MAX) as aValue
            </if>
            <if test="param.valueTypeName == 'MIN'">
                sum(V_Unbalance_MIN) as aValue
            </if>
            <if test="param.valueTypeName == 'CP95'">
                sum(V_Unbalance_CP95) as aValue
        </if>
        from
            data_v
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type ='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>

    </select>
    <select id="getDataV_v_zero" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
            TIMEID as timeId,
            PHASIC_TYPE as phasicType,
            <if test="param.valueTypeName == ''">
                sum(v_zero) as aValue,
                sum(v_pos) as bValue,
                sum(v_neg) as cValue
            </if>
            <if test="param.valueTypeName == 'MAX'">
                sum(v_zero_MAX) as aValue,
                sum(v_pos_MAX) as bValue,
                sum(v_neg_MAX) as cValue
            </if>
            <if test="param.valueTypeName == 'MIN'">
                sum(v_zero_MIN) as aValue,
                sum(v_pos_MIN) as bValue,
                sum(v_neg_MIN) as cValue
            </if>
            <if test="param.valueTypeName == 'CP95'">
                sum(v_zero_CP95) as aValue,
                sum(v_pos_CP95) as bValue,
                sum(v_neg_CP95) as cValue
            </if>
        from
            data_v
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type ='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataV_v_thd" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(v_thd) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(v_thd_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(v_thd_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(v_thd_CP95) as aValue
        </if>
        from
        data_v
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataI_rms" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
            TIMEID as timeId,
            PHASIC_TYPE as phasicType,
            <if test="param.valueTypeName == ''">
                sum(RMS) as aValue
            </if>
            <if test="param.valueTypeName == 'MAX'">
                sum(RMS_MAX) as aValue
            </if>
            <if test="param.valueTypeName == 'MIN'">
                sum(RMS_MIN) as aValue
            </if>
            <if test="param.valueTypeName == 'CP95'">
                sum(RMS_CP95) as aValue
            </if>
        from
            data_i
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type!='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataI_i_thd" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
            TIMEID as timeId,
            PHASIC_TYPE as phasicType,
            <if test="param.valueTypeName == ''">
                sum(I_THD) as aValue
            </if>
            <if test="param.valueTypeName == 'MAX'">
                sum(I_THD_MAX) as aValue
            </if>
            <if test="param.valueTypeName == 'MIN'">
                sum(I_THD_MIN) as aValue
            </if>
            <if test="param.valueTypeName == 'CP95'">
                sum(I_THD_CP95) as aValue
            </if>
        from
            data_i
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type!='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataI_i_neg" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
            TIMEID as timeId,
            PHASIC_TYPE as phasicType,
            <if test="param.valueTypeName == ''">
                sum(I_NEG) as aValue
            </if>
            <if test="param.valueTypeName == 'MAX'">
                sum(I_NEG_MAX) as aValue
            </if>
            <if test="param.valueTypeName == 'MIN'">
                sum(I_NEG_MIN) as aValue
            </if>
            <if test="param.valueTypeName == 'CP95'">
                sum(I_NEG_CP95) as aValue
            </if>
        from
            data_i
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type!='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataV_i_neg" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
            TIMEID as timeId,
            PHASIC_TYPE as phasicType,
            <if test="param.valueTypeName == ''">
                sum(FREQ) as aValue
            </if>
            <if test="param.valueTypeName == 'MAX'">
                sum(FREQ_MAX) as aValue
            </if>
            <if test="param.valueTypeName == 'MIN'">
                sum(FREQ_MIN) as aValue
            </if>
            <if test="param.valueTypeName == 'CP95'">
                sum(FREQ_CP95) as aValue
            </if>
        from
            data_v
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type ='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmratV_v" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
            TIMEID as timeId,
            PHASIC_TYPE as phasicType,
            <if test="param.valueTypeName == ''">
                sum(v_${number}) as aValue
            </if>
            <if test="param.valueTypeName == 'MAX'">
                sum(v_${number}_MAX) as aValue
            </if>
            <if test="param.valueTypeName == 'MIN'">
                sum(v_${number}_MIN) as aValue
            </if>
            <if test="param.valueTypeName == 'CP95'">
                sum(v_${number}_CP95) as aValue
            </if>
        from
            data_harmrate_v
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmratI_i" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(i_${number}) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(i_${number}_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(i_${number}_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(i_${number}_CP95) as aValue
        </if>
        from
        data_harmrate_i
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataV_v" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
            TIMEID as timeId,
            PHASIC_TYPE as phasicType,
            <if test="param.valueTypeName == ''">
                sum(v_${number}) as aValue
            </if>
            <if test="param.valueTypeName == 'MAX'">
                sum(v_${number}_MAX) as aValue
            </if>
            <if test="param.valueTypeName == 'MIN'">
                sum(v_${number}_MIN) as aValue
            </if>
            <if test="param.valueTypeName == 'CP95'">
                sum(v_${number}_CP95) as aValue
            </if>
        from
            data_v
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataI_i" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(i_${number}) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(i_${number}_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(i_${number}_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(i_${number}_CP95) as aValue
        </if>
        from
        data_i
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmphasic_v" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(v_${number}) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(v_${number}_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(v_${number}_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(v_${number}_CP95) as aValue
        </if>
        from
        data_harmphasic_v
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmphasic_i" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(i_${number}) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(i_${number}_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(i_${number}_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(i_${number}_CP95) as aValue
        </if>
        from
        data_harmphasic_i
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataInharmrateV_v" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(v_${number}) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(v_${number}_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(v_${number}_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(v_${number}_CP95) as aValue
        </if>
        from
        data_inharm_v
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataInharmrateI_i" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(i_${number}) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(i_${number}_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(i_${number}_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(i_${number}_CP95) as aValue
        </if>
        from
        data_inharm_i
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmpowerP_p" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(p_${number}) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(p_${number}_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(p_${number}_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(p_${number}_CP95) as aValue
        </if>
        from
            data_harmpower_p
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmpowerQ_q" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(q_${number}) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(q_${number}_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(q_${number}_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(q_${number}_CP95) as aValue
        </if>
        from
        data_harmpower_q
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmpowerS_s" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(s_${number}) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(s_${number}_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(s_${number}_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(s_${number}_CP95) as aValue
        </if>
        from
        data_harmpower_s
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmpowerP" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(p) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(p_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(p_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(p_CP95) as aValue
        </if>
        from
        data_harmpower_p
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmpowerQ" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(q) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(q_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(q_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(q_CP95) as aValue
        </if>
        from
        data_harmpower_q
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmpowerS" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(s) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(s_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(s_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(s_CP95) as aValue
        </if>
        from
        data_harmpower_s
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmpowerP_t" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(p) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(p_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(p_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(p_CP95) as aValue
        </if>
        from
        data_harmpower_p
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type ='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmpowerQ_t" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(q) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(q_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(q_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(q_CP95) as aValue
        </if>
        from
        data_harmpower_q
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type ='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmpowerS_t" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(s) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(s_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(s_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(s_CP95) as aValue
        </if>
        from
        data_harmpower_s
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type ='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmpowerP_pf" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(pf) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(pf_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(pf_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(pf_CP95) as aValue
        </if>
        from
        data_harmpower_p
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmpowerP_df" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(df) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(df_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(df_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(df_CP95) as aValue
        </if>
        from
        data_harmpower_p
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type !='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmpowerP_pf_T" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(pf) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(pf_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(pf_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(pf_CP95) as aValue
        </if>
        from
        data_harmpower_p
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type ='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataHarmpowerP_df_T" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        <if test="param.valueTypeName == ''">
            sum(df) as aValue
        </if>
        <if test="param.valueTypeName == 'MAX'">
            sum(df_MAX) as aValue
        </if>
        <if test="param.valueTypeName == 'MIN'">
            sum(df_MIN) as aValue
        </if>
        <if test="param.valueTypeName == 'CP95'">
            sum(df_CP95) as aValue
        </if>
        from
        data_harmpower_p
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type ='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataPlt" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        sum(plt) as aValue
        from
        data_plt
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type!='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataFlicker" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        sum(pst) as aValue
        from
        data_flicker
        <where>
            timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
            and phasic_type!='T'
            and lineid = #{param.lineId}
            group by timeid,PHASIC_TYPE
            order by timeId asc
        </where>
    </select>
    <select id="getDataFluc" resultType="com.njcn.influx.pojo.bo.HarmonicHistoryData">
        select
        TIMEID as timeId,
        PHASIC_TYPE as phasicType,
        sum(fluc) as aValue
        from
        data_fluc
        <where>
        timeId between to_date(#{param.startTime},'yyyy-mm-DD hh24:mi:ss') and to_date(#{param.endTime},'yyyy-mm-DD hh24:mi:ss')
        and phasic_type!='T'
        and lineid = #{param.lineId}
        group by timeid,PHASIC_TYPE
        order by timeId asc
        </where>
    </select>
</mapper>
