<?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.ShutdowneventMapper">
<!--  <cache type="org.mybatis.caches.ehcache.EhcacheCache">-->
<!--    <property name="timeToIdleSeconds" value="60"></property>&lt;!&ndash;&lt;!&ndash;当缓存闲置60秒后销毁&ndash;&gt;&ndash;&gt;-->
<!--    <property name="timeToLiveSeconds" value="160"></property>&lt;!&ndash;&lt;!&ndash;缓存存在160秒后销毁&ndash;&gt;&ndash;&gt;-->
<!--    <property name="maxEntriesLocalHeap" value="1000"></property>-->
<!--    <property name="maxEntriesLocalDisk" value="10000000"></property>-->
<!--    <property name="memoryStoreEvictionPolicy" value="LRU"></property>-->
<!--  </cache>-->
  <resultMap id="BaseResultMap" type="com.gyee.frame.model.auto.Shutdownevent">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="windPowerStationId" jdbcType="VARCHAR" property="windpowerstationid" />
    <result column="windTurbineId" jdbcType="VARCHAR" property="windturbineid" />
    <result column="stopTime" jdbcType="TIMESTAMP" property="stoptime" />
    <result column="startTime" jdbcType="TIMESTAMP" property="starttime" />
    <result column="stopHours" jdbcType="DECIMAL" property="stophours" />
    <result column="lossPower" jdbcType="DECIMAL" property="losspower" />
    <result column="stopTypeId" jdbcType="VARCHAR" property="stoptypeid" />
    <result column="isHandle" jdbcType="SMALLINT" property="ishandle" />
    <result column="warningId" jdbcType="VARCHAR" property="warningid" />
    <result column="projectId" jdbcType="VARCHAR" property="projectid" />
    <result column="handleWay" jdbcType="VARCHAR" property="handleway" />
    <result column="faultView" jdbcType="VARCHAR" property="faultview" />
    <result column="statusCode" jdbcType="INTEGER" property="statuscode" />
    <result column="mainId" jdbcType="VARCHAR" property="mainid" />
    <result column="resetRate" jdbcType="VARCHAR" property="resetrate" />
    <result column="stateRate" jdbcType="VARCHAR" property="staterate" />
    <result column="failRate" jdbcType="VARCHAR" property="failrate" />
    <result column="warningRecordsId" jdbcType="INTEGER" property="warningrecordsid" />
  </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.dateValue">
                  and ${criterion.condition} to_date(#{criterion.value},'yyyy-MM-dd')
                </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, stopTime, startTime, stopHours, lossPower, 
    stopTypeId, isHandle, warningId, projectId, handleWay, faultView, statusCode, mainId, 
    resetRate, stateRate, failRate, warningRecordsId
  </sql>
  <select id="selectByExample" parameterType="com.gyee.frame.model.auto.ShutdowneventExample" 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 shutdownevent
    <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.String" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select 
    <include refid="Base_Column_List" />
    from shutdownevent
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from shutdownevent
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.gyee.frame.model.auto.ShutdowneventExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from shutdownevent
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.gyee.frame.model.auto.Shutdownevent">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into shutdownevent (id, windPowerStationId, windTurbineId, 
      stopTime, startTime, stopHours, 
      lossPower, stopTypeId, isHandle, 
      warningId, projectId, handleWay, 
      faultView, statusCode, mainId, 
      resetRate, stateRate, failRate, 
      warningRecordsId)
    values (#{id,jdbcType=VARCHAR}, #{windpowerstationid,jdbcType=VARCHAR}, #{windturbineid,jdbcType=VARCHAR}, 
      #{stoptime,jdbcType=TIMESTAMP}, #{starttime,jdbcType=TIMESTAMP}, #{stophours,jdbcType=DECIMAL}, 
      #{losspower,jdbcType=DECIMAL}, #{stoptypeid,jdbcType=VARCHAR}, #{ishandle,jdbcType=SMALLINT}, 
      #{warningid,jdbcType=VARCHAR}, #{projectid,jdbcType=VARCHAR}, #{handleway,jdbcType=VARCHAR}, 
      #{faultview,jdbcType=VARCHAR}, #{statuscode,jdbcType=INTEGER}, #{mainid,jdbcType=VARCHAR}, 
      #{resetrate,jdbcType=VARCHAR}, #{staterate,jdbcType=VARCHAR}, #{failrate,jdbcType=VARCHAR}, 
      #{warningrecordsid,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.gyee.frame.model.auto.Shutdownevent">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into shutdownevent
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="windpowerstationid != null">
        windPowerStationId,
      </if>
      <if test="windturbineid != null">
        windTurbineId,
      </if>
      <if test="stoptime != null">
        stopTime,
      </if>
      <if test="starttime != null">
        startTime,
      </if>
      <if test="stophours != null">
        stopHours,
      </if>
      <if test="losspower != null">
        lossPower,
      </if>
      <if test="stoptypeid != null">
        stopTypeId,
      </if>
      <if test="ishandle != null">
        isHandle,
      </if>
      <if test="warningid != null">
        warningId,
      </if>
      <if test="projectid != null">
        projectId,
      </if>
      <if test="handleway != null">
        handleWay,
      </if>
      <if test="faultview != null">
        faultView,
      </if>
      <if test="statuscode != null">
        statusCode,
      </if>
      <if test="mainid != null">
        mainId,
      </if>
      <if test="resetrate != null">
        resetRate,
      </if>
      <if test="staterate != null">
        stateRate,
      </if>
      <if test="failrate != null">
        failRate,
      </if>
      <if test="warningrecordsid != null">
        warningRecordsId,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="windpowerstationid != null">
        #{windpowerstationid,jdbcType=VARCHAR},
      </if>
      <if test="windturbineid != null">
        #{windturbineid,jdbcType=VARCHAR},
      </if>
      <if test="stoptime != null">
        #{stoptime,jdbcType=TIMESTAMP},
      </if>
      <if test="starttime != null">
        #{starttime,jdbcType=TIMESTAMP},
      </if>
      <if test="stophours != null">
        #{stophours,jdbcType=DECIMAL},
      </if>
      <if test="losspower != null">
        #{losspower,jdbcType=DECIMAL},
      </if>
      <if test="stoptypeid != null">
        #{stoptypeid,jdbcType=VARCHAR},
      </if>
      <if test="ishandle != null">
        #{ishandle,jdbcType=SMALLINT},
      </if>
      <if test="warningid != null">
        #{warningid,jdbcType=VARCHAR},
      </if>
      <if test="projectid != null">
        #{projectid,jdbcType=VARCHAR},
      </if>
      <if test="handleway != null">
        #{handleway,jdbcType=VARCHAR},
      </if>
      <if test="faultview != null">
        #{faultview,jdbcType=VARCHAR},
      </if>
      <if test="statuscode != null">
        #{statuscode,jdbcType=INTEGER},
      </if>
      <if test="mainid != null">
        #{mainid,jdbcType=VARCHAR},
      </if>
      <if test="resetrate != null">
        #{resetrate,jdbcType=VARCHAR},
      </if>
      <if test="staterate != null">
        #{staterate,jdbcType=VARCHAR},
      </if>
      <if test="failrate != null">
        #{failrate,jdbcType=VARCHAR},
      </if>
      <if test="warningrecordsid != null">
        #{warningrecordsid,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.gyee.frame.model.auto.ShutdowneventExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select count(*) from shutdownevent
    <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 shutdownevent
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </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.stoptime != null">
        stopTime = #{record.stoptime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.starttime != null">
        startTime = #{record.starttime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.stophours != null">
        stopHours = #{record.stophours,jdbcType=DECIMAL},
      </if>
      <if test="record.losspower != null">
        lossPower = #{record.losspower,jdbcType=DECIMAL},
      </if>
      <if test="record.stoptypeid != null">
        stopTypeId = #{record.stoptypeid,jdbcType=VARCHAR},
      </if>
      <if test="record.ishandle != null">
        isHandle = #{record.ishandle,jdbcType=SMALLINT},
      </if>
      <if test="record.warningid != null">
        warningId = #{record.warningid,jdbcType=VARCHAR},
      </if>
      <if test="record.projectid != null">
        projectId = #{record.projectid,jdbcType=VARCHAR},
      </if>
      <if test="record.handleway != null">
        handleWay = #{record.handleway,jdbcType=VARCHAR},
      </if>
      <if test="record.faultview != null">
        faultView = #{record.faultview,jdbcType=VARCHAR},
      </if>
      <if test="record.statuscode != null">
        statusCode = #{record.statuscode,jdbcType=INTEGER},
      </if>
      <if test="record.mainid != null">
        mainId = #{record.mainid,jdbcType=VARCHAR},
      </if>
      <if test="record.resetrate != null">
        resetRate = #{record.resetrate,jdbcType=VARCHAR},
      </if>
      <if test="record.staterate != null">
        stateRate = #{record.staterate,jdbcType=VARCHAR},
      </if>
      <if test="record.failrate != null">
        failRate = #{record.failrate,jdbcType=VARCHAR},
      </if>
      <if test="record.warningrecordsid != null">
        warningRecordsId = #{record.warningrecordsid,jdbcType=INTEGER},
      </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 shutdownevent
    set id = #{record.id,jdbcType=VARCHAR},
      windPowerStationId = #{record.windpowerstationid,jdbcType=VARCHAR},
      windTurbineId = #{record.windturbineid,jdbcType=VARCHAR},
      stopTime = #{record.stoptime,jdbcType=TIMESTAMP},
      startTime = #{record.starttime,jdbcType=TIMESTAMP},
      stopHours = #{record.stophours,jdbcType=DECIMAL},
      lossPower = #{record.losspower,jdbcType=DECIMAL},
      stopTypeId = #{record.stoptypeid,jdbcType=VARCHAR},
      isHandle = #{record.ishandle,jdbcType=SMALLINT},
      warningId = #{record.warningid,jdbcType=VARCHAR},
      projectId = #{record.projectid,jdbcType=VARCHAR},
      handleWay = #{record.handleway,jdbcType=VARCHAR},
      faultView = #{record.faultview,jdbcType=VARCHAR},
      statusCode = #{record.statuscode,jdbcType=INTEGER},
      mainId = #{record.mainid,jdbcType=VARCHAR},
      resetRate = #{record.resetrate,jdbcType=VARCHAR},
      stateRate = #{record.staterate,jdbcType=VARCHAR},
      failRate = #{record.failrate,jdbcType=VARCHAR},
      warningRecordsId = #{record.warningrecordsid,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.gyee.frame.model.auto.Shutdownevent">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update shutdownevent
    <set>
      <if test="windpowerstationid != null">
        windPowerStationId = #{windpowerstationid,jdbcType=VARCHAR},
      </if>
      <if test="windturbineid != null">
        windTurbineId = #{windturbineid,jdbcType=VARCHAR},
      </if>
      <if test="stoptime != null">
        stopTime = #{stoptime,jdbcType=TIMESTAMP},
      </if>
      <if test="starttime != null">
        startTime = #{starttime,jdbcType=TIMESTAMP},
      </if>
      <if test="stophours != null">
        stopHours = #{stophours,jdbcType=DECIMAL},
      </if>
      <if test="losspower != null">
        lossPower = #{losspower,jdbcType=DECIMAL},
      </if>
      <if test="stoptypeid != null">
        stopTypeId = #{stoptypeid,jdbcType=VARCHAR},
      </if>
      <if test="ishandle != null">
        isHandle = #{ishandle,jdbcType=SMALLINT},
      </if>
      <if test="warningid != null">
        warningId = #{warningid,jdbcType=VARCHAR},
      </if>
      <if test="projectid != null">
        projectId = #{projectid,jdbcType=VARCHAR},
      </if>
      <if test="handleway != null">
        handleWay = #{handleway,jdbcType=VARCHAR},
      </if>
      <if test="faultview != null">
        faultView = #{faultview,jdbcType=VARCHAR},
      </if>
      <if test="statuscode != null">
        statusCode = #{statuscode,jdbcType=INTEGER},
      </if>
      <if test="mainid != null">
        mainId = #{mainid,jdbcType=VARCHAR},
      </if>
      <if test="resetrate != null">
        resetRate = #{resetrate,jdbcType=VARCHAR},
      </if>
      <if test="staterate != null">
        stateRate = #{staterate,jdbcType=VARCHAR},
      </if>
      <if test="failrate != null">
        failRate = #{failrate,jdbcType=VARCHAR},
      </if>
      <if test="warningrecordsid != null">
        warningRecordsId = #{warningrecordsid,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.gyee.frame.model.auto.Shutdownevent">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update shutdownevent
    set windPowerStationId = #{windpowerstationid,jdbcType=VARCHAR},
      windTurbineId = #{windturbineid,jdbcType=VARCHAR},
      stopTime = #{stoptime,jdbcType=TIMESTAMP},
      startTime = #{starttime,jdbcType=TIMESTAMP},
      stopHours = #{stophours,jdbcType=DECIMAL},
      lossPower = #{losspower,jdbcType=DECIMAL},
      stopTypeId = #{stoptypeid,jdbcType=VARCHAR},
      isHandle = #{ishandle,jdbcType=SMALLINT},
      warningId = #{warningid,jdbcType=VARCHAR},
      projectId = #{projectid,jdbcType=VARCHAR},
      handleWay = #{handleway,jdbcType=VARCHAR},
      faultView = #{faultview,jdbcType=VARCHAR},
      statusCode = #{statuscode,jdbcType=INTEGER},
      mainId = #{mainid,jdbcType=VARCHAR},
      resetRate = #{resetrate,jdbcType=VARCHAR},
      stateRate = #{staterate,jdbcType=VARCHAR},
      failRate = #{failrate,jdbcType=VARCHAR},
      warningRecordsId = #{warningrecordsid,jdbcType=INTEGER}
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="countStopByWp"  resultType="com.gyee.frame.model.custom.SimpleVo">
    select t.windpowerstationid id,count(*) value from shutdownevent t
    where  instr(t.windpowerstationid,'_FDC')>0 and t.statuscode=2
    and t.stoptime >= (select max(stoptime)-7 from shutdownevent)
    and t.stoptime  &lt;= (select max(stoptime) from shutdownevent)  group by t.windpowerstationid
  </select>

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