From 5ea5729ba83bcc8dc6aec39caaaa1300c92f854d Mon Sep 17 00:00:00 2001 From: cesar liu Date: Thu, 1 Sep 2022 10:58:42 +0800 Subject: [PATCH] =?UTF-8?q?debug=20=E5=B0=8F=E5=8D=A1=E8=B3=87=E8=A8=8A?= =?UTF-8?q?=EF=BC=9A30=E5=A4=A9=20=E5=B9=B3=E5=9D=87=E7=B4=AF=E8=A8=88?= =?UTF-8?q?=E6=97=A5=E7=85=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repository/Implement/PowerStationRepository.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index 6ce7be3..32bb7da 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -2936,12 +2936,20 @@ namespace SolarPower.Repository.Implement { var startDay = Convert.ToDateTime(nowDay).AddDays(-30).ToString("yyyy-MM-dd"); - var sql = $@"SELECT AVG(p.Irradiance) AS AvgIrradiance - FROM sensor_history_hour p + //var sql = $@"SELECT AVG(p.Irradiance) AS AvgIrradiance + // FROM sensor_history_hour p + // WHERE DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') BETWEEN @StartDay AND @EndDay + // AND p.Irradiance != 0 + // AND PowerStationId = @PowerStationId + // GROUP BY DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') + // "; + + var sql = $@"SELECT AVG(p.irrDay) AS AvgIrradiance + FROM sensor_history_day p WHERE DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') BETWEEN @StartDay AND @EndDay AND p.Irradiance != 0 AND PowerStationId = @PowerStationId - GROUP BY DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') + GROUP BY DATE_FORMAT(p.TIMESTAMP, '%Y-%m') "; result = await conn.QueryFirstOrDefaultAsync(sql, new { StartDay = startDay, EndDay = nowDay, PowerStationId = powerStationId });