<?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.trmbalancevalue.mapper.TRmBalanceValueMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.trmbalancevalue.model.TRmBalanceValue">
    <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="VARCHAR" property="fid" />
    <result column="USERID" jdbcType="VARCHAR" property="userid" />
    <result column="UPTIME" jdbcType="VARCHAR" property="uptime" />
    <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, USERID, UPTIME, 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.USERID, t.UPTIME, t.CRMAN
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM T_RM_BALANCE_VALUE
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM T_RM_BALANCE_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 != ''">
        and FID = #{fid}
      </if>
      <if test="userid != null and userid != ''">
        and USERID = #{userid}
      </if>
      <if test="uptime != null">
        and UPTIME = #{uptime}
      </if>
      <if test="crman != null">
        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 != ''">
        and FID LIKE '%${fid}%'
      </if>
      <if test="userid != null and userid != ''">
        and USERID LIKE '%${userid}%'
      </if>
      <if test="uptime != null">
        and UPTIME = #{uptime}
      </if>
      <if test="crman != null">
        and CRMAN = #{crman}
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="map">
    delete from T_RM_BALANCE_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_BALANCE_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 and fid != ''">
        or FID = #{fid}
      </if>
      <if test="userid != null and userid != ''">
        or USERID = #{userid}
      </if>
      <if test="uptime != null">
        or UPTIME = #{uptime}
      </if>
      <if test="crman != null">
        or CRMAN = #{crman}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.trmbalancevalue.model.TRmBalanceValue">
    insert into T_RM_BALANCE_VALUE (CLOCK, ITEMID, TIMEGRANID, 
      ACTUALVALUE, CORRECTVALUE, APPORTVALUE, 
      STDVALUE, SUMVALUE, SUMSTDVALUE, 
      REC_TIME, TEAMSORT, MODIFYFLAG, 
      ISLOCK, LOCKID, UCVALUE, 
      SUMUCVALUE, FID, USERID, 
      UPTIME, 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=VARCHAR}, #{userid,jdbcType=VARCHAR}, 
      #{uptime,jdbcType=VARCHAR}, #{crman,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.trmbalancevalue.model.TRmBalanceValue">
    insert into T_RM_BALANCE_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="userid != null">
        USERID,
      </if>
      <if test="uptime != null">
        UPTIME,
      </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=VARCHAR},
      </if>
      <if test="userid != null">
        #{userid,jdbcType=VARCHAR},
      </if>
      <if test="uptime != null">
        #{uptime,jdbcType=VARCHAR},
      </if>
      <if test="crman != null">
        #{crman,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.trmbalancevalue.model.TRmBalanceValue">
    update T_RM_BALANCE_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=VARCHAR},
      USERID = #{userid,jdbcType=VARCHAR},
      UPTIME = #{uptime,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.trmbalancevalue.model.TRmBalanceValue">
    update T_RM_BALANCE_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=VARCHAR},
      </if>
      <if test="userid != null">
        USERID = #{userid,jdbcType=VARCHAR},
      </if>
      <if test="uptime != null">
        UPTIME = #{uptime,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_BALANCE_VALUE 
      (CLOCK, 
      ITEMID, TIMEGRANID, ACTUALVALUE, 
      CORRECTVALUE, APPORTVALUE, STDVALUE, 
      SUMVALUE, SUMSTDVALUE, REC_TIME, 
      TEAMSORT, MODIFYFLAG, ISLOCK, 
      LOCKID, UCVALUE, SUMUCVALUE, 
      FID, USERID, UPTIME, 
      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=VARCHAR}, #{item.userid,jdbcType=VARCHAR}, #{item.uptime,jdbcType=VARCHAR}, 
      #{item.crman,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_RM_BALANCE_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=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>
       ,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>
       ,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_BALANCE_VALUE
    where CLOCK in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
    <!-- 能源平衡管理-平衡表数据维护页面，查询数据 -->
    <select id="getBalanceitemList" parameterType="java.util.HashMap" resultType = "Map">
        SELECT ta.itemid,
        ta.ENERGYID,
        ta.ITEMNAME,
        tu.id as UNITID,
        tv.CLOCK,
        trv.apportvalue as SJZ,
        tv.APPORTVALUE - trv.apportvalue as FTZ,
        tv.APPORTVALUE,
        tv.SUMVALUE,
        tv.ACTUALVALUE,
        tv.UCVALUE,
        tv.SUMUCVALUE,
        tv.REC_TIME,
        tv.TIMEGRANID,
        tv.CORRECTVALUE,
        tv.USERID,
        tv.STDVALUE,
        tv.SUMSTDVALUE,
        tv.REC_TIME as UPDATECLOCK
        FROM
        ( SELECT * FROM T_RM_ACT_ITEM
        <where>
        <if test="itemid != null and itemid != ''">
            and ITEMID = #{itemid}
        </if>
        <if test="itemname != null and itemname != ''">
            and ITEMNAME = #{itemname}
        </if>
        <if test="workprocid != null and workprocid != ''">
            and WORKPROCID = #{workprocid}
        </if>
        <if test="energyid != null and energyid != ''">
            and ENERGYID = #{energyid}
        </if>
        <if test="propertyid != null and propertyid != ''">
            and PROPERTYID = #{propertyid}
        </if>
        <if test="fid!='' ">
            and  FID =#{fid}
        </if>
        <if test="fid =='' ">
            and FID is null
        </if>
            and  itemtype='B'
            and  USEFLAG='1'
        </where>
        ) ta
        inner JOIN (select * from T_RM_BALANCE_VALUE
         <where>
          <if test="clock != null and clock !='' ">
              and  clock =#{clock}
          </if>
        </where>) tv ON ta.itemid = tv.itemid
        inner join (SELECT ta.energyid,
        ta.workprocid,
        ta.propertyid,
        tv.apportvalue,
        tv.clock
        FROM T_RM_ACT_ITEM ta
        INNER JOIN T_RM_ACT_VALUE tv
        ON ta.itemid = tv.itemid
        WHERE ta.itemtype = 'R'
        AND tv.timegranid = 'MONTH') trv
        ON ta.energyid = trv.energyid
        AND ta.workprocid = trv.workprocid
        AND ta.propertyid = trv.propertyid
        AND tv.clock = trv.clock
        inner JOIN T_RM_WORKPROC tw ON ta.WORKPROCID = tw.id
        inner JOIN T_RM_ENERGY tr ON ta.ENERGYID = tr.id
        inner JOIN T_RM_UNIT tu ON ta.UNITID = tu.id
        inner JOIN t_rm_energy_property tp ON ta.PROPERTYID = tp.id
      ORDER BY ta.SHOWNO
    </select>
    
    <!-- 获取每月的累积值 -->
    <select id="getSumvalue" parameterType="java.util.HashMap" resultType="double">
        select nvl(sum(apportvalue),0) from T_RM_BALANCE_VALUE
        <where>
            <if test="itemid != null and itemid !=''">
                and  itemid=#{itemid}
            </if>
            <if test="clock != null and clock !='' ">
                and  clock =#{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_BALANCE_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="getItem" parameterType="java.util.HashMap" resultType="Map">
			select ta.itemname,tv.TIMEGRANID,tv.CLOCK,tv.APPORTVALUE
			    FROM  T_RM_ACT_ITEM ta
				INNER JOIN
			   T_RM_ACT_VALUE tv
				on ta.itemid = tv.itemid 
				INNER JOIN
				T_RM_WORKPROC tw 
				on ta.WORKPROCID = tw.id
				<where>
				 <if test="clock!= null and clock!=''">
				    and tv.CLOCK= #{clock}
				 </if>
				 <if test="energyid != null  and energyid != ''">
				    and  ta.ENERGYID= #{energyid}
				 </if>
					and ta.PROPERTYID='2'
					and tw.NODE !='1'
				</where>
    </select>
    
  <!-- 获取数据条数 -->
  <select id="getCount" parameterType="java.util.HashMap" resultType="java.lang.Integer">
    select count(1) from T_RM_BALANCE_VALUE
    <include refid="where"/>
  </select>
</mapper>