<?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.cloud.mapper.AppSteadyUrlMapper">

    <select id="getFreqDev"  resultType="com.njcn.cloud.pojo.vo.SteadyUrlData">
        SELECT
            time AS timeId,
            freq_dev AS `value`
        FROM
            r_stat_data_v_d
        <where>
            <if test="startTime != null and startTime != ''">
                and DATE_FORMAT(time, '%Y-%m-%d') >= DATE_FORMAT(#{startTime}, '%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and DATE_FORMAT(time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endTime}, '%Y-%m-%d')
            </if>
            AND line_id = #{lineIndex}
            AND  phasic_type = 'T'
            AND value_type = "MAX"
        </where>
        ORDER BY
            time ASC
    </select>

    <select id="getVUDev"  resultType="com.njcn.cloud.pojo.vo.SteadyUrlData">
        SELECT
            time AS timeId,
            vu_dev AS `value`
        FROM
            r_stat_data_v_d
        <where>
            <if test="startTime != null and startTime != ''">
                and DATE_FORMAT(time, '%Y-%m-%d') >= DATE_FORMAT(#{startTime}, '%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and DATE_FORMAT(time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endTime}, '%Y-%m-%d')
            </if>
            AND line_id = #{lineIndex}
            AND  phasic_type = 'T'
            AND value_type = "MAX"
        </where>
        ORDER BY
            time ASC
    </select>

    <select id="getVUnbalance"  resultType="com.njcn.cloud.pojo.vo.SteadyUrlData">
        SELECT
            time AS timeId,
            v_unbalance AS `value`
        FROM
            r_stat_data_v_d
        <where>
            <if test="startTime != null and startTime != ''">
                and DATE_FORMAT(time, '%Y-%m-%d') >= DATE_FORMAT(#{startTime}, '%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and DATE_FORMAT(time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endTime}, '%Y-%m-%d')
            </if>
            AND line_id = #{lineIndex}
            AND  phasic_type = 'T'
            AND value_type = "CP95"
        </where>
        ORDER BY
            time ASC
    </select>

    <select id="getPLT"  resultType="com.njcn.cloud.pojo.vo.SteadyUrlData">
        SELECT
            time AS timeId,
            pst AS `value`
        FROM
            r_stat_data_flicker_d
        <where>
            <if test="startTime != null and startTime != ''">
                and DATE_FORMAT(time, '%Y-%m-%d') >= DATE_FORMAT(#{startTime}, '%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and DATE_FORMAT(time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endTime}, '%Y-%m-%d')
            </if>
                AND line_id = #{lineIndex}
                AND phasic_type =#{type}
        </where>
        ORDER BY
         time ASC
    </select>

    <select id="getVTHD"  resultType="com.njcn.cloud.pojo.vo.SteadyUrlData">
        SELECT
            time AS timeId,
            v_thd AS `value`
        FROM
            r_stat_data_v_d
        <where>
            <if test="startTime != null and startTime != ''">
                and DATE_FORMAT(time, '%Y-%m-%d') >= DATE_FORMAT(#{startTime}, '%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and DATE_FORMAT(time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endTime}, '%Y-%m-%d')
            </if>
            AND line_id = #{lineIndex}
            AND phasic_type = #{type}
            AND value_type = "MAX"
        </where>
        ORDER BY
            time ASC
    </select>

    <select id="getVHarmRate"  resultType="com.njcn.cloud.pojo.vo.SteadyUrlData">
        SELECT
            time AS timeId,
            v_${number} AS `value`
        FROM
            r_stat_data_harmrate_v_d
        <where>
            phasic_type = #{type}
            AND value_type = "CP95"
            <if test="startTime != null and startTime != ''">
                and DATE_FORMAT(time, '%Y-%m-%d') >= DATE_FORMAT(#{startTime}, '%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and DATE_FORMAT(time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endTime}, '%Y-%m-%d')
            </if>
            AND line_id = #{lineIndex}
        </where>
        ORDER BY
            time ASC

    </select>

    <select id="getIHarmPhasic"  resultType="com.njcn.cloud.pojo.vo.SteadyUrlData">
        SELECT
            time AS timeId,
            i_${number} AS `value`
            FROM
            r_stat_data_harmrate_v_d
        <where>
            phasic_type = #{type}
            AND value_type = "CP95"
            <if test="startTime != null and startTime != ''">
                and DATE_FORMAT(time, '%Y-%m-%d') >= DATE_FORMAT(#{startTime}, '%Y-%m-%d')
            </if>
            <if test="endTime != null and endTime != ''">
                and DATE_FORMAT(time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endTime}, '%Y-%m-%d')
            </if>
            AND line_id = #{lineIndex}
        </where>
        ORDER BY
            time ASC
    </select>
</mapper>
