<?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.gyee.frame.mapper.auto.AnalysissubtablebottomMapper">
    <resultMap id="BaseResultMap" type="com.gyee.frame.model.auto.Analysissubtablebottom">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <id column="ID" jdbcType="DECIMAL" property="id"/>
        <result column="TID" jdbcType="DECIMAL" property="tid"/>
        <result column="RECORDDATE" jdbcType="TIMESTAMP" property="recorddate"/>
        <result column="WPID" jdbcType="VARCHAR" property="wpid"/>
        <result column="METERID" jdbcType="VARCHAR" property="meterid"/>
        <result column="METERNAME" jdbcType="VARCHAR" property="metername"/>
        <result column="STOPCODE" jdbcType="DECIMAL" property="stopcode"/>
        <result column="STOPCODEMODIFY" jdbcType="DECIMAL" property="stopcodemodify"/>
        <result column="DAYVALUE" jdbcType="DECIMAL" property="dayvalue"/>
        <result column="DAYVALUEMODIFY" jdbcType="DECIMAL" property="dayvaluemodify"/>
    </resultMap>
    <sql id="Example_Where_Clause">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <where>
            <foreach collection="oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Update_By_Example_Where_Clause">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <where>
            <foreach collection="example.oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        ID, TID, RECORDDATE, WPID, METERID, METERNAME, STOPCODE, STOPCODEMODIFY, DAYVALUE,
        DAYVALUEMODIFY
    </sql>
    <select id="selectByExample" parameterType="com.gyee.frame.model.auto.AnalysissubtablebottomExample"
            resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from ANALYSISSUBTABLEBOTTOM
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
    </select>
    <select id="selectByPrimaryKey" parameterType="java.lang.Short" resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select
        <include refid="Base_Column_List"/>
        from ANALYSISSUBTABLEBOTTOM
        where ID = #{id,jdbcType=DECIMAL}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Short">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        delete from ANALYSISSUBTABLEBOTTOM
        where ID = #{id,jdbcType=DECIMAL}
    </delete>
    <delete id="deleteByExample" parameterType="com.gyee.frame.model.auto.AnalysissubtablebottomExample">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        delete from ANALYSISSUBTABLEBOTTOM
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </delete>
    <insert id="insert" parameterType="com.gyee.frame.model.auto.Analysissubtablebottom">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into ANALYSISSUBTABLEBOTTOM (ID, TID, RECORDDATE,
        WPID, METERID, METERNAME,
        STOPCODE, STOPCODEMODIFY, DAYVALUE,
        DAYVALUEMODIFY)
        values (#{id,jdbcType=DECIMAL}, #{tid,jdbcType=DECIMAL}, #{recorddate,jdbcType=TIMESTAMP},
        #{wpid,jdbcType=VARCHAR}, #{meterid,jdbcType=VARCHAR}, #{metername,jdbcType=VARCHAR},
        #{stopcode,jdbcType=DECIMAL}, #{stopcodemodify,jdbcType=DECIMAL}, #{dayvalue,jdbcType=DECIMAL},
        #{dayvaluemodify,jdbcType=DECIMAL})
    </insert>
    <insert id="insertSelective" parameterType="com.gyee.frame.model.auto.Analysissubtablebottom">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into ANALYSISSUBTABLEBOTTOM
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                ID,
            </if>
            <if test="tid != null">
                TID,
            </if>
            <if test="recorddate != null">
                RECORDDATE,
            </if>
            <if test="wpid != null">
                WPID,
            </if>
            <if test="meterid != null">
                METERID,
            </if>
            <if test="metername != null">
                METERNAME,
            </if>
            <if test="stopcode != null">
                STOPCODE,
            </if>
            <if test="stopcodemodify != null">
                STOPCODEMODIFY,
            </if>
            <if test="dayvalue != null">
                DAYVALUE,
            </if>
            <if test="dayvaluemodify != null">
                DAYVALUEMODIFY,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=DECIMAL},
            </if>
            <if test="tid != null">
                #{tid,jdbcType=DECIMAL},
            </if>
            <if test="recorddate != null">
                #{recorddate,jdbcType=TIMESTAMP},
            </if>
            <if test="wpid != null">
                #{wpid,jdbcType=VARCHAR},
            </if>
            <if test="meterid != null">
                #{meterid,jdbcType=VARCHAR},
            </if>
            <if test="metername != null">
                #{metername,jdbcType=VARCHAR},
            </if>
            <if test="stopcode != null">
                #{stopcode,jdbcType=DECIMAL},
            </if>
            <if test="stopcodemodify != null">
                #{stopcodemodify,jdbcType=DECIMAL},
            </if>
            <if test="dayvalue != null">
                #{dayvalue,jdbcType=DECIMAL},
            </if>
            <if test="dayvaluemodify != null">
                #{dayvaluemodify,jdbcType=DECIMAL},
            </if>
        </trim>
    </insert>
    <select id="countByExample" parameterType="com.gyee.frame.model.auto.AnalysissubtablebottomExample"
            resultType="java.lang.Long">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select count(*) from ANALYSISSUBTABLEBOTTOM
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </select>

    <update id="updateByExampleSelective" parameterType="map">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update ANALYSISSUBTABLEBOTTOM
        <set>
            <if test="record.id != null">
                ID = #{record.id,jdbcType=DECIMAL},
            </if>
            <if test="record.tid != null">
                TID = #{record.tid,jdbcType=DECIMAL},
            </if>
            <if test="record.recorddate != null">
                RECORDDATE = #{record.recorddate,jdbcType=TIMESTAMP},
            </if>
            <if test="record.wpid != null">
                WPID = #{record.wpid,jdbcType=VARCHAR},
            </if>
            <if test="record.meterid != null">
                METERID = #{record.meterid,jdbcType=VARCHAR},
            </if>
            <if test="record.metername != null">
                METERNAME = #{record.metername,jdbcType=VARCHAR},
            </if>
            <if test="record.stopcode != null">
                STOPCODE = #{record.stopcode,jdbcType=DECIMAL},
            </if>
            <if test="record.stopcodemodify != null">
                STOPCODEMODIFY = #{record.stopcodemodify,jdbcType=DECIMAL},
            </if>
            <if test="record.dayvalue != null">
                DAYVALUE = #{record.dayvalue,jdbcType=DECIMAL},
            </if>
            <if test="record.dayvaluemodify != null">
                DAYVALUEMODIFY = #{record.dayvaluemodify,jdbcType=DECIMAL},
            </if>
        </set>
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByExample" parameterType="map">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update ANALYSISSUBTABLEBOTTOM
        set ID = #{record.id,jdbcType=DECIMAL},
        TID = #{record.tid,jdbcType=DECIMAL},
        RECORDDATE = #{record.recorddate,jdbcType=TIMESTAMP},
        WPID = #{record.wpid,jdbcType=VARCHAR},
        METERID = #{record.meterid,jdbcType=VARCHAR},
        METERNAME = #{record.metername,jdbcType=VARCHAR},
        STOPCODE = #{record.stopcode,jdbcType=DECIMAL},
        STOPCODEMODIFY = #{record.stopcodemodify,jdbcType=DECIMAL},
        DAYVALUE = #{record.dayvalue,jdbcType=DECIMAL},
        DAYVALUEMODIFY = #{record.dayvaluemodify,jdbcType=DECIMAL}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.gyee.frame.model.auto.Analysissubtablebottom">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update ANALYSISSUBTABLEBOTTOM
        <set>
            <if test="tid != null">
                TID = #{tid,jdbcType=DECIMAL},
            </if>
            <if test="recorddate != null">
                RECORDDATE = #{recorddate,jdbcType=TIMESTAMP},
            </if>
            <if test="wpid != null">
                WPID = #{wpid,jdbcType=VARCHAR},
            </if>
            <if test="meterid != null">
                METERID = #{meterid,jdbcType=VARCHAR},
            </if>
            <if test="metername != null">
                METERNAME = #{metername,jdbcType=VARCHAR},
            </if>
            <if test="stopcode != null">
                STOPCODE = #{stopcode,jdbcType=DECIMAL},
            </if>
            <if test="stopcodemodify != null">
                STOPCODEMODIFY = #{stopcodemodify,jdbcType=DECIMAL},
            </if>
            <if test="dayvalue != null">
                DAYVALUE = #{dayvalue,jdbcType=DECIMAL},
            </if>
            <if test="dayvaluemodify != null">
                DAYVALUEMODIFY = #{dayvaluemodify,jdbcType=DECIMAL},
            </if>
        </set>
        where ID = #{id,jdbcType=DECIMAL}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.gyee.frame.model.auto.Analysissubtablebottom">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update ANALYSISSUBTABLEBOTTOM
        set TID = #{tid,jdbcType=DECIMAL},
        RECORDDATE = #{recorddate,jdbcType=TIMESTAMP},
        WPID = #{wpid,jdbcType=VARCHAR},
        METERID = #{meterid,jdbcType=VARCHAR},
        METERNAME = #{metername,jdbcType=VARCHAR},
        STOPCODE = #{stopcode,jdbcType=DECIMAL},
        STOPCODEMODIFY = #{stopcodemodify,jdbcType=DECIMAL},
        DAYVALUE = #{dayvalue,jdbcType=DECIMAL},
        DAYVALUEMODIFY = #{dayvaluemodify,jdbcType=DECIMAL}
        where ID = #{id,jdbcType=DECIMAL}
    </update>

    <select id="selectByRecorddateGrop" resultType="java.util.Map">

        select RECORDDATE recorddate, SUM(dayvaluemodify)/1000 swdl from Analysissubtablebottom
        <where>
            AND wpid = #{wpid}
            AND RECORDDATE >= to_date(#{startTs}, 'yyyy-mm-dd')
            AND RECORDDATE  &lt;=  to_date(#{endTs}, 'yyyy-mm-dd')
            AND meterid in
            <foreach collection="point" item="item" index="index" open= "(" separator="," close=")">
                #{item}
            </foreach>

        </where>
         group by RECORDDATE
         order by RECORDDATE


  </select>

</mapper>