<?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.psdc.mapper.PsdcElectricRtdataMapper">
    <resultMap type="com.psdc.entity.PsdcElectricRtdata" id="PsdcElectricRtdataMap">
        <result property="electricRtdataId" column="electric_rtdata_id" />
        <result property="deviceId" column="device_id" />
        <result property="updateTime" column="update_time" />
        <result property="ua" column="Ua" />
        <result property="ub" column="Ub" />
        <result property="uc" column="Uc" />
        <result property="ia" column="Ia" />
        <result property="ib" column="Ib" />
        <result property="ic" column="Ic" />
        <result property="pa" column="Pa" />
        <result property="pb" column="Pb" />
        <result property="pc" column="Pc" />
        <result property="totp" column="TotP" />
        <result property="qa" column="Qa" />
        <result property="qb" column="Qb" />
        <result property="qc" column="Qc" />
        <result property="totq" column="TotQ" />
        <result property="pfa" column="PFa" />
        <result property="pfb" column="PFb" />
        <result property="pfc" column="PFc" />
        <result property="totpf" column="TotPF" />
        <result property="supwh" column="SupWh" />
        <result property="rtlwh" column="RtlWh" />
        <result property="supqh" column="SupQh" />
        <result property="rtlqh" column="RtlQh" />
        <result property="sa" column="Sa" />
        <result property="sb" column="Sb" />
        <result property="sc" column="Sc" />
        <result property="tots" column="TotS" />
        <result property="totwh" column="TotWh" />
        <result property="totwh1" column="TotWh_1" />
        <result property="totwh2" column="TotWh_2" />
        <result property="totwh3" column="TotWh_3" />
        <result property="totwh4" column="TotWh_4" />
        <result property="hz" column="HZ" />
        <result property="uab" column="Uab" />
        <result property="ubc" column="Ubc" />
        <result property="uca" column="Uca" />
        <result property="combwh" column="CombWh" />
        <result property="combqh" column="CombQh" />
    </resultMap>

    <!-- 通过ID查询单条数据 -->
    <select id="queryById" resultMap="PsdcElectricRtdataMap">
        select
            electric_rtdata_id,device_id,update_time,Ua,Ub,Uc,Ia,Ib,Ic,Pa,Pb,Pc,TotP,Qa,Qb,Qc,TotQ,PFa,PFb,PFc,TotPF,SupWh,RtlWh,SupQh,RtlQh,Sa,Sb,Sc,TotS,
            TotWh,TotWh_1,TotWh_2,TotWh_3,TotWh_4,HZ,Uab,Ubc,Uca,CombWh,CombQh
        from psdc_electric_rtdata
        where electric_rtdata_id = #{electricRtdataId}
    </select>

    <!--分页查询指定行数据-->
    <select id="queryAllByLimit" resultMap="PsdcElectricRtdataMap">
        select
        electric_rtdata_id,device_id,update_time,Ua,Ub,Uc,Ia,Ib,Ic,Pa,Pb,Pc,TotP,Qa,Qb,Qc,TotQ,PFa,PFb,PFc,TotPF,SupWh,RtlWh,SupQh,RtlQh,Sa,Sb,Sc,TotS,
        TotWh,TotWh_1,TotWh_2,TotWh_3,TotWh_4,HZ,Uab,Ubc,Uca,CombWh,CombQh
        from psdc_electric_rtdata
        <where>
            <if test="electricRtdataId != null and electricRtdataId != ''">
                and electric_rtdata_id = #{electricRtdataId}
            </if>
            <if test="deviceId != null and deviceId != ''">
                and device_id = #{deviceId}
            </if>
            <if test="updateTime != null and updateTime != ''">
                and update_time = #{updateTime}
            </if>
            <if test="ua != null and ua != ''">
                and Ua = #{ua}
            </if>
            <if test="ub != null and ub != ''">
                and Ub = #{ub}
            </if>
            <if test="uc != null and uc != ''">
                and Uc = #{uc}
            </if>
            <if test="ia != null and ia != ''">
                and Ia = #{ia}
            </if>
            <if test="ib != null and ib != ''">
                and Ib = #{ib}
            </if>
            <if test="ic != null and ic != ''">
                and Ic = #{ic}
            </if>
            <if test="pa != null and pa != ''">
                and Pa = #{pa}
            </if>
            <if test="pb != null and pb != ''">
                and Pb = #{pb}
            </if>
            <if test="pc != null and pc != ''">
                and Pc = #{pc}
            </if>
            <if test="totp != null and totp != ''">
                and TotP = #{totp}
            </if>
            <if test="qa != null and qa != ''">
                and Qa = #{qa}
            </if>
            <if test="qb != null and qb != ''">
                and Qb = #{qb}
            </if>
            <if test="qc != null and qc != ''">
                and Qc = #{qc}
            </if>
            <if test="totq != null and totq != ''">
                and TotQ = #{totq}
            </if>
            <if test="pfa != null and pfa != ''">
                and PFa = #{pfa}
            </if>
            <if test="pfb != null and pfb != ''">
                and PFb = #{pfb}
            </if>
            <if test="pfc != null and pfc != ''">
                and PFc = #{pfc}
            </if>
            <if test="totpf != null and totpf != ''">
                and TotPF = #{totpf}
            </if>
            <if test="supwh != null and supwh != ''">
                and SupWh = #{supwh}
            </if>
            <if test="rtlwh != null and rtlwh != ''">
                and RtlWh = #{rtlwh}
            </if>
            <if test="supqh != null and supqh != ''">
                and SupQh = #{supqh}
            </if>
            <if test="rtlqh != null and rtlqh != ''">
                and RtlQh = #{rtlqh}
            </if>
            <if test="sa != null and sa != ''">
                and Sa = #{sa}
            </if>
            <if test="sb != null and sb != ''">
                and Sb = #{sb}
            </if>
            <if test="sc != null and sc != ''">
                and Sc = #{sc}
            </if>
            <if test="tots != null and tots != ''">
                and TotS = #{tots}
            </if>
            <if test="
totwh != null and
totwh != ''">
                and
                TotWh = #{
totwh}
            </if>
            <if test="totwh1 != null and totwh1 != ''">
                and TotWh_1 = #{totwh1}
            </if>
            <if test="totwh2 != null and totwh2 != ''">
                and TotWh_2 = #{totwh2}
            </if>
            <if test="totwh3 != null and totwh3 != ''">
                and TotWh_3 = #{totwh3}
            </if>
            <if test="totwh4 != null and totwh4 != ''">
                and TotWh_4 = #{totwh4}
            </if>
            <if test="hz != null and hz != ''">
                and HZ = #{hz}
            </if>
            <if test="uab != null and uab != ''">
                and Uab = #{uab}
            </if>
            <if test="ubc != null and ubc != ''">
                and Ubc = #{ubc}
            </if>
            <if test="uca != null and uca != ''">
                and Uca = #{uca}
            </if>
            <if test="combwh != null and combwh != ''">
                and CombWh = #{combwh}
            </if>
            <if test="combqh != null and combqh != ''">
                and CombQh = #{combqh}
            </if>
        </where>
        limit #{pageable.offset}, #{pageable.pageSize}
    </select>

    <!--统计总行数-->
    <select id="count" resultType="java.lang.Long">
        select count(1)
        from psdc_electric_rtdata
        <where>
            <if test="electricRtdataId != null and electricRtdataId != ''">
                and electric_rtdata_id = #{electricRtdataId}
            </if>
            <if test="deviceId != null and deviceId != ''">
                and device_id = #{deviceId}
            </if>
            <if test="updateTime != null and updateTime != ''">
                and update_time = #{updateTime}
            </if>
            <if test="ua != null and ua != ''">
                and Ua = #{ua}
            </if>
            <if test="ub != null and ub != ''">
                and Ub = #{ub}
            </if>
            <if test="uc != null and uc != ''">
                and Uc = #{uc}
            </if>
            <if test="ia != null and ia != ''">
                and Ia = #{ia}
            </if>
            <if test="ib != null and ib != ''">
                and Ib = #{ib}
            </if>
            <if test="ic != null and ic != ''">
                and Ic = #{ic}
            </if>
            <if test="pa != null and pa != ''">
                and Pa = #{pa}
            </if>
            <if test="pb != null and pb != ''">
                and Pb = #{pb}
            </if>
            <if test="pc != null and pc != ''">
                and Pc = #{pc}
            </if>
            <if test="totp != null and totp != ''">
                and TotP = #{totp}
            </if>
            <if test="qa != null and qa != ''">
                and Qa = #{qa}
            </if>
            <if test="qb != null and qb != ''">
                and Qb = #{qb}
            </if>
            <if test="qc != null and qc != ''">
                and Qc = #{qc}
            </if>
            <if test="totq != null and totq != ''">
                and TotQ = #{totq}
            </if>
            <if test="pfa != null and pfa != ''">
                and PFa = #{pfa}
            </if>
            <if test="pfb != null and pfb != ''">
                and PFb = #{pfb}
            </if>
            <if test="pfc != null and pfc != ''">
                and PFc = #{pfc}
            </if>
            <if test="totpf != null and totpf != ''">
                and TotPF = #{totpf}
            </if>
            <if test="supwh != null and supwh != ''">
                and SupWh = #{supwh}
            </if>
            <if test="rtlwh != null and rtlwh != ''">
                and RtlWh = #{rtlwh}
            </if>
            <if test="supqh != null and supqh != ''">
                and SupQh = #{supqh}
            </if>
            <if test="rtlqh != null and rtlqh != ''">
                and RtlQh = #{rtlqh}
            </if>
            <if test="sa != null and sa != ''">
                and Sa = #{sa}
            </if>
            <if test="sb != null and sb != ''">
                and Sb = #{sb}
            </if>
            <if test="sc != null and sc != ''">
                and Sc = #{sc}
            </if>
            <if test="tots != null and tots != ''">
                and TotS = #{tots}
            </if>
            <if test="
totwh != null and
totwh != ''">
                and
                TotWh = #{
totwh}
            </if>
            <if test="totwh1 != null and totwh1 != ''">
                and TotWh_1 = #{totwh1}
            </if>
            <if test="totwh2 != null and totwh2 != ''">
                and TotWh_2 = #{totwh2}
            </if>
            <if test="totwh3 != null and totwh3 != ''">
                and TotWh_3 = #{totwh3}
            </if>
            <if test="totwh4 != null and totwh4 != ''">
                and TotWh_4 = #{totwh4}
            </if>
            <if test="hz != null and hz != ''">
                and HZ = #{hz}
            </if>
            <if test="uab != null and uab != ''">
                and Uab = #{uab}
            </if>
            <if test="ubc != null and ubc != ''">
                and Ubc = #{ubc}
            </if>
            <if test="uca != null and uca != ''">
                and Uca = #{uca}
            </if>
            <if test="combwh != null and combwh != ''">
                and CombWh = #{combwh}
            </if>
            <if test="combqh != null and combqh != ''">
                and CombQh = #{combqh}
            </if>
        </where>
    </select>

    <!--新增数据-->
    <insert id="insert" >
        insert into psdc_electric_rtdata(electric_rtdata_id,device_id,update_time,Ua,Ub,Uc,Ia,Ib,Ic,Pa,Pb,Pc,TotP,Qa,Qb,Qc,TotQ,PFa,PFb,PFc,TotPF,SupWh,RtlWh,SupQh,RtlQh,Sa,Sb,Sc,TotS,
                                         TotWh,TotWh_1,TotWh_2,TotWh_3,TotWh_4,HZ,Uab,Ubc,Uca,CombWh,CombQh)
        values (#{electricRtdataId},#{deviceId},#{updateTime},#{ua},#{ub},#{uc},#{ia},#{ib},#{ic},#{pa},#{pb},#{pc},#{totp},#{qa},#{qb},#{qc},#{totq},#{pfa},#{pfb},#{pfc},#{totpf},#{supwh},#{rtlwh},#{supqh},#{rtlqh},#{sa},#{sb},#{sc},#{tots},#{
totwh},#{totwh1},#{totwh2},#{totwh3},#{totwh4},#{hz},#{uab},#{ubc},#{uca},#{combwh},#{combqh})
    </insert>

    <!-- 更新数据 -->
    <update id="update">
        update psdc_electric_rtdata
        <set>
            <if test="electricRtdataId != null and electricRtdataId != ''">
                electric_rtdata_id = #{electricRtdataId},
            </if>
            <if test="deviceId != null and deviceId != ''">
                device_id = #{deviceId},
            </if>
            <if test="updateTime != null and updateTime != ''">
                update_time = #{updateTime},
            </if>
            <if test="ua != null and ua != ''">
                Ua = #{ua},
            </if>
            <if test="ub != null and ub != ''">
                Ub = #{ub},
            </if>
            <if test="uc != null and uc != ''">
                Uc = #{uc},
            </if>
            <if test="ia != null and ia != ''">
                Ia = #{ia},
            </if>
            <if test="ib != null and ib != ''">
                Ib = #{ib},
            </if>
            <if test="ic != null and ic != ''">
                Ic = #{ic},
            </if>
            <if test="pa != null and pa != ''">
                Pa = #{pa},
            </if>
            <if test="pb != null and pb != ''">
                Pb = #{pb},
            </if>
            <if test="pc != null and pc != ''">
                Pc = #{pc},
            </if>
            <if test="totp != null and totp != ''">
                TotP = #{totp},
            </if>
            <if test="qa != null and qa != ''">
                Qa = #{qa},
            </if>
            <if test="qb != null and qb != ''">
                Qb = #{qb},
            </if>
            <if test="qc != null and qc != ''">
                Qc = #{qc},
            </if>
            <if test="totq != null and totq != ''">
                TotQ = #{totq},
            </if>
            <if test="pfa != null and pfa != ''">
                PFa = #{pfa},
            </if>
            <if test="pfb != null and pfb != ''">
                PFb = #{pfb},
            </if>
            <if test="pfc != null and pfc != ''">
                PFc = #{pfc},
            </if>
            <if test="totpf != null and totpf != ''">
                TotPF = #{totpf},
            </if>
            <if test="supwh != null and supwh != ''">
                SupWh = #{supwh},
            </if>
            <if test="rtlwh != null and rtlwh != ''">
                RtlWh = #{rtlwh},
            </if>
            <if test="supqh != null and supqh != ''">
                SupQh = #{supqh},
            </if>
            <if test="rtlqh != null and rtlqh != ''">
                RtlQh = #{rtlqh},
            </if>
            <if test="sa != null and sa != ''">
                Sa = #{sa},
            </if>
            <if test="sb != null and sb != ''">
                Sb = #{sb},
            </if>
            <if test="sc != null and sc != ''">
                Sc = #{sc},
            </if>
            <if test="tots != null and tots != ''">
                TotS = #{tots},
            </if>
            <if test="
totwh != null and
totwh != ''">

                TotWh = #{
totwh},
            </if>
            <if test="totwh1 != null and totwh1 != ''">
                TotWh_1 = #{totwh1},
            </if>
            <if test="totwh2 != null and totwh2 != ''">
                TotWh_2 = #{totwh2},
            </if>
            <if test="totwh3 != null and totwh3 != ''">
                TotWh_3 = #{totwh3},
            </if>
            <if test="totwh4 != null and totwh4 != ''">
                TotWh_4 = #{totwh4},
            </if>
            <if test="hz != null and hz != ''">
                HZ = #{hz},
            </if>
            <if test="uab != null and uab != ''">
                Uab = #{uab},
            </if>
            <if test="ubc != null and ubc != ''">
                Ubc = #{ubc},
            </if>
            <if test="uca != null and uca != ''">
                Uca = #{uca},
            </if>
            <if test="combwh != null and combwh != ''">
                CombWh = #{combwh},
            </if>
            <if test="combqh != null and combqh != ''">
                CombQh = #{combqh},
            </if>
        </set>
        where electric_rtdata_id = #{electricRtdataId}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        delete from psdc_electric_rtdata where electric_rtdata_id = #{electricRtdataId}
    </delete>
</mapper>