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 });