<?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.meterbasedatamigration.mapper.MeterBaseDataMigrationMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.baseinfo.meterbasedatamigration.model.MeterBaseDataMigration">
    <id column="DATA_MIGRATION_NO" jdbcType="VARCHAR" property="dataMigrationNo" />
    <result column="COUNT_TYPE_NO" jdbcType="VARCHAR" property="countTypeNo" />
    <result column="RATE_VALUE" jdbcType="VARCHAR" property="rateValue" />
    <result column="CONTRAST_TYPE_NO" jdbcType="VARCHAR" property="contrastTypeNo" />
    <result column="MEMO" jdbcType="VARCHAR" property="memo" />
    <result column="VALUE_FLAG" jdbcType="VARCHAR" property="valueFlag" />
    <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="MIGRATION_NUM" jdbcType="DECIMAL" property="migrationNum" />
    <result column="COUNT_PK" jdbcType="VARCHAR" property="countPk" />
  </resultMap>
  <sql id="columns">
    DATA_MIGRATION_NO, COUNT_TYPE_NO, RATE_VALUE, CONTRAST_TYPE_NO, MEMO, VALUE_FLAG,
    CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME, UPDATE_MAN_NO, UPDATE_MAN_NAME, UPDATE_TIME,
    MIGRATION_NUM, COUNT_PK
  </sql>
  <sql id="columns_alias">
    t.DATA_MIGRATION_NO, t.COUNT_TYPE_NO, t.RATE_VALUE, t.CONTRAST_TYPE_NO, t.MEMO, t.VALUE_FLAG,
    t.CREATE_MAN_NO, t.CREATE_MAN_NAME, t.CREATE_TIME, t.UPDATE_MAN_NO, t.UPDATE_MAN_NAME,
    t.UPDATE_TIME, t.MIGRATION_NUM, t.COUNT_PK
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM METER_BASE_DATA_MIGRATION
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM METER_BASE_DATA_MIGRATION t
  </sql>
  <sql id="where">
    <where>
      <if test="dataMigrationNo != null and dataMigrationNo != ''">
        and DATA_MIGRATION_NO = #{dataMigrationNo}
      </if>
      <if test="countTypeNo != null and countTypeNo != ''">
        and COUNT_TYPE_NO = #{countTypeNo}
      </if>
      <if test="rateValue != null and rateValue != ''">
        and RATE_VALUE = #{rateValue}
      </if>
      <if test="contrastTypeNo != null and contrastTypeNo != ''">
        and CONTRAST_TYPE_NO = #{contrastTypeNo}
      </if>
      <if test="memo != null and memo != ''">
        and MEMO = #{memo}
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        and VALUE_FLAG = #{valueFlag}
      </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="migrationNum != null">
        and MIGRATION_NUM = #{migrationNum}
      </if>
      <if test="countPk != null and countPk != ''">
        and COUNT_PK = #{countPk}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where>
      <if test="dataMigrationNo != null and dataMigrationNo != ''">
        and DATA_MIGRATION_NO LIKE '%${dataMigrationNo}%'
      </if>
      <if test="countTypeNo != null and countTypeNo != ''">
        and COUNT_TYPE_NO LIKE '%${countTypeNo}%'
      </if>
      <if test="rateValue != null and rateValue != ''">
        and RATE_VALUE LIKE '%${rateValue}%'
      </if>
      <if test="contrastTypeNo != null and contrastTypeNo != ''">
        and CONTRAST_TYPE_NO LIKE '%${contrastTypeNo}%'
      </if>
      <if test="memo != null and memo != ''">
        and MEMO LIKE '%${memo}%'
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        and VALUE_FLAG LIKE '%${valueFlag}%'
      </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="migrationNum != null">
        and MIGRATION_NUM = #{migrationNum}
      </if>
      <if test="countPk != null and countPk != ''">
        and COUNT_PK LIKE '%${countPk}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from METER_BASE_DATA_MIGRATION
    where DATA_MIGRATION_NO = #{dataMigrationNo,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_BASE_DATA_MIGRATION
    where 1!=1
    <if test="countTypeNo != null and countTypeNo != ''">
      or COUNT_TYPE_NO = #{countTypeNo}
    </if>
    <if test="rateValue != null and rateValue != ''">
      or RATE_VALUE = #{rateValue}
    </if>
    <if test="contrastTypeNo != null and contrastTypeNo != ''">
      or CONTRAST_TYPE_NO = #{contrastTypeNo}
    </if>
    <if test="memo != null and memo != ''">
      or MEMO = #{memo}
    </if>
    <if test="valueFlag != null and valueFlag != ''">
      or VALUE_FLAG = #{valueFlag}
    </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="migrationNum != null">
      or MIGRATION_NUM = #{migrationNum}
    </if>
    <if test="countPk != null and countPk != ''">
      or COUNT_PK = #{countPk}
    </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.baseinfo.meterbasedatamigration.model.MeterBaseDataMigration">
    insert into METER_BASE_DATA_MIGRATION (DATA_MIGRATION_NO, COUNT_TYPE_NO, RATE_VALUE,
      CONTRAST_TYPE_NO, MEMO, VALUE_FLAG,
      CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME,
      UPDATE_MAN_NO, UPDATE_MAN_NAME, UPDATE_TIME,
      MIGRATION_NUM, COUNT_PK)
    values (#{dataMigrationNo,jdbcType=VARCHAR}, #{countTypeNo,jdbcType=VARCHAR}, #{rateValue,jdbcType=VARCHAR},
      #{contrastTypeNo,jdbcType=VARCHAR}, #{memo,jdbcType=VARCHAR}, #{valueFlag,jdbcType=VARCHAR},
      #{createManNo,jdbcType=VARCHAR}, #{createManName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
      #{updateManNo,jdbcType=VARCHAR}, #{updateManName,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
      #{migrationNum,jdbcType=DECIMAL}, #{countPk,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.baseinfo.meterbasedatamigration.model.MeterBaseDataMigration">
    insert into METER_BASE_DATA_MIGRATION
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="dataMigrationNo != null">
        DATA_MIGRATION_NO,
      </if>
      <if test="countTypeNo != null">
        COUNT_TYPE_NO,
      </if>
      <if test="rateValue != null">
        RATE_VALUE,
      </if>
      <if test="contrastTypeNo != null">
        CONTRAST_TYPE_NO,
      </if>
      <if test="memo != null">
        MEMO,
      </if>
      <if test="valueFlag != null">
        VALUE_FLAG,
      </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="migrationNum != null">
        MIGRATION_NUM,
      </if>
      <if test="countPk != null">
        COUNT_PK,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="dataMigrationNo != null">
        #{dataMigrationNo,jdbcType=VARCHAR},
      </if>
      <if test="countTypeNo != null">
        #{countTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="rateValue != null">
        #{rateValue,jdbcType=VARCHAR},
      </if>
      <if test="contrastTypeNo != null">
        #{contrastTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="memo != null">
        #{memo,jdbcType=VARCHAR},
      </if>
      <if test="valueFlag != null">
        #{valueFlag,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="migrationNum != null">
        #{migrationNum,jdbcType=DECIMAL},
      </if>
      <if test="countPk != null">
        #{countPk,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.baseinfo.meterbasedatamigration.model.MeterBaseDataMigration">
    update METER_BASE_DATA_MIGRATION
    set COUNT_TYPE_NO = #{countTypeNo,jdbcType=VARCHAR},
      RATE_VALUE = #{rateValue,jdbcType=VARCHAR},
      CONTRAST_TYPE_NO = #{contrastTypeNo,jdbcType=VARCHAR},
      MEMO = #{memo,jdbcType=VARCHAR},
      VALUE_FLAG = #{valueFlag,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},
      MIGRATION_NUM = #{migrationNum,jdbcType=DECIMAL},
      COUNT_PK = #{countPk,jdbcType=VARCHAR}
    where DATA_MIGRATION_NO = #{dataMigrationNo,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.baseinfo.meterbasedatamigration.model.MeterBaseDataMigration">
    update METER_BASE_DATA_MIGRATION
    <set>
      <if test="countTypeNo != null">
        COUNT_TYPE_NO = #{countTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="rateValue != null">
        RATE_VALUE = #{rateValue,jdbcType=VARCHAR},
      </if>
      <if test="contrastTypeNo != null">
        CONTRAST_TYPE_NO = #{contrastTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="memo != null">
        MEMO = #{memo,jdbcType=VARCHAR},
      </if>
      <if test="valueFlag != null">
        VALUE_FLAG = #{valueFlag,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="migrationNum != null">
        MIGRATION_NUM = #{migrationNum,jdbcType=DECIMAL},
      </if>
      <if test="countPk != null">
        COUNT_PK = #{countPk,jdbcType=VARCHAR},
      </if>
    </set>
    where DATA_MIGRATION_NO = #{dataMigrationNo,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where DATA_MIGRATION_NO = #{dataMigrationNo,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="where"/>
    order by  DATA_MIGRATION_NO desc
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="whereLike"/>
    order by  DATA_MIGRATION_NO desc
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into METER_BASE_DATA_MIGRATION
    (DATA_MIGRATION_NO,
    COUNT_TYPE_NO, RATE_VALUE, CONTRAST_TYPE_NO,
    MEMO, VALUE_FLAG, CREATE_MAN_NO,
    CREATE_MAN_NAME, CREATE_TIME,
    UPDATE_MAN_NO, UPDATE_MAN_NAME, UPDATE_TIME,
    MIGRATION_NUM, COUNT_PK)
    ( <foreach collection="list" item="item" separator="union all">
    select
    #{item.dataMigrationNo,jdbcType=VARCHAR},
    #{item.countTypeNo,jdbcType=VARCHAR}, #{item.rateValue,jdbcType=VARCHAR}, #{item.contrastTypeNo,jdbcType=VARCHAR},
    #{item.memo,jdbcType=VARCHAR}, #{item.valueFlag,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.migrationNum,jdbcType=DECIMAL}, #{item.countPk,jdbcType=VARCHAR} from dual
  </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
    update METER_BASE_DATA_MIGRATION
    set
    DATA_MIGRATION_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case DATA_MIGRATION_NO" close="end">
      when #{item.dataMigrationNo,jdbcType=VARCHAR} then #{item.dataMigrationNo,jdbcType=VARCHAR}
    </foreach>
    ,COUNT_TYPE_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case DATA_MIGRATION_NO" close="end">
      when #{item.dataMigrationNo,jdbcType=VARCHAR} then #{item.countTypeNo,jdbcType=VARCHAR}
    </foreach>
    ,RATE_VALUE=
    <foreach collection="list" item="item" index="index" separator=" " open="case DATA_MIGRATION_NO" close="end">
      when #{item.dataMigrationNo,jdbcType=VARCHAR} then #{item.rateValue,jdbcType=VARCHAR}
    </foreach>
    ,CONTRAST_TYPE_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case DATA_MIGRATION_NO" close="end">
      when #{item.dataMigrationNo,jdbcType=VARCHAR} then #{item.contrastTypeNo,jdbcType=VARCHAR}
    </foreach>
    ,MEMO=
    <foreach collection="list" item="item" index="index" separator=" " open="case DATA_MIGRATION_NO" close="end">
      when #{item.dataMigrationNo,jdbcType=VARCHAR} then #{item.memo,jdbcType=VARCHAR}
    </foreach>
    ,VALUE_FLAG=
    <foreach collection="list" item="item" index="index" separator=" " open="case DATA_MIGRATION_NO" close="end">
      when #{item.dataMigrationNo,jdbcType=VARCHAR} then #{item.valueFlag,jdbcType=VARCHAR}
    </foreach>
    ,CREATE_MAN_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case DATA_MIGRATION_NO" close="end">
      when #{item.dataMigrationNo,jdbcType=VARCHAR} then #{item.createManNo,jdbcType=VARCHAR}
    </foreach>
    ,CREATE_MAN_NAME=
    <foreach collection="list" item="item" index="index" separator=" " open="case DATA_MIGRATION_NO" close="end">
      when #{item.dataMigrationNo,jdbcType=VARCHAR} then #{item.createManName,jdbcType=VARCHAR}
    </foreach>
    ,CREATE_TIME=
    <foreach collection="list" item="item" index="index" separator=" " open="case DATA_MIGRATION_NO" close="end">
      when #{item.dataMigrationNo,jdbcType=VARCHAR} then #{item.createTime,jdbcType=TIMESTAMP}
    </foreach>
    ,UPDATE_MAN_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case DATA_MIGRATION_NO" close="end">
      when #{item.dataMigrationNo,jdbcType=VARCHAR} then #{item.updateManNo,jdbcType=VARCHAR}
    </foreach>
    ,UPDATE_MAN_NAME=
    <foreach collection="list" item="item" index="index" separator=" " open="case DATA_MIGRATION_NO" close="end">
      when #{item.dataMigrationNo,jdbcType=VARCHAR} then #{item.updateManName,jdbcType=VARCHAR}
    </foreach>
    ,UPDATE_TIME=
    <foreach collection="list" item="item" index="index" separator=" " open="case DATA_MIGRATION_NO" close="end">
      when #{item.dataMigrationNo,jdbcType=VARCHAR} then #{item.updateTime,jdbcType=TIMESTAMP}
    </foreach>
    ,MIGRATION_NUM=
    <foreach collection="list" item="item" index="index" separator=" " open="case DATA_MIGRATION_NO" close="end">
      when #{item.dataMigrationNo,jdbcType=VARCHAR} then #{item.migrationNum,jdbcType=DECIMAL}
    </foreach>
    ,COUNT_PK=
    <foreach collection="list" item="item" index="index" separator=" " open="case DATA_MIGRATION_NO" close="end">
      when #{item.dataMigrationNo,jdbcType=VARCHAR} then #{item.countPk,jdbcType=VARCHAR}
    </foreach>
    where DATA_MIGRATION_NO in
    <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
      #{item.dataMigrationNo,jdbcType=VARCHAR}
    </foreach>
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_BASE_DATA_MIGRATION
    where DATA_MIGRATION_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(DATA_MIGRATION_NO, LENGTH(DATA_MIGRATION_NO) -3))),0) + 1,4,'0') DATA_MIGRATION_NO
    FROM METER_BASE_DATA_MIGRATION
  </select>
  <insert id="insertMigration" parameterType="java.util.HashMap">
    insert into ${contrastTypeNo}
    select *
    from ${countTypeNo}
    where ${countPk} in
      <foreach collection="list" item="id" open="(" close=")" separator=",">
        #{id}
      </foreach>
  </insert>

  <delete id="deleteMigration" parameterType="java.util.HashMap">
    delete from ${countTypeNo}
    where ${countPk} in
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
</mapper>