<?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.gyee.frame.mapper.auto.WarningRecordsMapper">
  <resultMap id="BaseResultMap" type="com.gyee.frame.model.auto.WarningRecords">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="windPowerStationId" jdbcType="VARCHAR" property="windpowerstationid" />
    <result column="windTurbineId" jdbcType="VARCHAR" property="windturbineid" />
    <result column="warningId" jdbcType="VARCHAR" property="warningid" />
    <result column="warningTime" jdbcType="TIMESTAMP" property="warningtime" />
    <result column="isConfirm" jdbcType="SMALLINT" property="isconfirm" />
    <result column="isHandle" jdbcType="SMALLINT" property="ishandle" />
    <result column="handle" jdbcType="VARCHAR" property="handle" />
    <result column="shutdownEventId" jdbcType="VARCHAR" property="shutdowneventid" />
    <result column="levelId" jdbcType="VARCHAR" property="levelid" />
    <result column="wtAiId" jdbcType="VARCHAR" property="wtaiid" />
    <result column="durationHour" jdbcType="DECIMAL" property="durationhour" />
    <result column="isFilter" jdbcType="SMALLINT" property="isfilter" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    id, windPowerStationId, windTurbineId, warningId, warningTime, isConfirm, isHandle, 
    handle, shutdownEventId, levelId, wtAiId, durationHour, isFilter
  </sql>
  <select id="selectByExample" parameterType="com.gyee.frame.model.auto.WarningRecordsExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from warningrecords
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select 
    <include refid="Base_Column_List" />
    from warningrecords
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from warningrecords
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.gyee.frame.model.auto.WarningRecordsExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from warningrecords
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.gyee.frame.model.auto.WarningRecords">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into warningrecords (id, windPowerStationId, windTurbineId, 
      warningId, warningTime, isConfirm, 
      isHandle, handle, shutdownEventId, 
      levelId, wtAiId, durationHour, 
      isFilter)
    values (#{id,jdbcType=INTEGER}, #{windpowerstationid,jdbcType=VARCHAR}, #{windturbineid,jdbcType=VARCHAR}, 
      #{warningid,jdbcType=VARCHAR}, #{warningtime,jdbcType=TIMESTAMP}, #{isconfirm,jdbcType=SMALLINT}, 
      #{ishandle,jdbcType=SMALLINT}, #{handle,jdbcType=VARCHAR}, #{shutdowneventid,jdbcType=VARCHAR}, 
      #{levelid,jdbcType=VARCHAR}, #{wtaiid,jdbcType=VARCHAR}, #{durationhour,jdbcType=DECIMAL}, 
      #{isfilter,jdbcType=SMALLINT})
  </insert>
  <insert id="insertSelective" parameterType="com.gyee.frame.model.auto.WarningRecords">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into warningrecords
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="windpowerstationid != null">
        windPowerStationId,
      </if>
      <if test="windturbineid != null">
        windTurbineId,
      </if>
      <if test="warningid != null">
        warningId,
      </if>
      <if test="warningtime != null">
        warningTime,
      </if>
      <if test="isconfirm != null">
        isConfirm,
      </if>
      <if test="ishandle != null">
        isHandle,
      </if>
      <if test="handle != null">
        handle,
      </if>
      <if test="shutdowneventid != null">
        shutdownEventId,
      </if>
      <if test="levelid != null">
        levelId,
      </if>
      <if test="wtaiid != null">
        wtAiId,
      </if>
      <if test="durationhour != null">
        durationHour,
      </if>
      <if test="isfilter != null">
        isFilter,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="windpowerstationid != null">
        #{windpowerstationid,jdbcType=VARCHAR},
      </if>
      <if test="windturbineid != null">
        #{windturbineid,jdbcType=VARCHAR},
      </if>
      <if test="warningid != null">
        #{warningid,jdbcType=VARCHAR},
      </if>
      <if test="warningtime != null">
        #{warningtime,jdbcType=TIMESTAMP},
      </if>
      <if test="isconfirm != null">
        #{isconfirm,jdbcType=SMALLINT},
      </if>
      <if test="ishandle != null">
        #{ishandle,jdbcType=SMALLINT},
      </if>
      <if test="handle != null">
        #{handle,jdbcType=VARCHAR},
      </if>
      <if test="shutdowneventid != null">
        #{shutdowneventid,jdbcType=VARCHAR},
      </if>
      <if test="levelid != null">
        #{levelid,jdbcType=VARCHAR},
      </if>
      <if test="wtaiid != null">
        #{wtaiid,jdbcType=VARCHAR},
      </if>
      <if test="durationhour != null">
        #{durationhour,jdbcType=DECIMAL},
      </if>
      <if test="isfilter != null">
        #{isfilter,jdbcType=SMALLINT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.gyee.frame.model.auto.WarningRecordsExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select count(*) from warningrecords
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update warningrecords
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.windpowerstationid != null">
        windPowerStationId = #{record.windpowerstationid,jdbcType=VARCHAR},
      </if>
      <if test="record.windturbineid != null">
        windTurbineId = #{record.windturbineid,jdbcType=VARCHAR},
      </if>
      <if test="record.warningid != null">
        warningId = #{record.warningid,jdbcType=VARCHAR},
      </if>
      <if test="record.warningtime != null">
        warningTime = #{record.warningtime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.isconfirm != null">
        isConfirm = #{record.isconfirm,jdbcType=SMALLINT},
      </if>
      <if test="record.ishandle != null">
        isHandle = #{record.ishandle,jdbcType=SMALLINT},
      </if>
      <if test="record.handle != null">
        handle = #{record.handle,jdbcType=VARCHAR},
      </if>
      <if test="record.shutdowneventid != null">
        shutdownEventId = #{record.shutdowneventid,jdbcType=VARCHAR},
      </if>
      <if test="record.levelid != null">
        levelId = #{record.levelid,jdbcType=VARCHAR},
      </if>
      <if test="record.wtaiid != null">
        wtAiId = #{record.wtaiid,jdbcType=VARCHAR},
      </if>
      <if test="record.durationhour != null">
        durationHour = #{record.durationhour,jdbcType=DECIMAL},
      </if>
      <if test="record.isfilter != null">
        isFilter = #{record.isfilter,jdbcType=SMALLINT},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update warningrecords
    set id = #{record.id,jdbcType=INTEGER},
      windPowerStationId = #{record.windpowerstationid,jdbcType=VARCHAR},
      windTurbineId = #{record.windturbineid,jdbcType=VARCHAR},
      warningId = #{record.warningid,jdbcType=VARCHAR},
      warningTime = #{record.warningtime,jdbcType=TIMESTAMP},
      isConfirm = #{record.isconfirm,jdbcType=SMALLINT},
      isHandle = #{record.ishandle,jdbcType=SMALLINT},
      handle = #{record.handle,jdbcType=VARCHAR},
      shutdownEventId = #{record.shutdowneventid,jdbcType=VARCHAR},
      levelId = #{record.levelid,jdbcType=VARCHAR},
      wtAiId = #{record.wtaiid,jdbcType=VARCHAR},
      durationHour = #{record.durationhour,jdbcType=DECIMAL},
      isFilter = #{record.isfilter,jdbcType=SMALLINT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.gyee.frame.model.auto.WarningRecords">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update warningrecords
    <set>
      <if test="windpowerstationid != null">
        windPowerStationId = #{windpowerstationid,jdbcType=VARCHAR},
      </if>
      <if test="windturbineid != null">
        windTurbineId = #{windturbineid,jdbcType=VARCHAR},
      </if>
      <if test="warningid != null">
        warningId = #{warningid,jdbcType=VARCHAR},
      </if>
      <if test="warningtime != null">
        warningTime = #{warningtime,jdbcType=TIMESTAMP},
      </if>
      <if test="isconfirm != null">
        isConfirm = #{isconfirm,jdbcType=SMALLINT},
      </if>
      <if test="ishandle != null">
        isHandle = #{ishandle,jdbcType=SMALLINT},
      </if>
      <if test="handle != null">
        handle = #{handle,jdbcType=VARCHAR},
      </if>
      <if test="shutdowneventid != null">
        shutdownEventId = #{shutdowneventid,jdbcType=VARCHAR},
      </if>
      <if test="levelid != null">
        levelId = #{levelid,jdbcType=VARCHAR},
      </if>
      <if test="wtaiid != null">
        wtAiId = #{wtaiid,jdbcType=VARCHAR},
      </if>
      <if test="durationhour != null">
        durationHour = #{durationhour,jdbcType=DECIMAL},
      </if>
      <if test="isfilter != null">
        isFilter = #{isfilter,jdbcType=SMALLINT},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.gyee.frame.model.auto.WarningRecords">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update warningrecords
    set windPowerStationId = #{windpowerstationid,jdbcType=VARCHAR},
      windTurbineId = #{windturbineid,jdbcType=VARCHAR},
      warningId = #{warningid,jdbcType=VARCHAR},
      warningTime = #{warningtime,jdbcType=TIMESTAMP},
      isConfirm = #{isconfirm,jdbcType=SMALLINT},
      isHandle = #{ishandle,jdbcType=SMALLINT},
      handle = #{handle,jdbcType=VARCHAR},
      shutdownEventId = #{shutdowneventid,jdbcType=VARCHAR},
      levelId = #{levelid,jdbcType=VARCHAR},
      wtAiId = #{wtaiid,jdbcType=VARCHAR},
      durationHour = #{durationhour,jdbcType=DECIMAL},
      isFilter = #{isfilter,jdbcType=SMALLINT}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="countWpwarnByWp"  resultType="com.gyee.frame.model.custom.SimpleVo">

    select t.windpowerstationid id,count(*) value from warningrecords t
    where  instr(t.windpowerstationid,'_FDC')>0
    and t.warningtime >= (select max(warningtime)-7 from warningrecords)
    and t.warningtime &lt;= (select max(warningtime) from warningrecords)  group by t.windpowerstationid
  </select>

  <select id="countWpwarnByPj"  resultType="com.gyee.frame.model.custom.SimpleVo">
select t1.projectid  id,count(*) value from warningrecords t,windturbine t1 where  instr(t.windpowerstationid,'_FDC')>0
    and t.warningtime >= (select max(warningtime)-7 from warningrecords)
    and t.warningtime &lt;= (select max(warningtime) from warningrecords) and t.windturbineid = t1.id group by t1.projectid  order by t1.projectid

  </select>
</mapper>