<?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.meterbaserailwaycarriageweight.mapper.MeterBaseRailwayCarriageWeightMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.baseinfo.meterbaserailwaycarriageweight.model.MeterBaseRailwayCarriageWeight">
    <id column="CARRIAGE_WEIGHT_NO" jdbcType="VARCHAR" property="carriageWeightNo" />
    <result column="CARRIAGE_CODE" jdbcType="VARCHAR" property="carriageCode" />
    <result column="CARRIAGE_WEIGHT" jdbcType="DECIMAL" property="carriageWeight" />
    <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" />
    <result column="CARRIAGE_NAME" jdbcType="VARCHAR" property="carriageName" />
  </resultMap>
  <sql id="columns">
    CARRIAGE_WEIGHT_NO, CARRIAGE_CODE, CARRIAGE_WEIGHT, VALUE_FLAG, CREATE_MAN_NO, CREATE_MAN_NAME,
    CREATE_TIME, UPDATE_MAN_NO, UPDATE_MAN_NAME, UPDATE_TIME, CARRIAGE_NAME
  </sql>
  <sql id="columns_alias">
    t.CARRIAGE_WEIGHT_NO, t.CARRIAGE_CODE, t.CARRIAGE_WEIGHT, 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,
    t.CARRIAGE_NAME
  </sql>
  <sql id="select">
    SELECT <include refid="columns" /> FROM METER_BASE_RAILWAY_CARRIAGE_WEIGHT
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias" /> FROM METER_BASE_RAILWAY_CARRIAGE_WEIGHT t
  </sql>
  <sql id="where">
    <where>
      <if test="carriageWeightNo != null and carriageWeightNo != ''">
        and CARRIAGE_WEIGHT_NO = #{carriageWeightNo}
      </if>
      <if test="carriageCode != null and carriageCode != ''">
        and CARRIAGE_CODE = #{carriageCode}
      </if>
      <if test="carriageWeight != null">
        and CARRIAGE_WEIGHT = #{carriageWeight}
      </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>
      <if test="carriageName != null and carriageName != ''">
        and CARRIAGE_NAME = #{carriageName}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where>
      <if test="carriageWeightNo != null and carriageWeightNo != ''">
        and CARRIAGE_WEIGHT_NO LIKE '%${carriageWeightNo}%'
      </if>
      <if test="carriageCode != null and carriageCode != ''">
        and CARRIAGE_CODE LIKE '%${carriageCode}%'
      </if>
      <if test="carriageWeight != null">
        and CARRIAGE_WEIGHT = #{carriageWeight}
      </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>
      <if test="carriageName != null and carriageName != ''">
        and CARRIAGE_NAME LIKE '%${carriageName}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from METER_BASE_RAILWAY_CARRIAGE_WEIGHT
    where CARRIAGE_WEIGHT_NO = #{carriageWeightNo,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_BASE_RAILWAY_CARRIAGE_WEIGHT
    where 1!=1
    <if test="carriageCode != null and carriageCode != ''">
      or CARRIAGE_CODE = #{carriageCode}
    </if>
    <if test="carriageWeight != null">
      or CARRIAGE_WEIGHT = #{carriageWeight}
    </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>
    <if test="carriageName != null and carriageName != ''">
      or CARRIAGE_NAME = #{carriageName}
    </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.baseinfo.meterbaserailwaycarriageweight.model.MeterBaseRailwayCarriageWeight">
    insert into METER_BASE_RAILWAY_CARRIAGE_WEIGHT (CARRIAGE_WEIGHT_NO, CARRIAGE_CODE, CARRIAGE_WEIGHT,
                                                    VALUE_FLAG, CREATE_MAN_NO, CREATE_MAN_NAME,
                                                    CREATE_TIME, UPDATE_MAN_NO, UPDATE_MAN_NAME,
                                                    UPDATE_TIME, CARRIAGE_NAME)
    values (#{carriageWeightNo,jdbcType=VARCHAR}, #{carriageCode,jdbcType=VARCHAR}, #{carriageWeight,jdbcType=DECIMAL},
            #{valueFlag,jdbcType=VARCHAR}, #{createManNo,jdbcType=VARCHAR}, #{createManName,jdbcType=VARCHAR},
            #{createTime,jdbcType=TIMESTAMP}, #{updateManNo,jdbcType=VARCHAR}, #{updateManName,jdbcType=VARCHAR},
            #{updateTime,jdbcType=TIMESTAMP}, #{carriageName,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.baseinfo.meterbaserailwaycarriageweight.model.MeterBaseRailwayCarriageWeight">
    insert into METER_BASE_RAILWAY_CARRIAGE_WEIGHT
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="carriageWeightNo != null">
        CARRIAGE_WEIGHT_NO,
      </if>
      <if test="carriageCode != null">
        CARRIAGE_CODE,
      </if>
      <if test="carriageWeight != null">
        CARRIAGE_WEIGHT,
      </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>
      <if test="carriageName != null">
        CARRIAGE_NAME,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="carriageWeightNo != null">
        #{carriageWeightNo,jdbcType=VARCHAR},
      </if>
      <if test="carriageCode != null">
        #{carriageCode,jdbcType=VARCHAR},
      </if>
      <if test="carriageWeight != null">
        #{carriageWeight,jdbcType=DECIMAL},
      </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>
      <if test="carriageName != null">
        #{carriageName,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.baseinfo.meterbaserailwaycarriageweight.model.MeterBaseRailwayCarriageWeight">
    update METER_BASE_RAILWAY_CARRIAGE_WEIGHT
    set CARRIAGE_CODE = #{carriageCode,jdbcType=VARCHAR},
        CARRIAGE_WEIGHT = #{carriageWeight,jdbcType=DECIMAL},
        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},
        CARRIAGE_NAME = #{carriageName,jdbcType=VARCHAR}
    where CARRIAGE_WEIGHT_NO = #{carriageWeightNo,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.baseinfo.meterbaserailwaycarriageweight.model.MeterBaseRailwayCarriageWeight">
    update METER_BASE_RAILWAY_CARRIAGE_WEIGHT
    <set>
      <if test="carriageCode != null">
        CARRIAGE_CODE = #{carriageCode,jdbcType=VARCHAR},
      </if>
      <if test="carriageWeight != null">
        CARRIAGE_WEIGHT = #{carriageWeight,jdbcType=DECIMAL},
      </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>
      <if test="carriageName != null">
        CARRIAGE_NAME = #{carriageName,jdbcType=VARCHAR},
      </if>
    </set>
    where CARRIAGE_WEIGHT_NO = #{carriageWeightNo,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select" />
    where CARRIAGE_WEIGHT_NO = #{carriageWeightNo,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_RAILWAY_CARRIAGE_WEIGHT
    (CARRIAGE_WEIGHT_NO,
    CARRIAGE_CODE, CARRIAGE_WEIGHT,
    VALUE_FLAG, CREATE_MAN_NO, CREATE_MAN_NAME,
    CREATE_TIME, UPDATE_MAN_NO, UPDATE_MAN_NAME,
    UPDATE_TIME, CARRIAGE_NAME)
    ( <foreach collection="list" item="item" separator="union all">
    select
    #{item.carriageWeightNo,jdbcType=VARCHAR},
    #{item.carriageCode,jdbcType=VARCHAR}, #{item.carriageWeight,jdbcType=DECIMAL},
    #{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}, #{item.carriageName,jdbcType=VARCHAR} from dual
  </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
    update METER_BASE_RAILWAY_CARRIAGE_WEIGHT
    set
    CARRIAGE_WEIGHT_NO=
    <foreach close="end" collection="list" index="index" item="item" open="case CARRIAGE_WEIGHT_NO" separator=" ">
      when #{item.carriageWeightNo,jdbcType=VARCHAR} then #{item.carriageWeightNo,jdbcType=VARCHAR}
    </foreach>
    ,CARRIAGE_CODE=
    <foreach close="end" collection="list" index="index" item="item" open="case CARRIAGE_WEIGHT_NO" separator=" ">
      when #{item.carriageWeightNo,jdbcType=VARCHAR} then #{item.carriageCode,jdbcType=VARCHAR}
    </foreach>
    ,CARRIAGE_WEIGHT=
    <foreach close="end" collection="list" index="index" item="item" open="case CARRIAGE_WEIGHT_NO" separator=" ">
      when #{item.carriageWeightNo,jdbcType=VARCHAR} then #{item.carriageWeight,jdbcType=DECIMAL}
    </foreach>
    ,VALUE_FLAG=
    <foreach close="end" collection="list" index="index" item="item" open="case CARRIAGE_WEIGHT_NO" separator=" ">
      when #{item.carriageWeightNo,jdbcType=VARCHAR} then #{item.valueFlag,jdbcType=VARCHAR}
    </foreach>
    ,CREATE_MAN_NO=
    <foreach close="end" collection="list" index="index" item="item" open="case CARRIAGE_WEIGHT_NO" separator=" ">
      when #{item.carriageWeightNo,jdbcType=VARCHAR} then #{item.createManNo,jdbcType=VARCHAR}
    </foreach>
    ,CREATE_MAN_NAME=
    <foreach close="end" collection="list" index="index" item="item" open="case CARRIAGE_WEIGHT_NO" separator=" ">
      when #{item.carriageWeightNo,jdbcType=VARCHAR} then #{item.createManName,jdbcType=VARCHAR}
    </foreach>
    ,CREATE_TIME=
    <foreach close="end" collection="list" index="index" item="item" open="case CARRIAGE_WEIGHT_NO" separator=" ">
      when #{item.carriageWeightNo,jdbcType=VARCHAR} then #{item.createTime,jdbcType=TIMESTAMP}
    </foreach>
    ,UPDATE_MAN_NO=
    <foreach close="end" collection="list" index="index" item="item" open="case CARRIAGE_WEIGHT_NO" separator=" ">
      when #{item.carriageWeightNo,jdbcType=VARCHAR} then #{item.updateManNo,jdbcType=VARCHAR}
    </foreach>
    ,UPDATE_MAN_NAME=
    <foreach close="end" collection="list" index="index" item="item" open="case CARRIAGE_WEIGHT_NO" separator=" ">
      when #{item.carriageWeightNo,jdbcType=VARCHAR} then #{item.updateManName,jdbcType=VARCHAR}
    </foreach>
    ,UPDATE_TIME=
    <foreach close="end" collection="list" index="index" item="item" open="case CARRIAGE_WEIGHT_NO" separator=" ">
      when #{item.carriageWeightNo,jdbcType=VARCHAR} then #{item.updateTime,jdbcType=TIMESTAMP}
    </foreach>
    ,CARRIAGE_NAME=
    <foreach close="end" collection="list" index="index" item="item" open="case CARRIAGE_WEIGHT_NO" separator=" ">
      when #{item.carriageWeightNo,jdbcType=VARCHAR} then #{item.carriageName,jdbcType=VARCHAR}
    </foreach>
    where CARRIAGE_WEIGHT_NO in
    <foreach close=")" collection="list" index="index" item="item" open="(" separator=",">
      #{item.carriageWeightNo,jdbcType=VARCHAR}
    </foreach>
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_BASE_RAILWAY_CARRIAGE_WEIGHT
    where CARRIAGE_WEIGHT_NO 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(CARRIAGE_WEIGHT_NO, LENGTH(CARRIAGE_WEIGHT_NO) - 4))),0) + 1,5,'0') CARRIAGE_WEIGHT_NO
    FROM METER_BASE_RAILWAY_CARRIAGE_WEIGHT
  </select>

  <select id="queryByTime" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    SELECT * FROM METER_BASE_RAILWAY_CARRIAGE_WEIGHT
    WHERE 1=1
    <if test="(beginTime != null and beginTime !='') and (endTime != null and endTime !='')">
     and   CREATE_TIME BETWEEN to_date(#{beginTime},'YYYY-MM-DD hh24:mi:ss') and to_date(#{endTime},'YYYY-MM-DD hh24:mi:ss')
    </if>
    <if test="valueFlag != null and valueFlag != ''" >
      and VALUE_FLAG = #{valueFlag}
    </if>
    <if test="carriageCode != null and carriageCode != ''" >
      and CARRIAGE_CODE like '%${carriageCode}%'
    </if>
    <if test="carriageName != null and carriageName != ''" >
      and CARRIAGE_NAME like '%${carriageName}%'
    </if>
    order by CREATE_TIME desc
  </select>
  
</mapper>