<?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.meterbasemattertimes.mapper.MeterBaseMatterTimesMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.baseinfo.meterbasemattertimes.model.MeterBaseMatterTimes">
    <id column="MATTER_TIMES_NO" jdbcType="VARCHAR" property="matterTimesNo" />
    <result column="TIMES_NO" jdbcType="VARCHAR" property="timesNo" />
    <result column="MATTER_NO" jdbcType="VARCHAR" property="matterNo" />
    <result column="MATTER_NAME" jdbcType="VARCHAR" property="matterName" />
    <result column="MATTER_NATURE_NO" jdbcType="VARCHAR" property="matterNatureNo" />
    <result column="MATTER_NATURE_NAME" jdbcType="VARCHAR" property="matterNatureName" />
    <result column="METER_NATURE_NO" jdbcType="VARCHAR" property="meterNatureNo" />
    <result column="METER_NATURE_NAME" jdbcType="VARCHAR" property="meterNatureName" />
    <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" />
  </resultMap>
  <sql id="columns">
    MATTER_TIMES_NO, TIMES_NO, MATTER_NO, MATTER_NAME, MATTER_NATURE_NO, MATTER_NATURE_NAME, 
    METER_NATURE_NO, METER_NATURE_NAME, CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME
  </sql>
  <sql id="columns_alias">
    t.MATTER_TIMES_NO, t.TIMES_NO, t.MATTER_NO, t.MATTER_NAME, t.MATTER_NATURE_NO, t.MATTER_NATURE_NAME, 
    t.METER_NATURE_NO, t.METER_NATURE_NAME, t.CREATE_MAN_NO, t.CREATE_MAN_NAME, t.CREATE_TIME
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM METER_BASE_MATTER_TIMES
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM METER_BASE_MATTER_TIMES t
  </sql>
  <sql id="where">
    <where>
      <if test="matterTimesNo != null and matterTimesNo != ''">
        and MATTER_TIMES_NO = #{matterTimesNo}
      </if>
      <if test="timesNo != null and timesNo != ''">
        and TIMES_NO = #{timesNo}
      </if>
      <if test="matterNo != null and matterNo != ''">
        and MATTER_NO = #{matterNo}
      </if>
      <if test="matterName != null and matterName != ''">
        and MATTER_NAME = #{matterName}
      </if>
      <if test="matterNatureNo != null and matterNatureNo != ''">
        and MATTER_NATURE_NO = #{matterNatureNo}
      </if>
      <if test="matterNatureName != null and matterNatureName != ''">
        and MATTER_NATURE_NAME = #{matterNatureName}
      </if>
      <if test="meterNatureNo != null and meterNatureNo != ''">
        and METER_NATURE_NO = #{meterNatureNo}
      </if>
      <if test="meterNatureName != null and meterNatureName != ''">
        and METER_NATURE_NAME = #{meterNatureName}
      </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>
    </where>
  </sql>
  <sql id="whereLike">
    <where>
      <if test="matterTimesNo != null and matterTimesNo != ''">
        and MATTER_TIMES_NO LIKE '%${matterTimesNo}%'
      </if>
      <if test="timesNo != null and timesNo != ''">
        and TIMES_NO LIKE '%${timesNo}%'
      </if>
      <if test="matterNo != null and matterNo != ''">
        and MATTER_NO LIKE '%${matterNo}%'
      </if>
      <if test="matterName != null and matterName != ''">
        and MATTER_NAME LIKE '%${matterName}%'
      </if>
      <if test="matterNatureNo != null and matterNatureNo != ''">
        and MATTER_NATURE_NO LIKE '%${matterNatureNo}%'
      </if>
      <if test="matterNatureName != null and matterNatureName != ''">
        and MATTER_NATURE_NAME LIKE '%${matterNatureName}%'
      </if>
      <if test="meterNatureNo != null and meterNatureNo != ''">
        and METER_NATURE_NO LIKE '%${meterNatureNo}%'
      </if>
      <if test="meterNatureName != null and meterNatureName != ''">
        and METER_NATURE_NAME LIKE '%${meterNatureName}%'
      </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>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from METER_BASE_MATTER_TIMES
    where MATTER_TIMES_NO = #{matterTimesNo,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_BASE_MATTER_TIMES
    where 1!=1 
      <if test="timesNo != null and timesNo != ''">
        or TIMES_NO = #{timesNo}
      </if>
      <if test="matterNo != null and matterNo != ''">
        or MATTER_NO = #{matterNo}
      </if>
      <if test="matterName != null and matterName != ''">
        or MATTER_NAME = #{matterName}
      </if>
      <if test="matterNatureNo != null and matterNatureNo != ''">
        or MATTER_NATURE_NO = #{matterNatureNo}
      </if>
      <if test="matterNatureName != null and matterNatureName != ''">
        or MATTER_NATURE_NAME = #{matterNatureName}
      </if>
      <if test="meterNatureNo != null and meterNatureNo != ''">
        or METER_NATURE_NO = #{meterNatureNo}
      </if>
      <if test="meterNatureName != null and meterNatureName != ''">
        or METER_NATURE_NAME = #{meterNatureName}
      </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>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.baseinfo.meterbasemattertimes.model.MeterBaseMatterTimes">
    insert into METER_BASE_MATTER_TIMES (MATTER_TIMES_NO, TIMES_NO, MATTER_NO, 
      MATTER_NAME, MATTER_NATURE_NO, MATTER_NATURE_NAME, 
      METER_NATURE_NO, METER_NATURE_NAME, CREATE_MAN_NO, 
      CREATE_MAN_NAME, CREATE_TIME)
    values (#{matterTimesNo,jdbcType=VARCHAR}, #{timesNo,jdbcType=VARCHAR}, #{matterNo,jdbcType=VARCHAR}, 
      #{matterName,jdbcType=VARCHAR}, #{matterNatureNo,jdbcType=VARCHAR}, #{matterNatureName,jdbcType=VARCHAR}, 
      #{meterNatureNo,jdbcType=VARCHAR}, #{meterNatureName,jdbcType=VARCHAR}, #{createManNo,jdbcType=VARCHAR}, 
      #{createManName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.baseinfo.meterbasemattertimes.model.MeterBaseMatterTimes">
    insert into METER_BASE_MATTER_TIMES
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="matterTimesNo != null">
        MATTER_TIMES_NO,
      </if>
      <if test="timesNo != null">
        TIMES_NO,
      </if>
      <if test="matterNo != null">
        MATTER_NO,
      </if>
      <if test="matterName != null">
        MATTER_NAME,
      </if>
      <if test="matterNatureNo != null">
        MATTER_NATURE_NO,
      </if>
      <if test="matterNatureName != null">
        MATTER_NATURE_NAME,
      </if>
      <if test="meterNatureNo != null">
        METER_NATURE_NO,
      </if>
      <if test="meterNatureName != null">
        METER_NATURE_NAME,
      </if>
      <if test="createManNo != null">
        CREATE_MAN_NO,
      </if>
      <if test="createManName != null">
        CREATE_MAN_NAME,
      </if>
      <if test="createTime != null">
        CREATE_TIME,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="matterTimesNo != null">
        #{matterTimesNo,jdbcType=VARCHAR},
      </if>
      <if test="timesNo != null">
        #{timesNo,jdbcType=VARCHAR},
      </if>
      <if test="matterNo != null">
        #{matterNo,jdbcType=VARCHAR},
      </if>
      <if test="matterName != null">
        #{matterName,jdbcType=VARCHAR},
      </if>
      <if test="matterNatureNo != null">
        #{matterNatureNo,jdbcType=VARCHAR},
      </if>
      <if test="matterNatureName != null">
        #{matterNatureName,jdbcType=VARCHAR},
      </if>
      <if test="meterNatureNo != null">
        #{meterNatureNo,jdbcType=VARCHAR},
      </if>
      <if test="meterNatureName != null">
        #{meterNatureName,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>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.baseinfo.meterbasemattertimes.model.MeterBaseMatterTimes">
    update METER_BASE_MATTER_TIMES
    set TIMES_NO = #{timesNo,jdbcType=VARCHAR},
      MATTER_NO = #{matterNo,jdbcType=VARCHAR},
      MATTER_NAME = #{matterName,jdbcType=VARCHAR},
      MATTER_NATURE_NO = #{matterNatureNo,jdbcType=VARCHAR},
      MATTER_NATURE_NAME = #{matterNatureName,jdbcType=VARCHAR},
      METER_NATURE_NO = #{meterNatureNo,jdbcType=VARCHAR},
      METER_NATURE_NAME = #{meterNatureName,jdbcType=VARCHAR},
      CREATE_MAN_NO = #{createManNo,jdbcType=VARCHAR},
      CREATE_MAN_NAME = #{createManName,jdbcType=VARCHAR},
      CREATE_TIME = #{createTime,jdbcType=TIMESTAMP}
    where MATTER_TIMES_NO = #{matterTimesNo,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.baseinfo.meterbasemattertimes.model.MeterBaseMatterTimes">
    update METER_BASE_MATTER_TIMES
    <set>
      <if test="timesNo != null">
        TIMES_NO = #{timesNo,jdbcType=VARCHAR},
      </if>
      <if test="matterNo != null">
        MATTER_NO = #{matterNo,jdbcType=VARCHAR},
      </if>
      <if test="matterName != null">
        MATTER_NAME = #{matterName,jdbcType=VARCHAR},
      </if>
      <if test="matterNatureNo != null">
        MATTER_NATURE_NO = #{matterNatureNo,jdbcType=VARCHAR},
      </if>
      <if test="matterNatureName != null">
        MATTER_NATURE_NAME = #{matterNatureName,jdbcType=VARCHAR},
      </if>
      <if test="meterNatureNo != null">
        METER_NATURE_NO = #{meterNatureNo,jdbcType=VARCHAR},
      </if>
      <if test="meterNatureName != null">
        METER_NATURE_NAME = #{meterNatureName,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>
    </set>
    where MATTER_TIMES_NO = #{matterTimesNo,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where MATTER_TIMES_NO = #{matterTimesNo,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="where"/>
    order by MATTER_TIMES_NO
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="whereLike"/>
    order by MATTER_TIMES_NO
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into METER_BASE_MATTER_TIMES 
      (MATTER_TIMES_NO, 
      TIMES_NO, MATTER_NO, MATTER_NAME, 
      MATTER_NATURE_NO, MATTER_NATURE_NAME, 
      METER_NATURE_NO, METER_NATURE_NAME, 
      CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME
      )
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.matterTimesNo,jdbcType=VARCHAR}, 
      #{item.timesNo,jdbcType=VARCHAR}, #{item.matterNo,jdbcType=VARCHAR}, #{item.matterName,jdbcType=VARCHAR}, 
      #{item.matterNatureNo,jdbcType=VARCHAR}, #{item.matterNatureName,jdbcType=VARCHAR}, 
      #{item.meterNatureNo,jdbcType=VARCHAR}, #{item.meterNatureName,jdbcType=VARCHAR}, 
      #{item.createManNo,jdbcType=VARCHAR}, #{item.createManName,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}
       from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update METER_BASE_MATTER_TIMES
     set
       MATTER_TIMES_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case MATTER_TIMES_NO" close="end">
          when #{item.matterTimesNo,jdbcType=VARCHAR} then #{item.matterTimesNo,jdbcType=VARCHAR}
       </foreach>
       ,TIMES_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case MATTER_TIMES_NO" close="end">
          when #{item.matterTimesNo,jdbcType=VARCHAR} then #{item.timesNo,jdbcType=VARCHAR}
       </foreach>
       ,MATTER_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case MATTER_TIMES_NO" close="end">
          when #{item.matterTimesNo,jdbcType=VARCHAR} then #{item.matterNo,jdbcType=VARCHAR}
       </foreach>
       ,MATTER_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case MATTER_TIMES_NO" close="end">
          when #{item.matterTimesNo,jdbcType=VARCHAR} then #{item.matterName,jdbcType=VARCHAR}
       </foreach>
       ,MATTER_NATURE_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case MATTER_TIMES_NO" close="end">
          when #{item.matterTimesNo,jdbcType=VARCHAR} then #{item.matterNatureNo,jdbcType=VARCHAR}
       </foreach>
       ,MATTER_NATURE_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case MATTER_TIMES_NO" close="end">
          when #{item.matterTimesNo,jdbcType=VARCHAR} then #{item.matterNatureName,jdbcType=VARCHAR}
       </foreach>
       ,METER_NATURE_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case MATTER_TIMES_NO" close="end">
          when #{item.matterTimesNo,jdbcType=VARCHAR} then #{item.meterNatureNo,jdbcType=VARCHAR}
       </foreach>
       ,METER_NATURE_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case MATTER_TIMES_NO" close="end">
          when #{item.matterTimesNo,jdbcType=VARCHAR} then #{item.meterNatureName,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_MAN_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case MATTER_TIMES_NO" close="end">
          when #{item.matterTimesNo,jdbcType=VARCHAR} then #{item.createManNo,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_MAN_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case MATTER_TIMES_NO" close="end">
          when #{item.matterTimesNo,jdbcType=VARCHAR} then #{item.createManName,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case MATTER_TIMES_NO" close="end">
          when #{item.matterTimesNo,jdbcType=VARCHAR} then #{item.createTime,jdbcType=TIMESTAMP}
       </foreach>
     where MATTER_TIMES_NO in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.matterTimesNo,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_BASE_MATTER_TIMES
    where MATTER_TIMES_NO 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(MATTER_TIMES_NO, LENGTH(MATTER_TIMES_NO) - 4))),0) + 1,5,'0') MATTER_TIMES_NO
  FROM METER_BASE_MATTER_TIMES
  WHERE MATTER_TIMES_NO LIKE '_____'
</select>
</mapper>