<?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.trmcalpointexvalue.mapper.TRmCalpointExValueMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.trmcalpointexvalue.model.TRmCalpointExValue">
    <id column="ID" jdbcType="VARCHAR" property="id" />
    <result column="CLOCK" jdbcType="VARCHAR" property="clock" />
    <result column="ITEMID" jdbcType="VARCHAR" property="itemid" />
    <result column="EXTYPE" jdbcType="VARCHAR" property="extype" />
    <result column="MAXVALUE" jdbcType="DECIMAL" property="maxvalue" />
    <result column="MINVALUE" jdbcType="DECIMAL" property="minvalue" />
    <result column="APPORTVALUE" jdbcType="DECIMAL" property="apportvalue" />
    <result column="BEFVALUE" jdbcType="DECIMAL" property="befvalue" />
    <result column="CURVALUE" jdbcType="DECIMAL" property="curvalue" />
    <result column="CREATETIME" jdbcType="VARCHAR" property="createtime" />
    <result column="BZ" jdbcType="VARCHAR" property="bz" />
  </resultMap>
  <sql id="columns">
    ID, CLOCK, ITEMID, EXTYPE, MAXVALUE, MINVALUE, APPORTVALUE, BEFVALUE, CURVALUE, CREATETIME, 
    BZ
  </sql>
  <sql id="columns_alias">
    t.ID, t.CLOCK, t.ITEMID, t.EXTYPE, t.MAXVALUE, t.MINVALUE, t.APPORTVALUE, t.BEFVALUE, 
    t.CURVALUE, t.CREATETIME, t.BZ
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM T_RM_CALPOINT_EX_VALUE
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM T_RM_CALPOINT_EX_VALUE t
  </sql>
  <sql id="where">
    <where> 
      <if test="clock != null and clock != ''">
        and CLOCK = #{clock}
      </if>
      <if test="itemid != null and itemid != ''">
        and ITEMID = #{itemid}
      </if>
      <if test="extype != null and extype != ''">
        and EXTYPE = #{extype}
      </if>
      <if test="maxvalue != null">
        and MAXVALUE = #{maxvalue}
      </if>
      <if test="minvalue != null">
        and MINVALUE = #{minvalue}
      </if>
      <if test="apportvalue != null">
        and APPORTVALUE = #{apportvalue}
      </if>
      <if test="befvalue != null">
        and BEFVALUE = #{befvalue}
      </if>
      <if test="curvalue != null">
        and CURVALUE = #{curvalue}
      </if>
      <if test="createtime != null and createtime != ''">
        and CREATETIME = #{createtime}
      </if>
      <if test="bz != null and bz != ''">
        and BZ = #{bz}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="clock != null and clock != ''">
        and CLOCK LIKE '%${clock}%'
      </if>
      <if test="itemid != null and itemid != ''">
        and ITEMID LIKE '%${itemid}%'
      </if>
      <if test="extype != null and extype != ''">
        and EXTYPE LIKE '%${extype}%'
      </if>
      <if test="maxvalue != null">
        and MAXVALUE = #{maxvalue}
      </if>
      <if test="minvalue != null">
        and MINVALUE = #{minvalue}
      </if>
      <if test="apportvalue != null">
        and APPORTVALUE = #{apportvalue}
      </if>
      <if test="befvalue != null">
        and BEFVALUE = #{befvalue}
      </if>
      <if test="curvalue != null">
        and CURVALUE = #{curvalue}
      </if>
      <if test="createtime != null and createtime != ''">
        and CREATETIME LIKE '%${createtime}%'
      </if>
      <if test="bz != null and bz != ''">
        and BZ LIKE '%${bz}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_RM_CALPOINT_EX_VALUE
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_RM_CALPOINT_EX_VALUE
    where 1!=1 
      <if test="clock != null and clock != ''">
        or CLOCK = #{clock}
      </if>
      <if test="itemid != null and itemid != ''">
        or ITEMID = #{itemid}
      </if>
      <if test="extype != null and extype != ''">
        or EXTYPE = #{extype}
      </if>
      <if test="maxvalue != null">
        or MAXVALUE = #{maxvalue}
      </if>
      <if test="minvalue != null">
        or MINVALUE = #{minvalue}
      </if>
      <if test="apportvalue != null">
        or APPORTVALUE = #{apportvalue}
      </if>
      <if test="befvalue != null">
        or BEFVALUE = #{befvalue}
      </if>
      <if test="curvalue != null">
        or CURVALUE = #{curvalue}
      </if>
      <if test="createtime != null and createtime != ''">
        or CREATETIME = #{createtime}
      </if>
      <if test="bz != null and bz != ''">
        or BZ = #{bz}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.trmcalpointexvalue.model.TRmCalpointExValue">
    insert into T_RM_CALPOINT_EX_VALUE (ID, CLOCK, ITEMID, 
      EXTYPE, MAXVALUE, MINVALUE, 
      APPORTVALUE, BEFVALUE, CURVALUE, 
      CREATETIME, BZ)
    values (#{id,jdbcType=VARCHAR}, #{clock,jdbcType=VARCHAR}, #{itemid,jdbcType=VARCHAR}, 
      #{extype,jdbcType=VARCHAR}, #{maxvalue,jdbcType=DECIMAL}, #{minvalue,jdbcType=DECIMAL}, 
      #{apportvalue,jdbcType=DECIMAL}, #{befvalue,jdbcType=DECIMAL}, #{curvalue,jdbcType=DECIMAL}, 
      #{createtime,jdbcType=VARCHAR}, #{bz,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.trmcalpointexvalue.model.TRmCalpointExValue">
    insert into T_RM_CALPOINT_EX_VALUE
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="clock != null">
        CLOCK,
      </if>
      <if test="itemid != null">
        ITEMID,
      </if>
      <if test="extype != null">
        EXTYPE,
      </if>
      <if test="maxvalue != null">
        MAXVALUE,
      </if>
      <if test="minvalue != null">
        MINVALUE,
      </if>
      <if test="apportvalue != null">
        APPORTVALUE,
      </if>
      <if test="befvalue != null">
        BEFVALUE,
      </if>
      <if test="curvalue != null">
        CURVALUE,
      </if>
      <if test="createtime != null">
        CREATETIME,
      </if>
      <if test="bz != null">
        BZ,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="clock != null">
        #{clock,jdbcType=VARCHAR},
      </if>
      <if test="itemid != null">
        #{itemid,jdbcType=VARCHAR},
      </if>
      <if test="extype != null">
        #{extype,jdbcType=VARCHAR},
      </if>
      <if test="maxvalue != null">
        #{maxvalue,jdbcType=DECIMAL},
      </if>
      <if test="minvalue != null">
        #{minvalue,jdbcType=DECIMAL},
      </if>
      <if test="apportvalue != null">
        #{apportvalue,jdbcType=DECIMAL},
      </if>
      <if test="befvalue != null">
        #{befvalue,jdbcType=DECIMAL},
      </if>
      <if test="curvalue != null">
        #{curvalue,jdbcType=DECIMAL},
      </if>
      <if test="createtime != null">
        #{createtime,jdbcType=VARCHAR},
      </if>
      <if test="bz != null">
        #{bz,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.trmcalpointexvalue.model.TRmCalpointExValue">
    update T_RM_CALPOINT_EX_VALUE
    set CLOCK = #{clock,jdbcType=VARCHAR},
      ITEMID = #{itemid,jdbcType=VARCHAR},
      EXTYPE = #{extype,jdbcType=VARCHAR},
      MAXVALUE = #{maxvalue,jdbcType=DECIMAL},
      MINVALUE = #{minvalue,jdbcType=DECIMAL},
      APPORTVALUE = #{apportvalue,jdbcType=DECIMAL},
      BEFVALUE = #{befvalue,jdbcType=DECIMAL},
      CURVALUE = #{curvalue,jdbcType=DECIMAL},
      CREATETIME = #{createtime,jdbcType=VARCHAR},
      BZ = #{bz,jdbcType=VARCHAR}
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.trmcalpointexvalue.model.TRmCalpointExValue">
    update T_RM_CALPOINT_EX_VALUE
    <set>
      <if test="clock != null">
        CLOCK = #{clock,jdbcType=VARCHAR},
      </if>
      <if test="itemid != null">
        ITEMID = #{itemid,jdbcType=VARCHAR},
      </if>
      <if test="extype != null">
        EXTYPE = #{extype,jdbcType=VARCHAR},
      </if>
      <if test="maxvalue != null">
        MAXVALUE = #{maxvalue,jdbcType=DECIMAL},
      </if>
      <if test="minvalue != null">
        MINVALUE = #{minvalue,jdbcType=DECIMAL},
      </if>
      <if test="apportvalue != null">
        APPORTVALUE = #{apportvalue,jdbcType=DECIMAL},
      </if>
      <if test="befvalue != null">
        BEFVALUE = #{befvalue,jdbcType=DECIMAL},
      </if>
      <if test="curvalue != null">
        CURVALUE = #{curvalue,jdbcType=DECIMAL},
      </if>
      <if test="createtime != null">
        CREATETIME = #{createtime,jdbcType=VARCHAR},
      </if>
      <if test="bz != null">
        BZ = #{bz,jdbcType=VARCHAR},
      </if>
    </set>
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where ID = #{id,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_CALPOINT_EX_VALUE 
      (ID, 
      CLOCK, ITEMID, EXTYPE, 
      MAXVALUE, MINVALUE, APPORTVALUE, 
      BEFVALUE, CURVALUE, CREATETIME, 
      BZ)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.id,jdbcType=VARCHAR}, 
      #{item.clock,jdbcType=VARCHAR}, #{item.itemid,jdbcType=VARCHAR}, #{item.extype,jdbcType=VARCHAR}, 
      #{item.maxvalue,jdbcType=DECIMAL}, #{item.minvalue,jdbcType=DECIMAL}, #{item.apportvalue,jdbcType=DECIMAL}, 
      #{item.befvalue,jdbcType=DECIMAL}, #{item.curvalue,jdbcType=DECIMAL}, #{item.createtime,jdbcType=VARCHAR}, 
      #{item.bz,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_RM_CALPOINT_EX_VALUE
     set
       ID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.id,jdbcType=VARCHAR}
       </foreach>
       ,CLOCK=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.clock,jdbcType=VARCHAR}
       </foreach>
       ,ITEMID=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.itemid,jdbcType=VARCHAR}
       </foreach>
       ,EXTYPE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.extype,jdbcType=VARCHAR}
       </foreach>
       ,MAXVALUE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.maxvalue,jdbcType=DECIMAL}
       </foreach>
       ,MINVALUE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.minvalue,jdbcType=DECIMAL}
       </foreach>
       ,APPORTVALUE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.apportvalue,jdbcType=DECIMAL}
       </foreach>
       ,BEFVALUE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.befvalue,jdbcType=DECIMAL}
       </foreach>
       ,CURVALUE=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.curvalue,jdbcType=DECIMAL}
       </foreach>
       ,CREATETIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.createtime,jdbcType=VARCHAR}
       </foreach>
       ,BZ=
       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
          when #{item.id,jdbcType=VARCHAR} then #{item.bz,jdbcType=VARCHAR}
       </foreach>
     where ID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.id,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from T_RM_CALPOINT_EX_VALUE
    where ID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  <!--查询异常数据-->
  <select id="getExData" parameterType="java.util.HashMap" resultType = "Map">
    select t.*,v.itemname,v.energyid,v.energytypeid,v.locateid from T_RM_CALPOINT_EX_VALUE t left join T_RM_CALPOINT v 
	on t.itemid = v.itemid 
	<where>
	  <if test="clock!=null and clock!=''">  
		and t.CLOCK &gt;= #{clock}
	  </if>
	  <if test="clocke!=null and clocke!=''">  
		and t.CLOCK &lt;= #{clocke}
	  </if>
	  <if test="itemid!=null and itemid!=''">  
		and t.ITEMID in (${itemid})
	  </if>
	  <if test="extype!=null and extype!=''">  
		and t.EXTYPE = #{extype}
	  </if>
	  <if test="maxvalue!=null and maxvalue!=''">  
		and t.MAXVALUE = #{maxvalue}
	  </if>
	  <if test="minvalue!=null and minvalue!=''">  
		and t.MINVALUE = #{minvalue}
	  </if>
	  <if test="apportvalue!=null and apportvalue!=''">  
		and t.APPORTVALUE = #{apportvalue}
	  </if>
	  <if test="befvalue!=null and befvalue!=''">  
		and t.BEFVALUE = #{befvalue}
	  </if>
	  <if test="curvalue!=null and curvalue!=''">  
		and t.CURVALUE = #{curvalue}
	  </if>
	  <if test="createtime!=null and createtime!=''">  
		and t.CREATETIME = #{createtime}
	  </if>
	  <if test="energyid!=null and energyid!=''">  
		and v.ENERGYID in (${energyid})
	  </if>
	  <if test="energytypeid!=null and energytypeid!=''">  
		and v.ENERGYTYPEID = #{energytypeid}
	  </if>
	  <if test="locateid!=null and locateid!=''">  
		and v.LOCATEID in (${locateid})
	  </if>
	</where>
	order by t.clock, t.itemid
  </select>

   <!--获取位置-->
   <select id="getlocateid" resultType = "Map">
	select NAME,ID from T_RM_LOCATION
   </select>
</mapper>
