<?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.trmelectricitylocation.mapper.TRmElectricityLocationMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.trmelectricitylocation.model.TRmElectricityLocation">
    <id column="ID" jdbcType="VARCHAR" property="id" />
    <result column="WORKPROCID" jdbcType="VARCHAR" property="workprocid" />
    <result column="LOCATION" jdbcType="VARCHAR" property="location" />
    <result column="TYPE" jdbcType="VARCHAR" property="type" />
    <result column="NOTE" jdbcType="VARCHAR" property="note" />
    <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" />
    <result column="ITEMNAME" jdbcType="VARCHAR" property="itemname" />
    <result column="BCODE" jdbcType="VARCHAR" property="bcode" />
    <result column="SEQNO" jdbcType="VARCHAR" property="seqno" />
    <result column="MODS" jdbcType="DECIMAL" property="mods" />
    <result column="STATE" jdbcType="VARCHAR" property="state" />
    <result column="WORKSHOP" jdbcType="VARCHAR" property="workshop" />
    <result column="ITEMID" jdbcType="VARCHAR" property="itemid" />
    <result column="FOURGITEM" jdbcType="VARCHAR" property="fourgitem" />
  </resultMap>
  <sql id="columns">
    ID, WORKPROCID, LOCATION, TYPE, NOTE, CREATEMAN, CREATETIME, UPDATEMAN, UPDATETIME, 
    ITEMNAME, BCODE, SEQNO, MODS, STATE, WORKSHOP, ITEMID, FOURGITEM
  </sql>
  <sql id="columns_alias">
    t.ID, t.WORKPROCID, t.LOCATION, t.TYPE, t.NOTE, t.CREATEMAN, t.CREATETIME, t.UPDATEMAN, 
    t.UPDATETIME, t.ITEMNAME, t.BCODE, t.SEQNO, t.MODS, t.STATE, t.WORKSHOP, t.ITEMID, 
    t.FOURGITEM
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM T_RM_ELECTRICITY_LOCATION
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM T_RM_ELECTRICITY_LOCATION t
  </sql>
  <sql id="where">
    <where> 
        <if test="workprocid != null and workprocid != ''">
        ${workprocid}
      </if>
      <if test="location != null and location != ''">
        ${location}
      </if>
      <if test="type != null and type != ''">
        ${type}
      </if>
      <if test="note != null and note != ''">
        and NOTE = #{note}
      </if>
      <if test="createman != null and createman != ''">
        and CREATEMAN = #{createman}
      </if>
      <if test="createtime != null">
        and TO_CHAR(CREATETIME,'yyyy-MM-dd') = #{createtime}
      </if>
      <if test="updateman != null and updateman != ''">
        and UPDATEMAN = #{updateman}
      </if>
      <if test="updatetime != null">
        and TO_CHAR(UPDATETIME,'yyyy-MM-dd') = #{updatetime}
      </if>
      <if test="itemname != null and itemname != ''">
        ${itemname}
      </if>
      <if test="bcode != null and bcode != ''">
        ${bcode}
      </if>
      <if test="bcode2 != null and bcode2 != ''">
        and bcode = #{bcode2}
      </if>
      <if test="seqno != null and seqno != ''">
        and SEQNO = #{seqno}
      </if>
      <if test="mods != null">
        ${mods}
      </if>
      <if test="state != null and state != ''">
        and STATE = #{state}
      </if>
      <if test="workshop != null and workshop != ''">
        ${workshop}
      </if>
      <if test="itemid != null and itemid != ''">
        and ITEMID in (${itemid})
      </if>
      <if test="fourgitem != null and fourgitem != ''">
        and FOURGITEM = #{fourgitem}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="id != null and id != ''">
        and ID LIKE '%${id}%'
      </if>
      <if test="workprocid != null and workprocid != ''">
        and WORKPROCID LIKE '%${workprocid}%'
      </if>
      <if test="location != null and location != ''">
        and LOCATION LIKE '%${location}%'
      </if>
      <if test="type != null and type != ''">
        and TYPE LIKE '%${type}%'
      </if>
      <if test="note != null and note != ''">
        and NOTE LIKE '%${note}%'
      </if>
      <if test="createman != null and createman != ''">
        and CREATEMAN LIKE '%${createman}%'
      </if>
      <if test="createtime != null">
        and TO_CHAR(CREATETIME,'yyyy-MM-dd') = #{createtime}
      </if>
      <if test="updateman != null and updateman != ''">
        and UPDATEMAN LIKE '%${updateman}%'
      </if>
      <if test="updatetime != null">
        and TO_CHAR(UPDATETIME,'yyyy-MM-dd') = #{updatetime}
      </if>
      <if test="itemname != null and itemname != ''">
        and ITEMNAME LIKE '%${itemname}%'
      </if>
      <if test="bcode != null and bcode != ''">
        and BCODE LIKE '%${bcode}%'
      </if>
      <if test="seqno != null and seqno != ''">
        and SEQNO LIKE '%${seqno}%'
      </if>
      <if test="mods != null">
        and MODS = #{mods}
      </if>
      <if test="state != null and state != ''">
        and STATE LIKE '%${state}%'
      </if>
      <if test="workshop != null and workshop != ''">
        and WORKSHOP LIKE '%${workshop}%'
      </if>
      <if test="itemid != null and itemid != ''">
        and ITEMID LIKE '%${itemid}%'
      </if>
      <if test="fourgitem != null and fourgitem != ''">
        and FOURGITEM LIKE '%${fourgitem}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_RM_ELECTRICITY_LOCATION
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_RM_ELECTRICITY_LOCATION
    where 1!=1 
      <if test="workprocid != null and workprocid != ''">
        or WORKPROCID = #{workprocid}
      </if>
      <if test="location != null and location != ''">
        or LOCATION = #{location}
      </if>
      <if test="type != null and type != ''">
        or TYPE = #{type}
      </if>
      <if test="note != null and note != ''">
        or NOTE = #{note}
      </if>
      <if test="createman != null and createman != ''">
        or CREATEMAN = #{createman}
      </if>
      <if test="createtime != null">
        or TO_CHAR(CREATETIME,'yyyy-MM-dd') = '#{createtime}'
      </if>
      <if test="updateman != null and updateman != ''">
        or UPDATEMAN = #{updateman}
      </if>
      <if test="updatetime != null">
        or TO_CHAR(UPDATETIME,'yyyy-MM-dd') = '#{updatetime}'
      </if>
      <if test="itemname != null and itemname != ''">
        or ITEMNAME = #{itemname}
      </if>
      <if test="bcode != null and bcode != ''">
        or BCODE = #{bcode}
      </if>
      <if test="seqno != null and seqno != ''">
        or SEQNO = #{seqno}
      </if>
      <if test="mods != null">
        or MODS = #{mods}
      </if>
      <if test="state != null and state != ''">
        or STATE = #{state}
      </if>
      <if test="workshop != null and workshop != ''">
        or WORKSHOP = #{workshop}
      </if>
      <if test="itemid != null and itemid != ''">
        or ITEMID = #{itemid}
      </if>
      <if test="fourgitem != null and fourgitem != ''">
        or FOURGITEM = #{fourgitem}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.trmelectricitylocation.model.TRmElectricityLocation">
    insert into T_RM_ELECTRICITY_LOCATION (ID, WORKPROCID, LOCATION, 
      TYPE, NOTE, CREATEMAN, 
      CREATETIME, UPDATEMAN, UPDATETIME, 
      ITEMNAME, BCODE, SEQNO, 
      MODS, STATE, WORKSHOP, 
      ITEMID, FOURGITEM)
    values (#{id,jdbcType=VARCHAR}, #{workprocid,jdbcType=VARCHAR}, #{location,jdbcType=VARCHAR}, 
      #{type,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR}, #{createman,jdbcType=VARCHAR}, 
      #{createtime,jdbcType=TIMESTAMP}, #{updateman,jdbcType=VARCHAR}, #{updatetime,jdbcType=TIMESTAMP}, 
      #{itemname,jdbcType=VARCHAR}, #{bcode,jdbcType=VARCHAR}, #{seqno,jdbcType=VARCHAR}, 
      #{mods,jdbcType=DECIMAL}, #{state,jdbcType=VARCHAR}, #{workshop,jdbcType=VARCHAR}, 
      #{itemid,jdbcType=VARCHAR}, #{fourgitem,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.trmelectricitylocation.model.TRmElectricityLocation">
    insert into T_RM_ELECTRICITY_LOCATION
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="workprocid != null">
        WORKPROCID,
      </if>
      <if test="location != null">
        LOCATION,
      </if>
      <if test="type != null">
        TYPE,
      </if>
      <if test="note != null">
        NOTE,
      </if>
      <if test="createman != null">
        CREATEMAN,
      </if>
      <if test="createtime != null">
        CREATETIME,
      </if>
      <if test="updateman != null">
        UPDATEMAN,
      </if>
      <if test="updatetime != null">
        UPDATETIME,
      </if>
      <if test="itemname != null">
        ITEMNAME,
      </if>
      <if test="bcode != null">
        BCODE,
      </if>
      <if test="seqno != null">
        SEQNO,
      </if>
      <if test="mods != null">
        MODS,
      </if>
      <if test="state != null">
        STATE,
      </if>
      <if test="workshop != null">
        WORKSHOP,
      </if>
      <if test="itemid != null">
        ITEMID,
      </if>
      <if test="fourgitem != null">
        FOURGITEM,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="workprocid != null">
        #{workprocid,jdbcType=VARCHAR},
      </if>
      <if test="location != null">
        #{location,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        #{type,jdbcType=VARCHAR},
      </if>
      <if test="note != null">
        #{note,jdbcType=VARCHAR},
      </if>
      <if test="createman != null">
        #{createman,jdbcType=VARCHAR},
      </if>
      <if test="createtime != null">
        #{createtime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateman != null">
        #{updateman,jdbcType=VARCHAR},
      </if>
      <if test="updatetime != null">
        #{updatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="itemname != null">
        #{itemname,jdbcType=VARCHAR},
      </if>
      <if test="bcode != null">
        #{bcode,jdbcType=VARCHAR},
      </if>
      <if test="seqno != null">
        #{seqno,jdbcType=VARCHAR},
      </if>
      <if test="mods != null">
        #{mods,jdbcType=DECIMAL},
      </if>
      <if test="state != null">
        #{state,jdbcType=VARCHAR},
      </if>
      <if test="workshop != null">
        #{workshop,jdbcType=VARCHAR},
      </if>
      <if test="itemid != null">
        #{itemid,jdbcType=VARCHAR},
      </if>
      <if test="fourgitem != null">
        #{fourgitem,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.trmelectricitylocation.model.TRmElectricityLocation">
    update T_RM_ELECTRICITY_LOCATION
    set WORKPROCID = #{workprocid,jdbcType=VARCHAR},
      LOCATION = #{location,jdbcType=VARCHAR},
      TYPE = #{type,jdbcType=VARCHAR},
      NOTE = #{note,jdbcType=VARCHAR},
      CREATEMAN = #{createman,jdbcType=VARCHAR},
      CREATETIME = #{createtime,jdbcType=TIMESTAMP},
      UPDATEMAN = #{updateman,jdbcType=VARCHAR},
      UPDATETIME = #{updatetime,jdbcType=TIMESTAMP},
      ITEMNAME = #{itemname,jdbcType=VARCHAR},
      BCODE = #{bcode,jdbcType=VARCHAR},
      SEQNO = #{seqno,jdbcType=VARCHAR},
      MODS = #{mods,jdbcType=DECIMAL},
      STATE = #{state,jdbcType=VARCHAR},
      WORKSHOP = #{workshop,jdbcType=VARCHAR},
      ITEMID = #{itemid,jdbcType=VARCHAR},
      FOURGITEM = #{fourgitem,jdbcType=VARCHAR}
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.trmelectricitylocation.model.TRmElectricityLocation">
    update T_RM_ELECTRICITY_LOCATION
    <set>
      <if test="workprocid != null">
        WORKPROCID = #{workprocid,jdbcType=VARCHAR},
      </if>
      <if test="location != null">
        LOCATION = #{location,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        TYPE = #{type,jdbcType=VARCHAR},
      </if>
      <if test="note != null">
        NOTE = #{note,jdbcType=VARCHAR},
      </if>
      <if test="createman != null">
        CREATEMAN = #{createman,jdbcType=VARCHAR},
      </if>
      <if test="createtime != null">
        CREATETIME = #{createtime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateman != null">
        UPDATEMAN = #{updateman,jdbcType=VARCHAR},
      </if>
      <if test="updatetime != null">
        UPDATETIME = #{updatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="itemname != null">
        ITEMNAME = #{itemname,jdbcType=VARCHAR},
      </if>
      <if test="bcode != null">
        BCODE = #{bcode,jdbcType=VARCHAR},
      </if>
      <if test="seqno != null">
        SEQNO = #{seqno,jdbcType=VARCHAR},
      </if>
      <if test="mods != null">
        MODS = #{mods,jdbcType=DECIMAL},
      </if>
      <if test="state != null">
        STATE = #{state,jdbcType=VARCHAR},
      </if>
      <if test="workshop != null">
        WORKSHOP = #{workshop,jdbcType=VARCHAR},
      </if>
      <if test="itemid != null">
        ITEMID = #{itemid,jdbcType=VARCHAR},
      </if>
      <if test="fourgitem != null">
        FOURGITEM = #{fourgitem,jdbcType=VARCHAR},
      </if>
    </set>
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where ID = #{id,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="where"/>
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="whereLike"/>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_RM_ELECTRICITY_LOCATION 
      (ID, 
      WORKPROCID, LOCATION, TYPE, 
      NOTE, CREATEMAN, CREATETIME, 
      UPDATEMAN, UPDATETIME, ITEMNAME, 
      BCODE, SEQNO, MODS, 
      STATE, WORKSHOP, ITEMID, 
      FOURGITEM)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.id,jdbcType=VARCHAR}, 
      #{item.workprocid,jdbcType=VARCHAR}, #{item.location,jdbcType=VARCHAR}, #{item.type,jdbcType=VARCHAR}, 
      #{item.note,jdbcType=VARCHAR}, #{item.createman,jdbcType=VARCHAR}, #{item.createtime,jdbcType=TIMESTAMP}, 
      #{item.updateman,jdbcType=VARCHAR}, #{item.updatetime,jdbcType=TIMESTAMP}, #{item.itemname,jdbcType=VARCHAR}, 
      #{item.bcode,jdbcType=VARCHAR}, #{item.seqno,jdbcType=VARCHAR}, #{item.mods,jdbcType=DECIMAL}, 
      #{item.state,jdbcType=VARCHAR}, #{item.workshop,jdbcType=VARCHAR}, #{item.itemid,jdbcType=VARCHAR}, 
      #{item.fourgitem,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_RM_ELECTRICITY_LOCATION
     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>
       ,WORKPROCID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.workprocid,jdbcType=VARCHAR}
       </foreach>
       ,LOCATION=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.location,jdbcType=VARCHAR}
       </foreach>
       ,TYPE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.type,jdbcType=VARCHAR}
       </foreach>
       ,NOTE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.note,jdbcType=VARCHAR}
       </foreach>
       ,CREATEMAN=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.createman,jdbcType=VARCHAR}
       </foreach>
       ,CREATETIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.createtime,jdbcType=TIMESTAMP}
       </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 #{item.updatetime,jdbcType=TIMESTAMP}
       </foreach>
       ,ITEMNAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.itemname,jdbcType=VARCHAR}
       </foreach>
       ,BCODE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.bcode,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=VARCHAR}
       </foreach>
       ,MODS=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.mods,jdbcType=DECIMAL}
       </foreach>
       ,STATE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.state,jdbcType=VARCHAR}
       </foreach>
       ,WORKSHOP=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.workshop,jdbcType=VARCHAR}
       </foreach>
       ,ITEMID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.itemid,jdbcType=VARCHAR}
       </foreach>
       ,FOURGITEM=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.fourgitem,jdbcType=VARCHAR}
       </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_ELECTRICITY_LOCATION
    where ID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
 <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  <select id="getMaxId" resultType="string">
    SELECT MAX(to_number(id)) FROM T_RM_ELECTRICITY_LOCATION
  </select>
  
  <!-- 根据itemid获取外供电地点 -->
  <select id="getByItemid" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where ITEMID = #{itemid,jdbcType=VARCHAR}
  </select>
</mapper>