<?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.meterbasecalibrastandard.mapper.MeterBaseCalibraStandardMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.baseinfo.meterbasecalibrastandard.model.MeterBaseCalibraStandard">
    <id column="STANDARD_NO" jdbcType="VARCHAR" property="standardNo" />
    <result column="CALIBRATION_TYPE_NO" jdbcType="VARCHAR" property="calibrationTypeNo" />
    <result column="CALIBRATION_TYPE_NAME" jdbcType="VARCHAR" property="calibrationTypeName" />
    <result column="UP_WEIGHT" jdbcType="DECIMAL" property="upWeight" />
    <result column="DOWN_WEIGHT" jdbcType="DECIMAL" property="downWeight" />
    <result column="DEVIATION_WEIGHT" jdbcType="DECIMAL" property="deviationWeight" />
    <result column="STANDARD" jdbcType="VARCHAR" property="standard" />
    <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" />
  </resultMap>
  <sql id="columns">
    STANDARD_NO, CALIBRATION_TYPE_NO, CALIBRATION_TYPE_NAME, UP_WEIGHT, DOWN_WEIGHT, 
    DEVIATION_WEIGHT, STANDARD, MEMO, VALUE_FLAG, CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME, 
    UPDATE_MAN_NO, UPDATE_MAN_NAME, UPDATE_TIME
  </sql>
  <sql id="columns_alias">
    t.STANDARD_NO, t.CALIBRATION_TYPE_NO, t.CALIBRATION_TYPE_NAME, t.UP_WEIGHT, t.DOWN_WEIGHT, 
    t.DEVIATION_WEIGHT, t.STANDARD, 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
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM METER_BASE_CALIBRA_STANDARD
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM METER_BASE_CALIBRA_STANDARD t
  </sql>
  <sql id="where">
    <where> 
      <if test="standardNo != null and standardNo != ''">
        and STANDARD_NO = #{standardNo}
      </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="upWeight != null">
        and UP_WEIGHT = #{upWeight}
      </if>
      <if test="downWeight != null">
        and DOWN_WEIGHT = #{downWeight}
      </if>
      <if test="deviationWeight != null">
        and DEVIATION_WEIGHT = #{deviationWeight}
      </if>
      <if test="standard != null and standard != ''">
        and STANDARD = #{standard}
      </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>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="standardNo != null and standardNo != ''">
        and STANDARD_NO LIKE '%${standardNo}%'
      </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="upWeight != null">
        and UP_WEIGHT = #{upWeight}
      </if>
      <if test="downWeight != null">
        and DOWN_WEIGHT = #{downWeight}
      </if>
      <if test="deviationWeight != null">
        and DEVIATION_WEIGHT = #{deviationWeight}
      </if>
      <if test="standard != null and standard != ''">
        and STANDARD LIKE '%${standard}%'
      </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>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from METER_BASE_CALIBRA_STANDARD
    where STANDARD_NO = #{standardNo,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_BASE_CALIBRA_STANDARD
    where 1!=1 
      <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="upWeight != null">
        or UP_WEIGHT = #{upWeight}
      </if>
      <if test="downWeight != null">
        or DOWN_WEIGHT = #{downWeight}
      </if>
      <if test="deviationWeight != null">
        or DEVIATION_WEIGHT = #{deviationWeight}
      </if>
      <if test="standard != null and standard != ''">
        or STANDARD = #{standard}
      </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>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.baseinfo.meterbasecalibrastandard.model.MeterBaseCalibraStandard">
    insert into METER_BASE_CALIBRA_STANDARD (STANDARD_NO, CALIBRATION_TYPE_NO, CALIBRATION_TYPE_NAME, 
      UP_WEIGHT, DOWN_WEIGHT, DEVIATION_WEIGHT, 
      STANDARD, MEMO, VALUE_FLAG, 
      CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME, 
      UPDATE_MAN_NO, UPDATE_MAN_NAME, UPDATE_TIME
      )
    values (#{standardNo,jdbcType=VARCHAR}, #{calibrationTypeNo,jdbcType=VARCHAR}, #{calibrationTypeName,jdbcType=VARCHAR}, 
      #{upWeight,jdbcType=DECIMAL}, #{downWeight,jdbcType=DECIMAL}, #{deviationWeight,jdbcType=DECIMAL}, 
      #{standard,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}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.baseinfo.meterbasecalibrastandard.model.MeterBaseCalibraStandard">
    insert into METER_BASE_CALIBRA_STANDARD
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="standardNo != null">
        STANDARD_NO,
      </if>
      <if test="calibrationTypeNo != null">
        CALIBRATION_TYPE_NO,
      </if>
      <if test="calibrationTypeName != null">
        CALIBRATION_TYPE_NAME,
      </if>
      <if test="upWeight != null">
        UP_WEIGHT,
      </if>
      <if test="downWeight != null">
        DOWN_WEIGHT,
      </if>
      <if test="deviationWeight != null">
        DEVIATION_WEIGHT,
      </if>
      <if test="standard != null">
        STANDARD,
      </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>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="standardNo != null">
        #{standardNo,jdbcType=VARCHAR},
      </if>
      <if test="calibrationTypeNo != null">
        #{calibrationTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="calibrationTypeName != null">
        #{calibrationTypeName,jdbcType=VARCHAR},
      </if>
      <if test="upWeight != null">
        #{upWeight,jdbcType=DECIMAL},
      </if>
      <if test="downWeight != null">
        #{downWeight,jdbcType=DECIMAL},
      </if>
      <if test="deviationWeight != null">
        #{deviationWeight,jdbcType=DECIMAL},
      </if>
      <if test="standard != null">
        #{standard,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>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.baseinfo.meterbasecalibrastandard.model.MeterBaseCalibraStandard">
    update METER_BASE_CALIBRA_STANDARD
    set CALIBRATION_TYPE_NO = #{calibrationTypeNo,jdbcType=VARCHAR},
      CALIBRATION_TYPE_NAME = #{calibrationTypeName,jdbcType=VARCHAR},
      UP_WEIGHT = #{upWeight,jdbcType=DECIMAL},
      DOWN_WEIGHT = #{downWeight,jdbcType=DECIMAL},
      DEVIATION_WEIGHT = #{deviationWeight,jdbcType=DECIMAL},
      STANDARD = #{standard,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}
    where STANDARD_NO = #{standardNo,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.baseinfo.meterbasecalibrastandard.model.MeterBaseCalibraStandard">
    update METER_BASE_CALIBRA_STANDARD
    <set>
      <if test="calibrationTypeNo != null">
        CALIBRATION_TYPE_NO = #{calibrationTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="calibrationTypeName != null">
        CALIBRATION_TYPE_NAME = #{calibrationTypeName,jdbcType=VARCHAR},
      </if>
      <if test="upWeight != null">
        UP_WEIGHT = #{upWeight,jdbcType=DECIMAL},
      </if>
      <if test="downWeight != null">
        DOWN_WEIGHT = #{downWeight,jdbcType=DECIMAL},
      </if>
      <if test="deviationWeight != null">
        DEVIATION_WEIGHT = #{deviationWeight,jdbcType=DECIMAL},
      </if>
      <if test="standard != null">
        STANDARD = #{standard,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>
    </set>
    where STANDARD_NO = #{standardNo,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where STANDARD_NO = #{standardNo,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_CALIBRA_STANDARD 
      (STANDARD_NO, 
      CALIBRATION_TYPE_NO, CALIBRATION_TYPE_NAME, 
      UP_WEIGHT, DOWN_WEIGHT, DEVIATION_WEIGHT, 
      STANDARD, MEMO, VALUE_FLAG, 
      CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME, 
      UPDATE_MAN_NO, UPDATE_MAN_NAME, UPDATE_TIME
      )
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.standardNo,jdbcType=VARCHAR}, 
      #{item.calibrationTypeNo,jdbcType=VARCHAR}, #{item.calibrationTypeName,jdbcType=VARCHAR}, 
      #{item.upWeight,jdbcType=DECIMAL}, #{item.downWeight,jdbcType=DECIMAL}, #{item.deviationWeight,jdbcType=DECIMAL}, 
      #{item.standard,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}
       from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update METER_BASE_CALIBRA_STANDARD
     set
       STANDARD_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case STANDARD_NO" close="end">
          when #{item.standardNo,jdbcType=VARCHAR} then #{item.standardNo,jdbcType=VARCHAR}
       </foreach>
       ,CALIBRATION_TYPE_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case STANDARD_NO" close="end">
          when #{item.standardNo,jdbcType=VARCHAR} then #{item.calibrationTypeNo,jdbcType=VARCHAR}
       </foreach>
       ,CALIBRATION_TYPE_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case STANDARD_NO" close="end">
          when #{item.standardNo,jdbcType=VARCHAR} then #{item.calibrationTypeName,jdbcType=VARCHAR}
       </foreach>
       ,UP_WEIGHT=
       <foreach collection="list" item="item" index="index" separator=" " open="case STANDARD_NO" close="end">
          when #{item.standardNo,jdbcType=VARCHAR} then #{item.upWeight,jdbcType=DECIMAL}
       </foreach>
       ,DOWN_WEIGHT=
       <foreach collection="list" item="item" index="index" separator=" " open="case STANDARD_NO" close="end">
          when #{item.standardNo,jdbcType=VARCHAR} then #{item.downWeight,jdbcType=DECIMAL}
       </foreach>
       ,DEVIATION_WEIGHT=
       <foreach collection="list" item="item" index="index" separator=" " open="case STANDARD_NO" close="end">
          when #{item.standardNo,jdbcType=VARCHAR} then #{item.deviationWeight,jdbcType=DECIMAL}
       </foreach>
       ,STANDARD=
       <foreach collection="list" item="item" index="index" separator=" " open="case STANDARD_NO" close="end">
          when #{item.standardNo,jdbcType=VARCHAR} then #{item.standard,jdbcType=VARCHAR}
       </foreach>
       ,MEMO=
       <foreach collection="list" item="item" index="index" separator=" " open="case STANDARD_NO" close="end">
          when #{item.standardNo,jdbcType=VARCHAR} then #{item.memo,jdbcType=VARCHAR}
       </foreach>
       ,VALUE_FLAG=
       <foreach collection="list" item="item" index="index" separator=" " open="case STANDARD_NO" close="end">
          when #{item.standardNo,jdbcType=VARCHAR} then #{item.valueFlag,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_MAN_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case STANDARD_NO" close="end">
          when #{item.standardNo,jdbcType=VARCHAR} then #{item.createManNo,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_MAN_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case STANDARD_NO" close="end">
          when #{item.standardNo,jdbcType=VARCHAR} then #{item.createManName,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case STANDARD_NO" close="end">
          when #{item.standardNo,jdbcType=VARCHAR} then #{item.createTime,jdbcType=TIMESTAMP}
       </foreach>
       ,UPDATE_MAN_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case STANDARD_NO" close="end">
          when #{item.standardNo,jdbcType=VARCHAR} then #{item.updateManNo,jdbcType=VARCHAR}
       </foreach>
       ,UPDATE_MAN_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case STANDARD_NO" close="end">
          when #{item.standardNo,jdbcType=VARCHAR} then #{item.updateManName,jdbcType=VARCHAR}
       </foreach>
       ,UPDATE_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case STANDARD_NO" close="end">
          when #{item.standardNo,jdbcType=VARCHAR} then #{item.updateTime,jdbcType=TIMESTAMP}
       </foreach>
     where STANDARD_NO in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.standardNo,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_BASE_CALIBRA_STANDARD
    where STANDARD_NO in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  <select id="findAll" resultMap="BaseResultMap">
      select * from METER_BASE_CALIBRA_STANDARD
  </select>

  <select id="GetNewID" parameterType="java.lang.String" resultType="java.lang.String">
    SELECT LPAD(NVL(MAX(TO_NUMBER(SUBSTR(STANDARD_NO, LENGTH(STANDARD_NO) - 4))),0) + 1,5,'0') STANDARD_NO
    FROM METER_BASE_CALIBRA_STANDARD
  </select>
</mapper>