<?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.baseinfo.meterbaserfidinfo.mapper.MeterBaseRfidInfoMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.baseinfo.meterbaserfidinfo.model.MeterBaseRfidInfo">
    <id column="RFID_ID" jdbcType="VARCHAR" property="rfidId" />
    <result column="RFID_CODE" jdbcType="VARCHAR" property="rfidCode" />
    <result column="CAR_NO" jdbcType="VARCHAR" property="carNo" />
    <result column="CREATE_MAN_NO" jdbcType="VARCHAR" property="createManNo" />
    <result column="CREATE_MAN_NAME" jdbcType="VARCHAR" property="createManName" />
    <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime" />
    <result column="VALUE_FLAG" jdbcType="VARCHAR" property="valueFlag" />
  </resultMap>
  <sql id="columns">
    RFID_ID, RFID_CODE, CAR_NO, CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME, VALUE_FLAG
  </sql>
  <sql id="columns_alias">
    t.RFID_ID, t.RFID_CODE, t.CAR_NO, t.CREATE_MAN_NO, t.CREATE_MAN_NAME, t.CREATE_TIME, 
    t.VALUE_FLAG
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM METER_BASE_RFID_INFO
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM METER_BASE_RFID_INFO t
  </sql>
  <sql id="where">
    <where> 
      <if test="rfidId != null and rfidId != ''">
        and RFID_ID = #{rfidId}
      </if>
      <if test="rfidCode != null and rfidCode != ''">
        and RFID_CODE = #{rfidCode}
      </if>
      <if test="carNo != null and carNo != ''">
        and CAR_NO = #{carNo}
      </if>
      <if test="createManNo != null and createManNo != ''">
        and CREATE_MAN_NO = #{createManNo}
      </if>
      <if test="createManName != null and createManName != ''">
        and CREATE_MAN_NAME = #{createManName}
      </if>
      <if test="createTime != null">
        and TO_CHAR(CREATE_TIME,'yyyy-MM-dd') = #{createTime}
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        and VALUE_FLAG = #{valueFlag}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="rfidId != null and rfidId != ''">
        and RFID_ID LIKE '%${rfidId}%'
      </if>
      <if test="rfidCode != null and rfidCode != ''">
        and RFID_CODE LIKE '%${rfidCode}%'
      </if>
      <if test="carNo != null and carNo != ''">
        and CAR_NO LIKE '%${carNo}%'
      </if>
      <if test="createManNo != null and createManNo != ''">
        and CREATE_MAN_NO LIKE '%${createManNo}%'
      </if>
      <if test="createManName != null and createManName != ''">
        and CREATE_MAN_NAME LIKE '%${createManName}%'
      </if>
      <if test="createTime != null">
        and TO_CHAR(CREATE_TIME,'yyyy-MM-dd') = #{createTime}
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        and VALUE_FLAG LIKE '%${valueFlag}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from METER_BASE_RFID_INFO
    where RFID_ID = #{rfidId,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_BASE_RFID_INFO
    where 1!=1 
      <if test="rfidCode != null and rfidCode != ''">
        or RFID_CODE = #{rfidCode}
      </if>
      <if test="carNo != null and carNo != ''">
        or CAR_NO = #{carNo}
      </if>
      <if test="createManNo != null and createManNo != ''">
        or CREATE_MAN_NO = #{createManNo}
      </if>
      <if test="createManName != null and createManName != ''">
        or CREATE_MAN_NAME = #{createManName}
      </if>
      <if test="createTime != null">
        or TO_CHAR(CREATE_TIME,'yyyy-MM-dd') = '#{createTime}'
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        or VALUE_FLAG = #{valueFlag}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.baseinfo.meterbaserfidinfo.model.MeterBaseRfidInfo">
    insert into METER_BASE_RFID_INFO (RFID_ID, RFID_CODE, CAR_NO, 
      CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME, 
      VALUE_FLAG)
    values (#{rfidId,jdbcType=VARCHAR}, #{rfidCode,jdbcType=VARCHAR}, #{carNo,jdbcType=VARCHAR}, 
      #{createManNo,jdbcType=VARCHAR}, #{createManName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
      #{valueFlag,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.baseinfo.meterbaserfidinfo.model.MeterBaseRfidInfo">
    insert into METER_BASE_RFID_INFO
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="rfidId != null">
        RFID_ID,
      </if>
      <if test="rfidCode != null">
        RFID_CODE,
      </if>
      <if test="carNo != null">
        CAR_NO,
      </if>
      <if test="createManNo != null">
        CREATE_MAN_NO,
      </if>
      <if test="createManName != null">
        CREATE_MAN_NAME,
      </if>
      <if test="createTime != null">
        CREATE_TIME,
      </if>
      <if test="valueFlag != null">
        VALUE_FLAG,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="rfidId != null">
        #{rfidId,jdbcType=VARCHAR},
      </if>
      <if test="rfidCode != null">
        #{rfidCode,jdbcType=VARCHAR},
      </if>
      <if test="carNo != null">
        #{carNo,jdbcType=VARCHAR},
      </if>
      <if test="createManNo != null">
        #{createManNo,jdbcType=VARCHAR},
      </if>
      <if test="createManName != null">
        #{createManName,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="valueFlag != null">
        #{valueFlag,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.baseinfo.meterbaserfidinfo.model.MeterBaseRfidInfo">
    update METER_BASE_RFID_INFO
    set RFID_CODE = #{rfidCode,jdbcType=VARCHAR},
      CAR_NO = #{carNo,jdbcType=VARCHAR},
      CREATE_MAN_NO = #{createManNo,jdbcType=VARCHAR},
      CREATE_MAN_NAME = #{createManName,jdbcType=VARCHAR},
      CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
      VALUE_FLAG = #{valueFlag,jdbcType=VARCHAR}
    where RFID_ID = #{rfidId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.baseinfo.meterbaserfidinfo.model.MeterBaseRfidInfo">
    update METER_BASE_RFID_INFO
    <set>
      <if test="rfidCode != null">
        RFID_CODE = #{rfidCode,jdbcType=VARCHAR},
      </if>
      <if test="carNo != null">
        CAR_NO = #{carNo,jdbcType=VARCHAR},
      </if>
      <if test="createManNo != null">
        CREATE_MAN_NO = #{createManNo,jdbcType=VARCHAR},
      </if>
      <if test="createManName != null">
        CREATE_MAN_NAME = #{createManName,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="valueFlag != null">
        VALUE_FLAG = #{valueFlag,jdbcType=VARCHAR},
      </if>
    </set>
    where RFID_ID = #{rfidId,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where RFID_ID = #{rfidId,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 METER_BASE_RFID_INFO 
      (RFID_ID, 
      RFID_CODE, CAR_NO, CREATE_MAN_NO, 
      CREATE_MAN_NAME, CREATE_TIME, 
      VALUE_FLAG)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.rfidId,jdbcType=VARCHAR}, 
      #{item.rfidCode,jdbcType=VARCHAR}, #{item.carNo,jdbcType=VARCHAR}, #{item.createManNo,jdbcType=VARCHAR}, 
      #{item.createManName,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, 
      #{item.valueFlag,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update METER_BASE_RFID_INFO
     set
       RFID_ID=
       <foreach collection="list" item="item" index="index" separator=" " open="case RFID_ID" close="end">
          when #{item.rfidId,jdbcType=VARCHAR} then #{item.rfidId,jdbcType=VARCHAR}
       </foreach>
       ,RFID_CODE=
       <foreach collection="list" item="item" index="index" separator=" " open="case RFID_ID" close="end">
          when #{item.rfidId,jdbcType=VARCHAR} then #{item.rfidCode,jdbcType=VARCHAR}
       </foreach>
       ,CAR_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case RFID_ID" close="end">
          when #{item.rfidId,jdbcType=VARCHAR} then #{item.carNo,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_MAN_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case RFID_ID" close="end">
          when #{item.rfidId,jdbcType=VARCHAR} then #{item.createManNo,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_MAN_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case RFID_ID" close="end">
          when #{item.rfidId,jdbcType=VARCHAR} then #{item.createManName,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case RFID_ID" close="end">
          when #{item.rfidId,jdbcType=VARCHAR} then #{item.createTime,jdbcType=TIMESTAMP}
       </foreach>
       ,VALUE_FLAG=
       <foreach collection="list" item="item" index="index" separator=" " open="case RFID_ID" close="end">
          when #{item.rfidId,jdbcType=VARCHAR} then #{item.valueFlag,jdbcType=VARCHAR}
       </foreach>
     where RFID_ID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.rfidId,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_BASE_RFID_INFO
    where RFID_ID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  <select id="getNewID" parameterType="java.lang.String" resultType="java.lang.String">
    SELECT LPAD(NVL(MAX(TO_NUMBER(SUBSTR(rfid_Id, LENGTH(rfid_Id) - 3))),0) + 1,4,'0') rfid_Id
    FROM meter_base_rfid_info where instr(rfid_Id,#{afl,jdbcType=VARCHAR})>0
  </select>
</mapper>