<?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.WindturbinepowercurvefittingMapper">
<!--  <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.Windturbinepowercurvefitting">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="ID" jdbcType="VARCHAR" property="id" />
    <result column="WINDTURBINEID" jdbcType="VARCHAR" property="windturbineid" />
    <result column="SPEED" jdbcType="DECIMAL" property="speed" />
    <result column="ACTUALPOWER" jdbcType="DECIMAL" property="actualpower" />
    <result column="OPTIMALPOWER" jdbcType="DECIMAL" property="optimalpower" />
    <result column="MAINID" jdbcType="VARCHAR" property="mainid" />
    <result column="OPTMALPOWER" jdbcType="FLOAT" property="optmalpower" />
  </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, WINDTURBINEID, SPEED, ACTUALPOWER, OPTIMALPOWER, MAINID, OPTMALPOWER
  </sql>
  <select id="selectByExample" parameterType="com.gyee.frame.model.auto.WindturbinepowercurvefittingExample" 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 WINDTURBINEPOWERCURVEFITTING
    <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 WINDTURBINEPOWERCURVEFITTING
    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 WINDTURBINEPOWERCURVEFITTING
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.gyee.frame.model.auto.WindturbinepowercurvefittingExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from WINDTURBINEPOWERCURVEFITTING
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.gyee.frame.model.auto.Windturbinepowercurvefitting">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into WINDTURBINEPOWERCURVEFITTING (ID, WINDTURBINEID, SPEED, 
      ACTUALPOWER, OPTIMALPOWER, MAINID, 
      OPTMALPOWER)
    values (#{id,jdbcType=VARCHAR}, #{windturbineid,jdbcType=VARCHAR}, #{speed,jdbcType=DECIMAL}, 
      #{actualpower,jdbcType=DECIMAL}, #{optimalpower,jdbcType=DECIMAL}, #{mainid,jdbcType=VARCHAR}, 
      #{optmalpower,jdbcType=FLOAT})
  </insert>
  <insert id="insertSelective" parameterType="com.gyee.frame.model.auto.Windturbinepowercurvefitting">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into WINDTURBINEPOWERCURVEFITTING
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="windturbineid != null">
        WINDTURBINEID,
      </if>
      <if test="speed != null">
        SPEED,
      </if>
      <if test="actualpower != null">
        ACTUALPOWER,
      </if>
      <if test="optimalpower != null">
        OPTIMALPOWER,
      </if>
      <if test="mainid != null">
        MAINID,
      </if>
      <if test="optmalpower != null">
        OPTMALPOWER,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="windturbineid != null">
        #{windturbineid,jdbcType=VARCHAR},
      </if>
      <if test="speed != null">
        #{speed,jdbcType=DECIMAL},
      </if>
      <if test="actualpower != null">
        #{actualpower,jdbcType=DECIMAL},
      </if>
      <if test="optimalpower != null">
        #{optimalpower,jdbcType=DECIMAL},
      </if>
      <if test="mainid != null">
        #{mainid,jdbcType=VARCHAR},
      </if>
      <if test="optmalpower != null">
        #{optmalpower,jdbcType=FLOAT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.gyee.frame.model.auto.WindturbinepowercurvefittingExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select count(*) from WINDTURBINEPOWERCURVEFITTING
    <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 WINDTURBINEPOWERCURVEFITTING
    <set>
      <if test="record.id != null">
        ID = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.windturbineid != null">
        WINDTURBINEID = #{record.windturbineid,jdbcType=VARCHAR},
      </if>
      <if test="record.speed != null">
        SPEED = #{record.speed,jdbcType=DECIMAL},
      </if>
      <if test="record.actualpower != null">
        ACTUALPOWER = #{record.actualpower,jdbcType=DECIMAL},
      </if>
      <if test="record.optimalpower != null">
        OPTIMALPOWER = #{record.optimalpower,jdbcType=DECIMAL},
      </if>
      <if test="record.mainid != null">
        MAINID = #{record.mainid,jdbcType=VARCHAR},
      </if>
      <if test="record.optmalpower != null">
        OPTMALPOWER = #{record.optmalpower,jdbcType=FLOAT},
      </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 WINDTURBINEPOWERCURVEFITTING
    set ID = #{record.id,jdbcType=VARCHAR},
      WINDTURBINEID = #{record.windturbineid,jdbcType=VARCHAR},
      SPEED = #{record.speed,jdbcType=DECIMAL},
      ACTUALPOWER = #{record.actualpower,jdbcType=DECIMAL},
      OPTIMALPOWER = #{record.optimalpower,jdbcType=DECIMAL},
      MAINID = #{record.mainid,jdbcType=VARCHAR},
      OPTMALPOWER = #{record.optmalpower,jdbcType=FLOAT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.gyee.frame.model.auto.Windturbinepowercurvefitting">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update WINDTURBINEPOWERCURVEFITTING
    <set>
      <if test="windturbineid != null">
        WINDTURBINEID = #{windturbineid,jdbcType=VARCHAR},
      </if>
      <if test="speed != null">
        SPEED = #{speed,jdbcType=DECIMAL},
      </if>
      <if test="actualpower != null">
        ACTUALPOWER = #{actualpower,jdbcType=DECIMAL},
      </if>
      <if test="optimalpower != null">
        OPTIMALPOWER = #{optimalpower,jdbcType=DECIMAL},
      </if>
      <if test="mainid != null">
        MAINID = #{mainid,jdbcType=VARCHAR},
      </if>
      <if test="optmalpower != null">
        OPTMALPOWER = #{optmalpower,jdbcType=FLOAT},
      </if>
    </set>
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.gyee.frame.model.auto.Windturbinepowercurvefitting">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update WINDTURBINEPOWERCURVEFITTING
    set WINDTURBINEID = #{windturbineid,jdbcType=VARCHAR},
      SPEED = #{speed,jdbcType=DECIMAL},
      ACTUALPOWER = #{actualpower,jdbcType=DECIMAL},
      OPTIMALPOWER = #{optimalpower,jdbcType=DECIMAL},
      MAINID = #{mainid,jdbcType=VARCHAR},
      OPTMALPOWER = #{optmalpower,jdbcType=FLOAT}
    where ID = #{id,jdbcType=VARCHAR}
  </update>

  <select id="getWindturbinepowercurvefittingByWtId"  resultType="com.gyee.frame.model.auto.Windturbinepowercurvefitting">
    select WINDTURBINEID,avg(Speed)   Speed,avg(Actualpower)   Actualpower
    ,avg(Optimalpower) Optimalpower
    from Windturbinecurvefitting
    where   WINDTURBINEID = #{wtId}
    group BY WINDTURBINEID,speed   ORDER BY Speed
  </select>
</mapper>