<?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.meterbaserailwayhistaredata.mapper.MeterBaseRailwayHisTareDataMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.baseinfo.meterbaserailwayhistaredata.model.MeterBaseRailwayHisTareData">
    <id column="DATA_NO" jdbcType="VARCHAR" property="dataNo" />
    <result column="BASE_SPOT_NO" jdbcType="VARCHAR" property="baseSpotNo" />
    <result column="BASE_SPOT_NAME" jdbcType="VARCHAR" property="baseSpotName" />
    <result column="RAILWAY_NO" jdbcType="VARCHAR" property="railwayNo" />
    <result column="METER_WEIGHT" jdbcType="DECIMAL" property="meterWeight" />
    <result column="METER_NAME" jdbcType="VARCHAR" property="meterName" />
    <result column="METER_TIME" jdbcType="TIMESTAMP" property="meterTime" />
    <result column="UP_WEIGHT" jdbcType="DECIMAL" property="upWeight" />
    <result column="AVG_WEIGHT" jdbcType="DECIMAL" property="avgWeight" />
    <result column="METER_NUM" jdbcType="DECIMAL" property="meterNum" />
    <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" />
  </resultMap>
  <sql id="columns">
    DATA_NO, BASE_SPOT_NO, BASE_SPOT_NAME, RAILWAY_NO, METER_WEIGHT, METER_NAME, METER_TIME, 
    UP_WEIGHT, AVG_WEIGHT, METER_NUM, VALUE_FLAG, CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME
  </sql>
  <sql id="columns_alias">
    t.DATA_NO, t.BASE_SPOT_NO, t.BASE_SPOT_NAME, t.RAILWAY_NO, t.METER_WEIGHT, t.METER_NAME, 
    t.METER_TIME, t.UP_WEIGHT, t.AVG_WEIGHT, t.METER_NUM, t.VALUE_FLAG, t.CREATE_MAN_NO, 
    t.CREATE_MAN_NAME, t.CREATE_TIME
  </sql>
  <sql id="select">
    SELECT <include refid="columns" /> FROM METER_BASE_RAILWAY_HIS_TARE_DATA
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias" /> FROM METER_BASE_RAILWAY_HIS_TARE_DATA t
  </sql>
  <sql id="where">
    <where> 
      <if test="dataNo != null and dataNo != ''">
        and DATA_NO = #{dataNo}
      </if>
      <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="railwayNo != null and railwayNo != ''">
        and RAILWAY_NO = #{railwayNo}
      </if>
      <if test="meterWeight != null">
        and METER_WEIGHT = #{meterWeight}
      </if>
      <if test="meterName != null and meterName != ''">
        and METER_NAME = #{meterName}
      </if>
      <if test="meterTime != null">
        and TO_CHAR(METER_TIME,'yyyy-MM-dd') = #{meterTime}
      </if>
      <if test="upWeight != null">
        and UP_WEIGHT = #{upWeight}
      </if>
      <if test="avgWeight != null">
        and AVG_WEIGHT = #{avgWeight}
      </if>
      <if test="meterNum != null">
        and METER_NUM = #{meterNum}
      </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>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="dataNo != null and dataNo != ''">
        and DATA_NO LIKE '%${dataNo}%'
      </if>
      <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="railwayNo != null and railwayNo != ''">
        and RAILWAY_NO LIKE '%${railwayNo}%'
      </if>
      <if test="meterWeight != null">
        and METER_WEIGHT = #{meterWeight}
      </if>
      <if test="meterName != null and meterName != ''">
        and METER_NAME LIKE '%${meterName}%'
      </if>
      <if test="meterTime != null">
        and TO_CHAR(METER_TIME,'yyyy-MM-dd') = #{meterTime}
      </if>
      <if test="upWeight != null">
        and UP_WEIGHT = #{upWeight}
      </if>
      <if test="avgWeight != null">
        and AVG_WEIGHT = #{avgWeight}
      </if>
      <if test="meterNum != null">
        and METER_NUM = #{meterNum}
      </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>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from METER_BASE_RAILWAY_HIS_TARE_DATA
    where DATA_NO = #{dataNo,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_BASE_RAILWAY_HIS_TARE_DATA
    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="railwayNo != null and railwayNo != ''">
        or RAILWAY_NO = #{railwayNo}
      </if>
      <if test="meterWeight != null">
        or METER_WEIGHT = #{meterWeight}
      </if>
      <if test="meterName != null and meterName != ''">
        or METER_NAME = #{meterName}
      </if>
      <if test="meterTime != null">
        or TO_CHAR(METER_TIME,'yyyy-MM-dd') = '#{meterTime}'
      </if>
      <if test="upWeight != null">
        or UP_WEIGHT = #{upWeight}
      </if>
      <if test="avgWeight != null">
        or AVG_WEIGHT = #{avgWeight}
      </if>
      <if test="meterNum != null">
        or METER_NUM = #{meterNum}
      </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>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.baseinfo.meterbaserailwayhistaredata.model.MeterBaseRailwayHisTareData">
    insert into METER_BASE_RAILWAY_HIS_TARE_DATA (DATA_NO, BASE_SPOT_NO, BASE_SPOT_NAME, 
      RAILWAY_NO, METER_WEIGHT, METER_NAME, 
      METER_TIME, UP_WEIGHT, AVG_WEIGHT, 
      METER_NUM, VALUE_FLAG, CREATE_MAN_NO, 
      CREATE_MAN_NAME, CREATE_TIME)
    values (#{dataNo,jdbcType=VARCHAR}, #{baseSpotNo,jdbcType=VARCHAR}, #{baseSpotName,jdbcType=VARCHAR}, 
      #{railwayNo,jdbcType=VARCHAR}, #{meterWeight,jdbcType=DECIMAL}, #{meterName,jdbcType=VARCHAR}, 
      #{meterTime,jdbcType=TIMESTAMP}, #{upWeight,jdbcType=DECIMAL}, #{avgWeight,jdbcType=DECIMAL}, 
      #{meterNum,jdbcType=DECIMAL}, #{valueFlag,jdbcType=VARCHAR}, #{createManNo,jdbcType=VARCHAR}, 
      #{createManName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.baseinfo.meterbaserailwayhistaredata.model.MeterBaseRailwayHisTareData">
    insert into METER_BASE_RAILWAY_HIS_TARE_DATA
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="dataNo != null">
        DATA_NO,
      </if>
      <if test="baseSpotNo != null">
        BASE_SPOT_NO,
      </if>
      <if test="baseSpotName != null">
        BASE_SPOT_NAME,
      </if>
      <if test="railwayNo != null">
        RAILWAY_NO,
      </if>
      <if test="meterWeight != null">
        METER_WEIGHT,
      </if>
      <if test="meterName != null">
        METER_NAME,
      </if>
      <if test="meterTime != null">
        METER_TIME,
      </if>
      <if test="upWeight != null">
        UP_WEIGHT,
      </if>
      <if test="avgWeight != null">
        AVG_WEIGHT,
      </if>
      <if test="meterNum != null">
        METER_NUM,
      </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>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="dataNo != null">
        #{dataNo,jdbcType=VARCHAR},
      </if>
      <if test="baseSpotNo != null">
        #{baseSpotNo,jdbcType=VARCHAR},
      </if>
      <if test="baseSpotName != null">
        #{baseSpotName,jdbcType=VARCHAR},
      </if>
      <if test="railwayNo != null">
        #{railwayNo,jdbcType=VARCHAR},
      </if>
      <if test="meterWeight != null">
        #{meterWeight,jdbcType=DECIMAL},
      </if>
      <if test="meterName != null">
        #{meterName,jdbcType=VARCHAR},
      </if>
      <if test="meterTime != null">
        #{meterTime,jdbcType=TIMESTAMP},
      </if>
      <if test="upWeight != null">
        #{upWeight,jdbcType=DECIMAL},
      </if>
      <if test="avgWeight != null">
        #{avgWeight,jdbcType=DECIMAL},
      </if>
      <if test="meterNum != null">
        #{meterNum,jdbcType=DECIMAL},
      </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>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.baseinfo.meterbaserailwayhistaredata.model.MeterBaseRailwayHisTareData">
    update METER_BASE_RAILWAY_HIS_TARE_DATA
    set BASE_SPOT_NO = #{baseSpotNo,jdbcType=VARCHAR},
      BASE_SPOT_NAME = #{baseSpotName,jdbcType=VARCHAR},
      RAILWAY_NO = #{railwayNo,jdbcType=VARCHAR},
      METER_WEIGHT = #{meterWeight,jdbcType=DECIMAL},
      METER_NAME = #{meterName,jdbcType=VARCHAR},
      METER_TIME = #{meterTime,jdbcType=TIMESTAMP},
      UP_WEIGHT = #{upWeight,jdbcType=DECIMAL},
      AVG_WEIGHT = #{avgWeight,jdbcType=DECIMAL},
      METER_NUM = #{meterNum,jdbcType=DECIMAL},
      VALUE_FLAG = #{valueFlag,jdbcType=VARCHAR},
      CREATE_MAN_NO = #{createManNo,jdbcType=VARCHAR},
      CREATE_MAN_NAME = #{createManName,jdbcType=VARCHAR},
      CREATE_TIME = #{createTime,jdbcType=TIMESTAMP}
    where DATA_NO = #{dataNo,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.baseinfo.meterbaserailwayhistaredata.model.MeterBaseRailwayHisTareData">
    update METER_BASE_RAILWAY_HIS_TARE_DATA
    <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="railwayNo != null">
        RAILWAY_NO = #{railwayNo,jdbcType=VARCHAR},
      </if>
      <if test="meterWeight != null">
        METER_WEIGHT = #{meterWeight,jdbcType=DECIMAL},
      </if>
      <if test="meterName != null">
        METER_NAME = #{meterName,jdbcType=VARCHAR},
      </if>
      <if test="meterTime != null">
        METER_TIME = #{meterTime,jdbcType=TIMESTAMP},
      </if>
      <if test="upWeight != null">
        UP_WEIGHT = #{upWeight,jdbcType=DECIMAL},
      </if>
      <if test="avgWeight != null">
        AVG_WEIGHT = #{avgWeight,jdbcType=DECIMAL},
      </if>
      <if test="meterNum != null">
        METER_NUM = #{meterNum,jdbcType=DECIMAL},
      </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>
    </set>
    where DATA_NO = #{dataNo,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select" />
    where DATA_NO = #{dataNo,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_RAILWAY_HIS_TARE_DATA 
      (DATA_NO, 
      BASE_SPOT_NO, BASE_SPOT_NAME, RAILWAY_NO, 
      METER_WEIGHT, METER_NAME, METER_TIME, 
      UP_WEIGHT, AVG_WEIGHT, METER_NUM, 
      VALUE_FLAG, CREATE_MAN_NO, CREATE_MAN_NAME, 
      CREATE_TIME)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.dataNo,jdbcType=VARCHAR}, 
      #{item.baseSpotNo,jdbcType=VARCHAR}, #{item.baseSpotName,jdbcType=VARCHAR}, #{item.railwayNo,jdbcType=VARCHAR}, 
      #{item.meterWeight,jdbcType=DECIMAL}, #{item.meterName,jdbcType=VARCHAR}, #{item.meterTime,jdbcType=TIMESTAMP}, 
      #{item.upWeight,jdbcType=DECIMAL}, #{item.avgWeight,jdbcType=DECIMAL}, #{item.meterNum,jdbcType=DECIMAL}, 
      #{item.valueFlag,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_RAILWAY_HIS_TARE_DATA
     set
       DATA_NO=
       <foreach close="end" collection="list" index="index" item="item" open="case DATA_NO" separator=" ">
          when #{item.dataNo,jdbcType=VARCHAR} then #{item.dataNo,jdbcType=VARCHAR}
       </foreach>
       ,BASE_SPOT_NO=
       <foreach close="end" collection="list" index="index" item="item" open="case DATA_NO" separator=" ">
          when #{item.dataNo,jdbcType=VARCHAR} then #{item.baseSpotNo,jdbcType=VARCHAR}
       </foreach>
       ,BASE_SPOT_NAME=
       <foreach close="end" collection="list" index="index" item="item" open="case DATA_NO" separator=" ">
          when #{item.dataNo,jdbcType=VARCHAR} then #{item.baseSpotName,jdbcType=VARCHAR}
       </foreach>
       ,RAILWAY_NO=
       <foreach close="end" collection="list" index="index" item="item" open="case DATA_NO" separator=" ">
          when #{item.dataNo,jdbcType=VARCHAR} then #{item.railwayNo,jdbcType=VARCHAR}
       </foreach>
       ,METER_WEIGHT=
       <foreach close="end" collection="list" index="index" item="item" open="case DATA_NO" separator=" ">
          when #{item.dataNo,jdbcType=VARCHAR} then #{item.meterWeight,jdbcType=DECIMAL}
       </foreach>
       ,METER_NAME=
       <foreach close="end" collection="list" index="index" item="item" open="case DATA_NO" separator=" ">
          when #{item.dataNo,jdbcType=VARCHAR} then #{item.meterName,jdbcType=VARCHAR}
       </foreach>
       ,METER_TIME=
       <foreach close="end" collection="list" index="index" item="item" open="case DATA_NO" separator=" ">
          when #{item.dataNo,jdbcType=VARCHAR} then #{item.meterTime,jdbcType=TIMESTAMP}
       </foreach>
       ,UP_WEIGHT=
       <foreach close="end" collection="list" index="index" item="item" open="case DATA_NO" separator=" ">
          when #{item.dataNo,jdbcType=VARCHAR} then #{item.upWeight,jdbcType=DECIMAL}
       </foreach>
       ,AVG_WEIGHT=
       <foreach close="end" collection="list" index="index" item="item" open="case DATA_NO" separator=" ">
          when #{item.dataNo,jdbcType=VARCHAR} then #{item.avgWeight,jdbcType=DECIMAL}
       </foreach>
       ,METER_NUM=
       <foreach close="end" collection="list" index="index" item="item" open="case DATA_NO" separator=" ">
          when #{item.dataNo,jdbcType=VARCHAR} then #{item.meterNum,jdbcType=DECIMAL}
       </foreach>
       ,VALUE_FLAG=
       <foreach close="end" collection="list" index="index" item="item" open="case DATA_NO" separator=" ">
          when #{item.dataNo,jdbcType=VARCHAR} then #{item.valueFlag,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_MAN_NO=
       <foreach close="end" collection="list" index="index" item="item" open="case DATA_NO" separator=" ">
          when #{item.dataNo,jdbcType=VARCHAR} then #{item.createManNo,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_MAN_NAME=
       <foreach close="end" collection="list" index="index" item="item" open="case DATA_NO" separator=" ">
          when #{item.dataNo,jdbcType=VARCHAR} then #{item.createManName,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_TIME=
       <foreach close="end" collection="list" index="index" item="item" open="case DATA_NO" separator=" ">
          when #{item.dataNo,jdbcType=VARCHAR} then #{item.createTime,jdbcType=TIMESTAMP}
       </foreach>
     where DATA_NO in 
     <foreach close=")" collection="list" index="index" item="item" open="(" separator=",">
    #{item.dataNo,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_BASE_RAILWAY_HIS_TARE_DATA
    where DATA_NO in 
    <foreach close=")" collection="list" item="id" open="(" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->

  <select id="getNewID" parameterType="java.lang.String" resultType="java.lang.String">
    SELECT LPAD(NVL(MAX(TO_NUMBER(SUBSTR(data_no, LENGTH(data_no) - 3))),0) + 1, 4, '0') data_no
    FROM meter_base_railway_his_tare_data
    where instr(data_no, #{afl, jdbcType = VARCHAR}) > 0
  </select>
  
</mapper>