<?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.trmworkprocmaterial.mapper.TRmWorkprocMaterialMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.trmworkprocmaterial.model.TRmWorkprocMaterial">
    <id column="ITEMID" jdbcType="VARCHAR" property="itemid" />
    <result column="MATERIALID" jdbcType="VARCHAR" property="materialid" />
    <result column="WORKPROCID" jdbcType="VARCHAR" property="workprocid" />
    <result column="PRIORITY" jdbcType="DECIMAL" property="priority" />
    <result column="USEFLAG" jdbcType="VARCHAR" property="useflag" />
    <result column="SEQNO" jdbcType="VARCHAR" property="seqno" />
    <result column="ITEMTYPE" jdbcType="VARCHAR" property="itemtype" />
    <result column="UNITID" jdbcType="VARCHAR" property="unitid" />
    <result column="DIGITS" jdbcType="DECIMAL" property="digits" />
    <result column="MES_MATERIALCODE" jdbcType="VARCHAR" property="mesMaterialcode" />
    <result column="MES_PRODLINE" jdbcType="VARCHAR" property="mesProdline" />
    <result column="CODE" jdbcType="VARCHAR" property="code" />
    <result column="SHOWNO" jdbcType="DECIMAL" property="showno" />
    <result column="CREATEMAN" jdbcType="VARCHAR" property="createman" />
    <result column="CREATETIME" jdbcType="TIMESTAMP" property="createtime" />
    <result column="UPDATEMAN" jdbcType="VARCHAR" property="updateman" />
    <result column="UPDATETIME" jdbcType="TIMESTAMP" property="updatetime" />
    <result column="ITEMNAME" jdbcType="VARCHAR" property="itemname" />
    <result column="ISFINANCEDATA" jdbcType="VARCHAR" property="isfinancedata" />
  </resultMap>
  <sql id="columns">
    ITEMID, MATERIALID, WORKPROCID, PRIORITY, USEFLAG, SEQNO, ITEMTYPE, UNITID, DIGITS, 
    MES_MATERIALCODE, MES_PRODLINE, CODE, SHOWNO, CREATEMAN, CREATETIME, UPDATEMAN, UPDATETIME, 
    ITEMNAME,ISFINANCEDATA
  </sql>
  <sql id="columns_alias">
    t.ITEMID, t.MATERIALID, t.WORKPROCID, t.PRIORITY, t.USEFLAG, t.SEQNO, t.ITEMTYPE, 
    t.UNITID, t.DIGITS, t.MES_MATERIALCODE, t.MES_PRODLINE, t.CODE, t.SHOWNO, t.CREATEMAN, 
    t.CREATETIME, t.UPDATEMAN, t.UPDATETIME, t.ITEMNAME,t.ISFINANCEDATA
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM T_RM_WORKPROC_MATERIAL
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM T_RM_WORKPROC_MATERIAL t
  </sql>
  <sql id="where">
    <where> 
      <if test="itemid != null and itemid != ''">
        and ITEMID = #{itemid}
      </if>
      <if test="materialid != null and materialid != ''">
        and MATERIALID = #{materialid}
      </if>
      <if test="workprocid != null and workprocid != ''">
        and WORKPROCID = #{workprocid}
      </if>
      <if test="priority != null">
        and PRIORITY = #{priority}
      </if>
      <if test="useflag != null and useflag != ''">
        and USEFLAG = #{useflag}
      </if>
      <if test="seqno != null and seqno != ''">
        and SEQNO = #{seqno}
      </if>
      <if test="itemtype != null and itemtype != ''">
        and ITEMTYPE = #{itemtype}
      </if>
      <if test="unitid != null and unitid != ''">
        and UNITID = #{unitid}
      </if>
      <if test="digits != null">
        and DIGITS = #{digits}
      </if>
      <if test="mesMaterialcode != null and mesMaterialcode != ''">
        and MES_MATERIALCODE = #{mesMaterialcode}
      </if>
      <if test="mesProdline != null and mesProdline != ''">
        and MES_PRODLINE = #{mesProdline}
      </if>
      <if test="code != null and code != ''">
        and CODE = #{code}
      </if>
      <if test="showno != null">
        and SHOWNO = #{showno}
      </if>
      <if test="createman != null and createman != ''">
        and CREATEMAN = #{createman}
      </if>
      <if test="createtime != null">
        and TO_CHAR(CREATETIME,'yyyy-MM-dd') = #{createtime}
      </if>
      <if test="updateman != null and updateman != ''">
        and UPDATEMAN = #{updateman}
      </if>
      <if test="updatetime != null">
        and TO_CHAR(UPDATETIME,'yyyy-MM-dd') = #{updatetime}
      </if>
      <if test="itemname != null and itemname != ''">
        and ITEMNAME = #{itemname}
      </if>
      <if test="isfinancedata != null and isfinancedata != ''">
        and ISFINANCEDATA = #{isfinancedata}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="itemid != null and itemid != ''">
        and ITEMID LIKE '%${itemid}%'
      </if>
      <if test="materialid != null and materialid != ''">
        and MATERIALID LIKE '%${materialid}%'
      </if>
      <if test="workprocid != null and workprocid != ''">
        and WORKPROCID LIKE '%${workprocid}%'
      </if>
      <if test="priority != null">
        and PRIORITY = #{priority}
      </if>
      <if test="useflag != null and useflag != ''">
        and USEFLAG LIKE '%${useflag}%'
      </if>
      <if test="seqno != null and seqno != ''">
        and SEQNO LIKE '%${seqno}%'
      </if>
      <if test="itemtype != null and itemtype != ''">
        and ITEMTYPE LIKE '%${itemtype}%'
      </if>
      <if test="unitid != null and unitid != ''">
        and UNITID LIKE '%${unitid}%'
      </if>
      <if test="digits != null">
        and DIGITS = #{digits}
      </if>
      <if test="mesMaterialcode != null and mesMaterialcode != ''">
        and MES_MATERIALCODE LIKE '%${mesMaterialcode}%'
      </if>
      <if test="mesProdline != null and mesProdline != ''">
        and MES_PRODLINE LIKE '%${mesProdline}%'
      </if>
      <if test="code != null and code != ''">
        and CODE LIKE '%${code}%'
      </if>
      <if test="showno != null">
        and SHOWNO = #{showno}
      </if>
      <if test="createman != null and createman != ''">
        and CREATEMAN LIKE '%${createman}%'
      </if>
      <if test="createtime != null">
        and TO_CHAR(CREATETIME,'yyyy-MM-dd') = #{createtime}
      </if>
      <if test="updateman != null and updateman != ''">
        and UPDATEMAN LIKE '%${updateman}%'
      </if>
      <if test="updatetime != null">
        and TO_CHAR(UPDATETIME,'yyyy-MM-dd') = #{updatetime}
      </if>
      <if test="itemname != null and itemname != ''">
        and ITEMNAME LIKE '%${itemname}%'
      </if>
      <if test="isfinancedata != null and isfinancedata != ''">
        and ISFINANCEDATA LIKE '%${isfinancedata}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_RM_WORKPROC_MATERIAL
    where ITEMID = #{itemid,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_RM_WORKPROC_MATERIAL
    where 1!=1 
      <if test="materialid != null and materialid != ''">
        or MATERIALID = #{materialid}
      </if>
      <if test="workprocid != null and workprocid != ''">
        or WORKPROCID = #{workprocid}
      </if>
      <if test="priority != null">
        or PRIORITY = #{priority}
      </if>
      <if test="useflag != null and useflag != ''">
        or USEFLAG = #{useflag}
      </if>
      <if test="seqno != null and seqno != ''">
        or SEQNO = #{seqno}
      </if>
      <if test="itemtype != null and itemtype != ''">
        or ITEMTYPE = #{itemtype}
      </if>
      <if test="unitid != null and unitid != ''">
        or UNITID = #{unitid}
      </if>
      <if test="digits != null">
        or DIGITS = #{digits}
      </if>
      <if test="mesMaterialcode != null and mesMaterialcode != ''">
        or MES_MATERIALCODE = #{mesMaterialcode}
      </if>
      <if test="mesProdline != null and mesProdline != ''">
        or MES_PRODLINE = #{mesProdline}
      </if>
      <if test="code != null and code != ''">
        or CODE = #{code}
      </if>
      <if test="showno != null">
        or SHOWNO = #{showno}
      </if>
      <if test="createman != null and createman != ''">
        or CREATEMAN = #{createman}
      </if>
      <if test="createtime != null">
        or TO_CHAR(CREATETIME,'yyyy-MM-dd') = '#{createtime}'
      </if>
      <if test="updateman != null and updateman != ''">
        or UPDATEMAN = #{updateman}
      </if>
      <if test="updatetime != null">
        or TO_CHAR(UPDATETIME,'yyyy-MM-dd') = '#{updatetime}'
      </if>
      <if test="itemname != null and itemname != ''">
        or ITEMNAME = #{itemname}
      </if>
      <if test="isfinancedata != null and isfinancedata != ''">
        or ISFINANCEDATA = #{isfinancedata}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.trmworkprocmaterial.model.TRmWorkprocMaterial">
    insert into T_RM_WORKPROC_MATERIAL (ITEMID, MATERIALID, WORKPROCID, 
      PRIORITY, USEFLAG, SEQNO, 
      ITEMTYPE, UNITID, DIGITS, 
      MES_MATERIALCODE, MES_PRODLINE, CODE, 
      SHOWNO, CREATEMAN, CREATETIME, 
      UPDATEMAN, UPDATETIME, ITEMNAME,ISFINANCEDATA
      )
    values (#{itemid,jdbcType=VARCHAR}, #{materialid,jdbcType=VARCHAR}, #{workprocid,jdbcType=VARCHAR}, 
      #{priority,jdbcType=DECIMAL}, #{useflag,jdbcType=VARCHAR}, #{seqno,jdbcType=VARCHAR}, 
      #{itemtype,jdbcType=VARCHAR}, #{unitid,jdbcType=VARCHAR}, #{digits,jdbcType=DECIMAL}, 
      #{mesMaterialcode,jdbcType=VARCHAR}, #{mesProdline,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, 
      #{showno,jdbcType=DECIMAL}, #{createman,jdbcType=VARCHAR}, #{createtime,jdbcType=TIMESTAMP}, 
      #{updateman,jdbcType=VARCHAR}, #{updatetime,jdbcType=TIMESTAMP}, #{itemname,jdbcType=VARCHAR}
      ,#{isfinancedata,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.trmworkprocmaterial.model.TRmWorkprocMaterial">
    insert into T_RM_WORKPROC_MATERIAL
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="itemid != null">
        ITEMID,
      </if>
      <if test="materialid != null">
        MATERIALID,
      </if>
      <if test="workprocid != null">
        WORKPROCID,
      </if>
      <if test="priority != null">
        PRIORITY,
      </if>
      <if test="useflag != null">
        USEFLAG,
      </if>
      <if test="seqno != null">
        SEQNO,
      </if>
      <if test="itemtype != null">
        ITEMTYPE,
      </if>
      <if test="unitid != null">
        UNITID,
      </if>
      <if test="digits != null">
        DIGITS,
      </if>
      <if test="mesMaterialcode != null">
        MES_MATERIALCODE,
      </if>
      <if test="mesProdline != null">
        MES_PRODLINE,
      </if>
      <if test="code != null">
        CODE,
      </if>
      <if test="showno != null">
        SHOWNO,
      </if>
      <if test="createman != null">
        CREATEMAN,
      </if>
      <if test="createtime != null">
        CREATETIME,
      </if>
      <if test="updateman != null">
        UPDATEMAN,
      </if>
      <if test="updatetime != null">
        UPDATETIME,
      </if>
      <if test="itemname != null">
        ITEMNAME,
      </if>
      <if test="isfinancedata != null">
        ISFINANCEDATA,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="itemid != null">
        #{itemid,jdbcType=VARCHAR},
      </if>
      <if test="materialid != null">
        #{materialid,jdbcType=VARCHAR},
      </if>
      <if test="workprocid != null">
        #{workprocid,jdbcType=VARCHAR},
      </if>
      <if test="priority != null">
        #{priority,jdbcType=DECIMAL},
      </if>
      <if test="useflag != null">
        #{useflag,jdbcType=VARCHAR},
      </if>
      <if test="seqno != null">
        #{seqno,jdbcType=VARCHAR},
      </if>
      <if test="itemtype != null">
        #{itemtype,jdbcType=VARCHAR},
      </if>
      <if test="unitid != null">
        #{unitid,jdbcType=VARCHAR},
      </if>
      <if test="digits != null">
        #{digits,jdbcType=DECIMAL},
      </if>
      <if test="mesMaterialcode != null">
        #{mesMaterialcode,jdbcType=VARCHAR},
      </if>
      <if test="mesProdline != null">
        #{mesProdline,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="showno != null">
        #{showno,jdbcType=DECIMAL},
      </if>
      <if test="createman != null">
        #{createman,jdbcType=VARCHAR},
      </if>
      <if test="createtime != null">
        #{createtime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateman != null">
        #{updateman,jdbcType=VARCHAR},
      </if>
      <if test="updatetime != null">
        #{updatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="itemname != null">
        #{itemname,jdbcType=VARCHAR},
      </if>
      <if test="isfinancedata != null">
        #{isfinancedata,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.trmworkprocmaterial.model.TRmWorkprocMaterial">
    update T_RM_WORKPROC_MATERIAL
    set MATERIALID = #{materialid,jdbcType=VARCHAR},
      WORKPROCID = #{workprocid,jdbcType=VARCHAR},
      PRIORITY = #{priority,jdbcType=DECIMAL},
      USEFLAG = #{useflag,jdbcType=VARCHAR},
      SEQNO = #{seqno,jdbcType=VARCHAR},
      ITEMTYPE = #{itemtype,jdbcType=VARCHAR},
      UNITID = #{unitid,jdbcType=VARCHAR},
      DIGITS = #{digits,jdbcType=DECIMAL},
      MES_MATERIALCODE = #{mesMaterialcode,jdbcType=VARCHAR},
      MES_PRODLINE = #{mesProdline,jdbcType=VARCHAR},
      CODE = #{code,jdbcType=VARCHAR},
      SHOWNO = #{showno,jdbcType=DECIMAL},
      CREATEMAN = #{createman,jdbcType=VARCHAR},
      CREATETIME = #{createtime,jdbcType=TIMESTAMP},
      UPDATEMAN = #{updateman,jdbcType=VARCHAR},
      UPDATETIME = #{updatetime,jdbcType=TIMESTAMP},
      ITEMNAME = #{itemname,jdbcType=VARCHAR},
      ISFINANCEDATA = #{isfinancedata,jdbcType=VARCHAR}
    where ITEMID = #{itemid,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.trmworkprocmaterial.model.TRmWorkprocMaterial">
    update T_RM_WORKPROC_MATERIAL
    <set>
      <if test="materialid != null">
        MATERIALID = #{materialid,jdbcType=VARCHAR},
      </if>
      <if test="workprocid != null">
        WORKPROCID = #{workprocid,jdbcType=VARCHAR},
      </if>
      <if test="priority != null">
        PRIORITY = #{priority,jdbcType=DECIMAL},
      </if>
      <if test="useflag != null">
        USEFLAG = #{useflag,jdbcType=VARCHAR},
      </if>
      <if test="seqno != null">
        SEQNO = #{seqno,jdbcType=VARCHAR},
      </if>
      <if test="itemtype != null">
        ITEMTYPE = #{itemtype,jdbcType=VARCHAR},
      </if>
      <if test="unitid != null">
        UNITID = #{unitid,jdbcType=VARCHAR},
      </if>
      <if test="digits != null">
        DIGITS = #{digits,jdbcType=DECIMAL},
      </if>
      <if test="mesMaterialcode != null">
        MES_MATERIALCODE = #{mesMaterialcode,jdbcType=VARCHAR},
      </if>
      <if test="mesProdline != null">
        MES_PRODLINE = #{mesProdline,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        CODE = #{code,jdbcType=VARCHAR},
      </if>
      <if test="showno != null">
        SHOWNO = #{showno,jdbcType=DECIMAL},
      </if>
      <if test="createman != null">
        CREATEMAN = #{createman,jdbcType=VARCHAR},
      </if>
      <if test="createtime != null">
        CREATETIME = #{createtime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateman != null">
        UPDATEMAN = #{updateman,jdbcType=VARCHAR},
      </if>
      <if test="updatetime != null">
        UPDATETIME = #{updatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="itemname != null">
        ITEMNAME = #{itemname,jdbcType=VARCHAR},
      </if>
      <if test="isfinancedata != null">
        ISFINANCEDATA = #{isfinancedata,jdbcType=VARCHAR},
      </if>
    </set>
    where ITEMID = #{itemid,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where ITEMID = #{itemid,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="where"/>
	ORDER BY CODE, SEQNO
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="whereLike"/>
	ORDER BY WORKPROCID ASC, SEQNO ASC,ITEMID ASC
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_RM_WORKPROC_MATERIAL 
      (ITEMID, 
      MATERIALID, WORKPROCID, PRIORITY, 
      USEFLAG, SEQNO, ITEMTYPE, 
      UNITID, DIGITS, MES_MATERIALCODE, 
      MES_PRODLINE, CODE, SHOWNO, 
      CREATEMAN, CREATETIME, UPDATEMAN, 
      UPDATETIME, ITEMNAME,ISFINANCEDATA)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.itemid,jdbcType=VARCHAR}, 
      #{item.materialid,jdbcType=VARCHAR}, #{item.workprocid,jdbcType=VARCHAR}, #{item.priority,jdbcType=DECIMAL}, 
      #{item.useflag,jdbcType=VARCHAR}, #{item.seqno,jdbcType=VARCHAR}, #{item.itemtype,jdbcType=VARCHAR}, 
      #{item.unitid,jdbcType=VARCHAR}, #{item.digits,jdbcType=DECIMAL}, #{item.mesMaterialcode,jdbcType=VARCHAR}, 
      #{item.mesProdline,jdbcType=VARCHAR}, #{item.code,jdbcType=VARCHAR}, #{item.showno,jdbcType=DECIMAL}, 
      #{item.createman,jdbcType=VARCHAR}, #{item.createtime,jdbcType=TIMESTAMP}, #{item.updateman,jdbcType=VARCHAR}, 
      #{item.updatetime,jdbcType=TIMESTAMP}, #{item.itemname,jdbcType=VARCHAR},#{item.isfinancedata,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_RM_WORKPROC_MATERIAL
     set
       ITEMID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.itemid,jdbcType=VARCHAR}
       </foreach>
       ,MATERIALID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.materialid,jdbcType=VARCHAR}
       </foreach>
       ,WORKPROCID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.workprocid,jdbcType=VARCHAR}
       </foreach>
       ,PRIORITY=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.priority,jdbcType=DECIMAL}
       </foreach>
       ,USEFLAG=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.useflag,jdbcType=VARCHAR}
       </foreach>
       ,SEQNO=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.seqno,jdbcType=VARCHAR}
       </foreach>
       ,ITEMTYPE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.itemtype,jdbcType=VARCHAR}
       </foreach>
       ,UNITID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.unitid,jdbcType=VARCHAR}
       </foreach>
       ,DIGITS=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.digits,jdbcType=DECIMAL}
       </foreach>
       ,MES_MATERIALCODE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.mesMaterialcode,jdbcType=VARCHAR}
       </foreach>
       ,MES_PRODLINE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.mesProdline,jdbcType=VARCHAR}
       </foreach>
       ,CODE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.code,jdbcType=VARCHAR}
       </foreach>
       ,SHOWNO=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.showno,jdbcType=DECIMAL}
       </foreach>
       ,CREATEMAN=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.createman,jdbcType=VARCHAR}
       </foreach>
       ,CREATETIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.createtime,jdbcType=TIMESTAMP}
       </foreach>
       ,UPDATEMAN=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.updateman,jdbcType=VARCHAR}
       </foreach>
       ,UPDATETIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.updatetime,jdbcType=TIMESTAMP}
       </foreach>
       ,ITEMNAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.itemname,jdbcType=VARCHAR}
       </foreach>
       ,ISFINANCEDATA=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.isfinancedata,jdbcType=VARCHAR}
       </foreach>
     where ITEMID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.itemid,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from T_RM_WORKPROC_MATERIAL
    where ITEMID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  
  <!--获取关联id-->
    <select id="getitemid" resultType="string">
        SELECT ITEMID FROM T_RM_WORKPROC_MATERIAL
    </select>

    <!--获取ems生产线-->
    <select id="getMes_prodline" parameterType="string" resultType="string">
    SELECT distinct t.mes_prodline from T_RM_WORKPROC_MATERIAL t where t.WORKPROCID=#{workprocid} AND t.mes_prodline IS NOT NULL
    </select>

    <!--获取MES关联的工序原料项目-->
    <select id="getMesItemid" parameterType="java.util.HashMap" resultMap="BaseResultMap">
      select ITEMID, MATERIALID, WORKPROCID, PRIORITY, USEFLAG, SEQNO, ITEMTYPE, UNITID, CODE, DIGITS,MES_MATERIALCODE,MES_PRODLINE
        from T_RM_WORKPROC_MATERIAL
      where ITEMTYPE = #{itemtype,jdbcType=VARCHAR}
        and instr(','||MES_MATERIALCODE||',', ',${mesMaterialcode},')>0
        and instr(','||MES_PRODLINE||',', ',${mesProdline},')>0
    </select>

    <!--获取关联name-->
    <select id="getName" parameterType="string" resultType="string">
        SELECT case when substr(#{itemid},0,6)='ZYG000' then a.NAME||b.NAME||'实绩量' 
        when substr(#{itemid},-1)='R' then a.NAME||b.NAME||'实绩用量' 
        when substr(#{itemid},-1)='P' then a.NAME||b.NAME||'计划用量' end name
        FROM T_RM_WORKPROC a,T_RM_MATERIAL b WHERE a.ID||b.ID=substr(#{itemid},0,length(#{itemid})-1)
    </select>

    <!--获取项目信息-用于每日计算-->
    <select id="getIdAndDigits" resultMap="BaseResultMap">
     SELECT ITEMID,DIGITS,WORKPROCID,CODE,MES_PRODLINE FROM T_RM_WORKPROC_MATERIAL WHERE USEFLAG='1' order by code,seqno
    </select>
</mapper>