<?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.ifemsmesactitem.mapper.IfEmsMesActitemMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.ifemsmesactitem.model.IfEmsMesActitem">
    <id column="ID" jdbcType="BIGINT" property="id" />
    <result column="STATE" jdbcType="VARCHAR" property="state" />
    <result column="WORKPROCID" jdbcType="VARCHAR" property="workprocid" />
    <result column="WORKPROCID_NAME" jdbcType="VARCHAR" property="workprocidName" />
    <result column="TIMEGRANID" jdbcType="VARCHAR" property="timegranid" />
    <result column="CLOCK" jdbcType="VARCHAR" property="clock" />
    <result column="ENERGYID" jdbcType="VARCHAR" property="energyid" />
    <result column="ENERGYID_NAME" jdbcType="VARCHAR" property="energyidName" />
    <result column="PROPERTYID" jdbcType="VARCHAR" property="propertyid" />
    <result column="PROPERTYID_NAME" jdbcType="VARCHAR" property="propertyidName" />
    <result column="UNITID" jdbcType="VARCHAR" property="unitid" />
    <result column="UNITID_NAME" jdbcType="VARCHAR" property="unitidName" />
    <result column="ITEMID" jdbcType="VARCHAR" property="itemid" />
    <result column="ITEMNAME" jdbcType="VARCHAR" property="itemname" />
    <result column="ITEMDESC" jdbcType="VARCHAR" property="itemdesc" />
    <result column="APPORTVALUE" jdbcType="DECIMAL" property="apportvalue" />
    <result column="OPERATOR_MAN" jdbcType="VARCHAR" property="operatorMan" />
    <result column="OPERATOR_DATE" jdbcType="TIMESTAMP" property="operatorDate" />
    <result column="MEMO" jdbcType="VARCHAR" property="memo" />
    <result column="LINE" jdbcType="VARCHAR" property="line" />
    <result column="FORMULA" jdbcType="VARCHAR" property="formula" />
    <result column="FORMULADESCRIPTION" jdbcType="VARCHAR" property="formuladescription" />
    <result column="RECMAN" jdbcType="VARCHAR" property="recman" />
    <result column="RECTIME" jdbcType="TIMESTAMP" property="rectime" />
  </resultMap>

  <select id="getId" resultType="java.lang.Long">
    select SEQ_IF_EMS_MES_ACTITEM_ID.Nextval from dual
  </select>

  <insert id="insert" parameterType="com.steerinfo.ems.ifemsmesactitem.model.IfEmsMesActitem">
    insert into IF_EMS_MES_ACTITEM (ID, STATE, WORKPROCID,
      WORKPROCID_NAME, TIMEGRANID, CLOCK,
      ENERGYID, ENERGYID_NAME, PROPERTYID,
      PROPERTYID_NAME, UNITID, UNITID_NAME,
      ITEMID, ITEMNAME, ITEMDESC, APPORTVALUE,
      OPERATOR_MAN, OPERATOR_DATE, MEMO, LINE, FORMULA, FORMULADESCRIPTION
      )
    values (#{id,jdbcType=BIGINT}, #{state,jdbcType=VARCHAR}, #{workprocid,jdbcType=VARCHAR},
      #{workprocidName,jdbcType=VARCHAR}, #{timegranid,jdbcType=VARCHAR}, #{clock,jdbcType=VARCHAR},
      #{energyid,jdbcType=VARCHAR}, #{energyidName,jdbcType=VARCHAR}, #{propertyid,jdbcType=VARCHAR},
      #{propertyidName,jdbcType=VARCHAR}, #{unitid,jdbcType=VARCHAR}, #{unitidName,jdbcType=VARCHAR},
      #{itemid,jdbcType=VARCHAR}, #{itemname,jdbcType=VARCHAR}, #{itemdesc,jdbcType=VARCHAR}, #{apportvalue,jdbcType=DECIMAL},
      #{operatorMan,jdbcType=VARCHAR}, #{operatorDate,jdbcType=TIMESTAMP}, #{memo,jdbcType=VARCHAR}, #{line,jdbcType=VARCHAR},
      #{formula,jdbcType=VARCHAR}, #{formuladescription,jdbcType=VARCHAR}
      )
  </insert>

  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    SELECT ID, STATE, WORKPROCID, WORKPROCID_NAME, TIMEGRANID, CLOCK, ENERGYID, ENERGYID_NAME, PROPERTYID, PROPERTYID_NAME,
    UNITID, UNITID_NAME, ITEMID, ITEMNAME, ITEMDESC, APPORTVALUE, OPERATOR_MAN, OPERATOR_DATE, MEMO, FORMULA, FORMULADESCRIPTION, RECMAN, RECTIME
    from IF_EMS_MES_ACTITEM
    where 1 = 1
      <if test="state != null and state != ''">
        ${state}
      </if>
      <if test="workprocid != null and workprocid != ''">
        ${workprocid}
      </if>
      <if test="workprocidName != null and workprocidName != ''">
        and WORKPROCID_NAME = #{workprocidName}
      </if>
      <if test="condition != null and condition != ''">
        ${condition}
      </if>
      <if test="energyid != null and energyid != ''">
        ${energyid}
      </if>
      <if test="energyidName != null and energyidName != ''">
        and ENERGYID_NAME = #{energyidName}
      </if>
      <if test="propertyidName != null and propertyidName != ''">
        and PROPERTYID_NAME = #{propertyidName}
      </if>
      <if test="unitid != null and unitid != ''">
        ${unitid}
      </if>
      <if test="unitidName != null and unitidName != ''">
        and UNITID_NAME = #{unitidName}
      </if>
      <if test="itemid != null and itemid != ''">
        ${itemid}
      </if>
      <if test="propertyid != null and propertyid != ''">
        ${propertyid}
      </if>
      <if test="itemname != null and itemname != ''">
        ${itemname}
      </if>
      <if test="itemdesc != null and itemdesc != ''">
        ${itemdesc}
      </if>
      <if test="operatorMan != null and operatorMan != ''">
        and OPERATOR_MAN = #{operatorMan}
      </if>
      <if test="operatorDate != null">
        and TO_CHAR(OPERATOR_DATE,'yyyy-MM-dd') = #{operatorDate}
      </if>
      <if test="memo != null and memo != ''">
        and MEMO = #{memo}
      </if>
    ORDER BY WORKPROCID, CLOCK, TIMEGRANID, decode(PROPERTYID_NAME, '使用量', 1, '放散量', 2, '损耗量', 3, '发生量', 4, '回收量', 5)
  </select>

  <update id="updateUKey" parameterType="com.steerinfo.ems.ifemsmesactitem.model.IfEmsMesActitem">
    update IF_EMS_MES_ACTITEM
    <set>
      <if test="state != null">
        STATE = #{state,jdbcType=VARCHAR},
      </if>
      <if test="workprocid != null">
        WORKPROCID = #{workprocid,jdbcType=VARCHAR},
      </if>
      <if test="workprocidName != null">
        WORKPROCID_NAME = #{workprocidName,jdbcType=VARCHAR},
      </if>
      <if test="energyid != null">
        ENERGYID = #{energyid,jdbcType=VARCHAR},
      </if>
      <if test="energyidName != null">
        ENERGYID_NAME = #{energyidName,jdbcType=VARCHAR},
      </if>
      <if test="propertyid != null">
        PROPERTYID = #{propertyid,jdbcType=VARCHAR},
      </if>
      <if test="propertyidName != null">
        PROPERTYID_NAME = #{propertyidName,jdbcType=VARCHAR},
      </if>
      <if test="unitid != null">
        UNITID = #{unitid,jdbcType=VARCHAR},
      </if>
      <if test="unitidName != null">
        UNITID_NAME = #{unitidName,jdbcType=VARCHAR},
      </if>
      <if test="itemname != null">
        ITEMNAME = #{itemname,jdbcType=VARCHAR},
      </if>
      <if test="itemdesc != null">
        ITEMDESC = #{itemdesc,jdbcType=VARCHAR},
      </if>
      <if test="apportvalue != null">
        APPORTVALUE = #{apportvalue,jdbcType=DECIMAL},
      </if>
      <if test="operatorMan != null">
        OPERATOR_MAN = #{operatorMan,jdbcType=VARCHAR},
      </if>
      <if test="operatorDate != null">
        OPERATOR_DATE = #{operatorDate,jdbcType=TIMESTAMP},
      </if>
      <if test="memo != null">
        MEMO = #{memo,jdbcType=VARCHAR},
      </if>
      <if test="line != null">
        LINE = #{line,jdbcType=VARCHAR},
      </if>
      <if test="formula != null">
        FORMULA = #{formula,jdbcType=VARCHAR},
      </if>
      <if test="formuladescription != null">
        FORMULADESCRIPTION = #{formuladescription,jdbcType=VARCHAR},
      </if>
    </set>
    where CLOCK = #{clock,jdbcType=VARCHAR}
    and TIMEGRANID = #{timegranid,jdbcType=VARCHAR}
    and ITEMID = #{itemid,jdbcType=VARCHAR}
  </update>

  <select id="getDataByUKey" parameterType="com.steerinfo.ems.ifemsmesactitem.model.IfEmsMesActitem" resultMap="BaseResultMap">
    SELECT ID, STATE, WORKPROCID, WORKPROCID_NAME, TIMEGRANID, CLOCK, ENERGYID, ENERGYID_NAME, PROPERTYID, PROPERTYID_NAME,
        UNITID, UNITID_NAME, ITEMID, ITEMNAME, ITEMDESC, APPORTVALUE, OPERATOR_MAN, OPERATOR_DATE, MEMO, FORMULA, FORMULADESCRIPTION, RECMAN, RECTIME
    from IF_EMS_MES_ACTITEM
    where CLOCK = #{clock,jdbcType=VARCHAR}
    and TIMEGRANID = #{timegranid,jdbcType=VARCHAR}
    and ITEMID = #{itemid,jdbcType=VARCHAR}
  </select>

  <select id="getDatatoMes" parameterType="com.steerinfo.ems.ifemsmesactitem.model.IfEmsMesActitem" resultMap="BaseResultMap">
    SELECT ID, STATE, WORKPROCID, WORKPROCID_NAME, TIMEGRANID, CLOCK, ENERGYID, ENERGYID_NAME, PROPERTYID, PROPERTYID_NAME,
        UNITID, UNITID_NAME, ITEMID, ITEMNAME, ITEMDESC, APPORTVALUE, OPERATOR_MAN, OPERATOR_DATE, MEMO, FORMULA, FORMULADESCRIPTION, RECMAN, RECTIME
    from IF_EMS_MES_ACTITEM
    where STATE = '1'
    and ROWNUM &lt;= 500
  </select>

  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.ifemsmesactitem.model.IfEmsMesActitem">
    update IF_EMS_MES_ACTITEM
    <set>
      <if test="state != null">
        STATE = #{state,jdbcType=VARCHAR},
      </if>
      <if test="memo != null">
        MEMO = #{memo,jdbcType=VARCHAR},
      </if>
      <if test="operatorMan != null">
        OPERATOR_MAN = #{operatorMan,jdbcType=VARCHAR},
      </if>
      <if test="operatorDate != null">
        OPERATOR_DATE = #{operatorDate,jdbcType=VARCHAR},
      </if>
      <if test="recman != null">
        RECMAN = #{recman,jdbcType=VARCHAR},
      </if>
      <if test="rectime != null">
        RECTIME = #{rectime,jdbcType=VARCHAR},
      </if>
    </set>
    where ID = #{id,jdbcType=BIGINT}
  </update>

  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select ID, STATE, WORKPROCID, WORKPROCID_NAME, TIMEGRANID, CLOCK, ENERGYID, ENERGYID_NAME,
    PROPERTYID, PROPERTYID_NAME, UNITID, UNITID_NAME, ITEMID, ITEMNAME, ITEMDESC, APPORTVALUE,
    OPERATOR_MAN, OPERATOR_DATE, MEMO, FORMULA, FORMULADESCRIPTION, RECMAN, RECTIME
    from IF_EMS_MES_ACTITEM
    where ID = #{id,jdbcType=BIGINT}
  </select>

  <!-- 参数表查询 -->
  <select id="selectParam" parameterType="java.util.HashMap" resultType="java.util.Map">
    select PARAM_KEY, PARAM_VALUE, KEY_COMMENT
    from T_PARAMS
    where PARAM_KEY = #{paramkey,jdbcType=VARCHAR}
  </select>
  <!-- 参数表新增 -->
  <insert id="insertParam" parameterType="java.util.HashMap">
    insert into T_PARAMS values (#{paramkey,jdbcType=VARCHAR},#{paramvalue,jdbcType=VARCHAR},#{keyconmment,jdbcType=VARCHAR})
  </insert>
  <!-- 参数表修改 -->
  <update id="updateParam" parameterType="java.util.HashMap">
    update T_PARAMS set PARAM_VALUE = #{paramvalue,jdbcType=VARCHAR}
    <if test="keyconmment != null">
      KEY_COMMENT = #{keyconmment,jdbcType=VARCHAR}
    </if>
    where PARAM_KEY = #{paramkey,jdbcType=VARCHAR}
  </update>

    <select id="getindex" resultMap="BaseResultMap">
        SELECT t.id, to_char(t2.APPORTVALUE / t.APPORTVALUE, 'fm99999990.00') AS MEMO
            FROM
	        IF_EMS_MES_ACTITEM t,
	        IF_EMS_MES_ACTITEM t2
        WHERE t.TIMEGRANID = t2.TIMEGRANID
	        AND t.CLOCK = t2.CLOCK
	        AND t.WORKPROCID = t2.WORKPROCID
	        AND t.WORKPROCID IN ( 'ZYA100','ZYA200' )
	        AND t.ENERGYID = 'P001'
	        AND t2.ENERGYID = 'E001'
	        AND t.APPORTVALUE > 0
	        AND t.STATE = '0'
	        AND ( t.MEMO is NULL OR t.MEMO = '' )
    </select>

  <!--
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.ifemsmesactitem.model.IfEmsMesActitem">
    update IF_EMS_MES_ACTITEM
    <set>
      <if test="state != null">
        STATE = #{state,jdbcType=VARCHAR},
      </if>
      <if test="workprocid != null">
        WORKPROCID = #{workprocid,jdbcType=VARCHAR},
      </if>
      <if test="workprocidName != null">
        WORKPROCID_NAME = #{workprocidName,jdbcType=VARCHAR},
      </if>
      <if test="timegranid != null">
        TIMEGRANID = #{timegranid,jdbcType=VARCHAR},
      </if>
      <if test="clock != null">
        CLOCK = #{clock,jdbcType=VARCHAR},
      </if>
      <if test="energyid != null">
        ENERGYID = #{energyid,jdbcType=VARCHAR},
      </if>
      <if test="energyidName != null">
        ENERGYID_NAME = #{energyidName,jdbcType=VARCHAR},
      </if>
      <if test="propertyid != null">
        PROPERTYID = #{propertyid,jdbcType=VARCHAR},
      </if>
      <if test="propertyidName != null">
        PROPERTYID_NAME = #{propertyidName,jdbcType=VARCHAR},
      </if>
      <if test="unitid != null">
        UNITID = #{unitid,jdbcType=VARCHAR},
      </if>
      <if test="unitidName != null">
        UNITID_NAME = #{unitidName,jdbcType=VARCHAR},
      </if>
      <if test="itemid != null">
        ITEMID = #{itemid,jdbcType=VARCHAR},
      </if>
      <if test="itemname != null">
        ITEMNAME = #{itemname,jdbcType=VARCHAR},
      </if>
      <if test="apportvalue != null">
        APPORTVALUE = #{apportvalue,jdbcType=DECIMAL},
      </if>
      <if test="operatorMan != null">
        OPERATOR_MAN = #{operatorMan,jdbcType=VARCHAR},
      </if>
      <if test="operatorDate != null">
        OPERATOR_DATE = #{operatorDate,jdbcType=TIMESTAMP},
      </if>
      <if test="memo != null">
        MEMO = #{memo,jdbcType=VARCHAR},
      </if>
      <if test="line != null">
        LINE = #{line,jdbcType=VARCHAR},
      </if>
    </set>
    where ID = #{id,jdbcType=BIGINT}
  </update>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    SELECT
    ID,
    STATE,
    WORKPROCID,
    WORKPROCID_NAME,
    TIMEGRANID,
    CLOCK,
    ENERGYID,
    ENERGYID_NAME,
    PROPERTYID,
    PROPERTYID_NAME,
    UNITID,
    UNITID_NAME,
    ITEMID,
    ITEMNAME,
    APPORTVALUE,
    OPERATOR_MAN,
    OPERATOR_DATE,
    MEMO
    from IF_EMS_MES_ACTITEM
    <where>
      <if test="state != null and state != ''">
        and STATE = #{state}
      </if>
      <if test="workprocid != null and workprocid != ''">
        and WORKPROCID in (${workprocid})
      </if>
      <if test="workprocidName != null and workprocidName != ''">
        and WORKPROCID_NAME = #{workprocidName}
      </if>
      <if test="timegranid != null and timegranid != ''">
        and TIMEGRANID = #{timegranid}
      </if>
      <if test="clock != null and clock != ''">
        and CLOCK = #{clock}
      </if>
      <if test="energyid != null and energyid != ''">
        and ENERGYID = #{energyid}
      </if>
      <if test="energyidName != null and energyidName != ''">
        and ENERGYID_NAME = #{energyidName}
      </if>
      <if test="propertyidName != null and propertyidName != ''">
        and PROPERTYID_NAME = #{propertyidName}
      </if>
      <if test="unitid != null and unitid != ''">
        and UNITID in (${unitid})
      </if>
      <if test="unitidName != null and unitidName != ''">
        and UNITID_NAME = #{unitidName}
      </if>
      <if test="itemid != null and itemid != ''">
        ${itemid}
      </if>
      <if test="propertyid != null and propertyid != ''">
        and PROPERTYID in (${propertyid})
      </if>
      <if test="itemname != null and itemname != ''">
        ${itemname}
      </if>
      <if test="operatorMan != null and operatorMan != ''">
        and OPERATOR_MAN = #{operatorMan}
      </if>
      <if test="operatorDate != null">
        and TO_CHAR(OPERATOR_DATE,'yyyy-MM-dd') = #{operatorDate}
      </if>
      <if test="memo != null and memo != ''">
        and MEMO = #{memo}
      </if>
    </where>
    ORDER BY CLOCK, WORKPROCID, TIMEGRANID, decode(PROPERTYID_NAME, '使用量', 1, '放散量', 2, '损耗量', 3, '发生量', 4, '回收量', 5)
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from IF_EMS_MES_ACTITEM
    where ID = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from IF_EMS_MES_ACTITEM
    where 1!=1 
      <if test="state != null and state != ''">
        and STATE = #{state}
      </if>
      <if test="workprocid != null and workprocid != ''">
        and WORKPROCID = #{workprocid}
      </if>
      <if test="workprocidName != null and workprocidName != ''">
        and WORKPROCID_NAME = #{workprocidName}
      </if>
      <if test="timegranid != null and timegranid != ''">
        and TIMEGRANID = #{timegranid}
      </if>
      <if test="clock != null and clock != ''">
        and CLOCK = #{clock}
      </if>
      <if test="energyid != null and energyid != ''">
        and ENERGYID = #{energyid}
      </if>
      <if test="energyidName != null and energyidName != ''">
        and ENERGYID_NAME = #{energyidName}
      </if>
      <if test="propertyid != null and propertyid != ''">
        and PROPERTYID = #{propertyid}
      </if>
      <if test="propertyidName != null and propertyidName != ''">
        and PROPERTYID_NAME = #{propertyidName}
      </if>
      <if test="unitid != null and unitid != ''">
        and UNITID = #{unitid}
      </if>
      <if test="unitidName != null and unitidName != ''">
        and UNITID_NAME = #{unitidName}
      </if>
      <if test="itemid != null and itemid != ''">
        and ITEMID = #{itemid}
      </if>
      <if test="itemname != null and itemname != ''">
        and ITEMNAME = #{itemname}
      </if>
      <if test="apportvalue != null">
        and APPORTVALUE = #{apportvalue}
      </if>
      <if test="operatorMan != null and operatorMan != ''">
        and OPERATOR_MAN = #{operatorMan}
      </if>
      <if test="operatorDate != null">
        and TO_CHAR(OPERATOR_DATE,'yyyy-MM-dd') = '#{operatorDate}'
      </if>
      <if test="memo != null and memo != ''">
        and MEMO = #{memo}
      </if>
  </delete>

  <insert id="insertSelective" parameterType="com.steerinfo.ems.ifemsmesactitem.model.IfEmsMesActitem">
    insert into IF_EMS_MES_ACTITEM
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="state != null">
        STATE,
      </if>
      <if test="workprocid != null">
        WORKPROCID,
      </if>
      <if test="workprocidName != null">
        WORKPROCID_NAME,
      </if>
      <if test="timegranid != null">
        TIMEGRANID,
      </if>
      <if test="clock != null">
        CLOCK,
      </if>
      <if test="energyid != null">
        ENERGYID,
      </if>
      <if test="energyidName != null">
        ENERGYID_NAME,
      </if>
      <if test="propertyid != null">
        PROPERTYID,
      </if>
      <if test="propertyidName != null">
        PROPERTYID_NAME,
      </if>
      <if test="unitid != null">
        UNITID,
      </if>
      <if test="unitidName != null">
        UNITID_NAME,
      </if>
      <if test="itemid != null">
        ITEMID,
      </if>
      <if test="itemname != null">
        ITEMNAME,
      </if>
      <if test="apportvalue != null">
        APPORTVALUE,
      </if>
      <if test="operatorMan != null">
        OPERATOR_MAN,
      </if>
      <if test="operatorDate != null">
        OPERATOR_DATE,
      </if>
      <if test="memo != null">
        MEMO,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="state != null">
        #{state,jdbcType=VARCHAR},
      </if>
      <if test="workprocid != null">
        #{workprocid,jdbcType=VARCHAR},
      </if>
      <if test="workprocidName != null">
        #{workprocidName,jdbcType=VARCHAR},
      </if>
      <if test="timegranid != null">
        #{timegranid,jdbcType=VARCHAR},
      </if>
      <if test="clock != null">
        #{clock,jdbcType=VARCHAR},
      </if>
      <if test="energyid != null">
        #{energyid,jdbcType=VARCHAR},
      </if>
      <if test="energyidName != null">
        #{energyidName,jdbcType=VARCHAR},
      </if>
      <if test="propertyid != null">
        #{propertyid,jdbcType=VARCHAR},
      </if>
      <if test="propertyidName != null">
        #{propertyidName,jdbcType=VARCHAR},
      </if>
      <if test="unitid != null">
        #{unitid,jdbcType=VARCHAR},
      </if>
      <if test="unitidName != null">
        #{unitidName,jdbcType=VARCHAR},
      </if>
      <if test="itemid != null">
        #{itemid,jdbcType=VARCHAR},
      </if>
      <if test="itemname != null">
        #{itemname,jdbcType=VARCHAR},
      </if>
      <if test="apportvalue != null">
        #{apportvalue,jdbcType=DECIMAL},
      </if>
      <if test="operatorMan != null">
        #{operatorMan,jdbcType=VARCHAR},
      </if>
      <if test="operatorDate != null">
        #{operatorDate,jdbcType=TIMESTAMP},
      </if>
      <if test="memo != null">
        #{memo,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.ifemsmesactitem.model.IfEmsMesActitem">
    update IF_EMS_MES_ACTITEM
    set STATE = #{state,jdbcType=VARCHAR},
      WORKPROCID = #{workprocid,jdbcType=VARCHAR},
      WORKPROCID_NAME = #{workprocidName,jdbcType=VARCHAR},
      TIMEGRANID = #{timegranid,jdbcType=VARCHAR},
      CLOCK = #{clock,jdbcType=VARCHAR},
      ENERGYID = #{energyid,jdbcType=VARCHAR},
      ENERGYID_NAME = #{energyidName,jdbcType=VARCHAR},
      PROPERTYID = #{propertyid,jdbcType=VARCHAR},
      PROPERTYID_NAME = #{propertyidName,jdbcType=VARCHAR},
      UNITID = #{unitid,jdbcType=VARCHAR},
      UNITID_NAME = #{unitidName,jdbcType=VARCHAR},
      ITEMID = #{itemid,jdbcType=VARCHAR},
      ITEMNAME = #{itemname,jdbcType=VARCHAR},
      APPORTVALUE = #{apportvalue,jdbcType=DECIMAL},
      OPERATOR_MAN = #{operatorMan,jdbcType=VARCHAR},
      OPERATOR_DATE = #{operatorDate,jdbcType=TIMESTAMP},
      MEMO = #{memo,jdbcType=VARCHAR}
    where ID = #{id,jdbcType=BIGINT}
  </update>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select ID, STATE, WORKPROCID, WORKPROCID_NAME, TIMEGRANID, CLOCK, ENERGYID, ENERGYID_NAME, 
    PROPERTYID, PROPERTYID_NAME, UNITID, UNITID_NAME, ITEMID, ITEMNAME, APPORTVALUE, 
    OPERATOR_MAN, OPERATOR_DATE, MEMO
    from IF_EMS_MES_ACTITEM
    <where> 
      <if test="state != null and state != ''">
        and STATE LIKE '%${state}%'
      </if>
      <if test="workprocid != null and workprocid != ''">
        and WORKPROCID LIKE '%${workprocid}%'
      </if>
      <if test="workprocidName != null and workprocidName != ''">
        and WORKPROCID_NAME LIKE '%${workprocidName}%'
      </if>
      <if test="timegranid != null and timegranid != ''">
        and TIMEGRANID LIKE '%${timegranid}%'
      </if>
      <if test="clock != null and clock != ''">
        and CLOCK LIKE '%${clock}%'
      </if>
      <if test="energyid != null and energyid != ''">
        and ENERGYID LIKE '%${energyid}%'
      </if>
      <if test="energyidName != null and energyidName != ''">
        and ENERGYID_NAME LIKE '%${energyidName}%'
      </if>
      <if test="propertyid != null and propertyid != ''">
        and PROPERTYID LIKE '%${propertyid}%'
      </if>
      <if test="propertyidName != null and propertyidName != ''">
        and PROPERTYID_NAME LIKE '%${propertyidName}%'
      </if>
      <if test="unitid != null and unitid != ''">
        and UNITID LIKE '%${unitid}%'
      </if>
      <if test="unitidName != null and unitidName != ''">
        and UNITID_NAME LIKE '%${unitidName}%'
      </if>
      <if test="itemid != null and itemid != ''">
        and ITEMID LIKE '%${itemid}%'
      </if>
      <if test="itemname != null and itemname != ''">
        and ITEMNAME LIKE '%${itemname}%'
      </if>
      <if test="apportvalue != null">
        and APPORTVALUE = #{apportvalue}
      </if>
      <if test="operatorMan != null and operatorMan != ''">
        and OPERATOR_MAN LIKE '%${operatorMan}%'
      </if>
      <if test="operatorDate != null">
        and TO_CHAR(OPERATOR_DATE,'yyyy-MM-dd') = #{operatorDate}
      </if>
      <if test="memo != null and memo != ''">
        and MEMO LIKE '%${memo}%'
      </if>
    </where>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into IF_EMS_MES_ACTITEM 
      (ID, 
      STATE, WORKPROCID, WORKPROCID_NAME, 
      TIMEGRANID, CLOCK, ENERGYID, 
      ENERGYID_NAME, PROPERTYID, PROPERTYID_NAME, 
      UNITID, UNITID_NAME, ITEMID, 
      ITEMNAME, APPORTVALUE, OPERATOR_MAN, 
      OPERATOR_DATE, MEMO)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.id,jdbcType=BIGINT},
      #{item.state,jdbcType=VARCHAR}, #{item.workprocid,jdbcType=VARCHAR}, #{item.workprocidName,jdbcType=VARCHAR}, 
      #{item.timegranid,jdbcType=VARCHAR}, #{item.clock,jdbcType=VARCHAR}, #{item.energyid,jdbcType=VARCHAR}, 
      #{item.energyidName,jdbcType=VARCHAR}, #{item.propertyid,jdbcType=VARCHAR}, #{item.propertyidName,jdbcType=VARCHAR}, 
      #{item.unitid,jdbcType=VARCHAR}, #{item.unitidName,jdbcType=VARCHAR}, #{item.itemid,jdbcType=VARCHAR}, 
      #{item.itemname,jdbcType=VARCHAR}, #{item.apportvalue,jdbcType=DECIMAL}, #{item.operatorMan,jdbcType=VARCHAR}, 
      #{item.operatorDate,jdbcType=TIMESTAMP}, #{item.memo,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update IF_EMS_MES_ACTITEM
     set
       ID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.id,jdbcType=BIGINT}
       </foreach>
       ,STATE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.state,jdbcType=VARCHAR}
       </foreach>
       ,WORKPROCID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.workprocid,jdbcType=VARCHAR}
       </foreach>
       ,WORKPROCID_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.workprocidName,jdbcType=VARCHAR}
       </foreach>
       ,TIMEGRANID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.timegranid,jdbcType=VARCHAR}
       </foreach>
       ,CLOCK=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.clock,jdbcType=VARCHAR}
       </foreach>
       ,ENERGYID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.energyid,jdbcType=VARCHAR}
       </foreach>
       ,ENERGYID_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.energyidName,jdbcType=VARCHAR}
       </foreach>
       ,PROPERTYID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.propertyid,jdbcType=VARCHAR}
       </foreach>
       ,PROPERTYID_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.propertyidName,jdbcType=VARCHAR}
       </foreach>
       ,UNITID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.unitid,jdbcType=VARCHAR}
       </foreach>
       ,UNITID_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.unitidName,jdbcType=VARCHAR}
       </foreach>
       ,ITEMID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.itemid,jdbcType=VARCHAR}
       </foreach>
       ,ITEMNAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.itemname,jdbcType=VARCHAR}
       </foreach>
       ,APPORTVALUE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.apportvalue,jdbcType=DECIMAL}
       </foreach>
       ,OPERATOR_MAN=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.operatorMan,jdbcType=VARCHAR}
       </foreach>
       ,OPERATOR_DATE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.operatorDate,jdbcType=TIMESTAMP}
       </foreach>
       ,MEMO=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=BIGINT} then #{item.memo,jdbcType=VARCHAR}
       </foreach>
     where ID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.id,jdbcType=BIGINT}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from IF_EMS_MES_ACTITEM
    where ID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  -->
</mapper>