<?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.AlarmsnapMapper">
  <resultMap id="BaseResultMap" type="com.gyee.frame.model.auto.Alarmsnap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="ID" jdbcType="DECIMAL" property="id" />
    <result column="STATIONID" jdbcType="VARCHAR" property="stationid" />
    <result column="PROJECTID" jdbcType="VARCHAR" property="projectid" />
    <result column="LINEID" jdbcType="VARCHAR" property="lineid" />
    <result column="WINDTURBINEID" jdbcType="VARCHAR" property="windturbineid" />
    <result column="ALERTVALUE" jdbcType="DECIMAL" property="alertvalue" />
    <result column="CATEGORY1" jdbcType="VARCHAR" property="category1" />
    <result column="CATEGORY2" jdbcType="VARCHAR" property="category2" />
    <result column="CATEGORY3" jdbcType="VARCHAR" property="category3" />
    <result column="RANK" jdbcType="VARCHAR" property="rank" />
    <result column="ISOPENED" jdbcType="DECIMAL" property="isopened" />
    <result column="STATIONNAME" jdbcType="VARCHAR" property="stationname" />
    <result column="PROJECTNAME" jdbcType="VARCHAR" property="projectname" />
    <result column="LINENAME" jdbcType="VARCHAR" property="linename" />
    <result column="WINDTURBINENAME" jdbcType="VARCHAR" property="windturbinename" />
    <result column="ALERTTEXT" jdbcType="VARCHAR" property="alerttext" />
    <result column="MODELID" jdbcType="VARCHAR" property="modelid" />
    <result column="TESTINGPOINTKEY" jdbcType="VARCHAR" property="testingpointkey" />
    <result column="LASTUPDATETIME" jdbcType="TIMESTAMP" property="lastupdatetime" />
    <result column="DATAINFO" jdbcType="VARCHAR" property="datainfo" />
  </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, STATIONID, PROJECTID, LINEID, WINDTURBINEID, ALERTVALUE, CATEGORY1, CATEGORY2, 
    CATEGORY3, RANK, ISOPENED, STATIONNAME, PROJECTNAME, LINENAME, WINDTURBINENAME, ALERTTEXT, 
    MODELID, TESTINGPOINTKEY, LASTUPDATETIME, DATAINFO
  </sql>
  <select id="selectByExample" parameterType="com.gyee.frame.model.auto.AlarmsnapExample" 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 ALARMSNAP
    <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.Short" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select 
    <include refid="Base_Column_List" />
    from ALARMSNAP
    where ID = #{id,jdbcType=DECIMAL}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Short">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from ALARMSNAP
    where ID = #{id,jdbcType=DECIMAL}
  </delete>
  <delete id="deleteByExample" parameterType="com.gyee.frame.model.auto.AlarmsnapExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from ALARMSNAP
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.gyee.frame.model.auto.Alarmsnap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into ALARMSNAP (ID, STATIONID, PROJECTID, 
      LINEID, WINDTURBINEID, ALERTVALUE, 
      CATEGORY1, CATEGORY2, CATEGORY3, 
      RANK, ISOPENED, STATIONNAME, 
      PROJECTNAME, LINENAME, WINDTURBINENAME, 
      ALERTTEXT, MODELID, TESTINGPOINTKEY, 
      LASTUPDATETIME, DATAINFO)
    values (#{id,jdbcType=DECIMAL}, #{stationid,jdbcType=VARCHAR}, #{projectid,jdbcType=VARCHAR}, 
      #{lineid,jdbcType=VARCHAR}, #{windturbineid,jdbcType=VARCHAR}, #{alertvalue,jdbcType=DECIMAL}, 
      #{category1,jdbcType=VARCHAR}, #{category2,jdbcType=VARCHAR}, #{category3,jdbcType=VARCHAR}, 
      #{rank,jdbcType=VARCHAR}, #{isopened,jdbcType=DECIMAL}, #{stationname,jdbcType=VARCHAR}, 
      #{projectname,jdbcType=VARCHAR}, #{linename,jdbcType=VARCHAR}, #{windturbinename,jdbcType=VARCHAR}, 
      #{alerttext,jdbcType=VARCHAR}, #{modelid,jdbcType=VARCHAR}, #{testingpointkey,jdbcType=VARCHAR}, 
      #{lastupdatetime,jdbcType=TIMESTAMP}, #{datainfo,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.gyee.frame.model.auto.Alarmsnap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into ALARMSNAP
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="stationid != null">
        STATIONID,
      </if>
      <if test="projectid != null">
        PROJECTID,
      </if>
      <if test="lineid != null">
        LINEID,
      </if>
      <if test="windturbineid != null">
        WINDTURBINEID,
      </if>
      <if test="alertvalue != null">
        ALERTVALUE,
      </if>
      <if test="category1 != null">
        CATEGORY1,
      </if>
      <if test="category2 != null">
        CATEGORY2,
      </if>
      <if test="category3 != null">
        CATEGORY3,
      </if>
      <if test="rank != null">
        RANK,
      </if>
      <if test="isopened != null">
        ISOPENED,
      </if>
      <if test="stationname != null">
        STATIONNAME,
      </if>
      <if test="projectname != null">
        PROJECTNAME,
      </if>
      <if test="linename != null">
        LINENAME,
      </if>
      <if test="windturbinename != null">
        WINDTURBINENAME,
      </if>
      <if test="alerttext != null">
        ALERTTEXT,
      </if>
      <if test="modelid != null">
        MODELID,
      </if>
      <if test="testingpointkey != null">
        TESTINGPOINTKEY,
      </if>
      <if test="lastupdatetime != null">
        LASTUPDATETIME,
      </if>
      <if test="datainfo != null">
        DATAINFO,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=DECIMAL},
      </if>
      <if test="stationid != null">
        #{stationid,jdbcType=VARCHAR},
      </if>
      <if test="projectid != null">
        #{projectid,jdbcType=VARCHAR},
      </if>
      <if test="lineid != null">
        #{lineid,jdbcType=VARCHAR},
      </if>
      <if test="windturbineid != null">
        #{windturbineid,jdbcType=VARCHAR},
      </if>
      <if test="alertvalue != null">
        #{alertvalue,jdbcType=DECIMAL},
      </if>
      <if test="category1 != null">
        #{category1,jdbcType=VARCHAR},
      </if>
      <if test="category2 != null">
        #{category2,jdbcType=VARCHAR},
      </if>
      <if test="category3 != null">
        #{category3,jdbcType=VARCHAR},
      </if>
      <if test="rank != null">
        #{rank,jdbcType=VARCHAR},
      </if>
      <if test="isopened != null">
        #{isopened,jdbcType=DECIMAL},
      </if>
      <if test="stationname != null">
        #{stationname,jdbcType=VARCHAR},
      </if>
      <if test="projectname != null">
        #{projectname,jdbcType=VARCHAR},
      </if>
      <if test="linename != null">
        #{linename,jdbcType=VARCHAR},
      </if>
      <if test="windturbinename != null">
        #{windturbinename,jdbcType=VARCHAR},
      </if>
      <if test="alerttext != null">
        #{alerttext,jdbcType=VARCHAR},
      </if>
      <if test="modelid != null">
        #{modelid,jdbcType=VARCHAR},
      </if>
      <if test="testingpointkey != null">
        #{testingpointkey,jdbcType=VARCHAR},
      </if>
      <if test="lastupdatetime != null">
        #{lastupdatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="datainfo != null">
        #{datainfo,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.gyee.frame.model.auto.AlarmsnapExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select count(*) from ALARMSNAP
    <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 ALARMSNAP
    <set>
      <if test="record.id != null">
        ID = #{record.id,jdbcType=DECIMAL},
      </if>
      <if test="record.stationid != null">
        STATIONID = #{record.stationid,jdbcType=VARCHAR},
      </if>
      <if test="record.projectid != null">
        PROJECTID = #{record.projectid,jdbcType=VARCHAR},
      </if>
      <if test="record.lineid != null">
        LINEID = #{record.lineid,jdbcType=VARCHAR},
      </if>
      <if test="record.windturbineid != null">
        WINDTURBINEID = #{record.windturbineid,jdbcType=VARCHAR},
      </if>
      <if test="record.alertvalue != null">
        ALERTVALUE = #{record.alertvalue,jdbcType=DECIMAL},
      </if>
      <if test="record.category1 != null">
        CATEGORY1 = #{record.category1,jdbcType=VARCHAR},
      </if>
      <if test="record.category2 != null">
        CATEGORY2 = #{record.category2,jdbcType=VARCHAR},
      </if>
      <if test="record.category3 != null">
        CATEGORY3 = #{record.category3,jdbcType=VARCHAR},
      </if>
      <if test="record.rank != null">
        RANK = #{record.rank,jdbcType=VARCHAR},
      </if>
      <if test="record.isopened != null">
        ISOPENED = #{record.isopened,jdbcType=DECIMAL},
      </if>
      <if test="record.stationname != null">
        STATIONNAME = #{record.stationname,jdbcType=VARCHAR},
      </if>
      <if test="record.projectname != null">
        PROJECTNAME = #{record.projectname,jdbcType=VARCHAR},
      </if>
      <if test="record.linename != null">
        LINENAME = #{record.linename,jdbcType=VARCHAR},
      </if>
      <if test="record.windturbinename != null">
        WINDTURBINENAME = #{record.windturbinename,jdbcType=VARCHAR},
      </if>
      <if test="record.alerttext != null">
        ALERTTEXT = #{record.alerttext,jdbcType=VARCHAR},
      </if>
      <if test="record.modelid != null">
        MODELID = #{record.modelid,jdbcType=VARCHAR},
      </if>
      <if test="record.testingpointkey != null">
        TESTINGPOINTKEY = #{record.testingpointkey,jdbcType=VARCHAR},
      </if>
      <if test="record.lastupdatetime != null">
        LASTUPDATETIME = #{record.lastupdatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.datainfo != null">
        DATAINFO = #{record.datainfo,jdbcType=VARCHAR},
      </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 ALARMSNAP
    set ID = #{record.id,jdbcType=DECIMAL},
      STATIONID = #{record.stationid,jdbcType=VARCHAR},
      PROJECTID = #{record.projectid,jdbcType=VARCHAR},
      LINEID = #{record.lineid,jdbcType=VARCHAR},
      WINDTURBINEID = #{record.windturbineid,jdbcType=VARCHAR},
      ALERTVALUE = #{record.alertvalue,jdbcType=DECIMAL},
      CATEGORY1 = #{record.category1,jdbcType=VARCHAR},
      CATEGORY2 = #{record.category2,jdbcType=VARCHAR},
      CATEGORY3 = #{record.category3,jdbcType=VARCHAR},
      RANK = #{record.rank,jdbcType=VARCHAR},
      ISOPENED = #{record.isopened,jdbcType=DECIMAL},
      STATIONNAME = #{record.stationname,jdbcType=VARCHAR},
      PROJECTNAME = #{record.projectname,jdbcType=VARCHAR},
      LINENAME = #{record.linename,jdbcType=VARCHAR},
      WINDTURBINENAME = #{record.windturbinename,jdbcType=VARCHAR},
      ALERTTEXT = #{record.alerttext,jdbcType=VARCHAR},
      MODELID = #{record.modelid,jdbcType=VARCHAR},
      TESTINGPOINTKEY = #{record.testingpointkey,jdbcType=VARCHAR},
      LASTUPDATETIME = #{record.lastupdatetime,jdbcType=TIMESTAMP},
      DATAINFO = #{record.datainfo,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.gyee.frame.model.auto.Alarmsnap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update ALARMSNAP
    <set>
      <if test="stationid != null">
        STATIONID = #{stationid,jdbcType=VARCHAR},
      </if>
      <if test="projectid != null">
        PROJECTID = #{projectid,jdbcType=VARCHAR},
      </if>
      <if test="lineid != null">
        LINEID = #{lineid,jdbcType=VARCHAR},
      </if>
      <if test="windturbineid != null">
        WINDTURBINEID = #{windturbineid,jdbcType=VARCHAR},
      </if>
      <if test="alertvalue != null">
        ALERTVALUE = #{alertvalue,jdbcType=DECIMAL},
      </if>
      <if test="category1 != null">
        CATEGORY1 = #{category1,jdbcType=VARCHAR},
      </if>
      <if test="category2 != null">
        CATEGORY2 = #{category2,jdbcType=VARCHAR},
      </if>
      <if test="category3 != null">
        CATEGORY3 = #{category3,jdbcType=VARCHAR},
      </if>
      <if test="rank != null">
        RANK = #{rank,jdbcType=VARCHAR},
      </if>
      <if test="isopened != null">
        ISOPENED = #{isopened,jdbcType=DECIMAL},
      </if>
      <if test="stationname != null">
        STATIONNAME = #{stationname,jdbcType=VARCHAR},
      </if>
      <if test="projectname != null">
        PROJECTNAME = #{projectname,jdbcType=VARCHAR},
      </if>
      <if test="linename != null">
        LINENAME = #{linename,jdbcType=VARCHAR},
      </if>
      <if test="windturbinename != null">
        WINDTURBINENAME = #{windturbinename,jdbcType=VARCHAR},
      </if>
      <if test="alerttext != null">
        ALERTTEXT = #{alerttext,jdbcType=VARCHAR},
      </if>
      <if test="modelid != null">
        MODELID = #{modelid,jdbcType=VARCHAR},
      </if>
      <if test="testingpointkey != null">
        TESTINGPOINTKEY = #{testingpointkey,jdbcType=VARCHAR},
      </if>
      <if test="lastupdatetime != null">
        LASTUPDATETIME = #{lastupdatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="datainfo != null">
        DATAINFO = #{datainfo,jdbcType=VARCHAR},
      </if>
    </set>
    where ID = #{id,jdbcType=DECIMAL}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.gyee.frame.model.auto.Alarmsnap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update ALARMSNAP
    set STATIONID = #{stationid,jdbcType=VARCHAR},
      PROJECTID = #{projectid,jdbcType=VARCHAR},
      LINEID = #{lineid,jdbcType=VARCHAR},
      WINDTURBINEID = #{windturbineid,jdbcType=VARCHAR},
      ALERTVALUE = #{alertvalue,jdbcType=DECIMAL},
      CATEGORY1 = #{category1,jdbcType=VARCHAR},
      CATEGORY2 = #{category2,jdbcType=VARCHAR},
      CATEGORY3 = #{category3,jdbcType=VARCHAR},
      RANK = #{rank,jdbcType=VARCHAR},
      ISOPENED = #{isopened,jdbcType=DECIMAL},
      STATIONNAME = #{stationname,jdbcType=VARCHAR},
      PROJECTNAME = #{projectname,jdbcType=VARCHAR},
      LINENAME = #{linename,jdbcType=VARCHAR},
      WINDTURBINENAME = #{windturbinename,jdbcType=VARCHAR},
      ALERTTEXT = #{alerttext,jdbcType=VARCHAR},
      MODELID = #{modelid,jdbcType=VARCHAR},
      TESTINGPOINTKEY = #{testingpointkey,jdbcType=VARCHAR},
      LASTUPDATETIME = #{lastupdatetime,jdbcType=TIMESTAMP},
      DATAINFO = #{datainfo,jdbcType=VARCHAR}
    where ID = #{id,jdbcType=DECIMAL}
  </update>

  <select id="getAlarmhistoryList"  resultType="com.gyee.frame.model.custom.TotalNumVo">

    select   b.windturbineid wtId,b.alertvalue number  from  #{tablename}  a,alarmsnap b
    where   a.snapid = b.id and category1='windturbine' and   b.category2 is not null
    and  b.category2!='other'  and a.alerttime>= #{beginDate}
    and a.alerttime &lt; #{endDate}
    group by b.windturbineid, b.alertvalue order by b.windturbineid

  </select>

  <select id="findAlertrulefailuresubMap"  resultType="com.gyee.frame.model.custom.TotalNumVo">

   select t.altype typeId,r.ednavalue number,r.id,t.name from alertrule2 r,alertrulefailuresub t where t.tid=r.id and t.altype is not null

  </select>

</mapper>