<?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.trmindexitem.mapper.TRmIndexItemMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.trmindexitem.model.TRmIndexItem">
    <id column="ITEMID" jdbcType="VARCHAR" property="itemid" />
    <result column="ITEMNAME" jdbcType="VARCHAR" property="itemname" />
    <result column="ITEMDESC" jdbcType="VARCHAR" property="itemdesc" />
    <result column="ITEMTYPE" jdbcType="VARCHAR" property="itemtype" />
    <result column="INDEXTYPE" jdbcType="VARCHAR" property="indextype" />
    <result column="TYPE1" jdbcType="VARCHAR" property="type1" />
    <result column="TYPE2" jdbcType="VARCHAR" property="type2" />
    <result column="TYPE3" jdbcType="VARCHAR" property="type3" />
    <result column="TYPE4" jdbcType="VARCHAR" property="type4" />
    <result column="ENERGYID" jdbcType="VARCHAR" property="energyid" />
    <result column="WORKPROCID" jdbcType="VARCHAR" property="workprocid" />
    <result column="FACTORYID" jdbcType="VARCHAR" property="factoryid" />
    <result column="USEFLAG" jdbcType="VARCHAR" property="useflag" />
    <result column="UNITID" jdbcType="VARCHAR" property="unitid" />
    <result column="DIGITS" jdbcType="DECIMAL" property="digits" />
    <result column="SEQNO" jdbcType="DECIMAL" property="seqno" />
    <result column="PARENTID" jdbcType="VARCHAR" property="parentid" />
    <result column="ITEMFLAG" jdbcType="VARCHAR" property="itemflag" />
    <result column="BZ" jdbcType="VARCHAR" property="bz" />
    <result column="MINTIMEGRANID" jdbcType="VARCHAR" property="mintimegranid" />
    <result column="WARNVALUE" jdbcType="DECIMAL" property="warnvalue" />
    <result column="PROPERTYID" jdbcType="VARCHAR" property="propertyid" />
    <result column="CREATEMAN" jdbcType="VARCHAR" property="createman" />
    <result column="CREATETIME" jdbcType="VARCHAR" property="createtime" />
    <result column="UPDATEMAN" jdbcType="VARCHAR" property="updateman" />
    <result column="UPDATETIME" jdbcType="VARCHAR" property="updatetime" />
    <result column="CODE" jdbcType="DECIMAL" property="code" />
    <result column="FLUVALUE" jdbcType="DECIMAL" property="fluvalue" />
    <result column="FLUITEMID" jdbcType="VARCHAR" property="fluitemid" />
  </resultMap>
  <sql id="columns">
    ITEMID, ITEMNAME, ITEMDESC, ITEMTYPE, INDEXTYPE, TYPE1, TYPE2, TYPE3, TYPE4, ENERGYID, 
    WORKPROCID, FACTORYID, USEFLAG, UNITID, DIGITS, SEQNO, PARENTID, ITEMFLAG, BZ, MINTIMEGRANID, 
    WARNVALUE, PROPERTYID, CREATEMAN, CREATETIME, UPDATEMAN, UPDATETIME, CODE, FLUVALUE, 
    FLUITEMID
  </sql>
  <sql id="columns_alias">
    t.ITEMID, t.ITEMNAME, t.ITEMDESC, t.ITEMTYPE, t.INDEXTYPE, t.TYPE1, t.TYPE2, t.TYPE3, 
    t.TYPE4, t.ENERGYID, t.WORKPROCID, t.FACTORYID, t.USEFLAG, t.UNITID, t.DIGITS, t.SEQNO, 
    t.PARENTID, t.ITEMFLAG, t.BZ, t.MINTIMEGRANID, t.WARNVALUE, t.PROPERTYID, t.CREATEMAN, 
    t.CREATETIME, t.UPDATEMAN, t.UPDATETIME, t.CODE, t.FLUVALUE, t.FLUITEMID
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM T_RM_INDEX_ITEM t
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM T_RM_INDEX_ITEM t
  </sql>
  <sql id="where">
    <where> 
      <if test="itemid != null and itemid != ''">
        and ITEMID = #{itemid}
      </if>
      <if test="itemname != null and itemname != ''">
        and ITEMNAME = #{itemname}
      </if>
      <if test="itemdesc != null and itemdesc != ''">
        and ITEMDESC = #{itemdesc}
      </if>
      <if test="itemtype != null and itemtype != ''">
        and ITEMTYPE = #{itemtype}
      </if>
      <if test="indextype != null and indextype != ''">
        and INDEXTYPE = #{indextype}
      </if>
      <if test="type1 != null and type1 != ''">
        and TYPE1 = #{type1}
      </if>
      <if test="type2 != null and type2 != ''">
        and TYPE2 = #{type2}
      </if>
      <if test="type3 != null and type3 != ''">
        and TYPE3 = #{type3}
      </if>
      <if test="type4 != null and type4 != ''">
        and TYPE4 = #{type4}
      </if>
      <if test="energyid != null and energyid != ''">
        and ENERGYID = #{energyid}
      </if>
      <if test="workprocid != null and workprocid != ''">
        and WORKPROCID = #{workprocid}
      </if>
      <if test="factoryid != null and factoryid != ''">
        and FACTORYID = #{factoryid}
      </if>
      <if test="useflag != null and useflag != ''">
        and USEFLAG = #{useflag}
      </if>
      <if test="unitid != null and unitid != ''">
        and UNITID = #{unitid}
      </if>
      <if test="digits != null">
        and DIGITS = #{digits}
      </if>
      <if test="seqno != null">
        and SEQNO = #{seqno}
      </if>
      <if test="parentid != null and parentid != ''">
        and PARENTID = #{parentid}
      </if>
      <if test="itemflag != null and itemflag != ''">
        and ITEMFLAG = #{itemflag}
      </if>
      <if test="bz != null and bz != ''">
        and BZ = #{bz}
      </if>
      <if test="mintimegranid != null and mintimegranid != ''">
        and MINTIMEGRANID = #{mintimegranid}
      </if>
      <if test="warnvalue != null">
        and WARNVALUE = #{warnvalue}
      </if>
      <if test="propertyid != null and propertyid != ''">
        and PROPERTYID = #{propertyid}
      </if>
      <if test="createman != null and createman != ''">
        and CREATEMAN = #{createman}
      </if>
      <if test="createtime != null and createtime != ''">
        and CREATETIME = #{createtime}
      </if>
      <if test="updateman != null and updateman != ''">
        and UPDATEMAN = #{updateman}
      </if>
      <if test="updatetime != null and updatetime != ''">
        and UPDATETIME = #{updatetime}
      </if>
      <if test="code != null">
        and CODE = #{code}
      </if>
      <if test="fluvalue != null">
        and FLUVALUE = #{fluvalue}
      </if>
      <if test="fluitemid != null and fluitemid != ''">
        and FLUITEMID = #{fluitemid}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="itemid != null and itemid != ''">
        and t.ITEMID LIKE '%${itemid}%'
      </if>
      <if test="itemname != null and itemname != ''">
        and t.ITEMNAME LIKE '%${itemname}%'
      </if>
      <if test="itemdesc != null and itemdesc != ''">
        and t.ITEMDESC LIKE '%${itemdesc}%'
      </if>
      <if test="itemtype != null and itemtype != ''">
        and t.ITEMTYPE in (${itemtype})
      </if>
      <if test="indextype != null and indextype != ''">
        and t.INDEXTYPE LIKE '%${indextype}%'
      </if>
      <if test="type1 != null and type1 != ''">
        and t.TYPE1 LIKE '%${type1}%'
      </if>
      <if test="type2 != null and type2 != ''">
        and t.TYPE2 LIKE '%${type2}%'
      </if>
      <if test="type3 != null and type3 != ''">
        and t.TYPE3 LIKE '%${type3}%'
      </if>
      <if test="type4 != null and type4 != ''">
        and t.TYPE4 LIKE '%${type4}%'
      </if>
      <if test="energyid != null and energyid != ''">
        and t.ENERGYID in (${energyid})
      </if>
      <if test="workprocid != null and workprocid != ''">
        and t.WORKPROCID in (${workprocid})
      </if>
      <if test="factoryid != null and factoryid != ''">
        and t.FACTORYID LIKE '%${factoryid}%'
      </if>
      <if test="useflag != null and useflag != ''">
        and t.USEFLAG LIKE '%${useflag}%'
      </if>
      <if test="unitid != null and unitid != ''">
        and t.UNITID LIKE '%${unitid}%'
      </if>
      <if test="digits != null">
        and t.DIGITS = #{digits}
      </if>
      <if test="seqno != null">
        and t.SEQNO = #{seqno}
      </if>
      <if test="parentid != null and parentid != ''">
        and t.PARENTID LIKE '%${parentid}%'
      </if>
      <if test="itemflag != null and itemflag != ''">
        and t.ITEMFLAG LIKE '%${itemflag}%'
      </if>
      <if test="bz != null and bz != ''">
        and t.BZ LIKE '%${bz}%'
      </if>
      <if test="mintimegranid != null and mintimegranid != ''">
        and t.MINTIMEGRANID LIKE '%${mintimegranid}%'
      </if>
      <if test="warnvalue != null">
        and t.WARNVALUE = #{warnvalue}
      </if>
      <if test="itemid != null and itemid != ''">
        and t.ITEMID LIKE '%${itemid}%'
      </if>
      <if test="propertyid != null and propertyid != ''">
        and t.PROPERTYID in (${propertyid})
      </if>
      <if test="code != null">
        and CODE = #{code}
      </if>
      <if test="fluvalue != null">
        and FLUVALUE = #{fluvalue}
      </if>
      <if test="fluitemid != null and fluitemid != ''">
        and FLUITEMID LIKE '%${fluitemid}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_RM_INDEX_ITEM
    where ITEMID = #{itemid,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_RM_INDEX_ITEM
    where 1!=1 
      <if test="itemname != null and itemname != ''">
        or ITEMNAME = #{itemname}
      </if>
      <if test="itemdesc != null and itemdesc != ''">
        or ITEMDESC = #{itemdesc}
      </if>
      <if test="itemtype != null and itemtype != ''">
        or ITEMTYPE = #{itemtype}
      </if>
      <if test="indextype != null and indextype != ''">
        or INDEXTYPE = #{indextype}
      </if>
      <if test="type1 != null and type1 != ''">
        or TYPE1 = #{type1}
      </if>
      <if test="type2 != null and type2 != ''">
        or TYPE2 = #{type2}
      </if>
      <if test="type3 != null and type3 != ''">
        or TYPE3 = #{type3}
      </if>
      <if test="type4 != null and type4 != ''">
        or TYPE4 = #{type4}
      </if>
      <if test="energyid != null and energyid != ''">
        or ENERGYID = #{energyid}
      </if>
      <if test="workprocid != null and workprocid != ''">
        or WORKPROCID = #{workprocid}
      </if>
      <if test="factoryid != null and factoryid != ''">
        or FACTORYID = #{factoryid}
      </if>
      <if test="useflag != null and useflag != ''">
        or USEFLAG = #{useflag}
      </if>
      <if test="unitid != null and unitid != ''">
        or UNITID = #{unitid}
      </if>
      <if test="digits != null">
        or DIGITS = #{digits}
      </if>
      <if test="seqno != null">
        or SEQNO = #{seqno}
      </if>
      <if test="parentid != null and parentid != ''">
        or PARENTID = #{parentid}
      </if>
      <if test="itemflag != null and itemflag != ''">
        or ITEMFLAG = #{itemflag}
      </if>
      <if test="bz != null and bz != ''">
        or BZ = #{bz}
      </if>
      <if test="mintimegranid != null and mintimegranid != ''">
        or MINTIMEGRANID = #{mintimegranid}
      </if>
      <if test="warnvalue != null">
        or WARNVALUE = #{warnvalue}
      </if>
      <if test="propertyid != null and propertyid != ''">
        or PROPERTYID = #{propertyid}
      </if>
      <if test="createman != null and createman != ''">
        or CREATEMAN = #{createman}
      </if>
      <if test="createtime != null and createtime != ''">
        or CREATETIME = #{createtime}
      </if>
      <if test="updateman != null and updateman != ''">
        or UPDATEMAN = #{updateman}
      </if>
      <if test="updatetime != null and updatetime != ''">
        or UPDATETIME = #{updatetime}
      </if>
      <if test="code != null">
        or CODE = #{code}
      </if>
      <if test="fluvalue != null">
        or FLUVALUE = #{fluvalue}
      </if>
      <if test="fluitemid != null and fluitemid != ''">
        or FLUITEMID = #{fluitemid}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.trmindexitem.model.TRmIndexItem">
    insert into T_RM_INDEX_ITEM (ITEMID, ITEMNAME, ITEMDESC, 
      ITEMTYPE, INDEXTYPE, TYPE1, 
      TYPE2, TYPE3, TYPE4, 
      ENERGYID, WORKPROCID, FACTORYID, 
      USEFLAG, UNITID, DIGITS, 
      SEQNO, PARENTID, ITEMFLAG, 
      BZ, MINTIMEGRANID, WARNVALUE, 
      PROPERTYID, CREATEMAN, CREATETIME, 
      UPDATEMAN, UPDATETIME, CODE, 
      FLUVALUE, FLUITEMID)
    values (#{itemid,jdbcType=VARCHAR}, #{itemname,jdbcType=VARCHAR}, #{itemdesc,jdbcType=VARCHAR}, 
      #{itemtype,jdbcType=VARCHAR}, #{indextype,jdbcType=VARCHAR}, #{type1,jdbcType=VARCHAR}, 
      #{type2,jdbcType=VARCHAR}, #{type3,jdbcType=VARCHAR}, #{type4,jdbcType=VARCHAR}, 
      #{energyid,jdbcType=VARCHAR}, #{workprocid,jdbcType=VARCHAR}, #{factoryid,jdbcType=VARCHAR}, 
      #{useflag,jdbcType=VARCHAR}, #{unitid,jdbcType=VARCHAR}, #{digits,jdbcType=DECIMAL}, 
      #{seqno,jdbcType=DECIMAL}, #{parentid,jdbcType=VARCHAR}, #{itemflag,jdbcType=VARCHAR}, 
      #{bz,jdbcType=VARCHAR}, #{mintimegranid,jdbcType=VARCHAR}, #{warnvalue,jdbcType=DECIMAL}, 
      #{propertyid,jdbcType=VARCHAR}, #{createman,jdbcType=VARCHAR}, #{createtime,jdbcType=VARCHAR}, 
      #{updateman,jdbcType=VARCHAR}, #{updatetime,jdbcType=VARCHAR}, #{code,jdbcType=DECIMAL}, 
      #{fluvalue,jdbcType=DECIMAL}, #{fluitemid,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.trmindexitem.model.TRmIndexItem">
    insert into T_RM_INDEX_ITEM
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="itemid != null">
        ITEMID,
      </if>
      <if test="itemname != null">
        ITEMNAME,
      </if>
      <if test="itemdesc != null">
        ITEMDESC,
      </if>
      <if test="itemtype != null">
        ITEMTYPE,
      </if>
      <if test="indextype != null">
        INDEXTYPE,
      </if>
      <if test="type1 != null">
        TYPE1,
      </if>
      <if test="type2 != null">
        TYPE2,
      </if>
      <if test="type3 != null">
        TYPE3,
      </if>
      <if test="type4 != null">
        TYPE4,
      </if>
      <if test="energyid != null">
        ENERGYID,
      </if>
      <if test="workprocid != null">
        WORKPROCID,
      </if>
      <if test="factoryid != null">
        FACTORYID,
      </if>
      <if test="useflag != null">
        USEFLAG,
      </if>
      <if test="unitid != null">
        UNITID,
      </if>
      <if test="digits != null">
        DIGITS,
      </if>
      <if test="seqno != null">
        SEQNO,
      </if>
      <if test="parentid != null">
        PARENTID,
      </if>
      <if test="itemflag != null">
        ITEMFLAG,
      </if>
      <if test="bz != null">
        BZ,
      </if>
      <if test="mintimegranid != null">
        MINTIMEGRANID,
      </if>
      <if test="warnvalue != null">
        WARNVALUE,
      </if>
      <if test="propertyid != null">
        PROPERTYID,
      </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="code != null">
        CODE,
      </if>
      <if test="fluvalue != null">
        FLUVALUE,
      </if>
      <if test="fluitemid != null">
        FLUITEMID,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="itemid != null">
        #{itemid,jdbcType=VARCHAR},
      </if>
      <if test="itemname != null">
        #{itemname,jdbcType=VARCHAR},
      </if>
      <if test="itemdesc != null">
        #{itemdesc,jdbcType=VARCHAR},
      </if>
      <if test="itemtype != null">
        #{itemtype,jdbcType=VARCHAR},
      </if>
      <if test="indextype != null">
        #{indextype,jdbcType=VARCHAR},
      </if>
      <if test="type1 != null">
        #{type1,jdbcType=VARCHAR},
      </if>
      <if test="type2 != null">
        #{type2,jdbcType=VARCHAR},
      </if>
      <if test="type3 != null">
        #{type3,jdbcType=VARCHAR},
      </if>
      <if test="type4 != null">
        #{type4,jdbcType=VARCHAR},
      </if>
      <if test="energyid != null">
        #{energyid,jdbcType=VARCHAR},
      </if>
      <if test="workprocid != null">
        #{workprocid,jdbcType=VARCHAR},
      </if>
      <if test="factoryid != null">
        #{factoryid,jdbcType=VARCHAR},
      </if>
      <if test="useflag != null">
        #{useflag,jdbcType=VARCHAR},
      </if>
      <if test="unitid != null">
        #{unitid,jdbcType=VARCHAR},
      </if>
      <if test="digits != null">
        #{digits,jdbcType=DECIMAL},
      </if>
      <if test="seqno != null">
        #{seqno,jdbcType=DECIMAL},
      </if>
      <if test="parentid != null">
        #{parentid,jdbcType=VARCHAR},
      </if>
      <if test="itemflag != null">
        #{itemflag,jdbcType=VARCHAR},
      </if>
      <if test="bz != null">
        #{bz,jdbcType=VARCHAR},
      </if>
      <if test="mintimegranid != null">
        #{mintimegranid,jdbcType=VARCHAR},
      </if>
      <if test="warnvalue != null">
        #{warnvalue,jdbcType=DECIMAL},
      </if>
      <if test="propertyid != null">
        #{propertyid,jdbcType=VARCHAR},
      </if>
      <if test="createman != null">
        #{createman,jdbcType=VARCHAR},
      </if>
      <if test="createtime != null">
        #{createtime,jdbcType=VARCHAR},
      </if>
      <if test="updateman != null">
        #{updateman,jdbcType=VARCHAR},
      </if>
      <if test="updatetime != null">
        #{updatetime,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        #{code,jdbcType=DECIMAL},
      </if>
      <if test="fluvalue != null">
        #{fluvalue,jdbcType=DECIMAL},
      </if>
      <if test="fluitemid != null">
        #{fluitemid,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.trmindexitem.model.TRmIndexItem">
    update T_RM_INDEX_ITEM
    set ITEMNAME = #{itemname,jdbcType=VARCHAR},
      ITEMDESC = #{itemdesc,jdbcType=VARCHAR},
      ITEMTYPE = #{itemtype,jdbcType=VARCHAR},
      INDEXTYPE = #{indextype,jdbcType=VARCHAR},
      TYPE1 = #{type1,jdbcType=VARCHAR},
      TYPE2 = #{type2,jdbcType=VARCHAR},
      TYPE3 = #{type3,jdbcType=VARCHAR},
      TYPE4 = #{type4,jdbcType=VARCHAR},
      ENERGYID = #{energyid,jdbcType=VARCHAR},
      WORKPROCID = #{workprocid,jdbcType=VARCHAR},
      FACTORYID = #{factoryid,jdbcType=VARCHAR},
      USEFLAG = #{useflag,jdbcType=VARCHAR},
      UNITID = #{unitid,jdbcType=VARCHAR},
      DIGITS = #{digits,jdbcType=DECIMAL},
      SEQNO = #{seqno,jdbcType=DECIMAL},
      PARENTID = #{parentid,jdbcType=VARCHAR},
      ITEMFLAG = #{itemflag,jdbcType=VARCHAR},
      BZ = #{bz,jdbcType=VARCHAR},
      MINTIMEGRANID = #{mintimegranid,jdbcType=VARCHAR},
      WARNVALUE = #{warnvalue,jdbcType=DECIMAL},
      PROPERTYID = #{propertyid,jdbcType=VARCHAR},
      CREATEMAN = #{createman,jdbcType=VARCHAR},
      CREATETIME = #{createtime,jdbcType=VARCHAR},
      UPDATEMAN = #{updateman,jdbcType=VARCHAR},
      UPDATETIME = #{updatetime,jdbcType=VARCHAR},
      CODE = #{code,jdbcType=DECIMAL},
      FLUVALUE = #{fluvalue,jdbcType=DECIMAL},
      FLUITEMID = #{fluitemid,jdbcType=VARCHAR}
    where ITEMID = #{itemid,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.trmindexitem.model.TRmIndexItem">
    update T_RM_INDEX_ITEM
    <set>
      <if test="itemname != null">
        ITEMNAME = #{itemname,jdbcType=VARCHAR},
      </if>
      <if test="itemdesc != null">
        ITEMDESC = #{itemdesc,jdbcType=VARCHAR},
      </if>
      <if test="itemtype != null">
        ITEMTYPE = #{itemtype,jdbcType=VARCHAR},
      </if>
      <if test="indextype != null">
        INDEXTYPE = #{indextype,jdbcType=VARCHAR},
      </if>
      <if test="type1 != null">
        TYPE1 = #{type1,jdbcType=VARCHAR},
      </if>
      <if test="type2 != null">
        TYPE2 = #{type2,jdbcType=VARCHAR},
      </if>
      <if test="type3 != null">
        TYPE3 = #{type3,jdbcType=VARCHAR},
      </if>
      <if test="type4 != null">
        TYPE4 = #{type4,jdbcType=VARCHAR},
      </if>
      <if test="energyid != null">
        ENERGYID = #{energyid,jdbcType=VARCHAR},
      </if>
      <if test="workprocid != null">
        WORKPROCID = #{workprocid,jdbcType=VARCHAR},
      </if>
      <if test="factoryid != null">
        FACTORYID = #{factoryid,jdbcType=VARCHAR},
      </if>
      <if test="useflag != null">
        USEFLAG = #{useflag,jdbcType=VARCHAR},
      </if>
      <if test="unitid != null">
        UNITID = #{unitid,jdbcType=VARCHAR},
      </if>
      <if test="digits != null">
        DIGITS = #{digits,jdbcType=DECIMAL},
      </if>
      <if test="seqno != null">
        SEQNO = #{seqno,jdbcType=DECIMAL},
      </if>
      <if test="parentid != null">
        PARENTID = #{parentid,jdbcType=VARCHAR},
      </if>
      <if test="itemflag != null">
        ITEMFLAG = #{itemflag,jdbcType=VARCHAR},
      </if>
      <if test="bz != null">
        BZ = #{bz,jdbcType=VARCHAR},
      </if>
      <if test="mintimegranid != null">
        MINTIMEGRANID = #{mintimegranid,jdbcType=VARCHAR},
      </if>
      <if test="warnvalue != null">
        WARNVALUE = #{warnvalue,jdbcType=DECIMAL},
      </if>
      <if test="propertyid != null">
        PROPERTYID = #{propertyid,jdbcType=VARCHAR},
      </if>
      <if test="createman != null">
        CREATEMAN = #{createman,jdbcType=VARCHAR},
      </if>
      <if test="createtime != null">
        CREATETIME = #{createtime,jdbcType=VARCHAR},
      </if>
      <if test="updateman != null">
        UPDATEMAN = #{updateman,jdbcType=VARCHAR},
      </if>
      <if test="updatetime != null">
        UPDATETIME = #{updatetime,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        CODE = #{code,jdbcType=DECIMAL},
      </if>
      <if test="fluvalue != null">
        FLUVALUE = #{fluvalue,jdbcType=DECIMAL},
      </if>
      <if test="fluitemid != null">
        FLUITEMID = #{fluitemid,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 INDEXTYPE,ITEMTYPE,WORKPROCID
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="whereLike"/>
	order by FACTORYID,INDEXTYPE,ITEMTYPE,WORKPROCID,SEQNO
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_RM_INDEX_ITEM 
      (ITEMID, 
      ITEMNAME, ITEMDESC, ITEMTYPE, 
      INDEXTYPE, TYPE1, TYPE2, 
      TYPE3, TYPE4, ENERGYID, 
      WORKPROCID, FACTORYID, USEFLAG, 
      UNITID, DIGITS, SEQNO, 
      PARENTID, ITEMFLAG, BZ, 
      MINTIMEGRANID, WARNVALUE, PROPERTYID, 
      CREATEMAN, CREATETIME, UPDATEMAN, 
      UPDATETIME, CODE, FLUVALUE, 
      FLUITEMID)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.itemid,jdbcType=VARCHAR}, 
      #{item.itemname,jdbcType=VARCHAR}, #{item.itemdesc,jdbcType=VARCHAR}, #{item.itemtype,jdbcType=VARCHAR}, 
      #{item.indextype,jdbcType=VARCHAR}, #{item.type1,jdbcType=VARCHAR}, #{item.type2,jdbcType=VARCHAR}, 
      #{item.type3,jdbcType=VARCHAR}, #{item.type4,jdbcType=VARCHAR}, #{item.energyid,jdbcType=VARCHAR}, 
      #{item.workprocid,jdbcType=VARCHAR}, #{item.factoryid,jdbcType=VARCHAR}, #{item.useflag,jdbcType=VARCHAR}, 
      #{item.unitid,jdbcType=VARCHAR}, #{item.digits,jdbcType=DECIMAL}, #{item.seqno,jdbcType=DECIMAL}, 
      #{item.parentid,jdbcType=VARCHAR}, #{item.itemflag,jdbcType=VARCHAR}, #{item.bz,jdbcType=VARCHAR}, 
      #{item.mintimegranid,jdbcType=VARCHAR}, #{item.warnvalue,jdbcType=DECIMAL}, #{item.propertyid,jdbcType=VARCHAR}, 
      #{item.createman,jdbcType=VARCHAR}, #{item.createtime,jdbcType=VARCHAR}, #{item.updateman,jdbcType=VARCHAR}, 
      #{item.updatetime,jdbcType=VARCHAR}, #{item.code,jdbcType=DECIMAL}, #{item.fluvalue,jdbcType=DECIMAL}, 
      #{item.fluitemid,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_RM_INDEX_ITEM
     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>
       ,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>
       ,ITEMDESC=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.itemdesc,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>
       ,INDEXTYPE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.indextype,jdbcType=VARCHAR}
       </foreach>
       ,TYPE1=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.type1,jdbcType=VARCHAR}
       </foreach>
       ,TYPE2=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.type2,jdbcType=VARCHAR}
       </foreach>
       ,TYPE3=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.type3,jdbcType=VARCHAR}
       </foreach>
       ,TYPE4=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.type4,jdbcType=VARCHAR}
       </foreach>
       ,ENERGYID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.energyid,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>
       ,FACTORYID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.factoryid,jdbcType=VARCHAR}
       </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>
       ,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>
       ,SEQNO=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.seqno,jdbcType=DECIMAL}
       </foreach>
       ,PARENTID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.parentid,jdbcType=VARCHAR}
       </foreach>
       ,ITEMFLAG=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.itemflag,jdbcType=VARCHAR}
       </foreach>
       ,BZ=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.bz,jdbcType=VARCHAR}
       </foreach>
       ,MINTIMEGRANID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.mintimegranid,jdbcType=VARCHAR}
       </foreach>
       ,WARNVALUE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.warnvalue,jdbcType=DECIMAL}
       </foreach>
       ,PROPERTYID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.propertyid,jdbcType=VARCHAR}
       </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=VARCHAR}
       </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=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=DECIMAL}
       </foreach>
       ,FLUVALUE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.fluvalue,jdbcType=DECIMAL}
       </foreach>
       ,FLUITEMID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ITEMID" close="end">
          when #{item.itemid,jdbcType=VARCHAR} then #{item.fluitemid,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_INDEX_ITEM
    where ITEMID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  <!-- 能源综合分析-供需实绩分析-工序能耗对比分析页面，查询数据 -->
    <select id="getDate613" parameterType="java.util.HashMap" resultType = "Map">
      select ITEMNAME,CLOCK,APPORTVALUE from vm_indexitem_detail 
      <where>
        <if test="timegranid != null and timegranid != ''">
         and TIMEGRANID = #{timegranid}
        </if>
        <if test="clock != null and clock != ''">
          and CLOCK = #{clock}
        </if>
        <if test="indexid != null and indexid != ''">
          and ITEMID in (${indexid})
        </if>
      </where>
    </select>
    
    <!-- 能源综合分析-供需实绩分析-工序能耗跟踪及趋势分析页面(表1) -->
    <select id="getDate6141" parameterType="java.util.HashMap" resultType = "Map">
      select a.CLOCK, a.workprocid,a.WORKPROCNAME, a.apportvalue, a.UNITNAME,b.PRODUCTNAME, a.itemname,a.itemid,
      round(b.apportvalue, 5) as productvalue
      from vm_indexitem_detail a
      left join vm_workproc_product_info b on a.workprocid = b.WORKPROCID
      and a.clock = b.CLOCK and a.timegranid = b.TIMEGRANID
      <where>
        <if test="timegranid != null and timegranid != ''">
         and a.TIMEGRANID = #{timegranid}
        </if>
        <if test="clock != null and clock != ''">
          and a.CLOCK &gt;= #{clock}
        </if>
        <if test="clocke != null and clocke != ''">
          and a.CLOCK &lt;= #{clocke}
        </if>
        <if test="indexid != null and indexid != ''">
          and a.ITEMID in (${indexid})
        </if>
      </where>
      and b.ITEMTYPE = 'R' and b.ISPRIMARY = 1
      order by clock,a.workprocid,a.itemid
    </select>
    
    <!-- 能源综合分析-供需实绩分析-工序能耗跟踪及趋势分析页面(表2) -->
    <select id="getDate6142" parameterType="java.util.HashMap" resultType = "Map">
       select a.UNITNAME, a.workprocname, a.workprocid, a.itemname,a.itemid,
       max(a.apportvalue) as MAXAPPORTVALUE,
       min(a.apportvalue) as MINAPPORTVALUE,
       round(avg(a.apportvalue), 5) as AVGAPPORTVALUE,
       round(min(b.apportvalue), 5) as minproductvalue,
       round(max(b.apportvalue), 5) as maxproductvalue,
       round(avg(b.apportvalue), 5) as avgproductvalue
	   from vm_indexitem_detail a left join vm_workproc_product_info b
	   on a.workprocid = b.WORKPROCID and a.clock = b.CLOCK and a.timegranid = b.TIMEGRANID and b.ITEMTYPE = 'R' and b.ISPRIMARY = 1
       <where>
		   <if test="timegranid != null and timegranid != ''">
	        and a.TIMEGRANID = #{timegranid}
	       </if>
	       <if test="clock != null and clock != ''">
	         and a.CLOCK &gt;= #{clock}
	       </if>
	       <if test="clocke != null and clocke != ''">
	         and a.CLOCK &lt;= #{clocke}
	       </if>
	       <if test="indexid != null and indexid != ''">
	         and a.ITEMID in (${indexid})
	       </if>
       </where>
       group by a.UNITNAME, a.WORKPROCNAME, a.workprocid, a.itemname, a.itemid
       order by a.workprocid,a.itemid
    </select>
    
    <!-- 能源综合分析-吨钢综合能耗分析-吨钢综合能耗跟踪及趋势分析页面，表1 -->
    <select id="getDate6311" parameterType="java.util.HashMap" resultType = "Map">
       select a.CLOCK,a.itemid,a.itemname,a.workprocid,a.workprocname,a.unitname,
       b.PRODUCTNAME,
       round(a.APPORTVALUE, 5) as apportvalue,
       round(b.apportvalue, 5) as productvalue
       from vm_indexitem_detail a
       left join vm_workproc_product_info b
       on a.workprocid = b.WORKPROCID and a.clock = b.CLOCK and a.timegranid = b.TIMEGRANID 
       where b.ITEMTYPE = 'R' and a.itemid = 'CNSJ_GXNH_0010010001' 
       <if test="clock != null and clock != ''">
         and a.CLOCK &gt;= #{clock}
       </if>
       <if test="clocke != null and clocke != ''">
         and a.CLOCK &lt;= #{clocke}
       </if>
       <if test="timegranid != null and timegranid != ''">
         and a.timegranid = #{timegranid}
       </if>
       order by a.clock
    </select>
    
    <!-- 能源综合分析-吨钢综合能耗分析-吨钢综合能耗跟踪及趋势分析页面，表2 -->
    <select id="getDate6312" parameterType="java.util.HashMap" resultType = "Map">
       select a.itemid,a.itemname,a.workprocid,a.workprocname,
       round(min(a.apportvalue), 5) as minapportvalue,
       round(max(a.apportvalue), 5) as maxapportvalue,
       round(avg(a.apportvalue), 5) as avgapportvalue,
       round(min(b.apportvalue), 5) as minproductvalue,
       round(max(b.apportvalue), 5) as maxproductvalue,
       round(avg(b.apportvalue), 5) as avgproductvalue
       from vm_indexitem_detail a
       left join vm_workproc_product_info b
       on a.workprocid = b.WORKPROCID and a.clock = b.CLOCK and a.timegranid = b.TIMEGRANID 
       where b.ITEMTYPE = 'R' and a.itemid = 'CNSJ_GXNH_0010010001' 
       <if test="clock != null and clock != ''">
         and a.CLOCK &gt;= #{clock}
       </if>
       <if test="clocke != null and clocke != ''">
         and a.CLOCK &lt;= #{clocke}
       </if>
       <if test="timegranid != null and timegranid != ''">
         and a.timegranid = #{timegranid}
       </if>
       group by a.WORKPROCNAME, a.workprocid, a.itemid, a.itemname
       order by a.workprocid
    </select>
    
    <!-- 能源综合分析-吨钢综合能耗分析-吨钢综合能耗影响因素分析页面，查询数据 -->
    <select id="getDate632" parameterType="java.util.HashMap" resultType = "Map">
        select c.clock,nvl(c.workprocname,d.workprocname) workprocname,c.APPORTVALUE,round(c.gbxs, 5) gbxs,
        d.clock as COMPARECLOCK,d.APPORTVALUE as COMPAPPORTVALUE,round(d.gbxs, 5) compgbxs,
        round((c.APPORTVALUE-d.APPORTVALUE), 5) SUBWORKPROCCONSUMPTION,round((c.gbxs-d.gbxs), 5) SUBSTEALMODULUS,
        round((nvl(c.APPORTVALUE,0)-nvl(d.APPORTVALUE,0))*round(c.gbxs, 5), 6) INFLWORKPROCCONSUMPTION,
        round(round((nvl(c.gbxs,0)-nvl(d.gbxs,0)), 5)*d.APPORTVALUE, 6) INFLSTEALMODULUS
        from
		(select a.clock,a.apportvalue,a.workprocid,a.workprocname,a.itemid,b.Apportvalue/#{p1} gbxs,0 as tp from VM_INDEXITEM_DETAIL a 
		left join vm_workproc_product_info b
		on a.workprocid = b.WORKPROCID and a.clock = b.CLOCK and a.timegranid = b.TIMEGRANID and b.ITEMTYPE = 'R' and b.ISPRIMARY = 1
		WHERE a.TIMEGRANID = #{timegranid} and a.CLOCK  = #{clock} and a.indextype = 'GXNH' and a.itemtype='CNSJ' and a.useflag = 1
		and a.workprocid in ('ZY5100','ZY5200','ZY7100','ZY7201','ZY7202','ZY8100','ZY8200','ZY9101','ZY9102','ZY9103','ZY9201','ZY9202')
		union all
		select a.clock,a.apportvalue,a.workprocid,a.workprocname,a.itemid,1 gbxs,1 as tp from VM_INDEXITEM_DETAIL a 
		left join vm_workproc_product_info b
		on a.workprocid = b.WORKPROCID and a.clock = b.CLOCK and a.timegranid = b.TIMEGRANID and b.ITEMTYPE = 'R' and b.ISPRIMARY = 1
		WHERE a.TIMEGRANID = #{timegranid} and a.CLOCK  = #{clock} and a.indextype = 'GXNH' and a.itemtype='CNSJ' and a.useflag = 1
		and a.workprocid in ('ZY1101','ZY1102','ZY1201','ZY1202','ZY3100','ZY3200','ZY4100','ZY4200','ZY6100','ZY6200','ZYA100','ZYA200')) c
		full join 
		(select a.clock,a.apportvalue,a.workprocid,a.workprocname,a.itemid,b.Apportvalue/#{p2} gbxs,0 as tp from VM_INDEXITEM_DETAIL a 
		left join vm_workproc_product_info b
		on a.workprocid = b.WORKPROCID and a.clock = b.CLOCK and a.timegranid = b.TIMEGRANID and b.ITEMTYPE = 'R' and b.ISPRIMARY = 1
		WHERE a.TIMEGRANID = #{timegranid} and a.CLOCK  = #{compareclock} and a.indextype = 'GXNH' and a.itemtype='CNSJ' and a.useflag = 1
		and a.workprocid in ('ZY5100','ZY5200','ZY7100','ZY7201','ZY7202','ZY8100','ZY8200','ZY9101','ZY9102','ZY9103','ZY9201','ZY9202')
		union all
		select a.clock,a.apportvalue,a.workprocid,a.workprocname,a.itemid,1 gbxs,1 as tp from VM_INDEXITEM_DETAIL a 
		left join vm_workproc_product_info b
		on a.workprocid = b.WORKPROCID and a.clock = b.CLOCK and a.timegranid = b.TIMEGRANID and b.ITEMTYPE = 'R' and b.ISPRIMARY = 1
		WHERE a.TIMEGRANID = #{timegranid} and a.CLOCK  = #{compareclock} and a.indextype = 'GXNH' and a.itemtype='CNSJ' and a.useflag = 1
		and a.workprocid in ('ZY1101','ZY1102','ZY1201','ZY1202','ZY3100','ZY3200','ZY4100','ZY4200','ZY6100','ZY6200','ZYA100','ZYA200')) d
		on c.itemid = d.itemid
		order by nvl(c.tp,d.tp), nvl(c.workprocid,d.workprocid)
    </select>

    <!--查询树-->
    <select id="getTrees" parameterType="java.util.HashMap" resultType="Map">
        SELECT ITEMID,ITEMNAME,ITEMDESC,ITEMTYPE,
        INDEXTYPE,TYPE1,TYPE2,TYPE3,TYPE4,ENERGYID,
        WORKPROCID,FACTORYID,USEFLAG,UNITID,DIGITS,
        SEQNO,PARENTID,ITEMFLAG
        FROM T_RM_INDEX_ITEM
        <where>
            <if test="indextype != null and indextype != ''">
                and INDEXTYPE = #{indextype}
            </if>
            <if test="itemflag !=null and itemflag!=''">
                AND  ITEMFLAG = #{itemflag}
            </if>
            <if test="parentid !=null and parentid !=''">
              AND  PARENTID = #{parentid}
            </if>
        </where>
      order by SEQNO
    </select>

    <!--求最大id值-->
    <select id="getMaxId" parameterType="com.steerinfo.ems.trmindexitem.model.TRmIndexItem" resultType="string">
        SELECT SUBSTR(MAX(ITEMID),instr(MAX(ITEMID),'0'))
        FROM
        T_RM_INDEX_ITEM
     <where>
         <if test="indextype != null and indextype != ''">
             AND INDEXTYPE = #{indextype}
         </if>
         <if test="itemflag !=null and itemflag!=''">
             AND  ITEMFLAG = #{itemflag}
         </if>
         <if test="parentid !=null and parentid !=''">
             AND  PARENTID = #{parentid}
         </if>
         <if test="itemtype !=null and itemtype !=''">
             AND  ITEMTYPE = #{itemtype}
         </if>
     </where>
    </select>

    <!--根据指标类型查询NameAndId-->
    <select id="getIdAndNameByIndextype" parameterType="string" resultType="com.steerinfo.ems.trmindexitem.model.TRmIndexItem">
        SELECT  t.ITEMID AS ITEMID , t.ITEMNAME as ITEMNAME
        FROM t_rm_index_item t
       <where>
           <if test="indextype != null and indextype !='' ">
               t.INDEXTYPE=#{indextype}
           </if>
           and t.ITEMFLAG =3
           and t.useflag = '1'
       </where>
        ORDER BY t.ITEMNAME
    </select>

    <select id="getDate641" parameterType="java.util.HashMap" resultType="Map">
        SELECT
        #{clock} AS CLOCK,
        #{compareclock} AS COMPARECLOCK,
        a.APPORTVALUE AS APPORTVALUE,
        b.APPORTVALUE AS COMPAPPORTVALUE,
        CASE
        WHEN b.APPORTVALUE = 0 THEN
        0 ELSE round((a.APPORTVALUE - b.APPORTVALUE) / b.APPORTVALUE, 5)
        END AS DIFFERENTVALUE,
        a.ITEMNAME,
        a.UNITNAME,
        a.ITEMID,
        a.TIMEGRANID
        FROM
        (SELECT
        CLOCK,
        APPORTVALUE,
        ITEMNAME,
        UNITNAME,
        ITEMID,
        TIMEGRANID
        FROM
        vm_indexitem_detail t
        WHERE CLOCK = #{clock}
        AND t.timegranid = #{timegranid}
        AND t.ITEMID IN (${itemid})
        ) a
        FULL JOIN (
        SELECT
        CLOCK,
        APPORTVALUE,
        ITEMNAME,
        UNITNAME,
        ITEMID,
        TIMEGRANID
        FROM
        vm_indexitem_detail c
        WHERE
        1 = 1
        AND CLOCK = #{compareclock}
        AND c.timegranid = #{timegranid}
        AND c.ITEMID IN (${itemid})
        ) b ON a.itemid = b.itemid
    </select>
    
    <!--能源综合分析-经济指标分析-能耗指标自身对比-对比视图-->
    <select id="getDate643" parameterType="java.util.HashMap" resultType="Map">
        select a.CLOCK, a.workprocid,a.WORKPROCNAME, a.apportvalue, a.UNITNAME, a.itemname,a.itemid
	    from vm_indexitem_detail a
	      <where>
	        <if test="timegranid != null and timegranid != ''">
	         and a.TIMEGRANID = #{timegranid}
	        </if>
	        <if test="clock != null and clock != ''">
	          and a.CLOCK &gt;= #{clock}
	        </if>
	        <if test="clocke != null and clocke != ''">
	          and a.CLOCK &lt;= #{clocke}
	        </if>
	        <if test="itemid != null and itemid != ''">
	          and a.ITEMID in (${itemid})
	        </if>
	      </where>
	      order by clock,a.workprocid,a.itemid
    </select>
    
    <select id="selectLikewByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
	    <include refid="select_alias"/>
	    left join T_RM_WORKPROC w on t.workprocid = w.id
	    <include refid="whereLike"/>
        order by w.seqno, t.code
	</select>
	
	<select id="selectByParasForFla" parameterType="java.util.HashMap" resultMap="BaseResultMap">
	    <include refid="select"/>
	    <include refid="where"/>
	    order by seqno
	</select>


  <!--求最大序号-->
  <select id="getMaxSeqNo" parameterType="com.steerinfo.ems.trmindexitem.model.TRmIndexItem" resultType="int">
    SELECT nvl(MAX(SEQNO),1)
    FROM
    T_RM_INDEX_ITEM
    <where>
      <if test="indextype != null and indextype != ''">
        AND INDEXTYPE = #{indextype}
      </if>
      <if test="itemflag !=null and itemflag!=''">
        AND  ITEMFLAG = #{itemflag}
      </if>
      <if test="parentid !=null and parentid !=''">
        AND  PARENTID = #{parentid}
      </if>
      <if test="itemtype !=null and itemtype !=''">
        AND  ITEMTYPE = #{itemtype}
      </if>
    </where>
  </select>
</mapper>