<?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.meterbasecalibrarelation.mapper.MeterBaseCalibraRelationMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.baseinfo.meterbasecalibrarelation.model.MeterBaseCalibraRelation">
    <id column="RELATION_NO" jdbcType="VARCHAR" property="relationNo" />
    <result column="BASE_SPOT_NO" jdbcType="VARCHAR" property="baseSpotNo" />
    <result column="BASE_SPOT_NAME" jdbcType="VARCHAR" property="baseSpotName" />
    <result column="CALIBRATION_TIME_UNIT" jdbcType="VARCHAR" property="calibrationTimeUnit" />
    <result column="START_TIME" jdbcType="TIMESTAMP" property="startTime" />
    <result column="END_TIME" jdbcType="TIMESTAMP" property="endTime" />
    <result column="DAY_NUM" jdbcType="DECIMAL" property="dayNum" />
    <result column="CALIBRATION_TYPE_NO" jdbcType="VARCHAR" property="calibrationTypeNo" />
    <result column="CALIBRATION_TYPE_NAME" jdbcType="VARCHAR" property="calibrationTypeName" />
    <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="VALID_FLAG" jdbcType="VARCHAR" property="validFlag" />
    <result column="UPDATE_MAN_NO" jdbcType="OTHER" property="updateManNo" />
    <result column="UPDATE_MAN_NAME" jdbcType="VARCHAR" property="updateManName" />
    <result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="DELETE_MAN_NO" jdbcType="VARCHAR" property="deleteManNo" />
    <result column="DELETE_MAN_NAME" jdbcType="VARCHAR" property="deleteManName" />
    <result column="DELETE_TIME" jdbcType="TIMESTAMP" property="deleteTime" />
    <result column="CALIBRATION_TIME_NO" jdbcType="VARCHAR" property="calibrationTimeNo" />
  </resultMap>
  <sql id="columns">
    RELATION_NO, BASE_SPOT_NO, BASE_SPOT_NAME, CALIBRATION_TIME_UNIT, START_TIME, END_TIME, 
    DAY_NUM, CALIBRATION_TYPE_NO, CALIBRATION_TYPE_NAME, CREATE_MAN_NO, CREATE_MAN_NAME, 
    CREATE_TIME, VALID_FLAG, UPDATE_MAN_NO, UPDATE_MAN_NAME, UPDATE_TIME, DELETE_MAN_NO,
    DELETE_MAN_NAME, DELETE_TIME, CALIBRATION_TIME_NO
  </sql>
  <sql id="columns_alias">
    t.RELATION_NO, t.BASE_SPOT_NO, t.BASE_SPOT_NAME, t.CALIBRATION_TIME_UNIT, t.START_TIME, 
    t.END_TIME, t.DAY_NUM, t.CALIBRATION_TYPE_NO, t.CALIBRATION_TYPE_NAME, t.CREATE_MAN_NO, 
    t.CREATE_MAN_NAME, t.CREATE_TIME, t.VALID_FLAG, t.UPDATE_MAN_NO, t.UPDATE_MAN_NAME,
    t.UPDATE_TIME, t.DELETE_MAN_NO, t.DELETE_MAN_NAME, t.DELETE_TIME, t.CALIBRATION_TIME_NO
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM METER_BASE_CALIBRA_RELATION
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM METER_BASE_CALIBRA_RELATION t
  </sql>
  <sql id="where">
    <where>
      <if test="relationNo != null and relationNo != ''">
        and RELATION_NO = #{relationNo}
      </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="calibrationTimeUnit != null and calibrationTimeUnit != ''">
        and CALIBRATION_TIME_UNIT = #{calibrationTimeUnit}
      </if>
      <if test="startTime != null">
        and TO_CHAR(START_TIME,'yyyy-MM-dd') = #{startTime}
      </if>
      <if test="endTime != null">
        and TO_CHAR(END_TIME,'yyyy-MM-dd') = #{endTime}
      </if>
      <if test="dayNum != null">
        and DAY_NUM = #{dayNum}
      </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="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="validFlag != null and validFlag != ''">
        and VALID_FLAG = #{validFlag}
      </if>
      <if test="updateManNo != null">
        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="deleteManNo != null and deleteManNo != ''">
        and DELETE_MAN_NO = #{deleteManNo}
      </if>
      <if test="deleteManName != null and deleteManName != ''">
        and DELETE_MAN_NAME = #{deleteManName}
      </if>
      <if test="deleteTime != null">
        and TO_CHAR(DELETE_TIME,'yyyy-MM-dd') = #{deleteTime}
      </if>
      <if test="calibrationTimeNo != null and calibrationTimeNo != ''">
        and CALIBRATION_TIME_NO = #{calibrationTimeNo}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where>
      <if test="relationNo != null and relationNo != ''">
        and RELATION_NO LIKE '%${relationNo}%'
      </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="calibrationTimeUnit != null and calibrationTimeUnit != ''">
        and CALIBRATION_TIME_UNIT LIKE '%${calibrationTimeUnit}%'
      </if>
      <if test="startTime != null">
        and TO_CHAR(START_TIME,'yyyy-MM-dd') = #{startTime}
      </if>
      <if test="endTime != null">
        and TO_CHAR(END_TIME,'yyyy-MM-dd') = #{endTime}
      </if>
      <if test="dayNum != null">
        and DAY_NUM = #{dayNum}
      </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="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="validFlag != null and validFlag != ''">
        and VALID_FLAG LIKE '%${validFlag}%'
      </if>
      <if test="updateManNo != null">
        and UPDATE_MAN_NO = #{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="deleteManNo != null and deleteManNo != ''">
        and DELETE_MAN_NO LIKE '%${deleteManNo}%'
      </if>
      <if test="deleteManName != null and deleteManName != ''">
        and DELETE_MAN_NAME LIKE '%${deleteManName}%'
      </if>
      <if test="deleteTime != null">
        and TO_CHAR(DELETE_TIME,'yyyy-MM-dd') = #{deleteTime}
      </if>
      <if test="calibrationTimeNo != null and calibrationTimeNo != ''">
        and CALIBRATION_TIME_NO LIKE '%${calibrationTimeNo}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from METER_BASE_CALIBRA_RELATION
    where RELATION_NO = #{relationNo,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_BASE_CALIBRA_RELATION
    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="calibrationTimeUnit != null and calibrationTimeUnit != ''">
        or CALIBRATION_TIME_UNIT = #{calibrationTimeUnit}
      </if>
      <if test="startTime != null">
        or TO_CHAR(START_TIME,'yyyy-MM-dd') = '#{startTime}'
      </if>
      <if test="endTime != null">
        or TO_CHAR(END_TIME,'yyyy-MM-dd') = '#{endTime}'
      </if>
      <if test="dayNum != null">
        or DAY_NUM = #{dayNum}
      </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="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="validFlag != null and validFlag != ''">
        or VALID_FLAG = #{validFlag}
      </if>
      <if test="updateManNo != null">
        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="deleteManNo != null and deleteManNo != ''">
        or DELETE_MAN_NO = #{deleteManNo}
      </if>
      <if test="deleteManName != null and deleteManName != ''">
        or DELETE_MAN_NAME = #{deleteManName}
      </if>
      <if test="deleteTime != null">
        or TO_CHAR(DELETE_TIME,'yyyy-MM-dd') = '#{deleteTime}'
      </if>
    <if test="calibrationTimeNo != null and calibrationTimeNo != ''">
      or CALIBRATION_TIME_NO = #{calibrationTimeNo}
    </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.baseinfo.meterbasecalibrarelation.model.MeterBaseCalibraRelation">
    insert into METER_BASE_CALIBRA_RELATION (RELATION_NO, BASE_SPOT_NO, BASE_SPOT_NAME, 
      CALIBRATION_TIME_UNIT, START_TIME, END_TIME, 
      DAY_NUM, CALIBRATION_TYPE_NO, CALIBRATION_TYPE_NAME, 
      CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME,
      VALID_FLAG, UPDATE_MAN_NO, UPDATE_MAN_NAME,
      UPDATE_TIME, DELETE_MAN_NO, DELETE_MAN_NAME,
      DELETE_TIME, CALIBRATION_TIME_NO)
      )
    values (#{relationNo,jdbcType=VARCHAR}, #{baseSpotNo,jdbcType=VARCHAR}, #{baseSpotName,jdbcType=VARCHAR}, 
      #{calibrationTimeUnit,jdbcType=VARCHAR}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, 
      #{dayNum,jdbcType=DECIMAL}, #{calibrationTypeNo,jdbcType=VARCHAR}, #{calibrationTypeName,jdbcType=VARCHAR}, 
      #{createManNo,jdbcType=VARCHAR}, #{createManName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
      #{validFlag,jdbcType=VARCHAR}, #{updateManNo,jdbcType=OTHER}, #{updateManName,jdbcType=VARCHAR},
      #{updateTime,jdbcType=TIMESTAMP}, #{deleteManNo,jdbcType=VARCHAR}, #{deleteManName,jdbcType=VARCHAR},
      #{deleteTime,jdbcType=TIMESTAMP}, #{calibrationTimeNo,jdbcType=VARCHAR})
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.baseinfo.meterbasecalibrarelation.model.MeterBaseCalibraRelation">
    insert into METER_BASE_CALIBRA_RELATION
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="relationNo != null">
        RELATION_NO,
      </if>
      <if test="baseSpotNo != null">
        BASE_SPOT_NO,
      </if>
      <if test="baseSpotName != null">
        BASE_SPOT_NAME,
      </if>
      <if test="calibrationTimeUnit != null">
        CALIBRATION_TIME_UNIT,
      </if>
      <if test="startTime != null">
        START_TIME,
      </if>
      <if test="endTime != null">
        END_TIME,
      </if>
      <if test="dayNum != null">
        DAY_NUM,
      </if>
      <if test="calibrationTypeNo != null">
        CALIBRATION_TYPE_NO,
      </if>
      <if test="calibrationTypeName != null">
        CALIBRATION_TYPE_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>
      <if test="validFlag != null">
        VALID_FLAG,
      </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="deleteManNo != null">
        DELETE_MAN_NO,
      </if>
      <if test="deleteManName != null">
        DELETE_MAN_NAME,
      </if>
      <if test="deleteTime != null">
        DELETE_TIME,
      </if>
      <if test="calibrationTimeNo != null">
        CALIBRATION_TIME_NO,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="relationNo != null">
        #{relationNo,jdbcType=VARCHAR},
      </if>
      <if test="baseSpotNo != null">
        #{baseSpotNo,jdbcType=VARCHAR},
      </if>
      <if test="baseSpotName != null">
        #{baseSpotName,jdbcType=VARCHAR},
      </if>
      <if test="calibrationTimeUnit != null">
        #{calibrationTimeUnit,jdbcType=VARCHAR},
      </if>
      <if test="startTime != null">
        #{startTime,jdbcType=TIMESTAMP},
      </if>
      <if test="endTime != null">
        #{endTime,jdbcType=TIMESTAMP},
      </if>
      <if test="dayNum != null">
        #{dayNum,jdbcType=DECIMAL},
      </if>
      <if test="calibrationTypeNo != null">
        #{calibrationTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="calibrationTypeName != null">
        #{calibrationTypeName,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="validFlag != null">
        #{validFlag,jdbcType=VARCHAR},
      </if>
      <if test="updateManNo != null">
        #{updateManNo,jdbcType=OTHER},
      </if>
      <if test="updateManName != null">
        #{updateManName,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="deleteManNo != null">
        #{deleteManNo,jdbcType=VARCHAR},
      </if>
      <if test="deleteManName != null">
        #{deleteManName,jdbcType=VARCHAR},
      </if>
      <if test="deleteTime != null">
        #{deleteTime,jdbcType=TIMESTAMP},
      </if>
      <if test="calibrationTimeNo != null">
        #{calibrationTimeNo,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.baseinfo.meterbasecalibrarelation.model.MeterBaseCalibraRelation">
    update METER_BASE_CALIBRA_RELATION
    set BASE_SPOT_NO = #{baseSpotNo,jdbcType=VARCHAR},
      BASE_SPOT_NAME = #{baseSpotName,jdbcType=VARCHAR},
      CALIBRATION_TIME_UNIT = #{calibrationTimeUnit,jdbcType=VARCHAR},
      START_TIME = #{startTime,jdbcType=TIMESTAMP},
      END_TIME = #{endTime,jdbcType=TIMESTAMP},
      DAY_NUM = #{dayNum,jdbcType=DECIMAL},
      CALIBRATION_TYPE_NO = #{calibrationTypeNo,jdbcType=VARCHAR},
      CALIBRATION_TYPE_NAME = #{calibrationTypeName,jdbcType=VARCHAR},
      CREATE_MAN_NO = #{createManNo,jdbcType=VARCHAR},
      CREATE_MAN_NAME = #{createManName,jdbcType=VARCHAR},
      CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
      VALID_FLAG = #{validFlag,jdbcType=VARCHAR},
      UPDATE_MAN_NO = #{updateManNo,jdbcType=OTHER},
      UPDATE_MAN_NAME = #{updateManName,jdbcType=VARCHAR},
      UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
      DELETE_MAN_NO = #{deleteManNo,jdbcType=VARCHAR},
      DELETE_MAN_NAME = #{deleteManName,jdbcType=VARCHAR},
      DELETE_TIME = #{deleteTime,jdbcType=TIMESTAMP},
      CALIBRATION_TIME_NO = #{calibrationTimeNo,jdbcType=VARCHAR}
    where RELATION_NO = #{relationNo,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.baseinfo.meterbasecalibrarelation.model.MeterBaseCalibraRelation">
    update METER_BASE_CALIBRA_RELATION
    <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="calibrationTimeUnit != null">
        CALIBRATION_TIME_UNIT = #{calibrationTimeUnit,jdbcType=VARCHAR},
      </if>
      <if test="startTime != null">
        START_TIME = #{startTime,jdbcType=TIMESTAMP},
      </if>
      <if test="endTime != null">
        END_TIME = #{endTime,jdbcType=TIMESTAMP},
      </if>
      <if test="dayNum != null">
        DAY_NUM = #{dayNum,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="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="validFlag != null">
        VALID_FLAG = #{validFlag,jdbcType=VARCHAR},
      </if>
      <if test="updateManNo != null">
        UPDATE_MAN_NO = #{updateManNo,jdbcType=OTHER},
      </if>
      <if test="updateManName != null">
        UPDATE_MAN_NAME = #{updateManName,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="deleteManNo != null">
        DELETE_MAN_NO = #{deleteManNo,jdbcType=VARCHAR},
      </if>
      <if test="deleteManName != null">
        DELETE_MAN_NAME = #{deleteManName,jdbcType=VARCHAR},
      </if>
      <if test="deleteTime != null">
        DELETE_TIME = #{deleteTime,jdbcType=TIMESTAMP},
      </if>
      <if test="calibrationTimeNo != null">
        CALIBRATION_TIME_NO = #{calibrationTimeNo,jdbcType=VARCHAR},
      </if>
    </set>
    where RELATION_NO = #{relationNo,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where RELATION_NO = #{relationNo,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="where"/>
    order by  RELATION_NO desc
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="whereLike"/>
    order by  RELATION_NO desc
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into METER_BASE_CALIBRA_RELATION 
      (RELATION_NO, 
      BASE_SPOT_NO, BASE_SPOT_NAME, CALIBRATION_TIME_UNIT, 
      START_TIME, END_TIME, DAY_NUM, 
      CALIBRATION_TYPE_NO, CALIBRATION_TYPE_NAME, 
      CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME,
    VALID_FLAG, UPDATE_MAN_NO, UPDATE_MAN_NAME,
    UPDATE_TIME, DELETE_MAN_NO, DELETE_MAN_NAME,
    DELETE_TIME, CALIBRATION_TIME_NO)
      )
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.relationNo,jdbcType=VARCHAR}, 
      #{item.baseSpotNo,jdbcType=VARCHAR}, #{item.baseSpotName,jdbcType=VARCHAR}, #{item.calibrationTimeUnit,jdbcType=VARCHAR}, 
      #{item.startTime,jdbcType=TIMESTAMP}, #{item.endTime,jdbcType=TIMESTAMP}, #{item.dayNum,jdbcType=DECIMAL}, 
      #{item.calibrationTypeNo,jdbcType=VARCHAR}, #{item.calibrationTypeName,jdbcType=VARCHAR}, 
      #{item.createManNo,jdbcType=VARCHAR}, #{item.createManName,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP},
    #{item.validFlag,jdbcType=VARCHAR}, #{item.updateManNo,jdbcType=OTHER}, #{item.updateManName,jdbcType=VARCHAR},
    #{item.updateTime,jdbcType=TIMESTAMP}, #{item.deleteManNo,jdbcType=VARCHAR}, #{item.deleteManName,jdbcType=VARCHAR},
    #{item.deleteTime,jdbcType=TIMESTAMP, #{item.calibrationTimeNo,jdbcType=VARCHAR}}
       from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update METER_BASE_CALIBRA_RELATION
     set
       RELATION_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
          when #{item.relationNo,jdbcType=VARCHAR} then #{item.relationNo,jdbcType=VARCHAR}
       </foreach>
       ,BASE_SPOT_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
          when #{item.relationNo,jdbcType=VARCHAR} then #{item.baseSpotNo,jdbcType=VARCHAR}
       </foreach>
       ,BASE_SPOT_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
          when #{item.relationNo,jdbcType=VARCHAR} then #{item.baseSpotName,jdbcType=VARCHAR}
       </foreach>
       ,CALIBRATION_TIME_UNIT=
       <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
          when #{item.relationNo,jdbcType=VARCHAR} then #{item.calibrationTimeUnit,jdbcType=VARCHAR}
       </foreach>
       ,START_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
          when #{item.relationNo,jdbcType=VARCHAR} then #{item.startTime,jdbcType=TIMESTAMP}
       </foreach>
       ,END_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
          when #{item.relationNo,jdbcType=VARCHAR} then #{item.endTime,jdbcType=TIMESTAMP}
       </foreach>
       ,DAY_NUM=
       <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
          when #{item.relationNo,jdbcType=VARCHAR} then #{item.dayNum,jdbcType=DECIMAL}
       </foreach>
       ,CALIBRATION_TYPE_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
          when #{item.relationNo,jdbcType=VARCHAR} then #{item.calibrationTypeNo,jdbcType=VARCHAR}
       </foreach>
       ,CALIBRATION_TYPE_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
          when #{item.relationNo,jdbcType=VARCHAR} then #{item.calibrationTypeName,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_MAN_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
          when #{item.relationNo,jdbcType=VARCHAR} then #{item.createManNo,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_MAN_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
          when #{item.relationNo,jdbcType=VARCHAR} then #{item.createManName,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
          when #{item.relationNo,jdbcType=VARCHAR} then #{item.createTime,jdbcType=TIMESTAMP}
       </foreach>
      ,VALID_FLAG=
      <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
        when #{item.relationNo,jdbcType=VARCHAR} then #{item.validFlag,jdbcType=VARCHAR}
      </foreach>
      ,UPDATE_MAN_NO=
      <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
        when #{item.relationNo,jdbcType=VARCHAR} then #{item.updateManNo,jdbcType=OTHER}
      </foreach>
      ,UPDATE_MAN_NAME=
      <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
        when #{item.relationNo,jdbcType=VARCHAR} then #{item.updateManName,jdbcType=VARCHAR}
      </foreach>
      ,UPDATE_TIME=
      <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
        when #{item.relationNo,jdbcType=VARCHAR} then #{item.updateTime,jdbcType=TIMESTAMP}
      </foreach>
      ,DELETE_MAN_NO=
      <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
        when #{item.relationNo,jdbcType=VARCHAR} then #{item.deleteManNo,jdbcType=VARCHAR}
      </foreach>
      ,DELETE_MAN_NAME=
      <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
        when #{item.relationNo,jdbcType=VARCHAR} then #{item.deleteManName,jdbcType=VARCHAR}
      </foreach>
      ,DELETE_TIME=
      <foreach collection="list" item="item" index="index" separator=" " open="case RELATION_NO" close="end">
        when #{item.relationNo,jdbcType=VARCHAR} then #{item.deleteTime,jdbcType=TIMESTAMP}
      </foreach>
      ,CALIBRATION_TIME_NO=
      <foreach close="end" collection="list" index="index" item="item" open="case RELATION_NO" separator=" ">
        when #{item.relationNo,jdbcType=VARCHAR} then #{item.calibrationTimeNo,jdbcType=VARCHAR}
      </foreach>
     where RELATION_NO in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.relationNo,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_BASE_CALIBRA_RELATION
    where RELATION_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(RELATION_NO, LENGTH(RELATION_NO) - 4))),0) + 1,5,'0') RELATION_NO
  FROM METER_BASE_CALIBRA_RELATION
</select>

  <select id="doQueryCalibrationWf" parameterType="java.lang.String" resultMap="BaseResultMap">
    select t1.*
          from METER_BASE_CALIBRA_RELATION t1,
               METER_WORK_CALIBRATION_MAIN tm
         where tm.value_flag = '2'
           and tm.base_spot_no = t1.base_spot_no
           and tm.base_spot_no =  #{baseSpotNo,jdbcType=VARCHAR}
           and tm.calibration_type_no = t1.calibration_type_no
           and (decode(t1.calibration_time_unit,
                       '0',
                       (tm.calibration_main_time + t1.day_num)) >= sysdate or
               decode(t1.calibration_time_unit,
                       '1',tm.calibration_main_time) between
               to_date(to_char(sysdate, 'yyyy-MM-dd') || ' ' ||
                        to_char(t1.start_time, 'HH24:mi:ss'),
                        'yyyy-MM-dd HH24:mi:ss') and
               to_date(to_char(sysdate, 'yyyy-MM-dd') || ' ' ||
                        to_char(t1.end_time, 'HH24:mi:ss'),
                        'yyyy-MM-dd HH24:mi:ss'))
  </select>
  <select id="doQueryCalibrationNeedWf" parameterType="java.lang.String" resultMap="BaseResultMap">
   select t2.*
          from METER_BASE_CALIBRA_RELATION t2
         where t2.base_spot_no =  #{baseSpotNo,jdbcType=VARCHAR}
           and (sysdate 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') or
               t2.calibration_time_unit = '0')
  </select>
  <select id="selectByCalibTimeNo" parameterType="java.lang.String" resultMap="BaseResultMap">
   select t2.*
          from METER_BASE_CALIBRA_RELATION t2
         where t2.calibration_time_no =  #{calibrationTimeNo,jdbcType=VARCHAR}
           and t2.valid_flag = '1'
  </select>
</mapper>