<?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.device.pms.mapper.majornetwork.RStatOrgMapper">

    <sql id="query_where">
        org_no IN
        <foreach collection="deptIds" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        <if test="startTime != null and startTime != ''">
            AND DATE_FORMAT(data_date, '%Y-%m-%d') &gt;= DATE_FORMAT(#{startTime}, '%Y-%m-%d')
        </if>
        <if test="endTime != null and endTime != ''">
            AND DATE_FORMAT(data_date, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endTime}, '%Y-%m-%d')
        </if>
    </sql>

    <sql id="query_field">
        org_no AS orgNo,
        data_date AS dataDate,
        effective_measurement_average AS effectiveMeasurementAverage,
        effective_measurement_accrued AS effectiveMeasurementAccrued,
        event_measurement_average AS eventMeasurementAverage,
        event_measurement_accrued AS eventMeasurementAccrued,
        event_count AS eventCount,
        event_freq AS eventFreq
    </sql>


    <!--获取年区域暂态指标统计-->
    <select id="getYearRStatOrgInfo" resultType="com.njcn.device.pms.pojo.vo.RStatOrgVO">
        SELECT
        <include refid="query_field"></include>
        FROM
        r_stat_org_y
        WHERE
        <include refid="query_where"></include>
    </select>

    <!--获取季区域暂态指标统计-->
    <select id="getQuarterRStatOrgInfo" resultType="com.njcn.device.pms.pojo.vo.RStatOrgVO">
        SELECT
        <include refid="query_field"></include>
        FROM
        r_stat_org_q
        WHERE
        <include refid="query_where"></include>
    </select>

    <!--获取月区域暂态指标统计-->
    <select id="getMonthRStatOrgInfo" resultType="com.njcn.device.pms.pojo.vo.RStatOrgVO">
        SELECT
        <include refid="query_field"></include>
        FROM
        r_stat_org_m
        WHERE
        <include refid="query_where"></include>
    </select>

</mapper>