<?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.meterbaseprint.mapper.MeterBasePrintMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.baseinfo.meterbaseprint.model.MeterBasePrint">
    <id column="PRINT_ID" jdbcType="VARCHAR" property="printId" />
    <result column="ACTUAL_NO" jdbcType="VARCHAR" property="actualNo" />
    <result column="PRINT_DATE" jdbcType="TIMESTAMP" property="printDate" />
    <result column="PRINT_NUM" jdbcType="VARCHAR" property="printNum" />
  </resultMap>
  <sql id="columns">
    PRINT_ID, ACTUAL_NO, PRINT_DATE, PRINT_NUM
  </sql>
  <sql id="columns_alias">
    t.PRINT_ID, t.ACTUAL_NO, t.PRINT_DATE, t.PRINT_NUM
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM METER_BASE_PRINT
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM METER_BASE_PRINT t
  </sql>
  <sql id="where">
    <where> 
      <if test="printId != null and printId != ''">
        and PRINT_ID = #{printId}
      </if>
      <if test="actualNo != null and actualNo != ''">
        and ACTUAL_NO = #{actualNo}
      </if>
      <if test="printDate != null">
        and TO_CHAR(PRINT_DATE,'yyyy-MM-dd') = #{printDate}
      </if>
      <if test="printNum != null and printNum != ''">
        and PRINT_NUM = #{printNum}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="printId != null and printId != ''">
        and PRINT_ID LIKE '%${printId}%'
      </if>
      <if test="actualNo != null and actualNo != ''">
        and ACTUAL_NO LIKE '%${actualNo}%'
      </if>
      <if test="printDate != null">
        and TO_CHAR(PRINT_DATE,'yyyy-MM-dd') = #{printDate}
      </if>
      <if test="printNum != null and printNum != ''">
        and PRINT_NUM LIKE '%${printNum}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from METER_BASE_PRINT
    where PRINT_ID = #{printId,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_BASE_PRINT
    where 1!=1 
      <if test="actualNo != null and actualNo != ''">
        or ACTUAL_NO = #{actualNo}
      </if>
      <if test="printDate != null">
        or TO_CHAR(PRINT_DATE,'yyyy-MM-dd') = '#{printDate}'
      </if>
      <if test="printNum != null and printNum != ''">
        or PRINT_NUM = #{printNum}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.baseinfo.meterbaseprint.model.MeterBasePrint">
    insert into METER_BASE_PRINT (PRINT_ID, ACTUAL_NO, PRINT_DATE, 
      PRINT_NUM)
    values (#{printId,jdbcType=VARCHAR}, #{actualNo,jdbcType=VARCHAR}, #{printDate,jdbcType=TIMESTAMP}, 
      #{printNum,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.baseinfo.meterbaseprint.model.MeterBasePrint">
    insert into METER_BASE_PRINT
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="printId != null">
        PRINT_ID,
      </if>
      <if test="actualNo != null">
        ACTUAL_NO,
      </if>
      <if test="printDate != null">
        PRINT_DATE,
      </if>
      <if test="printNum != null">
        PRINT_NUM,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="printId != null">
        #{printId,jdbcType=VARCHAR},
      </if>
      <if test="actualNo != null">
        #{actualNo,jdbcType=VARCHAR},
      </if>
      <if test="printDate != null">
        #{printDate,jdbcType=TIMESTAMP},
      </if>
      <if test="printNum != null">
        #{printNum,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.baseinfo.meterbaseprint.model.MeterBasePrint">
    update METER_BASE_PRINT
    set ACTUAL_NO = #{actualNo,jdbcType=VARCHAR},
      PRINT_DATE = #{printDate,jdbcType=TIMESTAMP},
      PRINT_NUM = #{printNum,jdbcType=VARCHAR}
    where PRINT_ID = #{printId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.baseinfo.meterbaseprint.model.MeterBasePrint">
    update METER_BASE_PRINT
    <set>
      <if test="actualNo != null">
        ACTUAL_NO = #{actualNo,jdbcType=VARCHAR},
      </if>
      <if test="printDate != null">
        PRINT_DATE = #{printDate,jdbcType=TIMESTAMP},
      </if>
      <if test="printNum != null">
        PRINT_NUM = #{printNum,jdbcType=VARCHAR},
      </if>
    </set>
    where PRINT_ID = #{printId,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where PRINT_ID = #{printId,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_PRINT 
      (PRINT_ID, 
      ACTUAL_NO, PRINT_DATE, PRINT_NUM
      )
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.printId,jdbcType=VARCHAR}, 
      #{item.actualNo,jdbcType=VARCHAR}, #{item.printDate,jdbcType=TIMESTAMP}, #{item.printNum,jdbcType=VARCHAR}
       from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update METER_BASE_PRINT
     set
       PRINT_ID=
       <foreach collection="list" item="item" index="index" separator=" " open="case PRINT_ID" close="end">
          when #{item.printId,jdbcType=VARCHAR} then #{item.printId,jdbcType=VARCHAR}
       </foreach>
       ,ACTUAL_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case PRINT_ID" close="end">
          when #{item.printId,jdbcType=VARCHAR} then #{item.actualNo,jdbcType=VARCHAR}
       </foreach>
       ,PRINT_DATE=
       <foreach collection="list" item="item" index="index" separator=" " open="case PRINT_ID" close="end">
          when #{item.printId,jdbcType=VARCHAR} then #{item.printDate,jdbcType=TIMESTAMP}
       </foreach>
       ,PRINT_NUM=
       <foreach collection="list" item="item" index="index" separator=" " open="case PRINT_ID" close="end">
          when #{item.printId,jdbcType=VARCHAR} then #{item.printNum,jdbcType=VARCHAR}
       </foreach>
     where PRINT_ID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.printId,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_BASE_PRINT
    where PRINT_ID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  
</mapper>