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


  <select id="unfinishedList"  resultType="com.gyee.frame.model.custom.WoBugEqVo">
    SELECT c.WFSHORTNAME,c.WFNAME,a.WTID,b.PRODTDEPTTIME,b.DEPARTURETIME,a.REASON,b.STATUS,a.RID,a.OPERATIONDATE,a.ISMAIN
    FROM  RECOMMENMAIN a left join WOBUGEQ b on a.wobugid=b.bugnum left join  WINDFARM c on a.wpnum=c.wfnum  where a.OPERATIONDATE IS NOT null
    AND (b.STATUS!='流程关闭' OR b.STATUS IS NULL)
    <if test="wpId!=null &amp;&amp; wpId.trim()!=''">
      and c.WFSHORTNAME=#{wpId}
    </if>
    <if test="wtId!=null &amp;&amp; wtId.trim()!=''">
      and a.WTID=#{wtId}
    </if>
    and a.OPERATIONDATE >= #{beginDate} and a.OPERATIONDATE &lt; #{endDate}
  </select>

  <select id="finishedList"  resultType="com.gyee.frame.model.custom.WoBugEqVo">
    SELECT  c.WFSHORTNAME,c.WFNAME,a.WTID,b.PRODTDEPTTIME,b.DEPARTURETIME,a.REASON,b.REPAIREDCOMMENT,a.RID,a.OPERATIONDATE,a.ISMAIN
    FROM  RECOMMENMAIN a left join WOBUGEQ b on a.wobugid=b.bugnum left join  WINDFARM c on a.wpnum=c.wfnum  where  a.ISMAIN='是' AND b.STATUS='流程关闭'
    <if test="wpId!=null &amp;&amp; wpId.trim()!=''">
      and c.WFSHORTNAME=#{wpId}
    </if>
    <if test="wtId!=null &amp;&amp; wtId.trim()!=''">
      and a.WTID=#{wtId}
    </if>

    and a.OPERATIONDATE >= #{beginDate} and a.OPERATIONDATE &lt; #{endDate}
  </select>

  <select id="totalList"  resultType="com.gyee.frame.model.custom.SimpleVo">
    SELECT count(*) value
    FROM  RECOMMENMAIN a left join WOBUGEQ b on a.wobugid=b.bugnum left join  WINDFARM c on a.wpnum=c.wfnum  where  a.ISMAIN='是' AND b.STATUS='流程关闭'
    <if test="wpId!=null &amp;&amp; wpId.trim()!=''">
      and c.WFSHORTNAME=#{wpId}
    </if>
    <if test="wtId!=null &amp;&amp; wtId.trim()!=''">
      and a.WTID in (#{wtId})
    </if>
    and a.OPERATIONDATE >= #{beginDate} and a.OPERATIONDATE &lt; #{endDate}
  </select>
</mapper>