<?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.meterfilestorage.mapper.MeterFileStorageMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.baseinfo.meterfilestorage.model.MeterFileStorage">
    <id column="FILE_ID" jdbcType="VARCHAR" property="fileId" />
    <result column="FILE_NAME" jdbcType="VARCHAR" property="fileName" />
    <result column="FILE_PATH" jdbcType="VARCHAR" property="filePath" />
    <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="UPDATE_MAN_NO" jdbcType="VARCHAR" property="updateManNo" />
    <result column="UPDATE_MAN_NAME" jdbcType="VARCHAR" property="updateManName" />
    <result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="MEMO" jdbcType="VARCHAR" property="memo" />
    <result column="VALID_FLAG" jdbcType="VARCHAR" property="validFlag" />
  </resultMap>
  <sql id="columns">
    FILE_ID, FILE_NAME, FILE_PATH, CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME, UPDATE_MAN_NO, 
    UPDATE_MAN_NAME, UPDATE_TIME, MEMO, VALID_FLAG
  </sql>
  <sql id="columns_alias">
    t.FILE_ID, t.FILE_NAME, t.FILE_PATH, t.CREATE_MAN_NO, t.CREATE_MAN_NAME, t.CREATE_TIME, 
    t.UPDATE_MAN_NO, t.UPDATE_MAN_NAME, t.UPDATE_TIME, t.MEMO, t.VALID_FLAG
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM METER_FILE_STORAGE
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM METER_FILE_STORAGE t
  </sql>
  <sql id="where">
    <where> 
      <if test="fileId != null and fileId != ''">
        and FILE_ID = #{fileId}
      </if>
      <if test="fileName != null and fileName != ''">
        and FILE_NAME = #{fileName}
      </if>
      <if test="filePath != null and filePath != ''">
        and FILE_PATH = #{filePath}
      </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="updateManNo != null and updateManNo != ''">
        and UPDATE_MAN_NO = #{updateManNo}
      </if>
      <if test="updateManName != null and updateManName != ''">
        and UPDATE_MAN_NAME = #{updateManName}
      </if>
      <if test="updateTime != null">
        and TO_CHAR(UPDATE_TIME,'yyyy-MM-dd') = #{updateTime}
      </if>
      <if test="memo != null and memo != ''">
        and MEMO = #{memo}
      </if>
      <if test="validFlag != null and validFlag != ''">
        and VALID_FLAG = #{validFlag}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="fileId != null and fileId != ''">
        and FILE_ID LIKE '%${fileId}%'
      </if>
      <if test="fileName != null and fileName != ''">
        and FILE_NAME LIKE '%${fileName}%'
      </if>
      <if test="filePath != null and filePath != ''">
        and FILE_PATH LIKE '%${filePath}%'
      </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="updateManNo != null and updateManNo != ''">
        and UPDATE_MAN_NO LIKE '%${updateManNo}%'
      </if>
      <if test="updateManName != null and updateManName != ''">
        and UPDATE_MAN_NAME LIKE '%${updateManName}%'
      </if>
      <if test="updateTime != null">
        and TO_CHAR(UPDATE_TIME,'yyyy-MM-dd') = #{updateTime}
      </if>
      <if test="memo != null and memo != ''">
        and MEMO LIKE '%${memo}%'
      </if>
      <if test="validFlag != null and validFlag != ''">
        and VALID_FLAG LIKE '%${validFlag}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from METER_FILE_STORAGE
    where FILE_ID = #{fileId,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_FILE_STORAGE
    where 1!=1 
      <if test="fileName != null and fileName != ''">
        or FILE_NAME = #{fileName}
      </if>
      <if test="filePath != null and filePath != ''">
        or FILE_PATH = #{filePath}
      </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="updateManNo != null and updateManNo != ''">
        or UPDATE_MAN_NO = #{updateManNo}
      </if>
      <if test="updateManName != null and updateManName != ''">
        or UPDATE_MAN_NAME = #{updateManName}
      </if>
      <if test="updateTime != null">
        or TO_CHAR(UPDATE_TIME,'yyyy-MM-dd') = '#{updateTime}'
      </if>
      <if test="memo != null and memo != ''">
        or MEMO = #{memo}
      </if>
      <if test="validFlag != null and validFlag != ''">
        or VALID_FLAG = #{validFlag}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.baseinfo.meterfilestorage.model.MeterFileStorage">
    insert into METER_FILE_STORAGE (FILE_ID, FILE_NAME, FILE_PATH, 
      CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME, 
      UPDATE_MAN_NO, UPDATE_MAN_NAME, UPDATE_TIME, 
      MEMO, VALID_FLAG)
    values (#{fileId,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR}, #{filePath,jdbcType=VARCHAR}, 
      #{createManNo,jdbcType=VARCHAR}, #{createManName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
      #{updateManNo,jdbcType=VARCHAR}, #{updateManName,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, 
      #{memo,jdbcType=VARCHAR}, #{validFlag,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.baseinfo.meterfilestorage.model.MeterFileStorage">
    insert into METER_FILE_STORAGE
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="fileId != null">
        FILE_ID,
      </if>
      <if test="fileName != null">
        FILE_NAME,
      </if>
      <if test="filePath != null">
        FILE_PATH,
      </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="updateManNo != null">
        UPDATE_MAN_NO,
      </if>
      <if test="updateManName != null">
        UPDATE_MAN_NAME,
      </if>
      <if test="updateTime != null">
        UPDATE_TIME,
      </if>
      <if test="memo != null">
        MEMO,
      </if>
      <if test="validFlag != null">
        VALID_FLAG,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="fileId != null">
        #{fileId,jdbcType=VARCHAR},
      </if>
      <if test="fileName != null">
        #{fileName,jdbcType=VARCHAR},
      </if>
      <if test="filePath != null">
        #{filePath,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="updateManNo != null">
        #{updateManNo,jdbcType=VARCHAR},
      </if>
      <if test="updateManName != null">
        #{updateManName,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="memo != null">
        #{memo,jdbcType=VARCHAR},
      </if>
      <if test="validFlag != null">
        #{validFlag,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.baseinfo.meterfilestorage.model.MeterFileStorage">
    update METER_FILE_STORAGE
    set FILE_NAME = #{fileName,jdbcType=VARCHAR},
      FILE_PATH = #{filePath,jdbcType=VARCHAR},
      CREATE_MAN_NO = #{createManNo,jdbcType=VARCHAR},
      CREATE_MAN_NAME = #{createManName,jdbcType=VARCHAR},
      CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
      UPDATE_MAN_NO = #{updateManNo,jdbcType=VARCHAR},
      UPDATE_MAN_NAME = #{updateManName,jdbcType=VARCHAR},
      UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
      MEMO = #{memo,jdbcType=VARCHAR},
      VALID_FLAG = #{validFlag,jdbcType=VARCHAR}
    where FILE_ID = #{fileId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.baseinfo.meterfilestorage.model.MeterFileStorage">
    update METER_FILE_STORAGE
    <set>
      <if test="fileName != null">
        FILE_NAME = #{fileName,jdbcType=VARCHAR},
      </if>
      <if test="filePath != null">
        FILE_PATH = #{filePath,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="updateManNo != null">
        UPDATE_MAN_NO = #{updateManNo,jdbcType=VARCHAR},
      </if>
      <if test="updateManName != null">
        UPDATE_MAN_NAME = #{updateManName,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="memo != null">
        MEMO = #{memo,jdbcType=VARCHAR},
      </if>
      <if test="validFlag != null">
        VALID_FLAG = #{validFlag,jdbcType=VARCHAR},
      </if>
    </set>
    where FILE_ID = #{fileId,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where FILE_ID = #{fileId,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_FILE_STORAGE 
      (FILE_ID, 
      FILE_NAME, FILE_PATH, CREATE_MAN_NO, 
      CREATE_MAN_NAME, CREATE_TIME, 
      UPDATE_MAN_NO, UPDATE_MAN_NAME, UPDATE_TIME, 
      MEMO, VALID_FLAG)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.fileId,jdbcType=VARCHAR}, 
      #{item.fileName,jdbcType=VARCHAR}, #{item.filePath,jdbcType=VARCHAR}, #{item.createManNo,jdbcType=VARCHAR}, 
      #{item.createManName,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, 
      #{item.updateManNo,jdbcType=VARCHAR}, #{item.updateManName,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP}, 
      #{item.memo,jdbcType=VARCHAR}, #{item.validFlag,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update METER_FILE_STORAGE
     set
       FILE_ID=
       <foreach collection="list" item="item" index="index" separator=" " open="case FILE_ID" close="end">
          when #{item.fileId,jdbcType=VARCHAR} then #{item.fileId,jdbcType=VARCHAR}
       </foreach>
       ,FILE_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case FILE_ID" close="end">
          when #{item.fileId,jdbcType=VARCHAR} then #{item.fileName,jdbcType=VARCHAR}
       </foreach>
       ,FILE_PATH=
       <foreach collection="list" item="item" index="index" separator=" " open="case FILE_ID" close="end">
          when #{item.fileId,jdbcType=VARCHAR} then #{item.filePath,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_MAN_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case FILE_ID" close="end">
          when #{item.fileId,jdbcType=VARCHAR} then #{item.createManNo,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_MAN_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case FILE_ID" close="end">
          when #{item.fileId,jdbcType=VARCHAR} then #{item.createManName,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case FILE_ID" close="end">
          when #{item.fileId,jdbcType=VARCHAR} then #{item.createTime,jdbcType=TIMESTAMP}
       </foreach>
       ,UPDATE_MAN_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case FILE_ID" close="end">
          when #{item.fileId,jdbcType=VARCHAR} then #{item.updateManNo,jdbcType=VARCHAR}
       </foreach>
       ,UPDATE_MAN_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case FILE_ID" close="end">
          when #{item.fileId,jdbcType=VARCHAR} then #{item.updateManName,jdbcType=VARCHAR}
       </foreach>
       ,UPDATE_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case FILE_ID" close="end">
          when #{item.fileId,jdbcType=VARCHAR} then #{item.updateTime,jdbcType=TIMESTAMP}
       </foreach>
       ,MEMO=
       <foreach collection="list" item="item" index="index" separator=" " open="case FILE_ID" close="end">
          when #{item.fileId,jdbcType=VARCHAR} then #{item.memo,jdbcType=VARCHAR}
       </foreach>
       ,VALID_FLAG=
       <foreach collection="list" item="item" index="index" separator=" " open="case FILE_ID" close="end">
          when #{item.fileId,jdbcType=VARCHAR} then #{item.validFlag,jdbcType=VARCHAR}
       </foreach>
     where FILE_ID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.fileId,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_FILE_STORAGE
    where FILE_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(FILE_ID,9))),0) + 1,4,'0') FILE_ID
    FROM METER_FILE_STORAGE where instr(FILE_ID,#{afl,jdbcType=VARCHAR})>0
  </select>
</mapper>