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

    <sql id="query_field">
        org_no AS orgNo,
        data_date AS dataDate,
        measurement_run_points AS measurementCount,
        effective_access_measurement_count AS effectiveAccessMeasurementCount,
        data_integrity_rate AS dataIntegrityRate,
        index_integrity_rate AS indexIntegrityRate,
        is_unusual AS isUnusual
    </sql>
    <sql id="query_where">
        org_no IN
        <foreach collection="deptIdList" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        <if test="param.startTime != null and param.startTime != ''">
            AND DATE_FORMAT(data_date, '%Y-%m-%d') &gt;= DATE_FORMAT(#{param.startTime}, '%Y-%m-%d')
        </if>
        <if test="param.endTime != null and param.endTime != ''">
            AND DATE_FORMAT(data_date, '%Y-%m-%d') &lt;= DATE_FORMAT(#{param.endTime}, '%Y-%m-%d')
        </if>
    </sql>


    <!--获取主网数据质量-监测指标数据质量统计（年）-->
    <select id="getYearInfo" resultType="com.njcn.device.pms.pojo.vo.ROperatingIndexVO">
        SELECT
        <include refid="query_field"></include>
        FROM
        r_operating_index_y
        WHERE
        <include refid="query_where"></include>
    </select>

    <!--获取主网数据质量-监测指标数据质量统计（季）-->
    <select id="getSeasonInfo" resultType="com.njcn.device.pms.pojo.vo.ROperatingIndexVO">
        SELECT
        <include refid="query_field"></include>
        FROM
        r_operating_index_q
        WHERE
        <include refid="query_where"></include>
    </select>

    <!--获取主网数据质量-监测指标数据质量统计（月）-->
    <select id="getMonthInfo" resultType="com.njcn.device.pms.pojo.vo.ROperatingIndexVO">
        SELECT
        <include refid="query_field"></include>
        FROM
        r_operating_index_m
        WHERE
        <include refid="query_where"></include>
    </select>
</mapper>