<?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.event.mapper.majornetwork.RStatSubstationVoltageMMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.njcn.event.pojo.po.RStatSubstationVoltageM">
        <id column="org_no" property="orgNo" />
        <result column="data_date" property="dataDate" />
        <result column="substation_voltage" property="substationVoltage" />
        <result column="substation_count" property="substationCount" />
        <result column="harmonic_count" property="harmonicCount" />
        <result column="event_count" property="eventCount" />
    </resultMap>
    <select id="getStatSubstationIcon" resultType="com.njcn.event.pojo.vo.RVoltageIconVO">
        SELECT
        substation_voltage as 'substationVoltage',
        sum( substation_count ) as 'substationCount',
        sum( event_count ) as 'harmonicCount'
        FROM
        r_stat_substation_voltage_m
        <where>
            <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  #{param.endTime} >= data_date
            </if>
        </where>
        GROUP BY substation_voltage
    </select>


</mapper>
