<?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.meterworkaddweight.mapper.MeterWorkAddWeightMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.meterwork.meterworkaddweight.model.MeterWorkAddWeight">
    <id column="ADD_WEIGHT_ACT_NO" jdbcType="VARCHAR" property="addWeightActNo" />
    <result column="ADD_WEIGHT_NO" jdbcType="VARCHAR" property="addWeightNo" />
    <result column="UTENSIL_NO" jdbcType="VARCHAR" property="utensilNo" />
    <result column="UTENSIL_NAME" jdbcType="VARCHAR" property="utensilName" />
    <result column="UTENSIL_WEIGHT" jdbcType="DECIMAL" property="utensilWeight" />
    <result column="UTENSIL_TYPE_NO" jdbcType="VARCHAR" property="utensilTypeNo" />
    <result column="UTENSIL_UTENSIL_NAME" jdbcType="VARCHAR" property="utensilUtensilName" />
    <result column="ACTUAL_FIRST_NO" jdbcType="VARCHAR" property="actualFirstNo" />
    <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">
    ADD_WEIGHT_ACT_NO, ADD_WEIGHT_NO, UTENSIL_NO, UTENSIL_NAME, UTENSIL_WEIGHT, UTENSIL_TYPE_NO, 
    UTENSIL_UTENSIL_NAME, ACTUAL_FIRST_NO, CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME
  </sql>
  <sql id="columns_alias">
    t.ADD_WEIGHT_ACT_NO, t.ADD_WEIGHT_NO, t.UTENSIL_NO, t.UTENSIL_NAME, t.UTENSIL_WEIGHT, 
    t.UTENSIL_TYPE_NO, t.UTENSIL_UTENSIL_NAME, t.ACTUAL_FIRST_NO, t.CREATE_MAN_NO, t.CREATE_MAN_NAME, 
    t.CREATE_TIME
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM METER_WORK_ADD_WEIGHT
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM METER_WORK_ADD_WEIGHT t
  </sql>
  <sql id="where">
    <where> 
      <if test="addWeightNo != null and addWeightNo != ''">
        and ADD_WEIGHT_NO = #{addWeightNo}
      </if>
      <if test="utensilNo != null and utensilNo != ''">
        and UTENSIL_NO = #{utensilNo}
      </if>
      <if test="utensilName != null and utensilName != ''">
        and UTENSIL_NAME = #{utensilName}
      </if>
      <if test="utensilWeight != null and utensilWeight != ''">
        and UTENSIL_WEIGHT = #{utensilWeight}
      </if>
      <if test="utensilTypeNo != null and utensilTypeNo != ''">
        and UTENSIL_TYPE_NO = #{utensilTypeNo}
      </if>
      <if test="utensilUtensilName != null and utensilUtensilName != ''">
        and UTENSIL_UTENSIL_NAME = #{utensilUtensilName}
      </if>
      <if test="actualFirstNo != null and actualFirstNo != ''">
        and ACTUAL_FIRST_NO = #{actualFirstNo}
      </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="addWeightNo != null and addWeightNo != ''">
        and ADD_WEIGHT_NO LIKE '%${addWeightNo}%'
      </if>
      <if test="utensilNo != null and utensilNo != ''">
        and UTENSIL_NO LIKE '%${utensilNo}%'
      </if>
      <if test="utensilName != null and utensilName != ''">
        and UTENSIL_NAME LIKE '%${utensilName}%'
      </if>
      <if test="utensilWeight != null and utensilWeight != ''">
        and UTENSIL_WEIGHT LIKE '%${utensilWeight}%'
      </if>
      <if test="utensilTypeNo != null and utensilTypeNo != ''">
        and UTENSIL_TYPE_NO LIKE '%${utensilTypeNo}%'
      </if>
      <if test="utensilUtensilName != null and utensilUtensilName != ''">
        and UTENSIL_UTENSIL_NAME LIKE '%${utensilUtensilName}%'
      </if>
      <if test="actualFirstNo != null and actualFirstNo != ''">
        and ACTUAL_FIRST_NO LIKE '%${actualFirstNo}%'
      </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_WORK_ADD_WEIGHT
    where ADD_WEIGHT_ACT_NO = #{addWeightActNo,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_WORK_ADD_WEIGHT
    where 1!=1 
      <if test="addWeightNo != null and addWeightNo != ''">
        or ADD_WEIGHT_NO = #{addWeightNo}
      </if>
      <if test="utensilNo != null and utensilNo != ''">
        or UTENSIL_NO = #{utensilNo}
      </if>
      <if test="utensilName != null and utensilName != ''">
        or UTENSIL_NAME = #{utensilName}
      </if>
      <if test="utensilWeight != null and utensilWeight != ''">
        or UTENSIL_WEIGHT = #{utensilWeight}
      </if>
      <if test="utensilTypeNo != null and utensilTypeNo != ''">
        or UTENSIL_TYPE_NO = #{utensilTypeNo}
      </if>
      <if test="utensilUtensilName != null and utensilUtensilName != ''">
        or UTENSIL_UTENSIL_NAME = #{utensilUtensilName}
      </if>
      <if test="actualFirstNo != null and actualFirstNo != ''">
        or ACTUAL_FIRST_NO = #{actualFirstNo}
      </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.meterwork.meterworkaddweight.model.MeterWorkAddWeight">
    insert into METER_WORK_ADD_WEIGHT (ADD_WEIGHT_ACT_NO, ADD_WEIGHT_NO, UTENSIL_NO, 
      UTENSIL_NAME, UTENSIL_WEIGHT, UTENSIL_TYPE_NO, 
      UTENSIL_UTENSIL_NAME, ACTUAL_FIRST_NO, CREATE_MAN_NO, 
      CREATE_MAN_NAME, CREATE_TIME)
    values (#{addWeightActNo,jdbcType=VARCHAR}, #{addWeightNo,jdbcType=VARCHAR}, #{utensilNo,jdbcType=VARCHAR}, 
      #{utensilName,jdbcType=VARCHAR}, #{utensilWeight,jdbcType=VARCHAR}, #{utensilTypeNo,jdbcType=VARCHAR}, 
      #{utensilUtensilName,jdbcType=VARCHAR}, #{actualFirstNo,jdbcType=VARCHAR}, #{createManNo,jdbcType=VARCHAR}, 
      #{createManName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.meterwork.meterworkaddweight.model.MeterWorkAddWeight">
    insert into METER_WORK_ADD_WEIGHT
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="addWeightActNo != null">
        ADD_WEIGHT_ACT_NO,
      </if>
      <if test="addWeightNo != null">
        ADD_WEIGHT_NO,
      </if>
      <if test="utensilNo != null">
        UTENSIL_NO,
      </if>
      <if test="utensilName != null">
        UTENSIL_NAME,
      </if>
      <if test="utensilWeight != null">
        UTENSIL_WEIGHT,
      </if>
      <if test="utensilTypeNo != null">
        UTENSIL_TYPE_NO,
      </if>
      <if test="utensilUtensilName != null">
        UTENSIL_UTENSIL_NAME,
      </if>
      <if test="actualFirstNo != null">
        ACTUAL_FIRST_NO,
      </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="addWeightActNo != null">
        #{addWeightActNo,jdbcType=VARCHAR},
      </if>
      <if test="addWeightNo != null">
        #{addWeightNo,jdbcType=VARCHAR},
      </if>
      <if test="utensilNo != null">
        #{utensilNo,jdbcType=VARCHAR},
      </if>
      <if test="utensilName != null">
        #{utensilName,jdbcType=VARCHAR},
      </if>
      <if test="utensilWeight != null">
        #{utensilWeight,jdbcType=VARCHAR},
      </if>
      <if test="utensilTypeNo != null">
        #{utensilTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="utensilUtensilName != null">
        #{utensilUtensilName,jdbcType=VARCHAR},
      </if>
      <if test="actualFirstNo != null">
        #{actualFirstNo,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.meterwork.meterworkaddweight.model.MeterWorkAddWeight">
    update METER_WORK_ADD_WEIGHT
    set ADD_WEIGHT_NO = #{addWeightNo,jdbcType=VARCHAR},
      UTENSIL_NO = #{utensilNo,jdbcType=VARCHAR},
      UTENSIL_NAME = #{utensilName,jdbcType=VARCHAR},
      UTENSIL_WEIGHT = #{utensilWeight,jdbcType=VARCHAR},
      UTENSIL_TYPE_NO = #{utensilTypeNo,jdbcType=VARCHAR},
      UTENSIL_UTENSIL_NAME = #{utensilUtensilName,jdbcType=VARCHAR},
      ACTUAL_FIRST_NO = #{actualFirstNo,jdbcType=VARCHAR},
      CREATE_MAN_NO = #{createManNo,jdbcType=VARCHAR},
      CREATE_MAN_NAME = #{createManName,jdbcType=VARCHAR},
      CREATE_TIME = #{createTime,jdbcType=TIMESTAMP}
    where ADD_WEIGHT_ACT_NO = #{addWeightActNo,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.meterwork.meterworkaddweight.model.MeterWorkAddWeight">
    update METER_WORK_ADD_WEIGHT
    <set>
      <if test="addWeightNo != null">
        ADD_WEIGHT_NO = #{addWeightNo,jdbcType=VARCHAR},
      </if>
      <if test="utensilNo != null">
        UTENSIL_NO = #{utensilNo,jdbcType=VARCHAR},
      </if>
      <if test="utensilName != null">
        UTENSIL_NAME = #{utensilName,jdbcType=VARCHAR},
      </if>
      <if test="utensilWeight != null">
        UTENSIL_WEIGHT = #{utensilWeight,jdbcType=VARCHAR},
      </if>
      <if test="utensilTypeNo != null">
        UTENSIL_TYPE_NO = #{utensilTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="utensilUtensilName != null">
        UTENSIL_UTENSIL_NAME = #{utensilUtensilName,jdbcType=VARCHAR},
      </if>
      <if test="actualFirstNo != null">
        ACTUAL_FIRST_NO = #{actualFirstNo,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 ADD_WEIGHT_ACT_NO = #{addWeightActNo,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where ADD_WEIGHT_ACT_NO = #{addWeightActNo,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="where"/>
    order by  ADD_WEIGHT_ACT_NO desc
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="whereLike"/>
    order by  ADD_WEIGHT_ACT_NO desc
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into METER_WORK_ADD_WEIGHT 
      (ADD_WEIGHT_ACT_NO, 
      ADD_WEIGHT_NO, UTENSIL_NO, UTENSIL_NAME, 
      UTENSIL_WEIGHT, UTENSIL_TYPE_NO, 
      UTENSIL_UTENSIL_NAME, ACTUAL_FIRST_NO, 
      CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME
      )
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.addWeightActNo,jdbcType=VARCHAR}, 
      #{item.addWeightNo,jdbcType=VARCHAR}, #{item.utensilNo,jdbcType=VARCHAR}, #{item.utensilName,jdbcType=VARCHAR}, 
      #{item.utensilWeight,jdbcType=VARCHAR}, #{item.utensilTypeNo,jdbcType=VARCHAR}, 
      #{item.utensilUtensilName,jdbcType=VARCHAR}, #{item.actualFirstNo,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_WORK_ADD_WEIGHT
    set
    ADD_WEIGHT_ACT_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.addWeightActNo,jdbcType=VARCHAR}
    </foreach>
    ,ADD_WEIGHT_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.addWeightNo,jdbcType=VARCHAR}
    </foreach>
    ,UTENSIL_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.utensilNo,jdbcType=VARCHAR}
    </foreach>
    ,UTENSIL_NAME=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.utensilName,jdbcType=VARCHAR}
    </foreach>
    ,UTENSIL_WEIGHT=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.utensilWeight,jdbcType=VARCHAR}
    </foreach>
    ,UTENSIL_TYPE_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.utensilTypeNo,jdbcType=VARCHAR}
    </foreach>
    ,UTENSIL_UTENSIL_NAME=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.utensilUtensilName,jdbcType=VARCHAR}
    </foreach>
    ,ACTUAL_FIRST_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.actualFirstNo,jdbcType=VARCHAR}
    </foreach>
    ,CREATE_MAN_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.createManNo,jdbcType=VARCHAR}
    </foreach>
    ,CREATE_MAN_NAME=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.createManName,jdbcType=VARCHAR}
    </foreach>
    ,CREATE_TIME=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.createTime,jdbcType=TIMESTAMP}
    </foreach>
    where ADD_WEIGHT_ACT_NO in
    <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
      #{item.addWeightActNo,jdbcType=VARCHAR}
    </foreach>
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_WORK_ADD_WEIGHT
    where ADD_WEIGHT_ACT_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(ADD_WEIGHT_ACT_NO,9))),0) + 1,4,'0') ADD_WEIGHT_ACT_NO
    FROM METER_WORK_ADD_WEIGHT where substr(ADD_WEIGHT_ACT_NO,0,8)=to_char(sysdate,'yyyyMMdd')
  </select>

  <update id="batchUpdate123" parameterType="java.util.List">
    update METER_WORK_ADD_WEIGHT
    set
    ADD_WEIGHT_ACT_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.addWeightActNo,jdbcType=VARCHAR}
    </foreach>
    ,ADD_WEIGHT_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.addWeightNo,jdbcType=VARCHAR}
    </foreach>
    ,UTENSIL_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.utensilNo,jdbcType=VARCHAR}
    </foreach>
    ,UTENSIL_NAME=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.utensilName,jdbcType=VARCHAR}
    </foreach>
    ,UTENSIL_WEIGHT=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.utensilWeight,jdbcType=VARCHAR}
    </foreach>
    ,UTENSIL_TYPE_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.utensilTypeNo,jdbcType=VARCHAR}
    </foreach>
    ,UTENSIL_UTENSIL_NAME=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.utensilUtensilName,jdbcType=VARCHAR}
    </foreach>
    ,ACTUAL_FIRST_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.actualFirstNo,jdbcType=VARCHAR}
    </foreach>
    ,CREATE_MAN_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.createManNo,jdbcType=VARCHAR}
    </foreach>
    ,CREATE_MAN_NAME=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.createManName,jdbcType=VARCHAR}
    </foreach>
    ,CREATE_TIME=
    <foreach collection="list" item="item" index="index" separator=" " open="case ADD_WEIGHT_ACT_NO" close="end">
      when #{item.addWeightActNo,jdbcType=VARCHAR} then #{item.createTime,jdbcType=TIMESTAMP}
    </foreach>
    where ADD_WEIGHT_ACT_NO in
    <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
      #{item.addWeightActNo,jdbcType=VARCHAR}
    </foreach>
  </update>
</mapper>