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

    <sql id="query_field">
        org_no AS orgNo,
        data_date AS dataDate,
        fundamental_voltage_abnormal AS fundamentalVoltageAbnormal,
        frequency_abnormal AS frequencyAbnormal,
        v_dev_abnormal AS vDevAbnormal,
        harmonic_voltage_abnormal AS harmonicVoltageAbnormal,
        centre_harmonic_voltage AS centreHarmonicVoltage,
        tp_voltage_unbalance AS tpVoltageUnbalance,
        v_dev_last_overlimit AS vDevLastOverlimit,
        traction_station_measurement_none AS tractionStationMeasurementNone,
        railway_fundamental_voltage_abnormal AS railwayFundamentalVoltageAbnormal,
        railway_fundamental_current_abnormal AS railwayFundamentalCurrentAbnormal,
        railway_total_active_power_abnormal AS railwayTotalActivePowerAbnormal,
        railway_harmonic_voltage_content_abnormal AS railwayHarmonicVoltageContentAbnormal,
        freq_upload_event AS freqUploadEvent,
        wave_upload_error AS waveUploadError,
        event_last_time_abnormal AS eventLastTimeAbnormal,
        event_type_amplitude_atypism AS eventTypeAmplitudeAtypism,
        event_type_amplitude_abnormal AS eventTypeAmplitudeAbnormal,
        event_phase_none AS eventPhaseNone,
        run_volatge_up AS runVolatgeUp,
        run_volatge_low AS runVolatgeLow,
        data_type AS dataType
    </sql>
    <sql id="query_where">
        org_no IN
        <foreach collection="deptIdList" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        AND data_type = #{mainnetPoint}
        <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="getRStatTargetCheckDataYearInfo" resultType="com.njcn.device.pms.pojo.vo.RStatTargetCheckDataVO">
        SELECT
        <include refid="query_field"></include>
        FROM
        r_stat_target_check_data_Y
        WHERE
        <include refid="query_where"></include>
    </select>

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

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