<?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.majornetwork.RStatHarmonicDMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.njcn.harmonic.pojo.po.RStatHarmonicD">
        <id column="org_no" property="orgNo" />
        <result column="data_date" property="dataDate" />
        <result column="measurement_type_class" property="measurementTypeClass" />
        <result column="harmonic_type" property="harmonicType" />
        <result column="over_limit_measurement" property="overLimitMeasurement" />
        <result column="over_limit_measurement_ratio" property="overLimitMeasurementRatio" />
        <result column="data_type" property="dataType" />
    </resultMap>
    <select id="selectInfoList" resultType="com.njcn.harmonic.pojo.po.RStatHarmonicD">
        SELECT
            data_date,
            measurement_type_class,
            harmonic_type,
            sum(over_limit_measurement) as overLimitMeasurement,
            sum(over_limit_measurement_ratio) as overLimitMeasurementRatio
        FROM
            r_stat_harmonic_d
        <where>
            and data_Type=#{dataType}
            and measurement_type_class=#{measurementId}
            and harmonic_type=#{harmonicId}
            <if test="param != null and  param.ids != null and param.ids.size > 0">
                AND org_no IN
                <foreach collection='param.ids' item='item' index="index" open='(' separator=',' close=')'>
                    #{item}
                </foreach>
            </if>
            <if test="param!=null and param.startTime != null and param.startTime !=''">
                AND  data_date >= #{param.startTime}
            </if>
            <if test="param!=null and param.endTime != null and param.endTime != ''">
                AND  data_date &lt;= #{param.endTime}
            </if>
        </where>
        GROUP BY
            data_date,
            measurement_type_class,
            harmonic_type
    </select>

</mapper>
