diff --git a/SolarPower/Models/Overview.cs b/SolarPower/Models/Overview.cs index f5fc772..663b031 100644 --- a/SolarPower/Models/Overview.cs +++ b/SolarPower/Models/Overview.cs @@ -204,6 +204,8 @@ namespace SolarPower.Models /// public double IrrDay { get; set; } public double IrrDayHour { get; set; } + public double GeneratingCapacity { get; set; } + public int days { get; set; } } public class ExceptionEmailInfo diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs index cc6fece..d187aa1 100644 --- a/SolarPower/Repository/Implement/OverviewRepository.cs +++ b/SolarPower/Repository/Implement/OverviewRepository.cs @@ -731,12 +731,18 @@ namespace SolarPower.Repository.Implement // LEFT JOIN sensor_history_month P ON P.`TIMESTAMP` = C.`TIMESTAMP` AND P.PowerStationId = C.PowerStationId // WHERE C.PowerStationId = {post.PowerstationId} // GROUP BY left(c.`TIMESTAMP`, 4) ORDER BY C.`TIMESTAMP` "; - sql = $@" select left(c.`TIMESTAMP`, 4) AS `TIMESTAMP`, sum(monthKWH) AS KWH, round(AVG(PR), 2) AS PR , round(AVG(PR), 2) AS avgPR , - ifnull(avg( P.IrrDay), 0) irrDay, avg(P.Temperature) AS Temp - FROM power_station_history_month C - LEFT JOIN sensor_history_month P ON DATE_FORMAT(P.TIMESTAMP, '%Y-%M') = DATE_FORMAT(C.TIMESTAMP, '%Y-%M') AND P.PowerStationId = C.PowerStationId - WHERE C.PowerStationId = {post.PowerstationId} - group by left(c.`TIMESTAMP`, 4) "; + sql = $@"select * from ( + select left(c.`TIMESTAMP`, 4) AS `TIMESTAMP`, sum(monthKWH) AS KWH, round(AVG(PR), 2) AS PR , round(AVG(PR), 2) AS avgPR , + ifnull(avg( P.IrrDay), 0) irrDay, avg(P.Temperature) AS Temp, ps.GeneratingCapacity AS GeneratingCapacity + FROM power_station_history_month C + LEFT JOIN sensor_history_month P ON DATE_FORMAT(P.TIMESTAMP, '%Y-%M') = DATE_FORMAT(C.TIMESTAMP, '%Y-%M') AND P.PowerStationId = C.PowerStationId + LEFT JOIN power_station ps ON ps.id = C.PowerStationId + WHERE C.PowerStationId = {post.PowerstationId} + group by left(c.`TIMESTAMP`, 4) + )x join + ( + select year(timestamp) yyyy, count(*) days from sensor_history_day where PowerStationId = {post.PowerstationId} group by year(timestamp) + )y on x.`TIMESTAMP` = y.yyyy"; break; } diff --git a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml index d9c58cf..ef31f48 100644 --- a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml +++ b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml @@ -2648,6 +2648,8 @@ var times = 1; var ALLkwhkwp = 0; var kwhkwp = 0; + var ALLDays = 0; + var ALLavgdaykwh = 0; $.each(rel.data, function (index, val) { @@ -2675,6 +2677,7 @@ //暫時先執行到這--->取kwhkwp var nowDisplayIrrDay = 0; + var avgdaykwh = 0; if (val.length != 0) { if (groupType != 6) { @@ -2682,7 +2685,7 @@ if (groupType == 0 && kwhkwp < val.kwhkwp.toFixed(2)) { kwhkwp = val.kwhkwp.toFixed(2); } - if (groupType != 0) { + if (groupType != 0 && groupType != 3) { ALLkwhkwp += val.kwhkwp; kwhkwp = (ALLkwhkwp / times).toFixed(2); times++; @@ -2691,16 +2694,25 @@ nowDisplayIrrDay = val.irrDayHour.toFixed(2); } else { - nowDisplayIrrDay = val.irradiance.toFixed(2); + nowDisplayIrrDay = val.irrDay.toFixed(2); + } + if (groupType == 3) + { + ALLDays += val.days; + avgdaykwh = (val.kwh / val.generatingCapacity / val.days); + ALLavgdaykwh += avgdaykwh; + } + else + { + avgdaykwh = val.kwhkwp; } // console.log(val); diffSOLARHOURALL = val.solarhour; $('#HistoryDetailTable').append('