<?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.meterworkcalibrationmain.mapper.MeterWorkCalibrationMainMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.meterwork.meterworkcalibrationmain.model.MeterWorkCalibrationMain">
    <id column="CALIBRATION_MAIN_NO" jdbcType="VARCHAR" property="calibrationMainNo" />
    <result column="BASE_SPOT_NO" jdbcType="VARCHAR" property="baseSpotNo" />
    <result column="BASE_SPOT_NAME" jdbcType="VARCHAR" property="baseSpotName" />
    <result column="SPOT_TYPE_NO" jdbcType="VARCHAR" property="spotTypeNo" />
    <result column="SPOT_TYPE_NAME" jdbcType="VARCHAR" property="spotTypeName" />
    <result column="CALIBRATION_NUM" jdbcType="DECIMAL" property="calibrationNum" />
    <result column="CALIBRATION_TYPE_NO" jdbcType="VARCHAR" property="calibrationTypeNo" />
    <result column="CALIBRATION_TYPE_NAME" jdbcType="VARCHAR" property="calibrationTypeName" />
    <result column="CALIBRATION_ACT_NUM" jdbcType="DECIMAL" property="calibrationActNum" />
    <result column="VALUE_FLAG" jdbcType="VARCHAR" property="valueFlag" />
    <result column="BASE_CONTRAST_SPOT_NO" jdbcType="VARCHAR" property="baseContrastSpotNo" />
    <result column="BASE_CONTRAST_SPOT_NAME" jdbcType="VARCHAR" property="baseContrastSpotName" />
    <result column="BASE_SUCC_CONT_SPOT_NO" jdbcType="VARCHAR" property="baseSuccContSpotNo" />
    <result column="BASE_SUCC_CON_SPOT_NAME" jdbcType="VARCHAR" property="baseSuccConSpotName" />
    <result column="CALIBRATION_MAIN_TIME" jdbcType="TIMESTAMP" property="calibrationMainTime" />
  </resultMap>
  <sql id="columns">
    CALIBRATION_MAIN_NO, BASE_SPOT_NO, BASE_SPOT_NAME, SPOT_TYPE_NO, SPOT_TYPE_NAME, 
    CALIBRATION_NUM, CALIBRATION_TYPE_NO, CALIBRATION_TYPE_NAME, CALIBRATION_ACT_NUM, 
    VALUE_FLAG, BASE_CONTRAST_SPOT_NO, BASE_CONTRAST_SPOT_NAME, BASE_SUCC_CONT_SPOT_NO, 
    BASE_SUCC_CON_SPOT_NAME, CALIBRATION_MAIN_TIME
  </sql>
  <sql id="columns_alias">
    t.CALIBRATION_MAIN_NO, t.BASE_SPOT_NO, t.BASE_SPOT_NAME, t.SPOT_TYPE_NO, t.SPOT_TYPE_NAME, 
    t.CALIBRATION_NUM, t.CALIBRATION_TYPE_NO, t.CALIBRATION_TYPE_NAME, t.CALIBRATION_ACT_NUM, 
    t.VALUE_FLAG, t.BASE_CONTRAST_SPOT_NO, t.BASE_CONTRAST_SPOT_NAME, t.BASE_SUCC_CONT_SPOT_NO, 
    t.BASE_SUCC_CON_SPOT_NAME, t.CALIBRATION_MAIN_TIME
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM METER_WORK_CALIBRATION_MAIN
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM METER_WORK_CALIBRATION_MAIN 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="spotTypeNo != null and spotTypeNo != ''">
        and SPOT_TYPE_NO = #{spotTypeNo}
      </if>
      <if test="spotTypeName != null and spotTypeName != ''">
        and SPOT_TYPE_NAME = #{spotTypeName}
      </if>
      <if test="calibrationNum != null">
        and CALIBRATION_NUM = #{calibrationNum}
      </if>
      <if test="calibrationTypeNo != null and calibrationTypeNo != ''">
        and CALIBRATION_TYPE_NO = #{calibrationTypeNo}
      </if>
      <if test="calibrationTypeName != null and calibrationTypeName != ''">
        and CALIBRATION_TYPE_NAME = #{calibrationTypeName}
      </if>
      <if test="calibrationActNum != null">
        and CALIBRATION_ACT_NUM = #{calibrationActNum}
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        and VALUE_FLAG = #{valueFlag}
      </if>
      <if test="baseContrastSpotNo != null and baseContrastSpotNo != ''">
        and BASE_CONTRAST_SPOT_NO = #{baseContrastSpotNo}
      </if>
      <if test="baseContrastSpotName != null and baseContrastSpotName != ''">
        and BASE_CONTRAST_SPOT_NAME = #{baseContrastSpotName}
      </if>
      <if test="baseSuccContSpotNo != null and baseSuccContSpotNo != ''">
        and BASE_SUCC_CONT_SPOT_NO = #{baseSuccContSpotNo}
      </if>
      <if test="baseSuccConSpotName != null and baseSuccConSpotName != ''">
        and BASE_SUCC_CON_SPOT_NAME = #{baseSuccConSpotName}
      </if>
      <if test="calibrationMainTime1 != null and calibrationMainTime1 != ''">
        and TO_CHAR(CALIBRATION_MAIN_TIME,'yyyy-MM-dd') >= #{calibrationMainTime1}
      </if>
      <if test="calibrationMainTime2 != null and calibrationMainTime2 != ''">
        and TO_CHAR(CALIBRATION_MAIN_TIME,'yyyy-MM-dd') &lt;= #{calibrationMainTime2}
      </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="spotTypeNo != null and spotTypeNo != ''">
        and SPOT_TYPE_NO LIKE '%${spotTypeNo}%'
      </if>
      <if test="spotTypeName != null and spotTypeName != ''">
        and SPOT_TYPE_NAME LIKE '%${spotTypeName}%'
      </if>
      <if test="calibrationNum != null">
        and CALIBRATION_NUM = #{calibrationNum}
      </if>
      <if test="calibrationTypeNo != null and calibrationTypeNo != ''">
        and CALIBRATION_TYPE_NO LIKE '%${calibrationTypeNo}%'
      </if>
      <if test="calibrationTypeName != null and calibrationTypeName != ''">
        and CALIBRATION_TYPE_NAME LIKE '%${calibrationTypeName}%'
      </if>
      <if test="calibrationActNum != null">
        and CALIBRATION_ACT_NUM = #{calibrationActNum}
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        and VALUE_FLAG LIKE '%${valueFlag}%'
      </if>
      <if test="baseContrastSpotNo != null and baseContrastSpotNo != ''">
        and BASE_CONTRAST_SPOT_NO LIKE '%${baseContrastSpotNo}%'
      </if>
      <if test="baseContrastSpotName != null and baseContrastSpotName != ''">
        and BASE_CONTRAST_SPOT_NAME LIKE '%${baseContrastSpotName}%'
      </if>
      <if test="baseSuccContSpotNo != null and baseSuccContSpotNo != ''">
        and BASE_SUCC_CONT_SPOT_NO LIKE '%${baseSuccContSpotNo}%'
      </if>
      <if test="baseSuccConSpotName != null and baseSuccConSpotName != ''">
        and BASE_SUCC_CON_SPOT_NAME LIKE '%${baseSuccConSpotName}%'
      </if>
      <if test="calibrationMainTime != null">
        and TO_CHAR(CALIBRATION_MAIN_TIME,'yyyy-MM-dd') = #{calibrationMainTime}
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from METER_WORK_CALIBRATION_MAIN
    where CALIBRATION_MAIN_NO = #{calibrationMainNo,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_WORK_CALIBRATION_MAIN
    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="spotTypeNo != null and spotTypeNo != ''">
        or SPOT_TYPE_NO = #{spotTypeNo}
      </if>
      <if test="spotTypeName != null and spotTypeName != ''">
        or SPOT_TYPE_NAME = #{spotTypeName}
      </if>
      <if test="calibrationNum != null">
        or CALIBRATION_NUM = #{calibrationNum}
      </if>
      <if test="calibrationTypeNo != null and calibrationTypeNo != ''">
        or CALIBRATION_TYPE_NO = #{calibrationTypeNo}
      </if>
      <if test="calibrationTypeName != null and calibrationTypeName != ''">
        or CALIBRATION_TYPE_NAME = #{calibrationTypeName}
      </if>
      <if test="calibrationActNum != null">
        or CALIBRATION_ACT_NUM = #{calibrationActNum}
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        or VALUE_FLAG = #{valueFlag}
      </if>
      <if test="baseContrastSpotNo != null and baseContrastSpotNo != ''">
        or BASE_CONTRAST_SPOT_NO = #{baseContrastSpotNo}
      </if>
      <if test="baseContrastSpotName != null and baseContrastSpotName != ''">
        or BASE_CONTRAST_SPOT_NAME = #{baseContrastSpotName}
      </if>
      <if test="baseSuccContSpotNo != null and baseSuccContSpotNo != ''">
        or BASE_SUCC_CONT_SPOT_NO = #{baseSuccContSpotNo}
      </if>
      <if test="baseSuccConSpotName != null and baseSuccConSpotName != ''">
        or BASE_SUCC_CON_SPOT_NAME = #{baseSuccConSpotName}
      </if>
      <if test="calibrationMainTime != null">
        or TO_CHAR(CALIBRATION_MAIN_TIME,'yyyy-MM-dd') = '#{calibrationMainTime}'
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.meterwork.meterworkcalibrationmain.model.MeterWorkCalibrationMain">
    insert into METER_WORK_CALIBRATION_MAIN (CALIBRATION_MAIN_NO, BASE_SPOT_NO, BASE_SPOT_NAME, 
      SPOT_TYPE_NO, SPOT_TYPE_NAME, CALIBRATION_NUM, 
      CALIBRATION_TYPE_NO, CALIBRATION_TYPE_NAME, 
      CALIBRATION_ACT_NUM, VALUE_FLAG, BASE_CONTRAST_SPOT_NO, 
      BASE_CONTRAST_SPOT_NAME, BASE_SUCC_CONT_SPOT_NO, 
      BASE_SUCC_CON_SPOT_NAME, CALIBRATION_MAIN_TIME
      )
    values (#{calibrationMainNo,jdbcType=VARCHAR}, #{baseSpotNo,jdbcType=VARCHAR}, #{baseSpotName,jdbcType=VARCHAR}, 
      #{spotTypeNo,jdbcType=VARCHAR}, #{spotTypeName,jdbcType=VARCHAR}, #{calibrationNum,jdbcType=DECIMAL}, 
      #{calibrationTypeNo,jdbcType=VARCHAR}, #{calibrationTypeName,jdbcType=VARCHAR}, 
      #{calibrationActNum,jdbcType=DECIMAL}, #{valueFlag,jdbcType=VARCHAR}, #{baseContrastSpotNo,jdbcType=VARCHAR}, 
      #{baseContrastSpotName,jdbcType=VARCHAR}, #{baseSuccContSpotNo,jdbcType=VARCHAR}, 
      #{baseSuccConSpotName,jdbcType=VARCHAR}, #{calibrationMainTime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.meterwork.meterworkcalibrationmain.model.MeterWorkCalibrationMain">
    insert into METER_WORK_CALIBRATION_MAIN
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="calibrationMainNo != null">
        CALIBRATION_MAIN_NO,
      </if>
      <if test="baseSpotNo != null">
        BASE_SPOT_NO,
      </if>
      <if test="baseSpotName != null">
        BASE_SPOT_NAME,
      </if>
      <if test="spotTypeNo != null">
        SPOT_TYPE_NO,
      </if>
      <if test="spotTypeName != null">
        SPOT_TYPE_NAME,
      </if>
      <if test="calibrationNum != null">
        CALIBRATION_NUM,
      </if>
      <if test="calibrationTypeNo != null">
        CALIBRATION_TYPE_NO,
      </if>
      <if test="calibrationTypeName != null">
        CALIBRATION_TYPE_NAME,
      </if>
      <if test="calibrationActNum != null">
        CALIBRATION_ACT_NUM,
      </if>
      <if test="valueFlag != null">
        VALUE_FLAG,
      </if>
      <if test="baseContrastSpotNo != null">
        BASE_CONTRAST_SPOT_NO,
      </if>
      <if test="baseContrastSpotName != null">
        BASE_CONTRAST_SPOT_NAME,
      </if>
      <if test="baseSuccContSpotNo != null">
        BASE_SUCC_CONT_SPOT_NO,
      </if>
      <if test="baseSuccConSpotName != null">
        BASE_SUCC_CON_SPOT_NAME,
      </if>
      <if test="calibrationMainTime != null">
        CALIBRATION_MAIN_TIME,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="calibrationMainNo != null">
        #{calibrationMainNo,jdbcType=VARCHAR},
      </if>
      <if test="baseSpotNo != null">
        #{baseSpotNo,jdbcType=VARCHAR},
      </if>
      <if test="baseSpotName != null">
        #{baseSpotName,jdbcType=VARCHAR},
      </if>
      <if test="spotTypeNo != null">
        #{spotTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="spotTypeName != null">
        #{spotTypeName,jdbcType=VARCHAR},
      </if>
      <if test="calibrationNum != null">
        #{calibrationNum,jdbcType=DECIMAL},
      </if>
      <if test="calibrationTypeNo != null">
        #{calibrationTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="calibrationTypeName != null">
        #{calibrationTypeName,jdbcType=VARCHAR},
      </if>
      <if test="calibrationActNum != null">
        #{calibrationActNum,jdbcType=DECIMAL},
      </if>
      <if test="valueFlag != null">
        #{valueFlag,jdbcType=VARCHAR},
      </if>
      <if test="baseContrastSpotNo != null">
        #{baseContrastSpotNo,jdbcType=VARCHAR},
      </if>
      <if test="baseContrastSpotName != null">
        #{baseContrastSpotName,jdbcType=VARCHAR},
      </if>
      <if test="baseSuccContSpotNo != null">
        #{baseSuccContSpotNo,jdbcType=VARCHAR},
      </if>
      <if test="baseSuccConSpotName != null">
        #{baseSuccConSpotName,jdbcType=VARCHAR},
      </if>
      <if test="calibrationMainTime != null">
        #{calibrationMainTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.meterwork.meterworkcalibrationmain.model.MeterWorkCalibrationMain">
    update METER_WORK_CALIBRATION_MAIN
    set BASE_SPOT_NO = #{baseSpotNo,jdbcType=VARCHAR},
      BASE_SPOT_NAME = #{baseSpotName,jdbcType=VARCHAR},
      SPOT_TYPE_NO = #{spotTypeNo,jdbcType=VARCHAR},
      SPOT_TYPE_NAME = #{spotTypeName,jdbcType=VARCHAR},
      CALIBRATION_NUM = #{calibrationNum,jdbcType=DECIMAL},
      CALIBRATION_TYPE_NO = #{calibrationTypeNo,jdbcType=VARCHAR},
      CALIBRATION_TYPE_NAME = #{calibrationTypeName,jdbcType=VARCHAR},
      CALIBRATION_ACT_NUM = #{calibrationActNum,jdbcType=DECIMAL},
      VALUE_FLAG = #{valueFlag,jdbcType=VARCHAR},
      BASE_CONTRAST_SPOT_NO = #{baseContrastSpotNo,jdbcType=VARCHAR},
      BASE_CONTRAST_SPOT_NAME = #{baseContrastSpotName,jdbcType=VARCHAR},
      BASE_SUCC_CONT_SPOT_NO = #{baseSuccContSpotNo,jdbcType=VARCHAR},
      BASE_SUCC_CON_SPOT_NAME = #{baseSuccConSpotName,jdbcType=VARCHAR},
      CALIBRATION_MAIN_TIME = #{calibrationMainTime,jdbcType=TIMESTAMP}
    where CALIBRATION_MAIN_NO = #{calibrationMainNo,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.meterwork.meterworkcalibrationmain.model.MeterWorkCalibrationMain">
    update METER_WORK_CALIBRATION_MAIN
    <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="spotTypeNo != null">
        SPOT_TYPE_NO = #{spotTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="spotTypeName != null">
        SPOT_TYPE_NAME = #{spotTypeName,jdbcType=VARCHAR},
      </if>
      <if test="calibrationNum != null">
        CALIBRATION_NUM = #{calibrationNum,jdbcType=DECIMAL},
      </if>
      <if test="calibrationTypeNo != null">
        CALIBRATION_TYPE_NO = #{calibrationTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="calibrationTypeName != null">
        CALIBRATION_TYPE_NAME = #{calibrationTypeName,jdbcType=VARCHAR},
      </if>
      <if test="calibrationActNum != null">
        CALIBRATION_ACT_NUM = #{calibrationActNum,jdbcType=DECIMAL},
      </if>
      <if test="valueFlag != null">
        VALUE_FLAG = #{valueFlag,jdbcType=VARCHAR},
      </if>
      <if test="baseContrastSpotNo != null">
        BASE_CONTRAST_SPOT_NO = #{baseContrastSpotNo,jdbcType=VARCHAR},
      </if>
      <if test="baseContrastSpotName != null">
        BASE_CONTRAST_SPOT_NAME = #{baseContrastSpotName,jdbcType=VARCHAR},
      </if>
      <if test="baseSuccContSpotNo != null">
        BASE_SUCC_CONT_SPOT_NO = #{baseSuccContSpotNo,jdbcType=VARCHAR},
      </if>
      <if test="baseSuccConSpotName != null">
        BASE_SUCC_CON_SPOT_NAME = #{baseSuccConSpotName,jdbcType=VARCHAR},
      </if>
      <if test="calibrationMainTime != null">
        CALIBRATION_MAIN_TIME = #{calibrationMainTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where CALIBRATION_MAIN_NO = #{calibrationMainNo,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where CALIBRATION_MAIN_NO = #{calibrationMainNo,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="where"/>
    <if test="string != null and string != ''">
     ${string}
    </if>
  </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_WORK_CALIBRATION_MAIN 
      (CALIBRATION_MAIN_NO, 
      BASE_SPOT_NO, BASE_SPOT_NAME, SPOT_TYPE_NO, 
      SPOT_TYPE_NAME, CALIBRATION_NUM, 
      CALIBRATION_TYPE_NO, CALIBRATION_TYPE_NAME, 
      CALIBRATION_ACT_NUM, VALUE_FLAG, 
      BASE_CONTRAST_SPOT_NO, BASE_CONTRAST_SPOT_NAME, 
      BASE_SUCC_CONT_SPOT_NO, BASE_SUCC_CON_SPOT_NAME, 
      CALIBRATION_MAIN_TIME)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.calibrationMainNo,jdbcType=VARCHAR}, 
      #{item.baseSpotNo,jdbcType=VARCHAR}, #{item.baseSpotName,jdbcType=VARCHAR}, #{item.spotTypeNo,jdbcType=VARCHAR}, 
      #{item.spotTypeName,jdbcType=VARCHAR}, #{item.calibrationNum,jdbcType=DECIMAL}, 
      #{item.calibrationTypeNo,jdbcType=VARCHAR}, #{item.calibrationTypeName,jdbcType=VARCHAR}, 
      #{item.calibrationActNum,jdbcType=DECIMAL}, #{item.valueFlag,jdbcType=VARCHAR}, 
      #{item.baseContrastSpotNo,jdbcType=VARCHAR}, #{item.baseContrastSpotName,jdbcType=VARCHAR}, 
      #{item.baseSuccContSpotNo,jdbcType=VARCHAR}, #{item.baseSuccConSpotName,jdbcType=VARCHAR}, 
      #{item.calibrationMainTime,jdbcType=TIMESTAMP} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update METER_WORK_CALIBRATION_MAIN
     set
       CALIBRATION_MAIN_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case CALIBRATION_MAIN_NO" close="end">
          when #{item.calibrationMainNo,jdbcType=VARCHAR} then #{item.calibrationMainNo,jdbcType=VARCHAR}
       </foreach>
       ,BASE_SPOT_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case CALIBRATION_MAIN_NO" close="end">
          when #{item.calibrationMainNo,jdbcType=VARCHAR} then #{item.baseSpotNo,jdbcType=VARCHAR}
       </foreach>
       ,BASE_SPOT_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case CALIBRATION_MAIN_NO" close="end">
          when #{item.calibrationMainNo,jdbcType=VARCHAR} then #{item.baseSpotName,jdbcType=VARCHAR}
       </foreach>
       ,SPOT_TYPE_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case CALIBRATION_MAIN_NO" close="end">
          when #{item.calibrationMainNo,jdbcType=VARCHAR} then #{item.spotTypeNo,jdbcType=VARCHAR}
       </foreach>
       ,SPOT_TYPE_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case CALIBRATION_MAIN_NO" close="end">
          when #{item.calibrationMainNo,jdbcType=VARCHAR} then #{item.spotTypeName,jdbcType=VARCHAR}
       </foreach>
       ,CALIBRATION_NUM=
       <foreach collection="list" item="item" index="index" separator=" " open="case CALIBRATION_MAIN_NO" close="end">
          when #{item.calibrationMainNo,jdbcType=VARCHAR} then #{item.calibrationNum,jdbcType=DECIMAL}
       </foreach>
       ,CALIBRATION_TYPE_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case CALIBRATION_MAIN_NO" close="end">
          when #{item.calibrationMainNo,jdbcType=VARCHAR} then #{item.calibrationTypeNo,jdbcType=VARCHAR}
       </foreach>
       ,CALIBRATION_TYPE_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case CALIBRATION_MAIN_NO" close="end">
          when #{item.calibrationMainNo,jdbcType=VARCHAR} then #{item.calibrationTypeName,jdbcType=VARCHAR}
       </foreach>
       ,CALIBRATION_ACT_NUM=
       <foreach collection="list" item="item" index="index" separator=" " open="case CALIBRATION_MAIN_NO" close="end">
          when #{item.calibrationMainNo,jdbcType=VARCHAR} then #{item.calibrationActNum,jdbcType=DECIMAL}
       </foreach>
       ,VALUE_FLAG=
       <foreach collection="list" item="item" index="index" separator=" " open="case CALIBRATION_MAIN_NO" close="end">
          when #{item.calibrationMainNo,jdbcType=VARCHAR} then #{item.valueFlag,jdbcType=VARCHAR}
       </foreach>
       ,BASE_CONTRAST_SPOT_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case CALIBRATION_MAIN_NO" close="end">
          when #{item.calibrationMainNo,jdbcType=VARCHAR} then #{item.baseContrastSpotNo,jdbcType=VARCHAR}
       </foreach>
       ,BASE_CONTRAST_SPOT_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case CALIBRATION_MAIN_NO" close="end">
          when #{item.calibrationMainNo,jdbcType=VARCHAR} then #{item.baseContrastSpotName,jdbcType=VARCHAR}
       </foreach>
       ,BASE_SUCC_CONT_SPOT_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case CALIBRATION_MAIN_NO" close="end">
          when #{item.calibrationMainNo,jdbcType=VARCHAR} then #{item.baseSuccContSpotNo,jdbcType=VARCHAR}
       </foreach>
       ,BASE_SUCC_CON_SPOT_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case CALIBRATION_MAIN_NO" close="end">
          when #{item.calibrationMainNo,jdbcType=VARCHAR} then #{item.baseSuccConSpotName,jdbcType=VARCHAR}
       </foreach>
       ,CALIBRATION_MAIN_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case CALIBRATION_MAIN_NO" close="end">
          when #{item.calibrationMainNo,jdbcType=VARCHAR} then #{item.calibrationMainTime,jdbcType=TIMESTAMP}
       </foreach>
     where CALIBRATION_MAIN_NO in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.calibrationMainNo,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_WORK_CALIBRATION_MAIN
    where CALIBRATION_MAIN_NO in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  <select id="selectForFlag" parameterType="java.util.HashMap" resultMap="BaseResultMap">
   select t1.* from METER_WORK_CALIBRATION_MAIN t1,
  ( select t.start_time start_time,t.end_time end_time from METER_BASE_CALIBRA_RELATION t
    where t.base_spot_no = #{baseSpotNo} and t.base_spot_name= #{baseSpotName} and t.calibration_type_no = #{calibrationTypeNo} and t.calibration_type_name = #{calibrationTypeName} )t2
    where t1.value_flag = #{valueFlag} and  #{calibrationMainTime} between
    to_date(to_char(sysdate, 'yyyy-MM-dd') ||' '||   to_char(t2.start_time,'HH24:mi:ss'),
                              'yyyy-MM-dd HH24:mi:ss') and to_date(to_char(sysdate, 'yyyy-MM-dd') ||' '||   to_char(t2.end_time,'HH24:mi:ss'),
                              'yyyy-MM-dd HH24:mi:ss')
  </select>

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



  <select id="doQuerySomeWf" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select * from(
      select * from METER_WORK_CALIBRATION_MAIN
      where  BASE_SPOT_NO = #{baseSpotNo}
      order by CALIBRATION_MAIN_TIME desc)
    where rownum &lt;=  #{pageSize}
  </select>

</mapper>