<?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.distribution.PwDataQualityCheckMapper">

    <sql id="query_field">
        org_no AS orgNo,
        data_date AS dataDate,
        dev_field_null AS devFieldNull,
        dev_run_time_abnormal AS devRunTimeAbnormal,
        dev_type_error AS devTypeError,
        dev_check_time_abnormal AS devCheckTimeAbnormal,
        dev_ip_error AS devIpError,
        measurement_field_null AS measurementFieldNull,
        measurement_name_abnormal AS measurementNameAbnormal,
        measurement_type_abnormal AS measurementTypeAbnormal,
        measurement_capacity_error AS measurementCapacityError,
        measurement_dev_not_match AS measurementDevNotMatch,
        measurement_type_error AS measurementTypeError,
        traction_station_measurement_redundancy AS tractionStationMeasurementRedundancy,
        railway_capacity_error AS railwayCapacityError,
        traction_station_measurement_missing AS tractionStationMeasurementMissing,
        data_type AS dataType
    </sql>
    <sql id="query_where">
        org_no IN
        <foreach collection="deptIds" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        <if test="distributionPoint != null and distributionPoint != '' ">
            AND data_type = #{distributionPoint}
        </if>
        <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.PwRStatAccountCheckDataVO">
        SELECT
        <include refid="query_field"></include>
        FROM
        r_stat_account_check_data_y
        WHERE
        <include refid="query_where"></include>
    </select>

    <!--获取配网数据质量-台帐类数据质量核查（季）-->
    <select id="getSeasonInfo" resultType="com.njcn.device.pms.pojo.vo.PwRStatAccountCheckDataVO">
        SELECT
        <include refid="query_field"></include>
        FROM
        r_stat_account_check_data_q
        WHERE
        <include refid="query_where"></include>
    </select>

    <!--获取配网数据质量-台帐类数据质量核查（月）-->
    <select id="getMonthInfo" resultType="com.njcn.device.pms.pojo.vo.PwRStatAccountCheckDataVO">
        SELECT
        <include refid="query_field"></include>
        FROM
        r_stat_account_check_data_m
        WHERE
        <include refid="query_where"></include>
    </select>
</mapper>
