<?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.steerinfo.ems.trmindex.mapper.TRmIndexMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.trmindex.model.TRmIndex">
    <id column="INDEXID" jdbcType="VARCHAR" property="indexid" />
    <result column="INDEXNAME" jdbcType="VARCHAR" property="indexname" />
    <result column="INDEXDESC" jdbcType="VARCHAR" property="indexdesc" />
    <result column="ISENERGY" jdbcType="VARCHAR" property="isenergy" />
    <result column="ISWORKPROC" jdbcType="VARCHAR" property="isworkproc" />
    <result column="ISFACTORY" jdbcType="VARCHAR" property="isfactory" />
    <result column="TYPE1" jdbcType="VARCHAR" property="type1" />
    <result column="TYPE2" jdbcType="VARCHAR" property="type2" />
    <result column="SEQNO" jdbcType="VARCHAR" property="seqno" />
    <result column="ITEMTYPE" jdbcType="VARCHAR" property="itemtype" />
  </resultMap>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_RM_INDEX
    where INDEXID = #{indexid,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_RM_INDEX
    where 1!=1 
      <if test="indexname != null and indexname != ''">
        and INDEXNAME = #{indexname}
      </if>
      <if test="indexdesc != null and indexdesc != ''">
        and INDEXDESC = #{indexdesc}
      </if>
      <if test="isenergy != null and isenergy != ''">
        and ISENERGY = #{isenergy}
      </if>
      <if test="isworkproc != null and isworkproc != ''">
        and ISWORKPROC = #{isworkproc}
      </if>
      <if test="isfactory != null and isfactory != ''">
        and ISFACTORY = #{isfactory}
      </if>
      <if test="type1 != null and type1 != ''">
        and TYPE1 = #{type1}
      </if>
      <if test="type2 != null and type2 != ''">
        and TYPE2 = #{type2}
      </if>
      <if test="seqno != null and seqno != ''">
        and SEQNO = #{seqno}
      </if>
      <if test="itemtype != null and itemtype != ''">
        and ITEMTYPE = #{itemtype}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.trmindex.model.TRmIndex">
    insert into T_RM_INDEX (INDEXID, INDEXNAME, INDEXDESC, 
      ISENERGY, ISWORKPROC, ISFACTORY, 
      TYPE1, TYPE2, SEQNO, 
      ITEMTYPE)
    values (#{indexid,jdbcType=VARCHAR}, #{indexname,jdbcType=VARCHAR}, #{indexdesc,jdbcType=VARCHAR}, 
      #{isenergy,jdbcType=VARCHAR}, #{isworkproc,jdbcType=VARCHAR}, #{isfactory,jdbcType=VARCHAR}, 
      #{type1,jdbcType=VARCHAR}, #{type2,jdbcType=VARCHAR}, #{seqno,jdbcType=VARCHAR}, 
      #{itemtype,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.trmindex.model.TRmIndex">
    insert into T_RM_INDEX
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="indexid != null">
        INDEXID,
      </if>
      <if test="indexname != null">
        INDEXNAME,
      </if>
      <if test="indexdesc != null">
        INDEXDESC,
      </if>
      <if test="isenergy != null">
        ISENERGY,
      </if>
      <if test="isworkproc != null">
        ISWORKPROC,
      </if>
      <if test="isfactory != null">
        ISFACTORY,
      </if>
      <if test="type1 != null">
        TYPE1,
      </if>
      <if test="type2 != null">
        TYPE2,
      </if>
      <if test="seqno != null">
        SEQNO,
      </if>
      <if test="itemtype != null">
        ITEMTYPE,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="indexid != null">
        #{indexid,jdbcType=VARCHAR},
      </if>
      <if test="indexname != null">
        #{indexname,jdbcType=VARCHAR},
      </if>
      <if test="indexdesc != null">
        #{indexdesc,jdbcType=VARCHAR},
      </if>
      <if test="isenergy != null">
        #{isenergy,jdbcType=VARCHAR},
      </if>
      <if test="isworkproc != null">
        #{isworkproc,jdbcType=VARCHAR},
      </if>
      <if test="isfactory != null">
        #{isfactory,jdbcType=VARCHAR},
      </if>
      <if test="type1 != null">
        #{type1,jdbcType=VARCHAR},
      </if>
      <if test="type2 != null">
        #{type2,jdbcType=VARCHAR},
      </if>
      <if test="seqno != null">
        #{seqno,jdbcType=VARCHAR},
      </if>
      <if test="itemtype != null">
        #{itemtype,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.trmindex.model.TRmIndex">
    update T_RM_INDEX
    set INDEXNAME = #{indexname,jdbcType=VARCHAR},
      INDEXDESC = #{indexdesc,jdbcType=VARCHAR},
      ISENERGY = #{isenergy,jdbcType=VARCHAR},
      ISWORKPROC = #{isworkproc,jdbcType=VARCHAR},
      ISFACTORY = #{isfactory,jdbcType=VARCHAR},
      TYPE1 = #{type1,jdbcType=VARCHAR},
      TYPE2 = #{type2,jdbcType=VARCHAR},
      SEQNO = #{seqno,jdbcType=VARCHAR},
      ITEMTYPE = #{itemtype,jdbcType=VARCHAR}
    where INDEXID = #{indexid,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.trmindex.model.TRmIndex">
    update T_RM_INDEX
    <set>
      <if test="indexname != null">
        INDEXNAME = #{indexname,jdbcType=VARCHAR},
      </if>
      <if test="indexdesc != null">
        INDEXDESC = #{indexdesc,jdbcType=VARCHAR},
      </if>
      <if test="isenergy != null">
        ISENERGY = #{isenergy,jdbcType=VARCHAR},
      </if>
      <if test="isworkproc != null">
        ISWORKPROC = #{isworkproc,jdbcType=VARCHAR},
      </if>
      <if test="isfactory != null">
        ISFACTORY = #{isfactory,jdbcType=VARCHAR},
      </if>
      <if test="type1 != null">
        TYPE1 = #{type1,jdbcType=VARCHAR},
      </if>
      <if test="type2 != null">
        TYPE2 = #{type2,jdbcType=VARCHAR},
      </if>
      <if test="seqno != null">
        SEQNO = #{seqno,jdbcType=VARCHAR},
      </if>
      <if test="itemtype != null">
        ITEMTYPE = #{itemtype,jdbcType=VARCHAR},
      </if>
    </set>
    where INDEXID = #{indexid,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select INDEXID, INDEXNAME, INDEXDESC, ISENERGY, ISWORKPROC, ISFACTORY, TYPE1, TYPE2, 
    SEQNO, ITEMTYPE
    from T_RM_INDEX
    where INDEXID = #{indexid,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select INDEXID, INDEXNAME, INDEXDESC, ISENERGY, ISWORKPROC, ISFACTORY, TYPE1, TYPE2, 
    SEQNO, ITEMTYPE
    from T_RM_INDEX
    <where> 
      <if test="indexname != null and indexname != ''">
        and INDEXNAME = #{indexname}
      </if>
      <if test="indexdesc != null and indexdesc != ''">
        and INDEXDESC = #{indexdesc}
      </if>
      <if test="isenergy != null and isenergy != ''">
        and ISENERGY = #{isenergy}
      </if>
      <if test="isworkproc != null and isworkproc != ''">
        and ISWORKPROC = #{isworkproc}
      </if>
      <if test="isfactory != null and isfactory != ''">
        and ISFACTORY = #{isfactory}
      </if>
      <if test="type1 != null and type1 != ''">
        and TYPE1 = #{type1}
      </if>
      <if test="type2 != null and type2 != ''">
        and TYPE2 = #{type2}
      </if>
      <if test="seqno != null and seqno != ''">
        and SEQNO = #{seqno}
      </if>
      <if test="itemtype != null and itemtype != ''">
        and ITEMTYPE = #{itemtype}
      </if>
    </where>
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select INDEXID, INDEXNAME, INDEXDESC, ISENERGY, ISWORKPROC, ISFACTORY, TYPE1, TYPE2, 
    SEQNO, ITEMTYPE
    from T_RM_INDEX
    <where> 
      <if test="indexname != null and indexname != ''">
        and INDEXNAME LIKE '%${indexname}%'
      </if>
      <if test="indexdesc != null and indexdesc != ''">
        and INDEXDESC LIKE '%${indexdesc}%'
      </if>
      <if test="isenergy != null and isenergy != ''">
        and ISENERGY LIKE '%${isenergy}%'
      </if>
      <if test="isworkproc != null and isworkproc != ''">
        and ISWORKPROC LIKE '%${isworkproc}%'
      </if>
      <if test="isfactory != null and isfactory != ''">
        and ISFACTORY LIKE '%${isfactory}%'
      </if>
      <if test="type1 != null and type1 != ''">
        and TYPE1 LIKE '%${type1}%'
      </if>
      <if test="type2 != null and type2 != ''">
        and TYPE2 LIKE '%${type2}%'
      </if>
      <if test="seqno != null and seqno != ''">
        and SEQNO LIKE '%${seqno}%'
      </if>
      <if test="itemtype != null and itemtype != ''">
        and ITEMTYPE LIKE '%${itemtype}%'
      </if>
    </where>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_RM_INDEX 
      (INDEXID, 
      INDEXNAME, INDEXDESC, ISENERGY, 
      ISWORKPROC, ISFACTORY, TYPE1, 
      TYPE2, SEQNO, ITEMTYPE
      )
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.indexid,jdbcType=VARCHAR}, 
      #{item.indexname,jdbcType=VARCHAR}, #{item.indexdesc,jdbcType=VARCHAR}, #{item.isenergy,jdbcType=VARCHAR}, 
      #{item.isworkproc,jdbcType=VARCHAR}, #{item.isfactory,jdbcType=VARCHAR}, #{item.type1,jdbcType=VARCHAR}, 
      #{item.type2,jdbcType=VARCHAR}, #{item.seqno,jdbcType=VARCHAR}, #{item.itemtype,jdbcType=VARCHAR}
       from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_RM_INDEX
     set
       INDEXID=
       <foreach collection="list" item="item" index="index" separator=" " open="case INDEXID" close="end">
          when #{item.indexid,jdbcType=VARCHAR} then #{item.indexid,jdbcType=VARCHAR}
       </foreach>
       ,INDEXNAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case INDEXID" close="end">
          when #{item.indexid,jdbcType=VARCHAR} then #{item.indexname,jdbcType=VARCHAR}
       </foreach>
       ,INDEXDESC=
       <foreach collection="list" item="item" index="index" separator=" " open="case INDEXID" close="end">
          when #{item.indexid,jdbcType=VARCHAR} then #{item.indexdesc,jdbcType=VARCHAR}
       </foreach>
       ,ISENERGY=
       <foreach collection="list" item="item" index="index" separator=" " open="case INDEXID" close="end">
          when #{item.indexid,jdbcType=VARCHAR} then #{item.isenergy,jdbcType=VARCHAR}
       </foreach>
       ,ISWORKPROC=
       <foreach collection="list" item="item" index="index" separator=" " open="case INDEXID" close="end">
          when #{item.indexid,jdbcType=VARCHAR} then #{item.isworkproc,jdbcType=VARCHAR}
       </foreach>
       ,ISFACTORY=
       <foreach collection="list" item="item" index="index" separator=" " open="case INDEXID" close="end">
          when #{item.indexid,jdbcType=VARCHAR} then #{item.isfactory,jdbcType=VARCHAR}
       </foreach>
       ,TYPE1=
       <foreach collection="list" item="item" index="index" separator=" " open="case INDEXID" close="end">
          when #{item.indexid,jdbcType=VARCHAR} then #{item.type1,jdbcType=VARCHAR}
       </foreach>
       ,TYPE2=
       <foreach collection="list" item="item" index="index" separator=" " open="case INDEXID" close="end">
          when #{item.indexid,jdbcType=VARCHAR} then #{item.type2,jdbcType=VARCHAR}
       </foreach>
       ,SEQNO=
       <foreach collection="list" item="item" index="index" separator=" " open="case INDEXID" close="end">
          when #{item.indexid,jdbcType=VARCHAR} then #{item.seqno,jdbcType=VARCHAR}
       </foreach>
       ,ITEMTYPE=
       <foreach collection="list" item="item" index="index" separator=" " open="case INDEXID" close="end">
          when #{item.indexid,jdbcType=VARCHAR} then #{item.itemtype,jdbcType=VARCHAR}
       </foreach>
     where INDEXID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.indexid,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from T_RM_INDEX
    where INDEXID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
</mapper>