<?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.ScadafaultMapper">
  <resultMap id="BaseResultMap" type="com.gyee.frame.model.auto.Scadafault">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="ID" jdbcType="DECIMAL" property="id" />
    <result column="POINTKEY" jdbcType="VARCHAR" property="pointkey" />
    <result column="DESCRIPTION" jdbcType="VARCHAR" property="description" />
    <result column="CATEGORY1" jdbcType="VARCHAR" property="category1" />
    <result column="CATEGORY2" jdbcType="VARCHAR" property="category2" />
    <result column="CATEGORY3" jdbcType="VARCHAR" property="category3" />
    <result column="CATEGORY4" jdbcType="VARCHAR" property="category4" />
    <result column="STATIONID" jdbcType="VARCHAR" property="stationid" />
    <result column="DEVICEID" jdbcType="VARCHAR" property="deviceid" />
    <result column="RANK" jdbcType="VARCHAR" property="rank" />
    <result column="ENABLED" jdbcType="DECIMAL" property="enabled" />
  </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, POINTKEY, DESCRIPTION, CATEGORY1, CATEGORY2, CATEGORY3, CATEGORY4, STATIONID, 
    DEVICEID, RANK, ENABLED
  </sql>
  <select id="selectByExample" parameterType="com.gyee.frame.model.auto.ScadafaultExample" 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 SCADAFAULT
    <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 SCADAFAULT
    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 SCADAFAULT
    where ID = #{id,jdbcType=DECIMAL}
  </delete>
  <delete id="deleteByExample" parameterType="com.gyee.frame.model.auto.ScadafaultExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from SCADAFAULT
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.gyee.frame.model.auto.Scadafault">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into SCADAFAULT (ID, POINTKEY, DESCRIPTION, 
      CATEGORY1, CATEGORY2, CATEGORY3, 
      CATEGORY4, STATIONID, DEVICEID, 
      RANK, ENABLED)
    values (#{id,jdbcType=DECIMAL}, #{pointkey,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, 
      #{category1,jdbcType=VARCHAR}, #{category2,jdbcType=VARCHAR}, #{category3,jdbcType=VARCHAR}, 
      #{category4,jdbcType=VARCHAR}, #{stationid,jdbcType=VARCHAR}, #{deviceid,jdbcType=VARCHAR}, 
      #{rank,jdbcType=VARCHAR}, #{enabled,jdbcType=DECIMAL})
  </insert>
  <insert id="insertSelective" parameterType="com.gyee.frame.model.auto.Scadafault">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into SCADAFAULT
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="pointkey != null">
        POINTKEY,
      </if>
      <if test="description != null">
        DESCRIPTION,
      </if>
      <if test="category1 != null">
        CATEGORY1,
      </if>
      <if test="category2 != null">
        CATEGORY2,
      </if>
      <if test="category3 != null">
        CATEGORY3,
      </if>
      <if test="category4 != null">
        CATEGORY4,
      </if>
      <if test="stationid != null">
        STATIONID,
      </if>
      <if test="deviceid != null">
        DEVICEID,
      </if>
      <if test="rank != null">
        RANK,
      </if>
      <if test="enabled != null">
        ENABLED,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=DECIMAL},
      </if>
      <if test="pointkey != null">
        #{pointkey,jdbcType=VARCHAR},
      </if>
      <if test="description != null">
        #{description,jdbcType=VARCHAR},
      </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="category4 != null">
        #{category4,jdbcType=VARCHAR},
      </if>
      <if test="stationid != null">
        #{stationid,jdbcType=VARCHAR},
      </if>
      <if test="deviceid != null">
        #{deviceid,jdbcType=VARCHAR},
      </if>
      <if test="rank != null">
        #{rank,jdbcType=VARCHAR},
      </if>
      <if test="enabled != null">
        #{enabled,jdbcType=DECIMAL},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.gyee.frame.model.auto.ScadafaultExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select count(*) from SCADAFAULT
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>

    <select id="selectByGZ" resultType="com.gyee.frame.model.auto.FaultInfo">
      SELECT
        h.id,h.faultTime,h.messageType,h.snapID,s.stationId,s.projectId,s.lineId,
            s.windturbineId,s.alertValue,s.rank,s.category1,s.category2,s.category3,
            s.isOpened,s.stationName,s.windturbineName,s.alertText,s.modelId
      FROM
        faulthistory h left join faultsnap s on h.snapid = s.id
      where s.category2='GZ'
        AND h.faultTime >= #{faulttime}
      order by h.faultTime desc
    </select>

    <update id="updateByExampleSelective" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update SCADAFAULT
    <set>
      <if test="record.id != null">
        ID = #{record.id,jdbcType=DECIMAL},
      </if>
      <if test="record.pointkey != null">
        POINTKEY = #{record.pointkey,jdbcType=VARCHAR},
      </if>
      <if test="record.description != null">
        DESCRIPTION = #{record.description,jdbcType=VARCHAR},
      </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.category4 != null">
        CATEGORY4 = #{record.category4,jdbcType=VARCHAR},
      </if>
      <if test="record.stationid != null">
        STATIONID = #{record.stationid,jdbcType=VARCHAR},
      </if>
      <if test="record.deviceid != null">
        DEVICEID = #{record.deviceid,jdbcType=VARCHAR},
      </if>
      <if test="record.rank != null">
        RANK = #{record.rank,jdbcType=VARCHAR},
      </if>
      <if test="record.enabled != null">
        ENABLED = #{record.enabled,jdbcType=DECIMAL},
      </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 SCADAFAULT
    set ID = #{record.id,jdbcType=DECIMAL},
      POINTKEY = #{record.pointkey,jdbcType=VARCHAR},
      DESCRIPTION = #{record.description,jdbcType=VARCHAR},
      CATEGORY1 = #{record.category1,jdbcType=VARCHAR},
      CATEGORY2 = #{record.category2,jdbcType=VARCHAR},
      CATEGORY3 = #{record.category3,jdbcType=VARCHAR},
      CATEGORY4 = #{record.category4,jdbcType=VARCHAR},
      STATIONID = #{record.stationid,jdbcType=VARCHAR},
      DEVICEID = #{record.deviceid,jdbcType=VARCHAR},
      RANK = #{record.rank,jdbcType=VARCHAR},
      ENABLED = #{record.enabled,jdbcType=DECIMAL}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.gyee.frame.model.auto.Scadafault">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update SCADAFAULT
    <set>
      <if test="pointkey != null">
        POINTKEY = #{pointkey,jdbcType=VARCHAR},
      </if>
      <if test="description != null">
        DESCRIPTION = #{description,jdbcType=VARCHAR},
      </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="category4 != null">
        CATEGORY4 = #{category4,jdbcType=VARCHAR},
      </if>
      <if test="stationid != null">
        STATIONID = #{stationid,jdbcType=VARCHAR},
      </if>
      <if test="deviceid != null">
        DEVICEID = #{deviceid,jdbcType=VARCHAR},
      </if>
      <if test="rank != null">
        RANK = #{rank,jdbcType=VARCHAR},
      </if>
      <if test="enabled != null">
        ENABLED = #{enabled,jdbcType=DECIMAL},
      </if>
    </set>
    where ID = #{id,jdbcType=DECIMAL}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.gyee.frame.model.auto.Scadafault">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update SCADAFAULT
    set POINTKEY = #{pointkey,jdbcType=VARCHAR},
      DESCRIPTION = #{description,jdbcType=VARCHAR},
      CATEGORY1 = #{category1,jdbcType=VARCHAR},
      CATEGORY2 = #{category2,jdbcType=VARCHAR},
      CATEGORY3 = #{category3,jdbcType=VARCHAR},
      CATEGORY4 = #{category4,jdbcType=VARCHAR},
      STATIONID = #{stationid,jdbcType=VARCHAR},
      DEVICEID = #{deviceid,jdbcType=VARCHAR},
      RANK = #{rank,jdbcType=VARCHAR},
      ENABLED = #{enabled,jdbcType=DECIMAL}
    where ID = #{id,jdbcType=DECIMAL}
  </update>
</mapper>