<?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.trmactvalue.mapper.TRmActValueMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.trmactvalue.model.TRmActValue">
    <id column="CLOCK" jdbcType="VARCHAR" property="clock" />
    <id column="ITEMID" jdbcType="VARCHAR" property="itemid" />
    <id column="TIMEGRANID" jdbcType="VARCHAR" property="timegranid" />
    <result column="ACTUALVALUE" jdbcType="DECIMAL" property="actualvalue" />
    <result column="CORRECTVALUE" jdbcType="DECIMAL" property="correctvalue" />
    <result column="APPORTVALUE" jdbcType="DECIMAL" property="apportvalue" />
    <result column="STDVALUE" jdbcType="DECIMAL" property="stdvalue" />
    <result column="SUMVALUE" jdbcType="DECIMAL" property="sumvalue" />
    <result column="SUMSTDVALUE" jdbcType="DECIMAL" property="sumstdvalue" />
    <result column="REC_TIME" jdbcType="VARCHAR" property="recTime" />
    <result column="TEAMSORT" jdbcType="VARCHAR" property="teamsort" />
    <result column="MODIFYFLAG" jdbcType="DECIMAL" property="modifyflag" />
    <result column="ISLOCK" jdbcType="VARCHAR" property="islock" />
    <result column="LOCKID" jdbcType="VARCHAR" property="lockid" />
    <result column="UCVALUE" jdbcType="DECIMAL" property="ucvalue" />
    <result column="SUMUCVALUE" jdbcType="DECIMAL" property="sumucvalue" />
    <result column="FID" jdbcType="DECIMAL" property="fid" />
    <result column="UPTIME" jdbcType="VARCHAR" property="uptime" />
    <result column="USERID" jdbcType="VARCHAR" property="userid" />
    <result column="CRMAN" jdbcType="VARCHAR" property="crman" />
  </resultMap>
  <sql id="columns">
    CLOCK, ITEMID, TIMEGRANID, ACTUALVALUE, CORRECTVALUE, APPORTVALUE, STDVALUE, SUMVALUE, 
    SUMSTDVALUE, REC_TIME, TEAMSORT, MODIFYFLAG, ISLOCK, LOCKID, UCVALUE, SUMUCVALUE, 
    FID, UPTIME, USERID, CRMAN
  </sql>
  <sql id="columns_alias">
    t.CLOCK, t.ITEMID, t.TIMEGRANID, t.ACTUALVALUE, t.CORRECTVALUE, t.APPORTVALUE, t.STDVALUE, 
    t.SUMVALUE, t.SUMSTDVALUE, t.REC_TIME, t.TEAMSORT, t.MODIFYFLAG, t.ISLOCK, t.LOCKID, 
    t.UCVALUE, t.SUMUCVALUE, t.FID, t.UPTIME, t.USERID, t.CRMAN
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM T_RM_ACT_VALUE
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM T_RM_ACT_VALUE t
  </sql>
  <sql id="where">
    <where> 
      <if test="itemid != null and itemid != ''">
        and ITEMID = #{itemid}
      </if>
      <if test="timegranid != null and timegranid != ''">
        and TIMEGRANID = #{timegranid}
      </if>
      <if test="actualvalue != null">
        and ACTUALVALUE = #{actualvalue}
      </if>
      <if test="correctvalue != null">
        and CORRECTVALUE = #{correctvalue}
      </if>
      <if test="apportvalue != null">
        and APPORTVALUE = #{apportvalue}
      </if>
      <if test="stdvalue != null">
        and STDVALUE = #{stdvalue}
      </if>
      <if test="sumvalue != null">
        and SUMVALUE = #{sumvalue}
      </if>
      <if test="sumstdvalue != null">
        and SUMSTDVALUE = #{sumstdvalue}
      </if>
      <if test="recTime != null and recTime != ''">
        and REC_TIME = #{recTime}
      </if>
      <if test="teamsort != null and teamsort != ''">
        and TEAMSORT = #{teamsort}
      </if>
      <if test="modifyflag != null">
        and MODIFYFLAG = #{modifyflag}
      </if>
      <if test="islock != null and islock != ''">
        and ISLOCK = #{islock}
      </if>
      <if test="lockid != null and lockid != ''">
        and LOCKID = #{lockid}
      </if>
      <if test="ucvalue != null">
        and UCVALUE = #{ucvalue}
      </if>
      <if test="sumucvalue != null">
        and SUMUCVALUE = #{sumucvalue}
      </if>
      <if test="fid != null">
        and FID = #{fid}
      </if>
      <if test="uptime != null and uptime != ''">
        and UPTIME = #{uptime}
      </if>
      <if test="userid != null and userid != ''">
        and USERID = #{userid}
      </if>
      <if test="crman != null and crman != ''">
        and CRMAN = #{crman}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="itemid != null and itemid != ''">
        and ITEMID LIKE '%${itemid}%'
      </if>
      <if test="timegranid != null and timegranid != ''">
        and TIMEGRANID LIKE '%${timegranid}%'
      </if>
      <if test="actualvalue != null">
        and ACTUALVALUE = #{actualvalue}
      </if>
      <if test="correctvalue != null">
        and CORRECTVALUE = #{correctvalue}
      </if>
      <if test="apportvalue != null">
        and APPORTVALUE = #{apportvalue}
      </if>
      <if test="stdvalue != null">
        and STDVALUE = #{stdvalue}
      </if>
      <if test="sumvalue != null">
        and SUMVALUE = #{sumvalue}
      </if>
      <if test="sumstdvalue != null">
        and SUMSTDVALUE = #{sumstdvalue}
      </if>
      <if test="recTime != null and recTime != ''">
        and REC_TIME LIKE '%${recTime}%'
      </if>
      <if test="teamsort != null and teamsort != ''">
        and TEAMSORT LIKE '%${teamsort}%'
      </if>
      <if test="modifyflag != null">
        and MODIFYFLAG = #{modifyflag}
      </if>
      <if test="islock != null and islock != ''">
        and ISLOCK LIKE '%${islock}%'
      </if>
      <if test="lockid != null and lockid != ''">
        and LOCKID LIKE '%${lockid}%'
      </if>
      <if test="ucvalue != null">
        and UCVALUE = #{ucvalue}
      </if>
      <if test="sumucvalue != null">
        and SUMUCVALUE = #{sumucvalue}
      </if>
      <if test="fid != null">
        and FID = #{fid}
      </if>
      <if test="uptime != null and uptime != ''">
        and UPTIME LIKE '%${uptime}%'
      </if>
      <if test="userid != null and userid != ''">
        and USERID LIKE '%${userid}%'
      </if>
      <if test="crman != null and crman != ''">
        and CRMAN LIKE '%${crman}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="map">
    delete from T_RM_ACT_VALUE
    where CLOCK = #{clock,jdbcType=VARCHAR}
      and ITEMID = #{itemid,jdbcType=VARCHAR}
      and TIMEGRANID = #{timegranid,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_RM_ACT_VALUE
    where 1!=1 
      <if test="itemid != null and itemid != ''">
        or ITEMID = #{itemid}
      </if>
      <if test="timegranid != null and timegranid != ''">
        or TIMEGRANID = #{timegranid}
      </if>
      <if test="actualvalue != null">
        or ACTUALVALUE = #{actualvalue}
      </if>
      <if test="correctvalue != null">
        or CORRECTVALUE = #{correctvalue}
      </if>
      <if test="apportvalue != null">
        or APPORTVALUE = #{apportvalue}
      </if>
      <if test="stdvalue != null">
        or STDVALUE = #{stdvalue}
      </if>
      <if test="sumvalue != null">
        or SUMVALUE = #{sumvalue}
      </if>
      <if test="sumstdvalue != null">
        or SUMSTDVALUE = #{sumstdvalue}
      </if>
      <if test="recTime != null and recTime != ''">
        or REC_TIME = #{recTime}
      </if>
      <if test="teamsort != null and teamsort != ''">
        or TEAMSORT = #{teamsort}
      </if>
      <if test="modifyflag != null">
        or MODIFYFLAG = #{modifyflag}
      </if>
      <if test="islock != null and islock != ''">
        or ISLOCK = #{islock}
      </if>
      <if test="lockid != null and lockid != ''">
        or LOCKID = #{lockid}
      </if>
      <if test="ucvalue != null">
        or UCVALUE = #{ucvalue}
      </if>
      <if test="sumucvalue != null">
        or SUMUCVALUE = #{sumucvalue}
      </if>
      <if test="fid != null">
        or FID = #{fid}
      </if>
      <if test="uptime != null and uptime != ''">
        or UPTIME = #{uptime}
      </if>
      <if test="userid != null and userid != ''">
        or USERID = #{userid}
      </if>
      <if test="crman != null and crman != ''">
        or CRMAN = #{crman}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.trmactvalue.model.TRmActValue">
    insert into T_RM_ACT_VALUE (CLOCK, ITEMID, TIMEGRANID, 
      ACTUALVALUE, CORRECTVALUE, APPORTVALUE, 
      STDVALUE, SUMVALUE, SUMSTDVALUE, 
      REC_TIME, TEAMSORT, MODIFYFLAG, 
      ISLOCK, LOCKID, UCVALUE, 
      SUMUCVALUE, FID, UPTIME, 
      USERID, CRMAN)
    values (#{clock,jdbcType=VARCHAR}, #{itemid,jdbcType=VARCHAR}, #{timegranid,jdbcType=VARCHAR}, 
      #{actualvalue,jdbcType=DECIMAL}, #{correctvalue,jdbcType=DECIMAL}, #{apportvalue,jdbcType=DECIMAL}, 
      #{stdvalue,jdbcType=DECIMAL}, #{sumvalue,jdbcType=DECIMAL}, #{sumstdvalue,jdbcType=DECIMAL}, 
      #{recTime,jdbcType=VARCHAR}, #{teamsort,jdbcType=VARCHAR}, #{modifyflag,jdbcType=DECIMAL}, 
      #{islock,jdbcType=VARCHAR}, #{lockid,jdbcType=VARCHAR}, #{ucvalue,jdbcType=DECIMAL}, 
      #{sumucvalue,jdbcType=DECIMAL}, #{fid,jdbcType=DECIMAL}, #{uptime,jdbcType=VARCHAR}, 
      #{userid,jdbcType=VARCHAR}, #{crman,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.trmactvalue.model.TRmActValue">
    insert into T_RM_ACT_VALUE
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="clock != null">
        CLOCK,
      </if>
      <if test="itemid != null">
        ITEMID,
      </if>
      <if test="timegranid != null">
        TIMEGRANID,
      </if>
      <if test="actualvalue != null">
        ACTUALVALUE,
      </if>
      <if test="correctvalue != null">
        CORRECTVALUE,
      </if>
      <if test="apportvalue != null">
        APPORTVALUE,
      </if>
      <if test="stdvalue != null">
        STDVALUE,
      </if>
      <if test="sumvalue != null">
        SUMVALUE,
      </if>
      <if test="sumstdvalue != null">
        SUMSTDVALUE,
      </if>
      <if test="recTime != null">
        REC_TIME,
      </if>
      <if test="teamsort != null">
        TEAMSORT,
      </if>
      <if test="modifyflag != null">
        MODIFYFLAG,
      </if>
      <if test="islock != null">
        ISLOCK,
      </if>
      <if test="lockid != null">
        LOCKID,
      </if>
      <if test="ucvalue != null">
        UCVALUE,
      </if>
      <if test="sumucvalue != null">
        SUMUCVALUE,
      </if>
      <if test="fid != null">
        FID,
      </if>
      <if test="uptime != null">
        UPTIME,
      </if>
      <if test="userid != null">
        USERID,
      </if>
      <if test="crman != null">
        CRMAN,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="clock != null">
        #{clock,jdbcType=VARCHAR},
      </if>
      <if test="itemid != null">
        #{itemid,jdbcType=VARCHAR},
      </if>
      <if test="timegranid != null">
        #{timegranid,jdbcType=VARCHAR},
      </if>
      <if test="actualvalue != null">
        #{actualvalue,jdbcType=DECIMAL},
      </if>
      <if test="correctvalue != null">
        #{correctvalue,jdbcType=DECIMAL},
      </if>
      <if test="apportvalue != null">
        #{apportvalue,jdbcType=DECIMAL},
      </if>
      <if test="stdvalue != null">
        #{stdvalue,jdbcType=DECIMAL},
      </if>
      <if test="sumvalue != null">
        #{sumvalue,jdbcType=DECIMAL},
      </if>
      <if test="sumstdvalue != null">
        #{sumstdvalue,jdbcType=DECIMAL},
      </if>
      <if test="recTime != null">
        #{recTime,jdbcType=VARCHAR},
      </if>
      <if test="teamsort != null">
        #{teamsort,jdbcType=VARCHAR},
      </if>
      <if test="modifyflag != null">
        #{modifyflag,jdbcType=DECIMAL},
      </if>
      <if test="islock != null">
        #{islock,jdbcType=VARCHAR},
      </if>
      <if test="lockid != null">
        #{lockid,jdbcType=VARCHAR},
      </if>
      <if test="ucvalue != null">
        #{ucvalue,jdbcType=DECIMAL},
      </if>
      <if test="sumucvalue != null">
        #{sumucvalue,jdbcType=DECIMAL},
      </if>
      <if test="fid != null">
        #{fid,jdbcType=DECIMAL},
      </if>
      <if test="uptime != null">
        #{uptime,jdbcType=VARCHAR},
      </if>
      <if test="userid != null">
        #{userid,jdbcType=VARCHAR},
      </if>
      <if test="crman != null">
        #{crman,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.trmactvalue.model.TRmActValue">
    update T_RM_ACT_VALUE
    set ACTUALVALUE = #{actualvalue,jdbcType=DECIMAL},
      CORRECTVALUE = #{correctvalue,jdbcType=DECIMAL},
      APPORTVALUE = #{apportvalue,jdbcType=DECIMAL},
      STDVALUE = #{stdvalue,jdbcType=DECIMAL},
      SUMVALUE = #{sumvalue,jdbcType=DECIMAL},
      SUMSTDVALUE = #{sumstdvalue,jdbcType=DECIMAL},
      REC_TIME = #{recTime,jdbcType=VARCHAR},
      TEAMSORT = #{teamsort,jdbcType=VARCHAR},
      MODIFYFLAG = #{modifyflag,jdbcType=DECIMAL},
      ISLOCK = #{islock,jdbcType=VARCHAR},
      LOCKID = #{lockid,jdbcType=VARCHAR},
      UCVALUE = #{ucvalue,jdbcType=DECIMAL},
      SUMUCVALUE = #{sumucvalue,jdbcType=DECIMAL},
      FID = #{fid,jdbcType=DECIMAL},
      UPTIME = #{uptime,jdbcType=VARCHAR},
      USERID = #{userid,jdbcType=VARCHAR},
      CRMAN = #{crman,jdbcType=VARCHAR}
    where CLOCK = #{clock,jdbcType=VARCHAR}
      and ITEMID = #{itemid,jdbcType=VARCHAR}
      and TIMEGRANID = #{timegranid,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.trmactvalue.model.TRmActValue">
    update T_RM_ACT_VALUE
    <set>
      <if test="actualvalue != null">
        ACTUALVALUE = #{actualvalue,jdbcType=DECIMAL},
      </if>
      <if test="correctvalue != null">
        CORRECTVALUE = #{correctvalue,jdbcType=DECIMAL},
      </if>
      <if test="apportvalue != null">
        APPORTVALUE = #{apportvalue,jdbcType=DECIMAL},
      </if>
      <if test="stdvalue != null">
        STDVALUE = #{stdvalue,jdbcType=DECIMAL},
      </if>
      <if test="sumvalue != null">
        SUMVALUE = #{sumvalue,jdbcType=DECIMAL},
      </if>
      <if test="sumstdvalue != null">
        SUMSTDVALUE = #{sumstdvalue,jdbcType=DECIMAL},
      </if>
      <if test="recTime != null">
        REC_TIME = #{recTime,jdbcType=VARCHAR},
      </if>
      <if test="teamsort != null">
        TEAMSORT = #{teamsort,jdbcType=VARCHAR},
      </if>
      <if test="modifyflag != null">
        MODIFYFLAG = #{modifyflag,jdbcType=DECIMAL},
      </if>
      <if test="islock != null">
        ISLOCK = #{islock,jdbcType=VARCHAR},
      </if>
      <if test="lockid != null">
        LOCKID = #{lockid,jdbcType=VARCHAR},
      </if>
      <if test="ucvalue != null">
        UCVALUE = #{ucvalue,jdbcType=DECIMAL},
      </if>
      <if test="sumucvalue != null">
        SUMUCVALUE = #{sumucvalue,jdbcType=DECIMAL},
      </if>
      <if test="fid != null">
        FID = #{fid,jdbcType=DECIMAL},
      </if>
      <if test="uptime != null">
        UPTIME = #{uptime,jdbcType=VARCHAR},
      </if>
      <if test="userid != null">
        USERID = #{userid,jdbcType=VARCHAR},
      </if>
      <if test="crman != null">
        CRMAN = #{crman,jdbcType=VARCHAR},
      </if>
    </set>
    where CLOCK = #{clock,jdbcType=VARCHAR}
      and ITEMID = #{itemid,jdbcType=VARCHAR}
      and TIMEGRANID = #{timegranid,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="map" resultMap="BaseResultMap">
    <include refid="select"/>
    where CLOCK = #{clock,jdbcType=VARCHAR}
      and ITEMID = #{itemid,jdbcType=VARCHAR}
      and TIMEGRANID = #{timegranid,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="where"/>
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="whereLike"/>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_RM_ACT_VALUE 
      (CLOCK, 
      ITEMID, TIMEGRANID, ACTUALVALUE, 
      CORRECTVALUE, APPORTVALUE, STDVALUE, 
      SUMVALUE, SUMSTDVALUE, REC_TIME, 
      TEAMSORT, MODIFYFLAG, ISLOCK, 
      LOCKID, UCVALUE, SUMUCVALUE, 
      FID, UPTIME, USERID, 
      CRMAN)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.clock,jdbcType=VARCHAR}, 
      #{item.itemid,jdbcType=VARCHAR}, #{item.timegranid,jdbcType=VARCHAR}, #{item.actualvalue,jdbcType=DECIMAL}, 
      #{item.correctvalue,jdbcType=DECIMAL}, #{item.apportvalue,jdbcType=DECIMAL}, #{item.stdvalue,jdbcType=DECIMAL}, 
      #{item.sumvalue,jdbcType=DECIMAL}, #{item.sumstdvalue,jdbcType=DECIMAL}, #{item.recTime,jdbcType=VARCHAR}, 
      #{item.teamsort,jdbcType=VARCHAR}, #{item.modifyflag,jdbcType=DECIMAL}, #{item.islock,jdbcType=VARCHAR}, 
      #{item.lockid,jdbcType=VARCHAR}, #{item.ucvalue,jdbcType=DECIMAL}, #{item.sumucvalue,jdbcType=DECIMAL}, 
      #{item.fid,jdbcType=DECIMAL}, #{item.uptime,jdbcType=VARCHAR}, #{item.userid,jdbcType=VARCHAR}, 
      #{item.crman,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_RM_ACT_VALUE
     set
       CLOCK=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.clock,jdbcType=VARCHAR}
       </foreach>
       ,ITEMID=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.itemid,jdbcType=VARCHAR}
       </foreach>
       ,TIMEGRANID=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.timegranid,jdbcType=VARCHAR}
       </foreach>
       ,ACTUALVALUE=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.actualvalue,jdbcType=DECIMAL}
       </foreach>
       ,CORRECTVALUE=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.correctvalue,jdbcType=DECIMAL}
       </foreach>
       ,APPORTVALUE=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.apportvalue,jdbcType=DECIMAL}
       </foreach>
       ,STDVALUE=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.stdvalue,jdbcType=DECIMAL}
       </foreach>
       ,SUMVALUE=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.sumvalue,jdbcType=DECIMAL}
       </foreach>
       ,SUMSTDVALUE=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.sumstdvalue,jdbcType=DECIMAL}
       </foreach>
       ,REC_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.recTime,jdbcType=VARCHAR}
       </foreach>
       ,TEAMSORT=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.teamsort,jdbcType=VARCHAR}
       </foreach>
       ,MODIFYFLAG=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.modifyflag,jdbcType=DECIMAL}
       </foreach>
       ,ISLOCK=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.islock,jdbcType=VARCHAR}
       </foreach>
       ,LOCKID=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.lockid,jdbcType=VARCHAR}
       </foreach>
       ,UCVALUE=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.ucvalue,jdbcType=DECIMAL}
       </foreach>
       ,SUMUCVALUE=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.sumucvalue,jdbcType=DECIMAL}
       </foreach>
       ,FID=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.fid,jdbcType=DECIMAL}
       </foreach>
       ,UPTIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.uptime,jdbcType=VARCHAR}
       </foreach>
       ,USERID=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.userid,jdbcType=VARCHAR}
       </foreach>
       ,CRMAN=
       <foreach collection="list" item="item" index="index" separator=" " open="case CLOCK" close="end">
          when #{item.clock,jdbcType=VARCHAR} then #{item.crman,jdbcType=VARCHAR}
       </foreach>
     where CLOCK in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.clock,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from T_RM_ACT_VALUE
    where CLOCK in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
    <!-- 能源综合分析-供需实绩分析-供需实绩对比分析页面，查询数据 -->
    <select id="getDate611" parameterType="java.util.HashMap" resultType = "Map">
      select a.CLOCK,a.APPORTVALUE,
       CASE WHEN a.ITEMNAME IS NULL THEN b.ITEMNAME else a.ITEMNAME end as ITEMNAME,
       CASE WHEN a.UNITNAME IS NULL THEN b.UNITNAME else a.UNITNAME end as UNITNAME,
       b.clock as COMPARECLOCK,
       b.apportvalue as COMPAREAPPORTVALUE,
       decode(b.apportvalue,0,0,round((a.apportvalue - b.apportvalue) / b.apportvalue, 5)) as DIFFERENTVALUE
       from (select CLOCK, APPORTVALUE, ITEMNAME, UNITNAME, itemid from v_ca_04_chart
       <where>
          <if test="clock != null and clock != ''">
            and CLOCK = #{clock}
          </if>
          <if test="timegranid != null and timegranid != ''">
            and TIMEGRANID = #{timegranid}
          </if>
          <if test="workprocid != null and workprocid != ''">
	        and WORKPROCID in (${workprocid})
	      </if>
          <if test="energyid != null and energyid != ''">
            and ENERGYID = #{energyid}
          </if>
          <if test="propertyid != null and propertyid != ''">
            and PROPERTYID = #{propertyid}
          </if>
       </where>) a
       full join (select CLOCK, APPORTVALUE, ITEMNAME, UNITNAME, itemid from v_ca_04_chart
       <where>
          <if test="compareclock != null and compareclock != ''">
            and CLOCK = #{compareclock}
          </if>
          <if test="timegranid != null and timegranid != ''">
            and TIMEGRANID = #{timegranid}
          </if>
          <if test="workprocid != null and workprocid != ''">
            and WORKPROCID in (${workprocid})
          </if>
          <if test="energyid != null and energyid != ''">
            and ENERGYID = #{energyid}
          </if>
          <if test="propertyid != null and propertyid != ''">
            and PROPERTYID = #{propertyid}
          </if>
       </where>) b
       on a.itemid = b.itemid
    </select>
    
    <!-- 能源综合分析-供需实绩分析-供需实绩跟踪及趋势分析页面(表1) -->
    <select id="getDate6121" parameterType="java.util.HashMap" resultType = "Map">
       select a.clock,a.ENERGYID,a.workprocid,
       a.WORKPROCNAME,
       a.itemdesc,
       a.UNITNAME,
       b.PRODUCTNAME,
       round(a.apportvalue, 5) as apportvalue,
       round(b.apportvalue, 5) as productvalue,
       case when b.apportvalue = 0 then  0 else round(a.apportvalue / b.apportvalue, 5) end as singlevalue
	   from ${ds} 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="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>
          <if test="workprocid != null and workprocid != ''">
            and a.WORKPROCID in (${workprocid})
          </if>
          <if test="energyid != null and energyid != ''">
            and a.ENERGYID = #{energyid}
          </if>
          <if test="propertyid != null and propertyid != ''">
            and a.PROPERTYID = #{propertyid}
          </if>
       </where>
       and b.ITEMTYPE = 'R' order by a.clock, a.workprocid
    </select>
    
    <!-- 能源综合分析-供需实绩分析-供需实绩跟踪及趋势分析页面(表2) -->
    <select id="getDate6122" parameterType="java.util.HashMap" resultType = "Map">
       select a.WORKPROCNAME,a.workprocid,a.itemdesc,a.UNITNAME,
       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,
       round(min(case b.apportvalue when 0 then 0 else round(a.apportvalue / b.apportvalue, 5) end), 5) as minsinglevalue,
       round(max(case b.apportvalue when 0 then 0 else round(a.apportvalue / b.apportvalue, 5) end), 5) as maxsinglevalue,
       round(avg(case b.apportvalue when 0 then 0 else round(a.apportvalue / b.apportvalue, 5) end), 5) as avgsinglevalue
	   from ${ds} 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'
       <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>
       <if test="workprocid != null and workprocid != ''">
         and a.WORKPROCID in (${workprocid})
       </if>
       <if test="energyid != null and energyid != ''">
         and a.ENERGYID = #{energyid}
       </if>
       <if test="propertyid != null and propertyid != ''">
         and a.PROPERTYID = #{propertyid}
       </if>
	   group by a.WORKPROCNAME, a.workprocid, a.itemdesc, a.UNITNAME
	   order by a.workprocid
    </select>

    <!--获取累计值-->
    <select id="getSumvalue" parameterType="java.util.HashMap" resultType="double">
        SELECT nvl(SUM(APPORTVALUE),0) FROM T_RM_ACT_VALUE
        <where>
            <if test="itemid !=null and itemid != '' ">
                AND  ITEMID=#{itemid}
            </if>
            <if test="clock !=null and clock !='' ">
                AND   CLOCK LIKE '${clock}%'
            </if>
            <if test="timegranid !=null and timegranid !='' ">
                AND  TIMEGRANID=#{timegranid}
            </if>
        </where>
    </select>
    
    <!--计算累计值2（计算日期小于参数值的累计值）-->
    <select id="getSumvalue2" parameterType="java.util.HashMap" resultType="double">
        SELECT nvl(SUM(APPORTVALUE),0) FROM T_RM_ACT_VALUE
        <where>
            <if test="itemid !=null and itemid != '' ">
                AND  ITEMID=#{itemid}
            </if>
            <if test="clock !=null and clock !='' ">
                AND CLOCK &lt; #{clock}
            </if>
            <if test="ckhead !=null and ckhead !='' ">
                AND CLOCK LIKE '${ckhead}%'
            </if>
            <if test="timegranid !=null and timegranid !='' ">
                AND TIMEGRANID=#{timegranid}
            </if>
        </where>
    </select>

    <!--获取计算值-->
    <select id="getTRmActValue" parameterType="java.util.HashMap" resultType="double">
    SELECT APPORTVALUE FROM T_RM_ACT_VALUE
    <where>
        <if test="itemid != null and itemid != '' ">
            AND  ITEMID=#{itemid}
        </if>
        <if test="clock != null and clock !='' ">
            AND   CLOCK &gt;=#{clock}
        </if>
        <if test="timegranid != null and timegranid !='' ">
            AND  TIMEGRANID=#{timegranid}
        </if>
    </where>
    </select>
    <!--实绩月产量-->
    <select id="getMonthOutPut" parameterType="java.util.HashMap" resultType="Map">
        SELECT
            nvl( b.sjcl, 0 ) sjcl,
            nvl( b.ljcl, 0 ) ljcl
        FROM
            (
          SELECT
                t.itemid,
                substr( v.clock, 0, 7 ) mm,
                sum( v.apportvalue ) "能介消耗",
                workprocid,
                itemname
            FROM
                t_rm_act_item t
                INNER JOIN t_rm_act_value v ON t.itemid = v.itemid
           <where>
           <if test="workprocid != null and workprocid!='' ">
               AND t.workprocid =#{workprocid}
           </if>
            <if test="timegranid != null and timegranid!='' ">
              AND v.timegranid = #{timegranid}
            </if>
            <if test="clock != null and clock !='' ">
                AND substr( v.clock, 0, 7 ) = substr( #{clock}, 0, 7 )
            </if>
            <if test="itemid != null and itemid != ''">
                AND t.itemid = #{itemid}
            </if>
           </where>
            GROUP BY
                t.itemid,
                substr( v.clock, 0, 7 ),
                t.workprocid,
                t.itemname
            ) a
            LEFT JOIN (
            SELECT
                workprocid,
                sum( w.apportvalue ) sjcl,
                sum( w.SUMVALUE ) ljcl,
                substr( w.clock, 0, 7 ) mm
            FROM
                t_rm_workproc_product_value w
                INNER JOIN t_rm_workproc_product p ON w.itemid = p.itemid
             <where>
                 <if test="timegranid !=null and timegranid !='' ">
                     AND w.timegranid =#{timegranid}
                 </if>
                 <if test="workprocid != null and workprocid !='' ">
                     AND p.workprocid = #{workprocid}
                     AND p.isprimary = '1'
                 </if>
                  <if test="clock != null and clock !='' ">
                      AND clock
                  </if>
             </where>
            GROUP BY
                p.workprocid,
            substr( w.clock, 0, 7 )) b ON a.mm = b.mm
            AND a.workprocid = b.workprocid
        </select>
  <select id="getUploadData" resultType="Map">
    SELECT T.TIMEGRANID, T.CLOCK, T.APPORTVALUE, T1.WORKPROCID, T1.ENERGYID, T1.PROPERTYID,
        T1.ITEMID, T1.UNITID, T1.ITEMNAME, T1.ITEMDESC, T1.ISUP
    FROM T_RM_ACT_VALUE T,
       T_RM_ACT_ITEM  T1
    WHERE T.ITEMID = T1.ITEMID
        AND T.FID IS NULL
        AND T1.USEFLAG = '1'
        AND T1.ISUP = '1'
    ORDER BY T.CLOCK, T1.WORKPROCID, T.TIMEGRANID, T1.PROPERTYID
  </select>

  <update id="updateFid" parameterType="com.steerinfo.ems.trmactvalue.model.TRmActValue">
    update T_RM_ACT_VALUE
    set FID = #{fid,jdbcType=BIGINT}
    where CLOCK = #{clock,jdbcType=VARCHAR}
      and ITEMID = #{itemid,jdbcType=VARCHAR}
      and TIMEGRANID = #{timegranid,jdbcType=VARCHAR}
  </update>

  <select id="getByFid" parameterType="java.lang.Long" resultType="java.util.Map">
    SELECT T.TIMEGRANID, T.CLOCK, T.APPORTVALUE, T1.WORKPROCID, T1.ENERGYID, T1.PROPERTYID,
        T1.ITEMID, T1.UNITID, T1.ITEMNAME, T1.ITEMDESC, T1.ISUP
    FROM T_RM_ACT_VALUE T,
       T_RM_ACT_ITEM  T1
    WHERE T.ITEMID = T1.ITEMID
    and T.FID = #{fid,jdbcType=BIGINT}
  </select>
  
  <!-- 获取数据条数 -->
  <select id="getCount" parameterType="java.util.HashMap" resultType="java.lang.Integer">
    select count(1) from T_RM_ACT_VALUE
    <include refid="where"/>
  </select>
</mapper>