<?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.meterwork.meterstoragemonitornote.mapper.MeterStorageMonitorNoteMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.meterwork.meterstoragemonitornote.model.MeterStorageMonitorNote">
    <id column="NOTE_NO" jdbcType="VARCHAR" property="noteNo" />
    <result column="BASE_SPOT_NO" jdbcType="VARCHAR" property="baseSpotNo" />
    <result column="BASE_SPOT_NAME" jdbcType="VARCHAR" property="baseSpotName" />
    <result column="OPERATION_CONTENT" jdbcType="VARCHAR" property="operationContent" />
    <result column="OPERATION_TIME" jdbcType="VARCHAR" property="operationTime" />
    <result column="PACKAGE_NO" jdbcType="VARCHAR" property="packageNo" />
    <result column="METER_MAN_NO" jdbcType="VARCHAR" property="meterManNo" />
    <result column="METER_MAN_NAME" jdbcType="VARCHAR" property="meterManName" />
    <result column="METER_NOTE_SOURCE" jdbcType="VARCHAR" property="meterNoteSource" />
  </resultMap>
  <sql id="columns">
    NOTE_NO, BASE_SPOT_NO, BASE_SPOT_NAME, OPERATION_CONTENT, OPERATION_TIME, PACKAGE_NO, 
    METER_MAN_NO, METER_MAN_NAME, METER_NOTE_SOURCE
  </sql>
  <sql id="columns_alias">
    t.NOTE_NO, t.BASE_SPOT_NO, t.BASE_SPOT_NAME, t.OPERATION_CONTENT, t.OPERATION_TIME, 
    t.PACKAGE_NO, t.METER_MAN_NO, t.METER_MAN_NAME, t.METER_NOTE_SOURCE
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM METER_STORAGE_MONITOR_NOTE
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM METER_STORAGE_MONITOR_NOTE t
  </sql>
  <sql id="where">
    <where> 
      <if test="baseSpotNo != null and baseSpotNo != ''">
        and BASE_SPOT_NO = #{baseSpotNo}
      </if>
      <if test="baseSpotName != null and baseSpotName != ''">
        and BASE_SPOT_NAME = #{baseSpotName}
      </if>
      <if test="operationContent != null and operationContent != ''">
        and OPERATION_CONTENT = #{operationContent}
      </if>
      <if test="operationTime != null and operationTime != ''">
        and OPERATION_TIME = #{operationTime}
      </if>
      <if test="packageNo != null and packageNo != ''">
        and PACKAGE_NO = #{packageNo}
      </if>
      <if test="meterManNo != null and meterManNo != ''">
        and METER_MAN_NO = #{meterManNo}
      </if>
      <if test="meterManName != null and meterManName != ''">
        and METER_MAN_NAME = #{meterManName}
      </if>
      <if test="meterNoteSource != null and meterNoteSource != ''">
        and METER_NOTE_SOURCE = #{meterNoteSource}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="baseSpotNo != null and baseSpotNo != ''">
        and BASE_SPOT_NO LIKE '%${baseSpotNo}%'
      </if>
      <if test="baseSpotName != null and baseSpotName != ''">
        and BASE_SPOT_NAME LIKE '%${baseSpotName}%'
      </if>
      <if test="operationContent != null and operationContent != ''">
        and OPERATION_CONTENT LIKE '%${operationContent}%'
      </if>
      <if test="operationTime != null and operationTime != ''">
        and OPERATION_TIME LIKE '%${operationTime}%'
      </if>
      <if test="packageNo != null and packageNo != ''">
        and PACKAGE_NO LIKE '%${packageNo}%'
      </if>
      <if test="meterManNo != null and meterManNo != ''">
        and METER_MAN_NO LIKE '%${meterManNo}%'
      </if>
      <if test="meterManName != null and meterManName != ''">
        and METER_MAN_NAME LIKE '%${meterManName}%'
      </if>
      <if test="meterNoteSource != null and meterNoteSource != ''">
        and METER_NOTE_SOURCE LIKE '%${meterNoteSource}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from METER_STORAGE_MONITOR_NOTE
    where NOTE_NO = #{noteNo,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_STORAGE_MONITOR_NOTE
    where 1!=1 
      <if test="baseSpotNo != null and baseSpotNo != ''">
        or BASE_SPOT_NO = #{baseSpotNo}
      </if>
      <if test="baseSpotName != null and baseSpotName != ''">
        or BASE_SPOT_NAME = #{baseSpotName}
      </if>
      <if test="operationContent != null and operationContent != ''">
        or OPERATION_CONTENT = #{operationContent}
      </if>
      <if test="operationTime != null and operationTime != ''">
        or OPERATION_TIME = #{operationTime}
      </if>
      <if test="packageNo != null and packageNo != ''">
        or PACKAGE_NO = #{packageNo}
      </if>
      <if test="meterManNo != null and meterManNo != ''">
        or METER_MAN_NO = #{meterManNo}
      </if>
      <if test="meterManName != null and meterManName != ''">
        or METER_MAN_NAME = #{meterManName}
      </if>
      <if test="meterNoteSource != null and meterNoteSource != ''">
        or METER_NOTE_SOURCE = #{meterNoteSource}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.meterwork.meterstoragemonitornote.model.MeterStorageMonitorNote">
    insert into METER_STORAGE_MONITOR_NOTE (NOTE_NO, BASE_SPOT_NO, BASE_SPOT_NAME, 
      OPERATION_CONTENT, OPERATION_TIME, PACKAGE_NO, 
      METER_MAN_NO, METER_MAN_NAME, METER_NOTE_SOURCE
      )
    values (#{noteNo,jdbcType=VARCHAR}, #{baseSpotNo,jdbcType=VARCHAR}, #{baseSpotName,jdbcType=VARCHAR}, 
      #{operationContent,jdbcType=VARCHAR}, #{operationTime,jdbcType=VARCHAR}, #{packageNo,jdbcType=VARCHAR}, 
      #{meterManNo,jdbcType=VARCHAR}, #{meterManName,jdbcType=VARCHAR}, #{meterNoteSource,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.meterwork.meterstoragemonitornote.model.MeterStorageMonitorNote">
    insert into METER_STORAGE_MONITOR_NOTE
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="noteNo != null">
        NOTE_NO,
      </if>
      <if test="baseSpotNo != null">
        BASE_SPOT_NO,
      </if>
      <if test="baseSpotName != null">
        BASE_SPOT_NAME,
      </if>
      <if test="operationContent != null">
        OPERATION_CONTENT,
      </if>
      <if test="operationTime != null">
        OPERATION_TIME,
      </if>
      <if test="packageNo != null">
        PACKAGE_NO,
      </if>
      <if test="meterManNo != null">
        METER_MAN_NO,
      </if>
      <if test="meterManName != null">
        METER_MAN_NAME,
      </if>
      <if test="meterNoteSource != null">
        METER_NOTE_SOURCE,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="noteNo != null">
        #{noteNo,jdbcType=VARCHAR},
      </if>
      <if test="baseSpotNo != null">
        #{baseSpotNo,jdbcType=VARCHAR},
      </if>
      <if test="baseSpotName != null">
        #{baseSpotName,jdbcType=VARCHAR},
      </if>
      <if test="operationContent != null">
        #{operationContent,jdbcType=VARCHAR},
      </if>
      <if test="operationTime != null">
        #{operationTime,jdbcType=VARCHAR},
      </if>
      <if test="packageNo != null">
        #{packageNo,jdbcType=VARCHAR},
      </if>
      <if test="meterManNo != null">
        #{meterManNo,jdbcType=VARCHAR},
      </if>
      <if test="meterManName != null">
        #{meterManName,jdbcType=VARCHAR},
      </if>
      <if test="meterNoteSource != null">
        #{meterNoteSource,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.meterwork.meterstoragemonitornote.model.MeterStorageMonitorNote">
    update METER_STORAGE_MONITOR_NOTE
    set BASE_SPOT_NO = #{baseSpotNo,jdbcType=VARCHAR},
      BASE_SPOT_NAME = #{baseSpotName,jdbcType=VARCHAR},
      OPERATION_CONTENT = #{operationContent,jdbcType=VARCHAR},
      OPERATION_TIME = #{operationTime,jdbcType=VARCHAR},
      PACKAGE_NO = #{packageNo,jdbcType=VARCHAR},
      METER_MAN_NO = #{meterManNo,jdbcType=VARCHAR},
      METER_MAN_NAME = #{meterManName,jdbcType=VARCHAR},
      METER_NOTE_SOURCE = #{meterNoteSource,jdbcType=VARCHAR}
    where NOTE_NO = #{noteNo,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.meterwork.meterstoragemonitornote.model.MeterStorageMonitorNote">
    update METER_STORAGE_MONITOR_NOTE
    <set>
      <if test="baseSpotNo != null">
        BASE_SPOT_NO = #{baseSpotNo,jdbcType=VARCHAR},
      </if>
      <if test="baseSpotName != null">
        BASE_SPOT_NAME = #{baseSpotName,jdbcType=VARCHAR},
      </if>
      <if test="operationContent != null">
        OPERATION_CONTENT = #{operationContent,jdbcType=VARCHAR},
      </if>
      <if test="operationTime != null">
        OPERATION_TIME = #{operationTime,jdbcType=VARCHAR},
      </if>
      <if test="packageNo != null">
        PACKAGE_NO = #{packageNo,jdbcType=VARCHAR},
      </if>
      <if test="meterManNo != null">
        METER_MAN_NO = #{meterManNo,jdbcType=VARCHAR},
      </if>
      <if test="meterManName != null">
        METER_MAN_NAME = #{meterManName,jdbcType=VARCHAR},
      </if>
      <if test="meterNoteSource != null">
        METER_NOTE_SOURCE = #{meterNoteSource,jdbcType=VARCHAR},
      </if>
    </set>
    where NOTE_NO = #{noteNo,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where NOTE_NO = #{noteNo,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="where"/>
    order by  OPERATION_TIME desc
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="whereLike"/>
    order by  OPERATION_TIME desc
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into METER_STORAGE_MONITOR_NOTE 
      (NOTE_NO, 
      BASE_SPOT_NO, BASE_SPOT_NAME, OPERATION_CONTENT, 
      OPERATION_TIME, PACKAGE_NO, METER_MAN_NO, 
      METER_MAN_NAME, METER_NOTE_SOURCE
      )
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.noteNo,jdbcType=VARCHAR}, 
      #{item.baseSpotNo,jdbcType=VARCHAR}, #{item.baseSpotName,jdbcType=VARCHAR}, #{item.operationContent,jdbcType=VARCHAR}, 
      #{item.operationTime,jdbcType=VARCHAR}, #{item.packageNo,jdbcType=VARCHAR}, #{item.meterManNo,jdbcType=VARCHAR}, 
      #{item.meterManName,jdbcType=VARCHAR}, #{item.meterNoteSource,jdbcType=VARCHAR}
       from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update METER_STORAGE_MONITOR_NOTE
     set
       NOTE_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTE_NO" close="end">
          when #{item.noteNo,jdbcType=VARCHAR} then #{item.noteNo,jdbcType=VARCHAR}
       </foreach>
       ,BASE_SPOT_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTE_NO" close="end">
          when #{item.noteNo,jdbcType=VARCHAR} then #{item.baseSpotNo,jdbcType=VARCHAR}
       </foreach>
       ,BASE_SPOT_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTE_NO" close="end">
          when #{item.noteNo,jdbcType=VARCHAR} then #{item.baseSpotName,jdbcType=VARCHAR}
       </foreach>
       ,OPERATION_CONTENT=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTE_NO" close="end">
          when #{item.noteNo,jdbcType=VARCHAR} then #{item.operationContent,jdbcType=VARCHAR}
       </foreach>
       ,OPERATION_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTE_NO" close="end">
          when #{item.noteNo,jdbcType=VARCHAR} then #{item.operationTime,jdbcType=VARCHAR}
       </foreach>
       ,PACKAGE_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTE_NO" close="end">
          when #{item.noteNo,jdbcType=VARCHAR} then #{item.packageNo,jdbcType=VARCHAR}
       </foreach>
       ,METER_MAN_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTE_NO" close="end">
          when #{item.noteNo,jdbcType=VARCHAR} then #{item.meterManNo,jdbcType=VARCHAR}
       </foreach>
       ,METER_MAN_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTE_NO" close="end">
          when #{item.noteNo,jdbcType=VARCHAR} then #{item.meterManName,jdbcType=VARCHAR}
       </foreach>
       ,METER_NOTE_SOURCE=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTE_NO" close="end">
          when #{item.noteNo,jdbcType=VARCHAR} then #{item.meterNoteSource,jdbcType=VARCHAR}
       </foreach>
     where NOTE_NO in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.noteNo,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_STORAGE_MONITOR_NOTE
    where NOTE_NO in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  <select id="selectView" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    SELECT <include refid="columns"/> from METER_STORAGE_MONITOR_NOTE_VIEW
    <where>
      <if test="baseSpotNo != null and baseSpotNo != ''">
        and BASE_SPOT_NO = #{baseSpotNo}
      </if>
      <if test="baseSpotName != null and baseSpotName != ''">
        and BASE_SPOT_NAME = #{baseSpotName}
      </if>
      <if test="packageNo != null and packageNo != ''">
        and PACKAGE_NO = #{packageNo}
      </if>
      <if test="operationTime1 != null and operationTime1 != ''">
        and  OPERATION_TIME  >= TO_DATE(#{operationTime1}, 'yyyy-MM-dd HH24:mi:ss')
      </if>
      <if test="operationTime2 != null and operationTime2!= ''">
        and OPERATION_TIME  &lt;=  TO_DATE(#{operationTime2}, 'yyyy-MM-dd HH24:mi:ss')
      </if>
    </where>
    order by  OPERATION_TIME desc
  </select>
</mapper>