debug 小卡資訊:30天 平均累計日照

This commit is contained in:
cesar liu 2022-09-01 10:58:42 +08:00
parent 048d983d29
commit 5ea5729ba8

View File

@ -2936,12 +2936,20 @@ namespace SolarPower.Repository.Implement
{ {
var startDay = Convert.ToDateTime(nowDay).AddDays(-30).ToString("yyyy-MM-dd"); var startDay = Convert.ToDateTime(nowDay).AddDays(-30).ToString("yyyy-MM-dd");
var sql = $@"SELECT AVG(p.Irradiance) AS AvgIrradiance //var sql = $@"SELECT AVG(p.Irradiance) AS AvgIrradiance
FROM sensor_history_hour p // 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 WHERE DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') BETWEEN @StartDay AND @EndDay
AND p.Irradiance != 0 AND p.Irradiance != 0
AND PowerStationId = @PowerStationId AND PowerStationId = @PowerStationId
GROUP BY DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') GROUP BY DATE_FORMAT(p.TIMESTAMP, '%Y-%m')
"; ";
result = await conn.QueryFirstOrDefaultAsync<AvgPyrheliometerHistory>(sql, new { StartDay = startDay, EndDay = nowDay, PowerStationId = powerStationId }); result = await conn.QueryFirstOrDefaultAsync<AvgPyrheliometerHistory>(sql, new { StartDay = startDay, EndDay = nowDay, PowerStationId = powerStationId });