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

    <select id="getAvgCount" resultType="com.njcn.harmonic.pojo.po.PQSComAssesPO">
        SELECT
            line_id,
            AVG ( vu_dev1 ) AS vu_dev1,
            AVG ( vu_dev2 ) AS vu_dev2,
            AVG ( vu_dev3 ) AS vu_dev3,
            AVG ( vu_dev4 ) AS vu_dev4,
            AVG ( vu_dev5 ) AS vu_dev5,
            AVG ( freq_dev1 ) AS freq_dev1,
            AVG ( freq_dev2 ) AS freq_dev2,
            AVG ( freq_dev3 ) AS freq_dev3,
            AVG ( freq_dev4 ) AS freq_dev4,
            AVG ( freq_dev5 ) AS freq_dev5,
            AVG ( data_plt1 ) AS data_plt1,
            AVG ( data_plt2 ) AS data_plt2,
            AVG ( data_plt3 ) AS data_plt3,
            AVG ( data_plt4 ) AS data_plt4,
            AVG ( data_plt5 ) AS data_plt5,
            AVG ( v_unbalance1 ) AS v_unbalance1,
            AVG ( v_unbalance2 ) AS v_unbalance2,
            AVG ( v_unbalance3 ) AS v_unbalance3,
            AVG ( v_unbalance4 ) AS v_unbalance4,
            AVG ( v_unbalance5 ) AS v_unbalance5,
            AVG ( v_thd1 ) AS v_thd1,
            AVG ( v_thd2 ) AS v_thd2,
            AVG ( v_thd3 ) AS v_thd3,
            AVG ( v_thd4 ) AS v_thd4,
            AVG ( v_thd5 ) AS v_thd5,
            AVG ( event1 ) AS event1,
            AVG ( event2 ) AS event2,
            AVG ( event3 ) AS event3,
            AVG ( event4 ) AS event4,
            AVG ( event5 ) AS event5
        FROM
            r_stat_comasses_d
        <where>
            <if test=" ids != null and ids.size > 0">
                AND line_id IN
                <foreach collection='ids' item='item' index="index" open='(' separator=',' close=')'>
                    #{item}
                </foreach>
            </if>
            <if test=" statTime != null and statTime !=''">
                AND  time_id >= #{statTime}
            </if>
            <if test="endTime != null and endTime != ''">
                AND  time_id &lt;= #{endTime}
            </if>
        </where>
        GROUP BY line_id

    </select>
</mapper>
