<?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.tcm0334.mapper.TCm0334Mapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.tcm0334.model.TCm0334">
    <id column="POWERMONITORCODE" jdbcType="VARCHAR" property="powermonitorcode" />
    <result column="RECORDID" jdbcType="VARCHAR" property="recordid" />
    <result column="POWERMONITORNAME" jdbcType="VARCHAR" property="powermonitorname" />
    <result column="POWERSYSTEMNAME" jdbcType="VARCHAR" property="powersystemname" />
    <result column="CREATYEAR" jdbcType="VARCHAR" property="creatyear" />
    <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_CM_0334
    where POWERMONITORCODE = #{powermonitorcode,jdbcType=VARCHAR}
  </delete>

  <insert id="insert" parameterType="com.steerinfo.ems.tcm0334.model.TCm0334">
    insert into T_CM_0334 (POWERMONITORCODE, RECORDID, POWERMONITORNAME, 
      POWERSYSTEMNAME, CREATYEAR, CREATEMAN, CREATETIME)
    values (#{powermonitorcode,jdbcType=VARCHAR}, #{recordid,jdbcType=VARCHAR}, #{powermonitorname,jdbcType=VARCHAR},
      #{powersystemname,jdbcType=VARCHAR}, #{creatyear,jdbcType=VARCHAR}, #{createman,jdbcType=VARCHAR}, SYSDATE)
  </insert>

  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.tcm0334.model.TCm0334">
    update T_CM_0334
    <set>
      <if test="recordid != null">
        RECORDID = #{recordid,jdbcType=VARCHAR},
      </if>
      <if test="powermonitorname != null">
        POWERMONITORNAME = #{powermonitorname,jdbcType=VARCHAR},
      </if>
      <if test="powersystemname != null">
        POWERSYSTEMNAME = #{powersystemname,jdbcType=VARCHAR},
      </if>
      <if test="creatyear != null">
        CREATYEAR = #{creatyear,jdbcType=VARCHAR},
      </if>
      UPDATEMAN = #{updateman, jdbcType=VARCHAR},
      UPDATETIME = SYSDATE
    </set>
    where POWERMONITORCODE = #{powermonitorcode,jdbcType=VARCHAR}
  </update>

  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select POWERMONITORCODE, RECORDID, POWERMONITORNAME, POWERSYSTEMNAME, CREATYEAR, CREATEMAN, CREATETIME, UPDATEMAN, UPDATETIME
    from T_CM_0334
    where POWERMONITORCODE = #{powermonitorcode,jdbcType=VARCHAR}
  </select>

  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select POWERMONITORCODE, RECORDID, POWERMONITORNAME, POWERSYSTEMNAME, CREATYEAR, CREATEMAN, CREATETIME, UPDATEMAN, UPDATETIME
    from T_CM_0334
    <where>
      <if test="powermonitorcode != null and powermonitorcode != ''">
        and POWERMONITORCODE like '%${powermonitorcode}%'
      </if>
      <if test="powermonitorname != null and powermonitorname != ''">
        and POWERMONITORNAME like '%${powermonitorname}%'
      </if>
      <if test="powersystemname != null and powersystemname != ''">
        and POWERSYSTEMNAME = #{powersystemname}
      </if>
      <if test="creatyear != null and creatyear != ''">
        and CREATYEAR like '%${creatyear}%'
      </if>
    </where>
    order by POWERMONITORCODE
  </select>

  <delete id="batchDelete" parameterType="java.util.List">
    delete from T_CM_0334
    where POWERMONITORCODE in
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>

  <select id="getNameAndId" resultMap="BaseResultMap">
    select POWERMONITORCODE, POWERMONITORNAME from T_CM_0334
    order by POWERMONITORNAME
  </select>
<!--
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_CM_0334
    where 1=1
    <if test="recordid != null">
      and RECORDID = #{recordid}
    </if>
    <if test="powermonitorname != null and powermonitorname != ''">
      and POWERMONITORNAME = #{powermonitorname}
    </if>
    <if test="powersystemname != null and powersystemname != ''">
      and POWERSYSTEMNAME = #{powersystemname}
    </if>
    <if test="creatyear != null and creatyear != ''">
      and CREATYEAR = #{creatyear}
    </if>
  </delete>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.tcm0334.model.TCm0334">
    insert into T_CM_0334
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="powermonitorcode != null">
        POWERMONITORCODE,
      </if>
      <if test="recordid != null">
        RECORDID,
      </if>
      <if test="powermonitorname != null">
        POWERMONITORNAME,
      </if>
      <if test="powersystemname != null">
        POWERSYSTEMNAME,
      </if>
      <if test="creatyear != null">
        CREATYEAR,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="powermonitorcode != null">
        #{powermonitorcode,jdbcType=VARCHAR},
      </if>
      <if test="recordid != null">
        #{recordid,jdbcType=VARCHAR},
      </if>
      <if test="powermonitorname != null">
        #{powermonitorname,jdbcType=VARCHAR},
      </if>
      <if test="powersystemname != null">
        #{powersystemname,jdbcType=VARCHAR},
      </if>
      <if test="creatyear != null">
        #{creatyear,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.tcm0334.model.TCm0334">
    update T_CM_0334
    set RECORDID = #{recordid,jdbcType=VARCHAR},
      POWERMONITORNAME = #{powermonitorname,jdbcType=VARCHAR},
      POWERSYSTEMNAME = #{powersystemname,jdbcType=VARCHAR},
      CREATYEAR = #{creatyear,jdbcType=VARCHAR}
    where POWERMONITORCODE = #{powermonitorcode,jdbcType=VARCHAR}
  </update>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select POWERMONITORCODE, RECORDID, POWERMONITORNAME, POWERSYSTEMNAME, CREATYEAR
    from T_CM_0334
    <where>
      <if test="powermonitorcode != null and powermonitorcode != ''">
        and POWERMONITORCODE = #{powermonitorcode}
      </if>
      <if test="recordid != null">
        and RECORDID = #{recordid}
      </if>
      <if test="powermonitorname != null and powermonitorname != ''">
        and POWERMONITORNAME LIKE '%${powermonitorname}%'
      </if>
      <if test="powersystemname != null and powersystemname != ''">
        and POWERSYSTEMNAME LIKE '%${powersystemname}%'
      </if>
      <if test="creatyear != null and creatyear != ''">
        and CREATYEAR LIKE '%${creatyear}%'
      </if>
    </where>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_CM_0334 
      (POWERMONITORCODE, 
      RECORDID, POWERMONITORNAME, POWERSYSTEMNAME, 
      CREATYEAR)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.powermonitorcode,jdbcType=VARCHAR}, 
      #{item.recordid,jdbcType=VARCHAR}, #{item.powermonitorname,jdbcType=VARCHAR}, #{item.powersystemname,jdbcType=VARCHAR},
      #{item.creatyear,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_CM_0334
     set
       POWERMONITORCODE=
       <foreach collection="list" item="item" index="index" separator=" " open="case POWERMONITORCODE" close="end">
          when #{item.powermonitorcode,jdbcType=VARCHAR} then #{item.powermonitorcode,jdbcType=VARCHAR}
       </foreach>
       ,RECORDID=
       <foreach collection="list" item="item" index="index" separator=" " open="case POWERMONITORCODE" close="end">
          when #{item.powermonitorcode,jdbcType=VARCHAR} then #{item.recordid,jdbcType=VARCHAR}
       </foreach>
       ,POWERMONITORNAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case POWERMONITORCODE" close="end">
          when #{item.powermonitorcode,jdbcType=VARCHAR} then #{item.powermonitorname,jdbcType=VARCHAR}
       </foreach>
       ,POWERSYSTEMNAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case POWERMONITORCODE" close="end">
          when #{item.powermonitorcode,jdbcType=VARCHAR} then #{item.powersystemname,jdbcType=VARCHAR}
       </foreach>
       ,CREATYEAR=
       <foreach collection="list" item="item" index="index" separator=" " open="case POWERMONITORCODE" close="end">
          when #{item.powermonitorcode,jdbcType=VARCHAR} then #{item.creatyear,jdbcType=VARCHAR}
       </foreach>
     where POWERMONITORCODE in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.powermonitorcode,jdbcType=VARCHAR}
     </foreach> 
  </update>
  -->
</mapper>