<?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.ems.emsprodplanroundweight.mapper.EmsProdplanRoundWeightMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.emsprodplanroundweight.model.EmsProdplanRoundWeight">
    <id column="FID" jdbcType="VARCHAR" property="fid" />
    <result column="PRODATE" jdbcType="VARCHAR" property="prodate" />
    <result column="MATERIALCODE" jdbcType="VARCHAR" property="materialcode" />
    <result column="MATERIALNAME" jdbcType="VARCHAR" property="materialname" />
    <result column="QTY" jdbcType="DECIMAL" property="qty" />
    <result column="UNIT" jdbcType="VARCHAR" property="unit" />
    <result column="LC_ID" jdbcType="VARCHAR" property="lcId" />
  </resultMap>
  <sql id="columns">
    FID, PRODATE, MATERIALCODE, MATERIALNAME, QTY, UNIT, LC_ID
  </sql>
  <sql id="columns_alias">
    t.FID, t.PRODATE, t.MATERIALCODE, t.MATERIALNAME, t.QTY, t.UNIT, t.LC_ID
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM EMS_PRODPLAN_ROUND_WEIGHT
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM EMS_PRODPLAN_ROUND_WEIGHT t
  </sql>
  <sql id="where">
    <where> 
      <if test="fid != null and fid != ''">
        and FID = #{fid}
      </if>
      <if test="prodate != null and prodate != ''">
        and PRODATE = #{prodate}
      </if>
      <if test="materialcode != null and materialcode != ''">
        and MATERIALCODE = #{materialcode}
      </if>
      <if test="materialname != null and materialname != ''">
        and MATERIALNAME = #{materialname}
      </if>
      <if test="qty != null">
        and QTY = #{qty}
      </if>
      <if test="unit != null and unit != ''">
        and UNIT = #{unit}
      </if>
      <if test="lcId != null and lcId != ''">
        and LC_ID = #{lcId}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="fid != null and fid != ''">
        and FID LIKE '%${fid}%'
      </if>
      <if test="prodate != null and prodate != ''">
        and PRODATE LIKE '%${prodate}%'
      </if>
      <if test="materialcode != null and materialcode != ''">
        and MATERIALCODE LIKE '%${materialcode}%'
      </if>
      <if test="materialname != null and materialname != ''">
        and MATERIALNAME LIKE '%${materialname}%'
      </if>
      <if test="qty != null">
        and QTY = #{qty}
      </if>
      <if test="unit != null and unit != ''">
        and UNIT LIKE '%${unit}%'
      </if>
      <if test="lcId != null and lcId != ''">
        and LC_ID LIKE '%${lcId}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from EMS_PRODPLAN_ROUND_WEIGHT
    where FID = #{fid,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from EMS_PRODPLAN_ROUND_WEIGHT
    where 1!=1 
      <if test="prodate != null and prodate != ''">
        or PRODATE = #{prodate}
      </if>
      <if test="materialcode != null and materialcode != ''">
        or MATERIALCODE = #{materialcode}
      </if>
      <if test="materialname != null and materialname != ''">
        or MATERIALNAME = #{materialname}
      </if>
      <if test="qty != null">
        or QTY = #{qty}
      </if>
      <if test="unit != null and unit != ''">
        or UNIT = #{unit}
      </if>
      <if test="lcId != null and lcId != ''">
        or LC_ID = #{lcId}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.emsprodplanroundweight.model.EmsProdplanRoundWeight">
    insert into EMS_PRODPLAN_ROUND_WEIGHT (FID, PRODATE, MATERIALCODE, 
      MATERIALNAME, QTY, UNIT, 
      LC_ID)
    values (#{fid,jdbcType=VARCHAR}, #{prodate,jdbcType=VARCHAR}, #{materialcode,jdbcType=VARCHAR}, 
      #{materialname,jdbcType=VARCHAR}, #{qty,jdbcType=DECIMAL}, #{unit,jdbcType=VARCHAR}, 
      #{lcId,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.emsprodplanroundweight.model.EmsProdplanRoundWeight">
    insert into EMS_PRODPLAN_ROUND_WEIGHT
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="fid != null">
        FID,
      </if>
      <if test="prodate != null">
        PRODATE,
      </if>
      <if test="materialcode != null">
        MATERIALCODE,
      </if>
      <if test="materialname != null">
        MATERIALNAME,
      </if>
      <if test="qty != null">
        QTY,
      </if>
      <if test="unit != null">
        UNIT,
      </if>
      <if test="lcId != null">
        LC_ID,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="fid != null">
        #{fid,jdbcType=VARCHAR},
      </if>
      <if test="prodate != null">
        #{prodate,jdbcType=VARCHAR},
      </if>
      <if test="materialcode != null">
        #{materialcode,jdbcType=VARCHAR},
      </if>
      <if test="materialname != null">
        #{materialname,jdbcType=VARCHAR},
      </if>
      <if test="qty != null">
        #{qty,jdbcType=DECIMAL},
      </if>
      <if test="unit != null">
        #{unit,jdbcType=VARCHAR},
      </if>
      <if test="lcId != null">
        #{lcId,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.emsprodplanroundweight.model.EmsProdplanRoundWeight">
    update EMS_PRODPLAN_ROUND_WEIGHT
    set PRODATE = #{prodate,jdbcType=VARCHAR},
      MATERIALCODE = #{materialcode,jdbcType=VARCHAR},
      MATERIALNAME = #{materialname,jdbcType=VARCHAR},
      QTY = #{qty,jdbcType=DECIMAL},
      UNIT = #{unit,jdbcType=VARCHAR},
      LC_ID = #{lcId,jdbcType=VARCHAR}
    where FID = #{fid,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.emsprodplanroundweight.model.EmsProdplanRoundWeight">
    update EMS_PRODPLAN_ROUND_WEIGHT
    <set>
      <if test="prodate != null">
        PRODATE = #{prodate,jdbcType=VARCHAR},
      </if>
      <if test="materialcode != null">
        MATERIALCODE = #{materialcode,jdbcType=VARCHAR},
      </if>
      <if test="materialname != null">
        MATERIALNAME = #{materialname,jdbcType=VARCHAR},
      </if>
      <if test="qty != null">
        QTY = #{qty,jdbcType=DECIMAL},
      </if>
      <if test="unit != null">
        UNIT = #{unit,jdbcType=VARCHAR},
      </if>
      <if test="lcId != null">
        LC_ID = #{lcId,jdbcType=VARCHAR},
      </if>
    </set>
    where FID = #{fid,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where FID = #{fid,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 EMS_PRODPLAN_ROUND_WEIGHT 
      (FID, 
      PRODATE, MATERIALCODE, MATERIALNAME, 
      QTY, UNIT, LC_ID
      )
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.fid,jdbcType=VARCHAR}, 
      #{item.prodate,jdbcType=VARCHAR}, #{item.materialcode,jdbcType=VARCHAR}, #{item.materialname,jdbcType=VARCHAR}, 
      #{item.qty,jdbcType=DECIMAL}, #{item.unit,jdbcType=VARCHAR}, #{item.lcId,jdbcType=VARCHAR}
       from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update EMS_PRODPLAN_ROUND_WEIGHT
     set
       FID=
       <foreach collection="list" item="item" index="index" separator=" " open="case FID" close="end">
          when #{item.fid,jdbcType=VARCHAR} then #{item.fid,jdbcType=VARCHAR}
       </foreach>
       ,PRODATE=
       <foreach collection="list" item="item" index="index" separator=" " open="case FID" close="end">
          when #{item.fid,jdbcType=VARCHAR} then #{item.prodate,jdbcType=VARCHAR}
       </foreach>
       ,MATERIALCODE=
       <foreach collection="list" item="item" index="index" separator=" " open="case FID" close="end">
          when #{item.fid,jdbcType=VARCHAR} then #{item.materialcode,jdbcType=VARCHAR}
       </foreach>
       ,MATERIALNAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case FID" close="end">
          when #{item.fid,jdbcType=VARCHAR} then #{item.materialname,jdbcType=VARCHAR}
       </foreach>
       ,QTY=
       <foreach collection="list" item="item" index="index" separator=" " open="case FID" close="end">
          when #{item.fid,jdbcType=VARCHAR} then #{item.qty,jdbcType=DECIMAL}
       </foreach>
       ,UNIT=
       <foreach collection="list" item="item" index="index" separator=" " open="case FID" close="end">
          when #{item.fid,jdbcType=VARCHAR} then #{item.unit,jdbcType=VARCHAR}
       </foreach>
       ,LC_ID=
       <foreach collection="list" item="item" index="index" separator=" " open="case FID" close="end">
          when #{item.fid,jdbcType=VARCHAR} then #{item.lcId,jdbcType=VARCHAR}
       </foreach>
     where FID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.fid,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from EMS_PRODPLAN_ROUND_WEIGHT
    where FID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  
</mapper>