<?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.meterworkprewgttype.mapper.MeterWorkPreWgttypeMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.meterwork.meterworkprewgttype.model.MeterWorkPreWgttype">
    <id column="WGT_TYPE_ID" jdbcType="VARCHAR" property="wgtTypeId" />
    <result column="CAR_NO" jdbcType="VARCHAR" property="carNo" />
    <result column="WEIGHT_TYPE_NO" jdbcType="VARCHAR" property="weightTypeNo" />
    <result column="WEIGHT_TYPE_NAME" jdbcType="VARCHAR" property="weightTypeName" />
    <result column="VALUE_FLAG" jdbcType="VARCHAR" property="valueFlag" />
    <result column="CREATE_MAN_NAME" jdbcType="VARCHAR" property="createManName" />
    <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime" />
    <result column="UPDATE_MAN_NAME" jdbcType="VARCHAR" property="updateManName" />
    <result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="CREATE_MAN_PHONE" jdbcType="VARCHAR" property="createManPhone" />
    <result column="UPDATE_MAN_PHONE" jdbcType="VARCHAR" property="updateManPhone" />
    <result column="ACTUAL_FIRST_NO" jdbcType="VARCHAR" property="actualFirstNo" />
    <result column="SUBMIT_FLAG" jdbcType="VARCHAR" property="submitFlag" />
  </resultMap>
  <sql id="columns">
    WGT_TYPE_ID, CAR_NO, WEIGHT_TYPE_NO, WEIGHT_TYPE_NAME, VALUE_FLAG, CREATE_MAN_NAME, 
    CREATE_TIME, UPDATE_MAN_NAME, UPDATE_TIME, CREATE_MAN_PHONE, UPDATE_MAN_PHONE, ACTUAL_FIRST_NO, 
    SUBMIT_FLAG
  </sql>
  <sql id="columns_alias">
    t.WGT_TYPE_ID, t.CAR_NO, t.WEIGHT_TYPE_NO, t.WEIGHT_TYPE_NAME, t.VALUE_FLAG, t.CREATE_MAN_NAME, 
    t.CREATE_TIME, t.UPDATE_MAN_NAME, t.UPDATE_TIME, t.CREATE_MAN_PHONE, t.UPDATE_MAN_PHONE, 
    t.ACTUAL_FIRST_NO, t.SUBMIT_FLAG
  </sql>
  <sql id="select">
    SELECT <include refid="columns" /> FROM METER_WORK_PRE_WGTTYPE
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias" /> FROM METER_WORK_PRE_WGTTYPE t
  </sql>
  <sql id="where">
    <where> 
      <if test="wgtTypeId != null and wgtTypeId != ''">
        and WGT_TYPE_ID = #{wgtTypeId}
      </if>
      <if test="carNo != null and carNo != ''">
        and CAR_NO = #{carNo}
      </if>
      <if test="weightTypeNo != null and weightTypeNo != ''">
        and WEIGHT_TYPE_NO = #{weightTypeNo}
      </if>
      <if test="weightTypeName != null and weightTypeName != ''">
        and WEIGHT_TYPE_NAME = #{weightTypeName}
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        and VALUE_FLAG = #{valueFlag}
      </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="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="createManPhone != null and createManPhone != ''">
        and CREATE_MAN_PHONE = #{createManPhone}
      </if>
      <if test="updateManPhone != null and updateManPhone != ''">
        and UPDATE_MAN_PHONE = #{updateManPhone}
      </if>
      <if test="actualFirstNo != null and actualFirstNo != ''">
        and ACTUAL_FIRST_NO = #{actualFirstNo}
      </if>
      <if test="submitFlag != null and submitFlag != ''">
        and SUBMIT_FLAG = #{submitFlag}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="wgtTypeId != null and wgtTypeId != ''">
        and WGT_TYPE_ID LIKE '%${wgtTypeId}%'
      </if>
      <if test="carNo != null and carNo != ''">
        and CAR_NO LIKE '%${carNo}%'
      </if>
      <if test="weightTypeNo != null and weightTypeNo != ''">
        and WEIGHT_TYPE_NO LIKE '%${weightTypeNo}%'
      </if>
      <if test="weightTypeName != null and weightTypeName != ''">
        and WEIGHT_TYPE_NAME LIKE '%${weightTypeName}%'
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        and VALUE_FLAG LIKE '%${valueFlag}%'
      </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="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="createManPhone != null and createManPhone != ''">
        and CREATE_MAN_PHONE LIKE '%${createManPhone}%'
      </if>
      <if test="updateManPhone != null and updateManPhone != ''">
        and UPDATE_MAN_PHONE LIKE '%${updateManPhone}%'
      </if>
      <if test="actualFirstNo != null and actualFirstNo != ''">
        and ACTUAL_FIRST_NO LIKE '%${actualFirstNo}%'
      </if>
      <if test="submitFlag != null and submitFlag != ''">
        and SUBMIT_FLAG LIKE '%${submitFlag}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from METER_WORK_PRE_WGTTYPE
    where WGT_TYPE_ID = #{wgtTypeId,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_WORK_PRE_WGTTYPE
    where 1!=1 
      <if test="carNo != null and carNo != ''">
        or CAR_NO = #{carNo}
      </if>
      <if test="weightTypeNo != null and weightTypeNo != ''">
        or WEIGHT_TYPE_NO = #{weightTypeNo}
      </if>
      <if test="weightTypeName != null and weightTypeName != ''">
        or WEIGHT_TYPE_NAME = #{weightTypeName}
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        or VALUE_FLAG = #{valueFlag}
      </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="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="createManPhone != null and createManPhone != ''">
        or CREATE_MAN_PHONE = #{createManPhone}
      </if>
      <if test="updateManPhone != null and updateManPhone != ''">
        or UPDATE_MAN_PHONE = #{updateManPhone}
      </if>
      <if test="actualFirstNo != null and actualFirstNo != ''">
        or ACTUAL_FIRST_NO = #{actualFirstNo}
      </if>
      <if test="submitFlag != null and submitFlag != ''">
        or SUBMIT_FLAG = #{submitFlag}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.meterwork.meterworkprewgttype.model.MeterWorkPreWgttype">
    insert into METER_WORK_PRE_WGTTYPE (WGT_TYPE_ID, CAR_NO, WEIGHT_TYPE_NO, 
      WEIGHT_TYPE_NAME, VALUE_FLAG, CREATE_MAN_NAME, 
      CREATE_TIME, UPDATE_MAN_NAME, UPDATE_TIME, 
      CREATE_MAN_PHONE, UPDATE_MAN_PHONE, ACTUAL_FIRST_NO, 
      SUBMIT_FLAG)
    values (#{wgtTypeId,jdbcType=VARCHAR}, #{carNo,jdbcType=VARCHAR}, #{weightTypeNo,jdbcType=VARCHAR}, 
      #{weightTypeName,jdbcType=VARCHAR}, #{valueFlag,jdbcType=VARCHAR}, #{createManName,jdbcType=VARCHAR}, 
      #{createTime,jdbcType=TIMESTAMP}, #{updateManName,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, 
      #{createManPhone,jdbcType=VARCHAR}, #{updateManPhone,jdbcType=VARCHAR}, #{actualFirstNo,jdbcType=VARCHAR}, 
      #{submitFlag,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.meterwork.meterworkprewgttype.model.MeterWorkPreWgttype">
    insert into METER_WORK_PRE_WGTTYPE
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="wgtTypeId != null">
        WGT_TYPE_ID,
      </if>
      <if test="carNo != null">
        CAR_NO,
      </if>
      <if test="weightTypeNo != null">
        WEIGHT_TYPE_NO,
      </if>
      <if test="weightTypeName != null">
        WEIGHT_TYPE_NAME,
      </if>
      <if test="valueFlag != null">
        VALUE_FLAG,
      </if>
      <if test="createManName != null">
        CREATE_MAN_NAME,
      </if>
      <if test="createTime != null">
        CREATE_TIME,
      </if>
      <if test="updateManName != null">
        UPDATE_MAN_NAME,
      </if>
      <if test="updateTime != null">
        UPDATE_TIME,
      </if>
      <if test="createManPhone != null">
        CREATE_MAN_PHONE,
      </if>
      <if test="updateManPhone != null">
        UPDATE_MAN_PHONE,
      </if>
      <if test="actualFirstNo != null">
        ACTUAL_FIRST_NO,
      </if>
      <if test="submitFlag != null">
        SUBMIT_FLAG,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="wgtTypeId != null">
        #{wgtTypeId,jdbcType=VARCHAR},
      </if>
      <if test="carNo != null">
        #{carNo,jdbcType=VARCHAR},
      </if>
      <if test="weightTypeNo != null">
        #{weightTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="weightTypeName != null">
        #{weightTypeName,jdbcType=VARCHAR},
      </if>
      <if test="valueFlag != null">
        #{valueFlag,jdbcType=VARCHAR},
      </if>
      <if test="createManName != null">
        #{createManName,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateManName != null">
        #{updateManName,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createManPhone != null">
        #{createManPhone,jdbcType=VARCHAR},
      </if>
      <if test="updateManPhone != null">
        #{updateManPhone,jdbcType=VARCHAR},
      </if>
      <if test="actualFirstNo != null">
        #{actualFirstNo,jdbcType=VARCHAR},
      </if>
      <if test="submitFlag != null">
        #{submitFlag,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.meterwork.meterworkprewgttype.model.MeterWorkPreWgttype">
    update METER_WORK_PRE_WGTTYPE
    set CAR_NO = #{carNo,jdbcType=VARCHAR},
      WEIGHT_TYPE_NO = #{weightTypeNo,jdbcType=VARCHAR},
      WEIGHT_TYPE_NAME = #{weightTypeName,jdbcType=VARCHAR},
      VALUE_FLAG = #{valueFlag,jdbcType=VARCHAR},
      CREATE_MAN_NAME = #{createManName,jdbcType=VARCHAR},
      CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
      UPDATE_MAN_NAME = #{updateManName,jdbcType=VARCHAR},
      UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
      CREATE_MAN_PHONE = #{createManPhone,jdbcType=VARCHAR},
      UPDATE_MAN_PHONE = #{updateManPhone,jdbcType=VARCHAR},
      ACTUAL_FIRST_NO = #{actualFirstNo,jdbcType=VARCHAR},
      SUBMIT_FLAG = #{submitFlag,jdbcType=VARCHAR}
    where WGT_TYPE_ID = #{wgtTypeId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.meterwork.meterworkprewgttype.model.MeterWorkPreWgttype">
    update METER_WORK_PRE_WGTTYPE
    <set>
      <if test="carNo != null">
        CAR_NO = #{carNo,jdbcType=VARCHAR},
      </if>
      <if test="weightTypeNo != null">
        WEIGHT_TYPE_NO = #{weightTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="weightTypeName != null">
        WEIGHT_TYPE_NAME = #{weightTypeName,jdbcType=VARCHAR},
      </if>
      <if test="valueFlag != null">
        VALUE_FLAG = #{valueFlag,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="updateManName != null">
        UPDATE_MAN_NAME = #{updateManName,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createManPhone != null">
        CREATE_MAN_PHONE = #{createManPhone,jdbcType=VARCHAR},
      </if>
      <if test="updateManPhone != null">
        UPDATE_MAN_PHONE = #{updateManPhone,jdbcType=VARCHAR},
      </if>
      <if test="actualFirstNo != null">
        ACTUAL_FIRST_NO = #{actualFirstNo,jdbcType=VARCHAR},
      </if>
      <if test="submitFlag != null">
        SUBMIT_FLAG = #{submitFlag,jdbcType=VARCHAR},
      </if>
    </set>
    where WGT_TYPE_ID = #{wgtTypeId,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select" />
    where WGT_TYPE_ID = #{wgtTypeId,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_WORK_PRE_WGTTYPE 
      (WGT_TYPE_ID, 
      CAR_NO, WEIGHT_TYPE_NO, WEIGHT_TYPE_NAME, 
      VALUE_FLAG, CREATE_MAN_NAME, CREATE_TIME, 
      UPDATE_MAN_NAME, UPDATE_TIME, 
      CREATE_MAN_PHONE, UPDATE_MAN_PHONE, 
      ACTUAL_FIRST_NO, SUBMIT_FLAG)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.wgtTypeId,jdbcType=VARCHAR}, 
      #{item.carNo,jdbcType=VARCHAR}, #{item.weightTypeNo,jdbcType=VARCHAR}, #{item.weightTypeName,jdbcType=VARCHAR}, 
      #{item.valueFlag,jdbcType=VARCHAR}, #{item.createManName,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, 
      #{item.updateManName,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP}, 
      #{item.createManPhone,jdbcType=VARCHAR}, #{item.updateManPhone,jdbcType=VARCHAR}, 
      #{item.actualFirstNo,jdbcType=VARCHAR}, #{item.submitFlag,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update METER_WORK_PRE_WGTTYPE
     set
       WGT_TYPE_ID=
       <foreach close="end" collection="list" index="index" item="item" open="case WGT_TYPE_ID" separator=" ">
          when #{item.wgtTypeId,jdbcType=VARCHAR} then #{item.wgtTypeId,jdbcType=VARCHAR}
       </foreach>
       ,CAR_NO=
       <foreach close="end" collection="list" index="index" item="item" open="case WGT_TYPE_ID" separator=" ">
          when #{item.wgtTypeId,jdbcType=VARCHAR} then #{item.carNo,jdbcType=VARCHAR}
       </foreach>
       ,WEIGHT_TYPE_NO=
       <foreach close="end" collection="list" index="index" item="item" open="case WGT_TYPE_ID" separator=" ">
          when #{item.wgtTypeId,jdbcType=VARCHAR} then #{item.weightTypeNo,jdbcType=VARCHAR}
       </foreach>
       ,WEIGHT_TYPE_NAME=
       <foreach close="end" collection="list" index="index" item="item" open="case WGT_TYPE_ID" separator=" ">
          when #{item.wgtTypeId,jdbcType=VARCHAR} then #{item.weightTypeName,jdbcType=VARCHAR}
       </foreach>
       ,VALUE_FLAG=
       <foreach close="end" collection="list" index="index" item="item" open="case WGT_TYPE_ID" separator=" ">
          when #{item.wgtTypeId,jdbcType=VARCHAR} then #{item.valueFlag,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_MAN_NAME=
       <foreach close="end" collection="list" index="index" item="item" open="case WGT_TYPE_ID" separator=" ">
          when #{item.wgtTypeId,jdbcType=VARCHAR} then #{item.createManName,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_TIME=
       <foreach close="end" collection="list" index="index" item="item" open="case WGT_TYPE_ID" separator=" ">
          when #{item.wgtTypeId,jdbcType=VARCHAR} then #{item.createTime,jdbcType=TIMESTAMP}
       </foreach>
       ,UPDATE_MAN_NAME=
       <foreach close="end" collection="list" index="index" item="item" open="case WGT_TYPE_ID" separator=" ">
          when #{item.wgtTypeId,jdbcType=VARCHAR} then #{item.updateManName,jdbcType=VARCHAR}
       </foreach>
       ,UPDATE_TIME=
       <foreach close="end" collection="list" index="index" item="item" open="case WGT_TYPE_ID" separator=" ">
          when #{item.wgtTypeId,jdbcType=VARCHAR} then #{item.updateTime,jdbcType=TIMESTAMP}
       </foreach>
       ,CREATE_MAN_PHONE=
       <foreach close="end" collection="list" index="index" item="item" open="case WGT_TYPE_ID" separator=" ">
          when #{item.wgtTypeId,jdbcType=VARCHAR} then #{item.createManPhone,jdbcType=VARCHAR}
       </foreach>
       ,UPDATE_MAN_PHONE=
       <foreach close="end" collection="list" index="index" item="item" open="case WGT_TYPE_ID" separator=" ">
          when #{item.wgtTypeId,jdbcType=VARCHAR} then #{item.updateManPhone,jdbcType=VARCHAR}
       </foreach>
       ,ACTUAL_FIRST_NO=
       <foreach close="end" collection="list" index="index" item="item" open="case WGT_TYPE_ID" separator=" ">
          when #{item.wgtTypeId,jdbcType=VARCHAR} then #{item.actualFirstNo,jdbcType=VARCHAR}
       </foreach>
       ,SUBMIT_FLAG=
       <foreach close="end" collection="list" index="index" item="item" open="case WGT_TYPE_ID" separator=" ">
          when #{item.wgtTypeId,jdbcType=VARCHAR} then #{item.submitFlag,jdbcType=VARCHAR}
       </foreach>
     where WGT_TYPE_ID in 
     <foreach close=")" collection="list" index="index" item="item" open="(" separator=",">
    #{item.wgtTypeId,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_WORK_PRE_WGTTYPE
    where WGT_TYPE_ID in 
    <foreach close=")" collection="list" item="id" open="(" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  <select id="GetNewID" parameterType="java.lang.String" resultType="java.lang.String">
    SELECT LPAD(NVL(MAX(TO_NUMBER(SUBSTR(WGT_TYPE_ID, LENGTH(WGT_TYPE_ID) -3))),0) + 1,4,'0') WGT_TYPE_ID
    FROM METER_WORK_PRE_WGTTYPE
  </select>

  <update id="updatePreWeight" parameterType="java.lang.String">
    update METER_WORK_PRE_WGTTYPE set VALUE_FLAG = '2' where VALUE_FLAG = '1' and CAR_NO = #{CarNo}
  </update>

  <update id="updateSubmitFlag" parameterType="java.lang.String">
    update METER_WORK_PRE_WGTTYPE
        set SUBMIT_FLAG = '1'
    where VALUE_FLAG = '1'
        and CAR_NO = #{CarNo}
  </update>
</mapper>