<?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.tcm0315.mapper.TCm0315Mapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.tcm0315.model.TCm0315">
    <id column="RECORDID" jdbcType="VARCHAR" property="recordid" />
    <result column="POWERDETECDEPARTMENT" jdbcType="VARCHAR" property="powerdetecdepartment" />
    <result column="POWERMONITORNAME" jdbcType="VARCHAR" property="powermonitorname" />
    <result column="POWERSYSTEMNAME" jdbcType="VARCHAR" property="powersystemname" />
    <result column="DETECTIONF" jdbcType="VARCHAR" property="detectionf" />
    <result column="CREATYEAR" jdbcType="VARCHAR" property="creatyear" />
    <result column="LOWERLIMIT" jdbcType="VARCHAR" property="lowerlimit" />
    <result column="UPPERLIMIT" jdbcType="VARCHAR" property="upperlimit" />
    <result column="UNIT" jdbcType="VARCHAR" property="unit" />
    <result column="SITEM" jdbcType="VARCHAR" property="sitem" />
    <result column="TIMEGRANID" jdbcType="VARCHAR" property="timegranid" />
  </resultMap>

  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.tcm0315.model.TCm0315">
    update T_CM_0315
    <set>
      <if test="creatyear != null">
        CREATYEAR = #{creatyear,jdbcType=VARCHAR},
      </if>
      <if test="powerdetecdepartment != null">
        POWERDETECDEPARTMENT = #{powerdetecdepartment,jdbcType=VARCHAR},
      </if>
      <if test="detectionf != null">
        DETECTIONF = #{detectionf,jdbcType=VARCHAR},
      </if>
      <if test="note != null">
        NOTE = #{note,jdbcType=VARCHAR},
      </if>
      <if test="powermonitorname != null">
        POWERMONITORNAME = #{powermonitorname,jdbcType=VARCHAR},
      </if>
      <if test="sitem != null">
        SITEM = #{sitem,jdbcType=VARCHAR},
      </if>
      <if test="powersystemname != null">
        POWERSYSTEMNAME = #{powersystemname,jdbcType=VARCHAR},
      </if>
      <if test="unit != null">
        UNIT = #{unit,jdbcType=VARCHAR},
      </if>
      <if test="timegranid != null">
        TIMEGRANID = #{timegranid,jdbcType=VARCHAR},
      </if>
    </set>
    where RECORDID = #{recordid,jdbcType=VARCHAR}
  </update>

  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select RECORDID, CREATYEAR, POWERDETECDEPARTMENT, DETECTIONF, LOWERLIMIT, NOTE, POWERMONITORNAME, SITEM, POWERSYSTEMNAME, UNIT, UPPERLIMIT, TIMEGRANID
    from T_CM_0315
    where RECORDID = #{recordid,jdbcType=VARCHAR}
  </select>

  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select T.RECORDID, T.CREATYEAR, T.POWERDETECDEPARTMENT, T.DETECTIONF, T.POWERMONITORNAME, T.SITEM, T.POWERSYSTEMNAME,
    T.UNIT, T.TIMEGRANID
    from T_CM_0315 T
    <where>
      <if test="creatyear != null and creatyear != ''">
        and CREATYEAR like '%${creatyear,jdbcType=VARCHAR}%'
      </if>
      <if test="powerdetecdepartment != null and powerdetecdepartment != ''">
        and POWERDETECDEPARTMENT = #{powerdetecdepartment,jdbcType=VARCHAR}
      </if>
      <if test="detectionf != null and detectionf != ''">
        and DETECTIONF = #{detectionf,jdbcType=VARCHAR}
      </if>
      <if test="powermonitorname != null and powermonitorname != ''">
        and POWERMONITORNAME = #{powermonitorname,jdbcType=VARCHAR}
      </if>
      <if test="powersystemname != null and powersystemname != ''">
        and POWERSYSTEMNAME = #{powersystemname,jdbcType=VARCHAR}
      </if>
      <if test="timegranid != null and timegranid != ''">
        and TIMEGRANID = #{timegranid,jdbcType=VARCHAR}
      </if>
    </where>
  </select>

  <insert id="insert" parameterType="com.steerinfo.ems.tcm0315.model.TCm0315">
    insert into T_CM_0315 (RECORDID, CREATYEAR, POWERDETECDEPARTMENT, DETECTIONF, POWERMONITORNAME, SITEM, POWERSYSTEMNAME, TIMEGRANID)
    values (#{recordid,jdbcType=VARCHAR}, #{creatyear,jdbcType=VARCHAR}, #{powerdetecdepartment,jdbcType=VARCHAR}, #{detectionf,jdbcType=VARCHAR},
        #{powermonitorname,jdbcType=VARCHAR}, #{sitem,jdbcType=VARCHAR}, #{powersystemname,jdbcType=VARCHAR}, #{timegranid,jdbcType=VARCHAR})
  </insert>

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

  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_CM_0315
    where RECORDID = #{recordid,jdbcType=VARCHAR}
  </delete>

  <select id="getPlanNameAndId" resultType="com.steerinfo.ems.tcm0315.model.VPowerPlanId">
    select ITEMCODE, ITEMNAME from V_POWER_PLANID order by ITEMNAME
  </select>

  <!--

  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_CM_0315
    where RECORDID = #{recordid,jdbcType=VARCHAR}
  </delete>

  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_CM_0315
    where 1!=1 
      <if test="powerdetecdepartment != null and powerdetecdepartment != ''">
        and POWERDETECDEPARTMENT = #{powerdetecdepartment}
      </if>
      <if test="powermonitorname != null and powermonitorname != ''">
        and POWERMONITORNAME = #{powermonitorname}
      </if>
      <if test="powersystemname != null and powersystemname != ''">
        and POWERSYSTEMNAME = #{powersystemname}
      </if>
      <if test="detectionf != null and detectionf != ''">
        and DETECTIONF = #{detectionf}
      </if>
      <if test="creatyear != null and creatyear != ''">
        and CREATYEAR = #{creatyear}
      </if>
      <if test="lowerlimit != null and lowerlimit != ''">
        and LOWERLIMIT = #{lowerlimit}
      </if>
      <if test="upperlimit != null and upperlimit != ''">
        and UPPERLIMIT = #{upperlimit}
      </if>
      <if test="unit != null and unit != ''">
        and UNIT = #{unit}
      </if>
      <if test="sitem != null and sitem != ''">
        and SITEM = #{sitem}
      </if>
      <if test="timegranid != null and timegranid != ''">
        and TIMEGRANID = #{timegranid}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.tcm0315.model.TCm0315">
    insert into T_CM_0315 (RECORDID, POWERDETECDEPARTMENT, POWERMONITORNAME, 
      POWERSYSTEMNAME, DETECTIONF, CREATYEAR, LOWERLIMIT, UPPERLIMIT, UNIT, SITEM, TIMEGRANID)
    values (#{recordid,jdbcType=VARCHAR}, #{powerdetecdepartment,jdbcType=VARCHAR}, #{powermonitorname,jdbcType=VARCHAR},
      #{powersystemname,jdbcType=VARCHAR}, #{detectionf,jdbcType=VARCHAR}, #{creatyear,jdbcType=VARCHAR},
      #{lowerlimit,jdbcType=VARCHAR}, #{upperlimit,jdbcType=VARCHAR}, #{unit,jdbcType=VARCHAR}, #{sitem,jdbcType=VARCHAR}, #{timegranid,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.tcm0315.model.TCm0315">
    insert into T_CM_0315
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="recordid != null">
        RECORDID,
      </if>
      <if test="powerdetecdepartment != null">
        POWERDETECDEPARTMENT,
      </if>
      <if test="powermonitorname != null">
        POWERMONITORNAME,
      </if>
      <if test="powersystemname != null">
        POWERSYSTEMNAME,
      </if>
      <if test="detectionf != null">
        DETECTIONF,
      </if>
      <if test="creatyear != null">
        CREATYEAR,
      </if>
      <if test="lowerlimit != null">
        LOWERLIMIT,
      </if>
      <if test="upperlimit != null">
        UPPERLIMIT,
      </if>
      <if test="unit != null">
        UNIT,
      </if>
      <if test="sitem != null">
        SITEM,
      </if>
      <if test="timegranid != null">
        TIMEGRANID,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="recordid != null">
        #{recordid,jdbcType=VARCHAR},
      </if>
      <if test="powerdetecdepartment != null">
        #{powerdetecdepartment,jdbcType=VARCHAR},
      </if>
      <if test="powermonitorname != null">
        #{powermonitorname,jdbcType=VARCHAR},
      </if>
      <if test="powersystemname != null">
        #{powersystemname,jdbcType=VARCHAR},
      </if>
      <if test="detectionf != null">
        #{detectionf,jdbcType=VARCHAR},
      </if>
      <if test="creatyear != null">
        #{creatyear,jdbcType=VARCHAR},
      </if>
      <if test="lowerlimit != null">
        #{lowerlimit,jdbcType=VARCHAR},
      </if>
      <if test="upperlimit != null">
        #{upperlimit,jdbcType=VARCHAR},
      </if>
      <if test="unit != null">
        #{unit,jdbcType=VARCHAR},
      </if>
      <if test="sitem != null">
        #{sitem,jdbcType=VARCHAR},
      </if>
      <if test="timegranid != null">
        #{timegranid,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.tcm0315.model.TCm0315">
    update T_CM_0315
    set POWERDETECDEPARTMENT = #{powerdetecdepartment,jdbcType=VARCHAR},
      POWERMONITORNAME = #{powermonitorname,jdbcType=VARCHAR},
      POWERSYSTEMNAME = #{powersystemname,jdbcType=VARCHAR},
      DETECTIONF = #{detectionf,jdbcType=VARCHAR},
      CREATYEAR = #{creatyear,jdbcType=VARCHAR},
      LOWERLIMIT = #{lowerlimit,jdbcType=VARCHAR},
      UPPERLIMIT = #{upperlimit,jdbcType=VARCHAR},
      UNIT = #{unit,jdbcType=VARCHAR},
      SITEM = #{sitem,jdbcType=VARCHAR},
      TIMEGRANID = #{timegranid,jdbcType=VARCHAR}
    where RECORDID = #{recordid,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.tcm0315.model.TCm0315">
    update T_CM_0315
    <set>
      <if test="powerdetecdepartment != null">
        POWERDETECDEPARTMENT = #{powerdetecdepartment,jdbcType=VARCHAR},
      </if>
      <if test="powermonitorname != null">
        POWERMONITORNAME = #{powermonitorname,jdbcType=VARCHAR},
      </if>
      <if test="powersystemname != null">
        POWERSYSTEMNAME = #{powersystemname,jdbcType=VARCHAR},
      </if>
      <if test="detectionf != null">
        DETECTIONF = #{detectionf,jdbcType=VARCHAR},
      </if>
      <if test="creatyear != null">
        CREATYEAR = #{creatyear,jdbcType=VARCHAR},
      </if>
      <if test="lowerlimit != null">
        LOWERLIMIT = #{lowerlimit,jdbcType=VARCHAR},
      </if>
      <if test="upperlimit != null">
        UPPERLIMIT = #{upperlimit,jdbcType=VARCHAR},
      </if>
      <if test="unit != null">
        UNIT = #{unit,jdbcType=VARCHAR},
      </if>
      <if test="sitem != null">
        SITEM = #{sitem,jdbcType=VARCHAR},
      </if>
      <if test="timegranid != null">
        TIMEGRANID = #{timegranid,jdbcType=VARCHAR},
      </if>
    </set>
    where RECORDID = #{recordid,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select RECORDID, POWERDETECDEPARTMENT, POWERMONITORNAME, POWERSYSTEMNAME, DETECTIONF,
    CREATYEAR, LOWERLIMIT, UPPERLIMIT, UNIT, SITEM, TIMEGRANID
    from T_CM_0315
    where RECORDID = #{recordid,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select RECORDID, POWERDETECDEPARTMENT, POWERMONITORNAME, POWERSYSTEMNAME, DETECTIONF,
    CREATYEAR, LOWERLIMIT, UPPERLIMIT, UNIT, SITEM, TIMEGRANID
    from T_CM_0315
    <where> 
      <if test="powerdetecdepartment != null and powerdetecdepartment != ''">
        and POWERDETECDEPARTMENT = #{powerdetecdepartment}
      </if>
      <if test="powermonitorname != null and powermonitorname != ''">
        and POWERMONITORNAME = #{powermonitorname}
      </if>
      <if test="powersystemname != null and powersystemname != ''">
        and POWERSYSTEMNAME = #{powersystemname}
      </if>
      <if test="detectionf != null and detectionf != ''">
        and DETECTIONF = #{detectionf}
      </if>
      <if test="creatyear != null and creatyear != ''">
        and CREATYEAR = #{creatyear}
      </if>
      <if test="lowerlimit != null and lowerlimit != ''">
        and LOWERLIMIT = #{lowerlimit}
      </if>
      <if test="upperlimit != null and upperlimit != ''">
        and UPPERLIMIT = #{upperlimit}
      </if>
      <if test="unit != null and unit != ''">
        and UNIT = #{unit}
      </if>
      <if test="sitem != null and sitem != ''">
        and SITEM = #{sitem}
      </if>
      <if test="timegranid != null and timegranid != ''">
        and TIMEGRANID = #{timegranid}
      </if>
    </where>
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select RECORDID, POWERDETECDEPARTMENT, POWERMONITORNAME, POWERSYSTEMNAME, DETECTIONF,
    CREATYEAR, LOWERLIMIT, UPPERLIMIT, UNIT, SITEM, TIMEGRANID
    from T_CM_0315
    <where> 
      <if test="powerdetecdepartment != null and powerdetecdepartment != ''">
        and POWERDETECDEPARTMENT LIKE '%${powerdetecdepartment}%'
      </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="detectionf != null and detectionf != ''">
        and DETECTIONF LIKE '%${detectionf}%'
      </if>
      <if test="creatyear != null and creatyear != ''">
        and CREATYEAR LIKE '%${creatyear}%'
      </if>
      <if test="lowerlimit != null and lowerlimit != ''">
        and LOWERLIMIT LIKE '%${lowerlimit}%'
      </if>
      <if test="upperlimit != null and upperlimit != ''">
        and UPPERLIMIT LIKE '%${upperlimit}%'
      </if>
      <if test="unit != null and unit != ''">
        and UNIT LIKE '%${unit}%'
      </if>
      <if test="sitem != null and sitem != ''">
        and SITEM LIKE '%${sitem}%'
      </if>
      <if test="timegranid != null and timegranid != ''">
        and TIMEGRANID LIKE '%${timegranid}%'
      </if>
    </where>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_CM_0315 
      (RECORDID, POWERDETECDEPARTMENT, POWERMONITORNAME, POWERSYSTEMNAME, DETECTIONF, CREATYEAR, LOWERLIMIT, UPPERLIMIT, UNIT, SITEM, TIMEGRANID)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.recordid,jdbcType=VARCHAR},
      #{item.powerdetecdepartment,jdbcType=VARCHAR}, #{item.powermonitorname,jdbcType=VARCHAR}, 
      #{item.powersystemname,jdbcType=VARCHAR}, #{item.detectionf,jdbcType=VARCHAR},
      #{item.creatyear,jdbcType=VARCHAR}, #{item.lowerlimit,jdbcType=VARCHAR}, #{item.upperlimit,jdbcType=VARCHAR}, 
      #{item.unit,jdbcType=VARCHAR}, #{item.sitem,jdbcType=VARCHAR},  #{item.timegranid,jdbcType=VARCHAR} from dual
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_CM_0315
     set
       RECORDID=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.recordid,jdbcType=VARCHAR}
       </foreach>
       ,POWERDETECDEPARTMENT=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.powerdetecdepartment,jdbcType=VARCHAR}
       </foreach>
       ,POWERMONITORNAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.powermonitorname,jdbcType=VARCHAR}
       </foreach>
       ,POWERSYSTEMNAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.powersystemname,jdbcType=VARCHAR}
       </foreach>
       ,DETECTIONF=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.detectionf,jdbcType=VARCHAR}
       </foreach>
       ,CREATYEAR=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.creatyear,jdbcType=VARCHAR}
       </foreach>
       ,LOWERLIMIT=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.lowerlimit,jdbcType=VARCHAR}
       </foreach>
       ,UPPERLIMIT=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.upperlimit,jdbcType=VARCHAR}
       </foreach>
       ,UNIT=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.unit,jdbcType=VARCHAR}
       </foreach>
       ,SITEM=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.sitem,jdbcType=VARCHAR}
       </foreach>
       ,TIMEGRANID=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.timegranid,jdbcType=VARCHAR}
       </foreach>
     where RECORDID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.recordid,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from T_CM_0315
    where RECORDID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  -->
</mapper>