<?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.meterworkbeltxiaopi.mapper.MeterWorkBeltXiaopiMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.meterwork.meterworkbeltxiaopi.model.MeterWorkBeltXiaopi">
    <id column="CHECKBELT_NO" jdbcType="VARCHAR" property="checkbeltNo" />
    <result column="PREDICTION_NO" jdbcType="VARCHAR" property="predictionNo" />
    <result column="PRODUCT_NAME" jdbcType="VARCHAR" property="productName" />
    <result column="PRODUCT_NO" jdbcType="VARCHAR" property="productNo" />
    <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="BASE_SPOT_NO" jdbcType="VARCHAR" property="baseSpotNo" />
    <result column="BASE_SPOT_NAME" jdbcType="VARCHAR" property="baseSpotName" />
    <result column="NEW_ZERO" jdbcType="DECIMAL" property="newZero" />
    <result column="SCALE_NAME" jdbcType="VARCHAR" property="scaleName" />
  </resultMap>
  <sql id="columns">
    CHECKBELT_NO, PREDICTION_NO, PRODUCT_NAME, PRODUCT_NO, CREATE_MAN_NO, CREATE_MAN_NAME,
    CREATE_TIME, BASE_SPOT_NO, BASE_SPOT_NAME, NEW_ZERO, SCALE_NAME
  </sql>
  <sql id="columns_alias">
    t.CHECKBELT_NO, t.PREDICTION_NO, t.PRODUCT_NAME, t.PRODUCT_NO, t.CREATE_MAN_NO, t.CREATE_MAN_NAME,
    t.CREATE_TIME, t.BASE_SPOT_NO, t.BASE_SPOT_NAME, t.NEW_ZERO, t.SCALE_NAME
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM METER_WORK_BELT_XIAOPI
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM METER_WORK_BELT_XIAOPI t
  </sql>
  <sql id="where">
    <where>
      <if test="checkbeltNo != null and checkbeltNo != ''">
        and CHECKBELT_NO = #{checkbeltNo}
      </if>
      <if test="predictionNo != null and predictionNo != ''">
        and PREDICTION_NO = #{predictionNo}
      </if>
      <if test="productName != null and productName != ''">
        and PRODUCT_NAME = #{productName}
      </if>
      <if test="productNo != null and productNo != ''">
        and PRODUCT_NO = #{productNo}
      </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="baseSpotNo != null and baseSpotNo != ''">
        and BASE_SPOT_NO = #{baseSpotNo}
      </if>
      <if test="baseSpotName != null and baseSpotName != ''">
        and BASE_SPOT_NAME = #{baseSpotName}
      </if>
      <if test="newZero != null">
        and NEW_ZERO = #{newZero}
      </if>
      <if test="scaleName != null and scaleName != ''">
        and SCALE_NAME = #{scaleName}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where>
      <if test="checkbeltNo != null and checkbeltNo != ''">
        and CHECKBELT_NO LIKE '%${checkbeltNo}%'
      </if>
      <if test="predictionNo != null and predictionNo != ''">
        and PREDICTION_NO LIKE '%${predictionNo}%'
      </if>
      <if test="productName != null and productName != ''">
        and PRODUCT_NAME LIKE '%${productName}%'
      </if>
      <if test="productNo != null and productNo != ''">
        and PRODUCT_NO LIKE '%${productNo}%'
      </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="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="newZero != null">
        and NEW_ZERO = #{newZero}
      </if>
      <if test="scaleName != null and scaleName != ''">
        and SCALE_NAME LIKE '%${scaleName}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from METER_WORK_BELT_XIAOPI
    where CHECKBELT_NO = #{checkbeltNo,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_WORK_BELT_XIAOPI
    where 1!=1
    <if test="predictionNo != null and predictionNo != ''">
      or PREDICTION_NO = #{predictionNo}
    </if>
    <if test="productName != null and productName != ''">
      or PRODUCT_NAME = #{productName}
    </if>
    <if test="productNo != null and productNo != ''">
      or PRODUCT_NO = #{productNo}
    </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="baseSpotNo != null and baseSpotNo != ''">
      or BASE_SPOT_NO = #{baseSpotNo}
    </if>
    <if test="baseSpotName != null and baseSpotName != ''">
      or BASE_SPOT_NAME = #{baseSpotName}
    </if>
    <if test="newZero != null">
      or NEW_ZERO = #{newZero}
    </if>
    <if test="scaleName != null and scaleName != ''">
      or SCALE_NAME = #{scaleName}
    </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.meterwork.meterworkbeltxiaopi.model.MeterWorkBeltXiaopi">
    insert into METER_WORK_BELT_XIAOPI (CHECKBELT_NO, PREDICTION_NO, PRODUCT_NAME,
      PRODUCT_NO, CREATE_MAN_NO, CREATE_MAN_NAME,
      CREATE_TIME, BASE_SPOT_NO, BASE_SPOT_NAME,
      NEW_ZERO, SCALE_NAME)
    values (#{checkbeltNo,jdbcType=VARCHAR}, #{predictionNo,jdbcType=VARCHAR}, #{productName,jdbcType=VARCHAR},
      #{productNo,jdbcType=VARCHAR}, #{createManNo,jdbcType=VARCHAR}, #{createManName,jdbcType=VARCHAR},
      #{createTime,jdbcType=TIMESTAMP}, #{baseSpotNo,jdbcType=VARCHAR}, #{baseSpotName,jdbcType=VARCHAR},
      #{newZero,jdbcType=DECIMAL}, #{scaleName,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.meterwork.meterworkbeltxiaopi.model.MeterWorkBeltXiaopi">
    insert into METER_WORK_BELT_XIAOPI
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="checkbeltNo != null">
        CHECKBELT_NO,
      </if>
      <if test="predictionNo != null">
        PREDICTION_NO,
      </if>
      <if test="productName != null">
        PRODUCT_NAME,
      </if>
      <if test="productNo != null">
        PRODUCT_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>
      <if test="baseSpotNo != null">
        BASE_SPOT_NO,
      </if>
      <if test="baseSpotName != null">
        BASE_SPOT_NAME,
      </if>
      <if test="newZero != null">
        NEW_ZERO,
      </if>
      <if test="scaleName != null">
        SCALE_NAME,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="checkbeltNo != null">
        #{checkbeltNo,jdbcType=VARCHAR},
      </if>
      <if test="predictionNo != null">
        #{predictionNo,jdbcType=VARCHAR},
      </if>
      <if test="productName != null">
        #{productName,jdbcType=VARCHAR},
      </if>
      <if test="productNo != null">
        #{productNo,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="baseSpotNo != null">
        #{baseSpotNo,jdbcType=VARCHAR},
      </if>
      <if test="baseSpotName != null">
        #{baseSpotName,jdbcType=VARCHAR},
      </if>
      <if test="newZero != null">
        #{newZero,jdbcType=DECIMAL},
      </if>
      <if test="scaleName != null">
        #{scaleName,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.meterwork.meterworkbeltxiaopi.model.MeterWorkBeltXiaopi">
    update METER_WORK_BELT_XIAOPI
    set PREDICTION_NO = #{predictionNo,jdbcType=VARCHAR},
      PRODUCT_NAME = #{productName,jdbcType=VARCHAR},
      PRODUCT_NO = #{productNo,jdbcType=VARCHAR},
      CREATE_MAN_NO = #{createManNo,jdbcType=VARCHAR},
      CREATE_MAN_NAME = #{createManName,jdbcType=VARCHAR},
      CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
      BASE_SPOT_NO = #{baseSpotNo,jdbcType=VARCHAR},
      BASE_SPOT_NAME = #{baseSpotName,jdbcType=VARCHAR},
      NEW_ZERO = #{newZero,jdbcType=DECIMAL},
      SCALE_NAME = #{scaleName,jdbcType=VARCHAR}
    where CHECKBELT_NO = #{checkbeltNo,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.meterwork.meterworkbeltxiaopi.model.MeterWorkBeltXiaopi">
    update METER_WORK_BELT_XIAOPI
    <set>
      <if test="predictionNo != null">
        PREDICTION_NO = #{predictionNo,jdbcType=VARCHAR},
      </if>
      <if test="productName != null">
        PRODUCT_NAME = #{productName,jdbcType=VARCHAR},
      </if>
      <if test="productNo != null">
        PRODUCT_NO = #{productNo,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="baseSpotNo != null">
        BASE_SPOT_NO = #{baseSpotNo,jdbcType=VARCHAR},
      </if>
      <if test="baseSpotName != null">
        BASE_SPOT_NAME = #{baseSpotName,jdbcType=VARCHAR},
      </if>
      <if test="newZero != null">
        NEW_ZERO = #{newZero,jdbcType=DECIMAL},
      </if>
      <if test="scaleName != null">
        SCALE_NAME = #{scaleName,jdbcType=VARCHAR},
      </if>
    </set>
    where CHECKBELT_NO = #{checkbeltNo,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where CHECKBELT_NO = #{checkbeltNo,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_BELT_XIAOPI
    (CHECKBELT_NO,
    PREDICTION_NO, PRODUCT_NAME, PRODUCT_NO,
    CREATE_MAN_NO, CREATE_MAN_NAME, CREATE_TIME,
    BASE_SPOT_NO, BASE_SPOT_NAME, NEW_ZERO,
    SCALE_NAME)
    ( <foreach collection="list" item="item" separator="union all">
    select
    #{item.checkbeltNo,jdbcType=VARCHAR},
    #{item.predictionNo,jdbcType=VARCHAR}, #{item.productName,jdbcType=VARCHAR}, #{item.productNo,jdbcType=VARCHAR},
    #{item.createManNo,jdbcType=VARCHAR}, #{item.createManName,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP},
    #{item.baseSpotNo,jdbcType=VARCHAR}, #{item.baseSpotName,jdbcType=VARCHAR}, #{item.newZero,jdbcType=DECIMAL},
    #{item.scaleName,jdbcType=VARCHAR} from dual
  </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
    update METER_WORK_BELT_XIAOPI
    set
    CHECKBELT_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case CHECKBELT_NO" close="end">
      when #{item.checkbeltNo,jdbcType=VARCHAR} then #{item.checkbeltNo,jdbcType=VARCHAR}
    </foreach>
    ,PREDICTION_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case CHECKBELT_NO" close="end">
      when #{item.checkbeltNo,jdbcType=VARCHAR} then #{item.predictionNo,jdbcType=VARCHAR}
    </foreach>
    ,PRODUCT_NAME=
    <foreach collection="list" item="item" index="index" separator=" " open="case CHECKBELT_NO" close="end">
      when #{item.checkbeltNo,jdbcType=VARCHAR} then #{item.productName,jdbcType=VARCHAR}
    </foreach>
    ,PRODUCT_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case CHECKBELT_NO" close="end">
      when #{item.checkbeltNo,jdbcType=VARCHAR} then #{item.productNo,jdbcType=VARCHAR}
    </foreach>
    ,CREATE_MAN_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case CHECKBELT_NO" close="end">
      when #{item.checkbeltNo,jdbcType=VARCHAR} then #{item.createManNo,jdbcType=VARCHAR}
    </foreach>
    ,CREATE_MAN_NAME=
    <foreach collection="list" item="item" index="index" separator=" " open="case CHECKBELT_NO" close="end">
      when #{item.checkbeltNo,jdbcType=VARCHAR} then #{item.createManName,jdbcType=VARCHAR}
    </foreach>
    ,CREATE_TIME=
    <foreach collection="list" item="item" index="index" separator=" " open="case CHECKBELT_NO" close="end">
      when #{item.checkbeltNo,jdbcType=VARCHAR} then #{item.createTime,jdbcType=TIMESTAMP}
    </foreach>
    ,BASE_SPOT_NO=
    <foreach collection="list" item="item" index="index" separator=" " open="case CHECKBELT_NO" close="end">
      when #{item.checkbeltNo,jdbcType=VARCHAR} then #{item.baseSpotNo,jdbcType=VARCHAR}
    </foreach>
    ,BASE_SPOT_NAME=
    <foreach collection="list" item="item" index="index" separator=" " open="case CHECKBELT_NO" close="end">
      when #{item.checkbeltNo,jdbcType=VARCHAR} then #{item.baseSpotName,jdbcType=VARCHAR}
    </foreach>
    ,NEW_ZERO=
    <foreach collection="list" item="item" index="index" separator=" " open="case CHECKBELT_NO" close="end">
      when #{item.checkbeltNo,jdbcType=VARCHAR} then #{item.newZero,jdbcType=DECIMAL}
    </foreach>
    ,SCALE_NAME=
    <foreach collection="list" item="item" index="index" separator=" " open="case CHECKBELT_NO" close="end">
      when #{item.checkbeltNo,jdbcType=VARCHAR} then #{item.scaleName,jdbcType=VARCHAR}
    </foreach>
    where CHECKBELT_NO in
    <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
      #{item.checkbeltNo,jdbcType=VARCHAR}
    </foreach>
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_WORK_BELT_XIAOPI
    where CHECKBELT_NO in
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->

  <select id="doQueryWf" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    SELECT <include refid="columns"/> from METER_WORK_BELT_XIAOPI
        where 1=1
        <if test="startTime !=null and startTime !=''">
          and CREATE_TIME between TO_DATE(#{startTime},'yyyy-MM-dd HH24:mi:ss') and TO_DATE(#{endTime},'yyyy-MM-dd HH24:mi:ss')
        </if>
        <if test="baseSpotNo != null and baseSpotNo != ''">
          and BASE_SPOT_NO = #{baseSpotNo}
        </if>
        <if test="scaleName != null and scaleName != ''">
          and SCALE_NAME = #{scaleName}
        </if>
        order by CREATE_TIME desc
  </select>

  <select id="doQueryWf_One" parameterType="java.util.HashMap" resultMap="BaseResultMap">
      select  NEW_ZERO  from (SELECT NEW_ZERO from METER_WORK_BELT_XIAOPI
      where 1=1
      <if test="startTime !=null and startTime !=''">
        and CREATE_TIME between TO_DATE(#{startTime},'yyyy-MM-dd HH24:mi:ss') and TO_DATE(#{endTime},'yyyy-MM-dd HH24:mi:ss')
      </if>
      <if test="baseSpotNo != null and baseSpotNo != ''">
        and BASE_SPOT_NO = #{baseSpotNo}
      </if>
      <if test="scaleName != null and scaleName != ''">
        and SCALE_NAME = #{scaleName}
      </if>
      order by CREATE_TIME desc ) where rownum=1
  </select>

</mapper>