<?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.ruoyi.project.aspen.mapper.TDashboarddayeleceightMapper">
    
    <resultMap type="TDashboarddayeleceight" id="TDashboarddayeleceightResult">
        <result property="id"    column="id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createrCode"    column="creater_code"    />
        <result property="createdate"    column="createdate"    />
        <result property="updaterCode"    column="updater_code"    />
        <result property="updatedate"    column="updatedate"    />
        <result property="evconsume"    column="evconsume"    />
        <result property="elecp"    column="elecp"    />
        <result property="hechengqi"    column="hechengqi"    />
        <result property="u2"    column="u2"    />
        <result property="dataDate"    column="data_date"    />
        <result property="dateDay"    column="date_day"    />
        <result property="deptName" column="dept_name" />
    </resultMap>

    <sql id="selectTDashboarddayeleceightVo">
        select d.id, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.evconsume, d.elecp, d.hechengqi, d.u2, d.data_date, d.date_day ,s.dept_name from t_dashboarddayeleceight d
      left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTDashboarddayeleceightList" parameterType="TDashboarddayeleceight" resultMap="TDashboarddayeleceightResult">
        <include refid="selectTDashboarddayeleceightVo"/>
        <where>  
            <if test="createrCode != null  and createrCode != ''"> and creater_code = #{createrCode}</if>
            <if test="createdate != null "> and createdate = #{createdate}</if>
            <if test="updaterCode != null  and updaterCode != ''"> and updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
            <if test="evconsume != null  and evconsume != ''"> and evconsume = #{evconsume}</if>
            <if test="elecp != null  and elecp != ''"> and elecp = #{elecp}</if>
            <if test="hechengqi != null  and hechengqi != ''"> and hechengqi = #{hechengqi}</if>
            <if test="u2 != null  and u2 != ''"> and u2 = #{u2}</if>
            <if test="dataDate != null "> and data_date = #{dataDate}</if>
            <if test="dateDay != null  and dateDay != ''"> and date_day = #{dateDay}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>
    
    <select id="selectTDashboarddayeleceightById" parameterType="Long" resultMap="TDashboarddayeleceightResult">
        <include refid="selectTDashboarddayeleceightVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTDashboarddayeleceight" parameterType="TDashboarddayeleceight">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_dashboarddayeleceight.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_dashboarddayeleceight
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createrCode != null">creater_code,</if>
            <if test="createdate != null">createdate,</if>
            <if test="updaterCode != null">updater_code,</if>
            <if test="updatedate != null">updatedate,</if>
            <if test="evconsume != null">evconsume,</if>
            <if test="elecp != null">elecp,</if>
            <if test="hechengqi != null">hechengqi,</if>
            <if test="u2 != null">u2,</if>
            <if test="dataDate != null">data_date,</if>
            <if test="dateDay != null">date_day,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createrCode != null">#{createrCode},</if>
            <if test="createdate != null">#{createdate},</if>
            <if test="updaterCode != null">#{updaterCode},</if>
            <if test="updatedate != null">#{updatedate},</if>
            <if test="evconsume != null">#{evconsume},</if>
            <if test="elecp != null">#{elecp},</if>
            <if test="hechengqi != null">#{hechengqi},</if>
            <if test="u2 != null">#{u2},</if>
            <if test="dataDate != null">#{dataDate},</if>
            <if test="dateDay != null">#{dateDay},</if>
         </trim>
    </insert>

    <update id="updateTDashboarddayeleceight" parameterType="TDashboarddayeleceight">
        update t_dashboarddayeleceight
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createrCode != null">creater_code = #{createrCode},</if>
            <if test="createdate != null">createdate = #{createdate},</if>
            <if test="updaterCode != null">updater_code = #{updaterCode},</if>
            <if test="updatedate != null">updatedate = #{updatedate},</if>
            <if test="evconsume != null">evconsume = #{evconsume},</if>
            <if test="elecp != null">elecp = #{elecp},</if>
            <if test="hechengqi != null">hechengqi = #{hechengqi},</if>
            <if test="u2 != null">u2 = #{u2},</if>
            <if test="dataDate != null">data_date = #{dataDate},</if>
            <if test="dateDay != null">date_day = #{dateDay},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="deleteTDashboarddayeleceightById" parameterType="Long">
        update t_dashboarddayeleceight set del_flag = 2 where id = #{id}
    </update>

    <update id="deleteTDashboarddayeleceightByIds" parameterType="String">
        update t_dashboarddayeleceight set del_flag = 2 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

    <select id="selectWeek" parameterType="TDashboarddayeleceight" resultMap="TDashboarddayeleceightResult">
        select * from ( select * from t_dashboarddayeleceight where del_flag = 0 order by id asc ) WHERE 8 > ROWNUM
    </select>
    
</mapper>