<?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.yeejoin.amos.boot.module.hygf.api.tdenginemapper.DayGenerateMapper">

    <select id="getDayGenerateph" resultType="com.yeejoin.amos.boot.module.hygf.api.entity.DayGenerate">
        SELECT
        *
        FROM house_pv_data.td_hygf_station_day_generate
        <where>
            <if test="dto!=null">
                third_station_id in
                <foreach collection="dto" item="item" index="index" open="(" separator="," close=")">
                    #{item.thirdStationId}
                </foreach>
            </if>
            <if test="dateTime!=null">
              and  day_time = #{dateTime}
            </if>
            <if test="regionalCompaniesCode!=null and regionalCompaniesCode != ''">
                and regional_companies_code = #{regionalCompaniesCode}
            </if>

            <if test="amosCompanyCode!=null and amosCompanyCode != ''">
                and amos_company_code = #{amosCompanyCode}
            </if>

        </where>
        <if test="sort=='desc'">
            ORDER by fullhour desc
        </if>
        <if test="sort=='asc'">
            ORDER by fullhour asc
        </if>
        limit 10
    </select>


    <select id="getDayGeneratqx"  resultType="com.yeejoin.amos.boot.module.hygf.api.dto.PowerCurveDto">
        SELECT
        sum(generate)num,
        `day_time` date
        FROM house_pv_data.td_hygf_station_day_generate
        <where>
        <if test="dto!=null">
            third_station_id in
            <foreach collection="dto" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
            <if test="regionalCompaniesCode!=null and regionalCompaniesCode != ''">
                and regional_companies_code = #{regionalCompaniesCode}
            </if>
            <if test="amosCompanyCode!=null and amosCompanyCode != ''">
                and amos_company_code = #{amosCompanyCode}
            </if>
            <if test="stationType!=null and stationType != ''">
                and stationType = #{stationType}
            </if>

        <if test="thirdStationId!=null and thirdStationId != ''">
            and third_station_id = #{thirdStationId}
        </if>
            and year_month = #{date}
        </where>



        GROUP BY `day_time`
    </select>
    <select id="getMonthGenerateqx"  resultType="com.yeejoin.amos.boot.module.hygf.api.dto.PowerCurveDto">
        SELECT
        sum(generate)num,
        `month_time` date
        FROM house_pv_data.td_hygf_station_month_generate

        <where>
            <if test="dto!=null">
                third_station_id in
                <foreach collection="dto" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>

            <if test="regionalCompaniesCode!=null and regionalCompaniesCode != ''">
                and regional_companies_code = #{regionalCompaniesCode}
            </if>
            <if test="amosCompanyCode!=null and amosCompanyCode != ''">
                and amos_company_code = #{amosCompanyCode}
            </if>
            <if test="stationType!=null and stationType != ''">
                and stationType = #{stationType}
            </if>

            <if test="thirdStationId!=null and thirdStationId != ''">
                and third_station_id = #{thirdStationId}
            </if>
            and year = #{date}
        </where>




        GROUP BY `month_time`
    </select>
    <select id="getYearGenerateqx"  resultType="com.yeejoin.amos.boot.module.hygf.api.dto.PowerCurveDto">
        SELECT
        sum(generate)num,
        `year_time` date
        FROM house_pv_data.td_hygf_station_year_generate
        <where>
            <if test="dto!=null">
                third_station_id in
                <foreach collection="dto" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>

            <if test="regionalCompaniesCode!=null and regionalCompaniesCode != ''">
                and regional_companies_code = #{regionalCompaniesCode}
            </if>
            <if test="amosCompanyCode!=null and amosCompanyCode != ''">
                and amos_company_code = #{amosCompanyCode}
            </if>
            <if test="stationType!=null and stationType != ''">
                and stationType = #{stationType}
            </if>

            <if test="thirdStationId!=null and thirdStationId != ''">
                and third_station_id = #{thirdStationId}
            </if>
        </where>

        GROUP BY `year_time`
    </select>


    <select id="selectPagenewDayGenerate"  resultType="com.yeejoin.amos.boot.module.hygf.api.entity.DayGenerate">
        SELECT
      *
        FROM house_pv_data.td_hygf_station_day_generate
        <where>
            <if test="dto!=null">
                third_station_id in
                <foreach collection="dto" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="dateTime!=null and dateTime != ''">
               and day_time = #{dateTime}
            </if>
            <if test="stationState!=null and stationState != ''">
                and station_state = #{stationState}
            </if>
        </where>
        LIMIT #{current} ,#{size}
    </select>


</mapper>
