<?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.RecommenmainMapper">
  <resultMap id="BaseResultMap" type="com.gyee.frame.model.auto.Recommenmain">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="RID" jdbcType="VARCHAR" property="rid" />
    <result column="ID" jdbcType="DECIMAL" property="id" />
    <result column="WTID" jdbcType="VARCHAR" property="wtid" />
    <result column="RECODEDATE" jdbcType="TIMESTAMP" property="recodedate" />
    <result column="CREATEDATE" jdbcType="TIMESTAMP" property="createdate" />
    <result column="SPEED" jdbcType="DECIMAL" property="speed" />
    <result column="REASON" jdbcType="VARCHAR" property="reason" />
    <result column="ISMAIN" jdbcType="VARCHAR" property="ismain" />
    <result column="WOBUGID" jdbcType="VARCHAR" property="wobugid" />
    <result column="OPERATION" jdbcType="VARCHAR" property="operation" />
    <result column="OPERATIONDATE" jdbcType="TIMESTAMP" property="operationdate" />
    <result column="REMARK" jdbcType="VARCHAR" property="remark" />
    <result column="BAK1" jdbcType="VARCHAR" property="bak1" />
    <result column="BAK2" jdbcType="VARCHAR" property="bak2" />
    <result column="WPID" jdbcType="VARCHAR" property="wpid" />
    <result column="WTNUM" jdbcType="DECIMAL" property="wtnum" />
    <result column="WPNUM" jdbcType="DECIMAL" property="wpnum" />
  </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.
    -->
    RID, ID, WTID, RECODEDATE, CREATEDATE, SPEED, REASON, ISMAIN, WOBUGID, OPERATION, 
    OPERATIONDATE, REMARK, BAK1, BAK2, WPID, WTNUM, WPNUM
  </sql>
  <select id="selectByExample" parameterType="com.gyee.frame.model.auto.RecommenmainExample" 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 RECOMMENMAIN
    <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 RECOMMENMAIN
    where RID = #{rid,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 RECOMMENMAIN
    where RID = #{rid,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.gyee.frame.model.auto.RecommenmainExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from RECOMMENMAIN
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.gyee.frame.model.auto.Recommenmain">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into RECOMMENMAIN (RID, ID, WTID, 
      RECODEDATE, CREATEDATE, SPEED, 
      REASON, ISMAIN, WOBUGID, 
      OPERATION, OPERATIONDATE, REMARK, 
      BAK1, BAK2, WPID, WTNUM, 
      WPNUM)
    values (#{rid,jdbcType=VARCHAR}, #{id,jdbcType=DECIMAL}, #{wtid,jdbcType=VARCHAR}, 
      #{recodedate,jdbcType=TIMESTAMP}, #{createdate,jdbcType=TIMESTAMP}, #{speed,jdbcType=DECIMAL}, 
      #{reason,jdbcType=VARCHAR}, #{ismain,jdbcType=VARCHAR}, #{wobugid,jdbcType=VARCHAR}, 
      #{operation,jdbcType=VARCHAR}, #{operationdate,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR}, 
      #{bak1,jdbcType=VARCHAR}, #{bak2,jdbcType=VARCHAR}, #{wpid,jdbcType=VARCHAR}, #{wtnum,jdbcType=DECIMAL}, 
      #{wpnum,jdbcType=DECIMAL})
  </insert>
  <insert id="insertSelective" parameterType="com.gyee.frame.model.auto.Recommenmain">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into RECOMMENMAIN
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="rid != null">
        RID,
      </if>
      <if test="id != null">
        ID,
      </if>
      <if test="wtid != null">
        WTID,
      </if>
      <if test="recodedate != null">
        RECODEDATE,
      </if>
      <if test="createdate != null">
        CREATEDATE,
      </if>
      <if test="speed != null">
        SPEED,
      </if>
      <if test="reason != null">
        REASON,
      </if>
      <if test="ismain != null">
        ISMAIN,
      </if>
      <if test="wobugid != null">
        WOBUGID,
      </if>
      <if test="operation != null">
        OPERATION,
      </if>
      <if test="operationdate != null">
        OPERATIONDATE,
      </if>
      <if test="remark != null">
        REMARK,
      </if>
      <if test="bak1 != null">
        BAK1,
      </if>
      <if test="bak2 != null">
        BAK2,
      </if>
      <if test="wpid != null">
        WPID,
      </if>
      <if test="wtnum != null">
        WTNUM,
      </if>
      <if test="wpnum != null">
        WPNUM,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="rid != null">
        #{rid,jdbcType=VARCHAR},
      </if>
      <if test="id != null">
        #{id,jdbcType=DECIMAL},
      </if>
      <if test="wtid != null">
        #{wtid,jdbcType=VARCHAR},
      </if>
      <if test="recodedate != null">
        #{recodedate,jdbcType=TIMESTAMP},
      </if>
      <if test="createdate != null">
        #{createdate,jdbcType=TIMESTAMP},
      </if>
      <if test="speed != null">
        #{speed,jdbcType=DECIMAL},
      </if>
      <if test="reason != null">
        #{reason,jdbcType=VARCHAR},
      </if>
      <if test="ismain != null">
        #{ismain,jdbcType=VARCHAR},
      </if>
      <if test="wobugid != null">
        #{wobugid,jdbcType=VARCHAR},
      </if>
      <if test="operation != null">
        #{operation,jdbcType=VARCHAR},
      </if>
      <if test="operationdate != null">
        #{operationdate,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="bak1 != null">
        #{bak1,jdbcType=VARCHAR},
      </if>
      <if test="bak2 != null">
        #{bak2,jdbcType=VARCHAR},
      </if>
      <if test="wpid != null">
        #{wpid,jdbcType=VARCHAR},
      </if>
      <if test="wtnum != null">
        #{wtnum,jdbcType=DECIMAL},
      </if>
      <if test="wpnum != null">
        #{wpnum,jdbcType=DECIMAL},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.gyee.frame.model.auto.RecommenmainExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select count(*) from RECOMMENMAIN
    <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 RECOMMENMAIN
    <set>
      <if test="record.rid != null">
        RID = #{record.rid,jdbcType=VARCHAR},
      </if>
      <if test="record.id != null">
        ID = #{record.id,jdbcType=DECIMAL},
      </if>
      <if test="record.wtid != null">
        WTID = #{record.wtid,jdbcType=VARCHAR},
      </if>
      <if test="record.recodedate != null">
        RECODEDATE = #{record.recodedate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createdate != null">
        CREATEDATE = #{record.createdate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.speed != null">
        SPEED = #{record.speed,jdbcType=DECIMAL},
      </if>
      <if test="record.reason != null">
        REASON = #{record.reason,jdbcType=VARCHAR},
      </if>
      <if test="record.ismain != null">
        ISMAIN = #{record.ismain,jdbcType=VARCHAR},
      </if>
      <if test="record.wobugid != null">
        WOBUGID = #{record.wobugid,jdbcType=VARCHAR},
      </if>
      <if test="record.operation != null">
        OPERATION = #{record.operation,jdbcType=VARCHAR},
      </if>
      <if test="record.operationdate != null">
        OPERATIONDATE = #{record.operationdate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.remark != null">
        REMARK = #{record.remark,jdbcType=VARCHAR},
      </if>
      <if test="record.bak1 != null">
        BAK1 = #{record.bak1,jdbcType=VARCHAR},
      </if>
      <if test="record.bak2 != null">
        BAK2 = #{record.bak2,jdbcType=VARCHAR},
      </if>
      <if test="record.wpid != null">
        WPID = #{record.wpid,jdbcType=VARCHAR},
      </if>
      <if test="record.wtnum != null">
        WTNUM = #{record.wtnum,jdbcType=DECIMAL},
      </if>
      <if test="record.wpnum != null">
        WPNUM = #{record.wpnum,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 RECOMMENMAIN
    set RID = #{record.rid,jdbcType=VARCHAR},
      ID = #{record.id,jdbcType=DECIMAL},
      WTID = #{record.wtid,jdbcType=VARCHAR},
      RECODEDATE = #{record.recodedate,jdbcType=TIMESTAMP},
      CREATEDATE = #{record.createdate,jdbcType=TIMESTAMP},
      SPEED = #{record.speed,jdbcType=DECIMAL},
      REASON = #{record.reason,jdbcType=VARCHAR},
      ISMAIN = #{record.ismain,jdbcType=VARCHAR},
      WOBUGID = #{record.wobugid,jdbcType=VARCHAR},
      OPERATION = #{record.operation,jdbcType=VARCHAR},
      OPERATIONDATE = #{record.operationdate,jdbcType=TIMESTAMP},
      REMARK = #{record.remark,jdbcType=VARCHAR},
      BAK1 = #{record.bak1,jdbcType=VARCHAR},
      BAK2 = #{record.bak2,jdbcType=VARCHAR},
      WPID = #{record.wpid,jdbcType=VARCHAR},
      WTNUM = #{record.wtnum,jdbcType=DECIMAL},
      WPNUM = #{record.wpnum,jdbcType=DECIMAL}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.gyee.frame.model.auto.Recommenmain">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update RECOMMENMAIN
    <set>
      <if test="id != null">
        ID = #{id,jdbcType=DECIMAL},
      </if>
      <if test="wtid != null">
        WTID = #{wtid,jdbcType=VARCHAR},
      </if>
      <if test="recodedate != null">
        RECODEDATE = #{recodedate,jdbcType=TIMESTAMP},
      </if>
      <if test="createdate != null">
        CREATEDATE = #{createdate,jdbcType=TIMESTAMP},
      </if>
      <if test="speed != null">
        SPEED = #{speed,jdbcType=DECIMAL},
      </if>
      <if test="reason != null">
        REASON = #{reason,jdbcType=VARCHAR},
      </if>
      <if test="ismain != null">
        ISMAIN = #{ismain,jdbcType=VARCHAR},
      </if>
      <if test="wobugid != null">
        WOBUGID = #{wobugid,jdbcType=VARCHAR},
      </if>
      <if test="operation != null">
        OPERATION = #{operation,jdbcType=VARCHAR},
      </if>
      <if test="operationdate != null">
        OPERATIONDATE = #{operationdate,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null">
        REMARK = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="bak1 != null">
        BAK1 = #{bak1,jdbcType=VARCHAR},
      </if>
      <if test="bak2 != null">
        BAK2 = #{bak2,jdbcType=VARCHAR},
      </if>
      <if test="wpid != null">
        WPID = #{wpid,jdbcType=VARCHAR},
      </if>
      <if test="wtnum != null">
        WTNUM = #{wtnum,jdbcType=DECIMAL},
      </if>
      <if test="wpnum != null">
        WPNUM = #{wpnum,jdbcType=DECIMAL},
      </if>
    </set>
    where RID = #{rid,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.gyee.frame.model.auto.Recommenmain">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update RECOMMENMAIN
    set ID = #{id,jdbcType=DECIMAL},
      WTID = #{wtid,jdbcType=VARCHAR},
      RECODEDATE = #{recodedate,jdbcType=TIMESTAMP},
      CREATEDATE = #{createdate,jdbcType=TIMESTAMP},
      SPEED = #{speed,jdbcType=DECIMAL},
      REASON = #{reason,jdbcType=VARCHAR},
      ISMAIN = #{ismain,jdbcType=VARCHAR},
      WOBUGID = #{wobugid,jdbcType=VARCHAR},
      OPERATION = #{operation,jdbcType=VARCHAR},
      OPERATIONDATE = #{operationdate,jdbcType=TIMESTAMP},
      REMARK = #{remark,jdbcType=VARCHAR},
      BAK1 = #{bak1,jdbcType=VARCHAR},
      BAK2 = #{bak2,jdbcType=VARCHAR},
      WPID = #{wpid,jdbcType=VARCHAR},
      WTNUM = #{wtnum,jdbcType=DECIMAL},
      WPNUM = #{wpnum,jdbcType=DECIMAL}
    where RID = #{rid,jdbcType=VARCHAR}
  </update>


  <select id="getRecommenmainDay"  resultType="com.gyee.frame.model.auto.Recommenmain">

    select * from recommenmain t where t.rid in
    (select max(rid) from recommenmain where ismain=#{ismain} and  recodedate >= #{beginDate} and recodedate &lt; #{endDate} group by wtid )
    order by t.recodedate

  </select>

  <select id="getRecommenmainTotal"  resultType="com.gyee.frame.model.custom.RecommenmainVo">

    select t.wtid wtId ,count(t.wtid) nums from recommenmain t where
     t.recodedate >= to_date('${beginDate}','YYYY-MM-DD HH24:MI:SS')
    and t.recodedate &lt; to_date('${endDate}','YYYY-MM-DD HH24:MI:SS')
    <if test="wpId != null">
     and wpid = #{wpId,jdbcType=VARCHAR}
    </if>
    and wpid !='QS_FDC'
    group by t.wtid order by nums desc

  </select>

</mapper>