<?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.trmenergyproperty.mapper.TRmEnergyPropertyMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.trmenergyproperty.model.TRmEnergyProperty">
    <id column="ID" jdbcType="VARCHAR" property="id" />
    <result column="NAME" jdbcType="VARCHAR" property="name" />
    <result column="SEQNO" jdbcType="DECIMAL" property="seqno" />
    <result column="REMARK" jdbcType="VARCHAR" property="remark" />
    <result column="PROPERTYTYPE" jdbcType="VARCHAR" property="propertytype" />
    <result column="CREATEMAN" jdbcType="VARCHAR" property="createman" />
    <result column="CREATETIME" jdbcType="TIMESTAMP" property="createtime" />
    <result column="UPDATEMAN" jdbcType="VARCHAR" property="updateman" />
    <result column="UPDATETIME" jdbcType="TIMESTAMP" property="updatetime" />
  </resultMap>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_RM_ENERGY_PROPERTY
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_RM_ENERGY_PROPERTY
    where 1=1
      <if test="name != null and name != ''">
        and NAME = #{name}
      </if>
      <if test="seqno != null and seqno != ''">
        and SEQNO = #{seqno}
      </if>
      <if test="remark != null and remark != ''">
        and REMARK = #{remark}
      </if>
      <if test="propertytype != null and propertytype != ''">
        and PROPERTYTYPE = #{propertytype}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.trmenergyproperty.model.TRmEnergyProperty">
    insert into T_RM_ENERGY_PROPERTY (ID, NAME, SEQNO, 
      REMARK, PROPERTYTYPE, CREATEMAN, CREATETIME)
    values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{seqno,jdbcType=DECIMAL},
      #{remark,jdbcType=VARCHAR}, #{propertytype,jdbcType=VARCHAR}, #{createman,jdbcType=VARCHAR}, SYSDATE)
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.trmenergyproperty.model.TRmEnergyProperty">
    insert into T_RM_ENERGY_PROPERTY
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="name != null">
        NAME,
      </if>
      <if test="seqno != null">
        SEQNO,
      </if>
      <if test="remark != null">
        REMARK,
      </if>
      <if test="propertytype != null">
        PROPERTYTYPE,
      </if>
        CREATEMAN,
        CREATETIME
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="seqno != null">
        #{seqno,jdbcType=DECIMAL},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="propertytype != null">
        #{propertytype,jdbcType=VARCHAR},
      </if>
        #{createman,jdbcType=VARCHAR},
        SYSDATE
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.trmenergyproperty.model.TRmEnergyProperty">
    update T_RM_ENERGY_PROPERTY
    set NAME = #{name,jdbcType=VARCHAR},
      SEQNO = #{seqno,jdbcType=DECIMAL},
      REMARK = #{remark,jdbcType=VARCHAR},
      PROPERTYTYPE = #{propertytype,jdbcType=VARCHAR},
      UPDATEMAN = #{updateman, jdbcType=VARCHAR},
      UPDATETIME = SYSDATE
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.trmenergyproperty.model.TRmEnergyProperty">
    update T_RM_ENERGY_PROPERTY
    <set>
      <if test="id != null and id != ''">
        ID = #{id},
      </if>
      <if test="name != null">
        NAME = #{name,jdbcType=VARCHAR},
      </if>
      <if test="seqno != null">
        SEQNO = #{seqno,jdbcType=DECIMAL},
      </if>
      <if test="remark != null">
        REMARK = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="propertytype != null">
        PROPERTYTYPE = #{propertytype,jdbcType=VARCHAR},
      </if>
        UPDATEMAN = #{updateman, jdbcType=VARCHAR},
        UPDATETIME = SYSDATE
    </set>
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select ID, NAME, SEQNO, REMARK, PROPERTYTYPE
    from T_RM_ENERGY_PROPERTY
    where ID = #{id,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select ID, NAME, SEQNO, REMARK, PROPERTYTYPE, CREATEMAN, CREATETIME, UPDATEMAN, UPDATETIME
    from T_RM_ENERGY_PROPERTY
    <where> 
      <if test="name != null and name != ''">
        and NAME = #{name}
      </if>
      <if test="seqno != null and seqno != ''">
        and SEQNO = #{seqno}
      </if>
      <if test="remark != null and remark != ''">
        and REMARK = #{remark}
      </if>
      <if test="propertytype != null and propertytype != ''">
        and PROPERTYTYPE = #{propertytype}
      </if>
    </where>
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select ID, NAME, SEQNO, REMARK, PROPERTYTYPE, CREATEMAN, CREATETIME, UPDATEMAN, UPDATETIME
    from T_RM_ENERGY_PROPERTY
    <where>
      <if test="id != null and id != ''">
        and ID LIKE '%${id}%'
      </if>
      <if test="name != null and name != ''">
        and NAME LIKE '%${name}%'
      </if>
      <if test="seqno != null and seqno != ''">
        and SEQNO LIKE '%${seqno}%'
      </if>
      <if test="remark != null and remark != ''">
        and REMARK LIKE '%${remark}%'
      </if>
      <if test="propertytype != null and propertytype != ''">
        and PROPERTYTYPE LIKE '%${propertytype}%'
      </if>
    </where>
    order by SEQNO
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_RM_ENERGY_PROPERTY 
      (ID, 
      NAME, SEQNO, REMARK, 
      PROPERTYTYPE, CREATEMAN, CREATETIME)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.id,jdbcType=VARCHAR}, 
      #{item.name,jdbcType=VARCHAR}, #{item.seqno,jdbcType=DECIMAL}, #{item.remark,jdbcType=VARCHAR},
      #{item.propertytype,jdbcType=VARCHAR}, #{item.createman,jdbcType=VARCHAR}, SYSDATE
      from dual
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_RM_ENERGY_PROPERTY
     set
       ID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.id,jdbcType=VARCHAR}
       </foreach>
       ,NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.name,jdbcType=VARCHAR}
       </foreach>
       ,SEQNO=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.seqno,jdbcType=DECIMAL}
       </foreach>
       ,REMARK=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.remark,jdbcType=VARCHAR}
       </foreach>
       ,PROPERTYTYPE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.propertytype,jdbcType=VARCHAR}
       </foreach>
       ,UPDATEMAN=
        <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
            when #{item.id,jdbcType=VARCHAR} then #{item.updateman,jdbcType=VARCHAR}
        </foreach>
        ,UPDATETIME=
        <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
            when #{item.id,jdbcType=VARCHAR} then SYSDATE
        </foreach>
     where ID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.id,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from T_RM_ENERGY_PROPERTY
    where ID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <select id="getNameAndId" resultMap="BaseResultMap">
    select ID, NAME from T_RM_ENERGY_PROPERTY order by NAME
  </select>
  <select id="getMaxSeqNo" resultType="java.lang.Integer">
    select max(SEQNO) from T_RM_ENERGY_PROPERTY
  </select>
  <select id="getMaxID" resultType="java.lang.String">
    select max(ID+0) from T_RM_ENERGY_PROPERTY
  </select>
</mapper>