From bc33b47ce1bd1391eba9f12d2b2d946862e814b8 Mon Sep 17 00:00:00 2001 From: "wanling040@gmail.com" Date: Thu, 11 Aug 2022 17:50:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=BB=E7=AB=99=E8=B3=87=E8=A8=8A-=E6=AD=B7?= =?UTF-8?q?=E5=8F=B2=E7=B4=80=E9=8C=84:=20=E4=BF=AE=E6=94=B9=E6=AD=B7?= =?UTF-8?q?=E5=B9=B4=E7=9A=84=E6=97=A5=E5=9D=87=E7=99=BC=E9=9B=BB=E5=BA=A6?= =?UTF-8?q?=E6=95=B8=E3=80=81=E7=B4=AF=E7=A9=8D=E6=97=A5=E7=85=A7=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Models/Overview.cs | 2 + .../Implement/OverviewRepository.cs | 18 ++++--- .../StationOverviewInfo.cshtml | 52 ++++++++++++++----- 3 files changed, 54 insertions(+), 18 deletions(-) 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('' + '' + val.timestamp + '' + '' + (toThousands(val.kwh.toFixed(2))) + '' + - '' + (toThousands(val.kwhkwp.toFixed(2))) + '' + - '' + (toThousands(nowDisplayIrrDay)) + '' + //irrDay - //'' + val.irradiance.toFixed(2) + '' + + '' + (toThousands(avgdaykwh.toFixed(2))) + '' +//val.kwhkwp + '' + (toThousands(nowDisplayIrrDay)) + '' + '' + (toThousands(val.pr.toFixed(2))) + '' + '' + (toThousands(val.temp.toFixed(2))) + '' + ''); @@ -2713,25 +2725,33 @@ listtemperature.push(parseFloat(val.temp.toFixed(2))); listsolarhour.push(parseFloat(val.solarhour.toFixed(2))); listpr.push(parseFloat(val.pr.toFixed(2))); - listkwhkwp.push(parseFloat(val.kwhkwp.toFixed(2))); + listkwhkwp.push(parseFloat(avgdaykwh));//val.kwhkwp } else { 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++; } + + if (groupType == 3) { + ALLDays += val.days; + avgdaykwh = (val.kwh / val.generatingCapacity / val.days); + ALLavgdaykwh += avgdaykwh; + } + else { + avgdaykwh = val.kwhkwp; + } diffSOLARHOURALL += val.diffSOLARHOUR; $('#HistoryDetailTable').append('' + '' + val.timestamp + '' + '' + (toThousands(val.kwh.toFixed(2))) + '' + - '' + (toThousands(val.kwhkwp.toFixed(2))) + '' + - - //'' + val.irradiance.toFixed(2) + '' + + '' + (toThousands(avgdaykwh.toFixed(2))) + '' +//val.kwhkwp + '' + (toThousands(val.irrDay.toFixed(2))) + '' + '' + (toThousands(val.pr.toFixed(2))) + '' + '' + (toThousands(val.temp.toFixed(2))) + '' + ''); @@ -2744,7 +2764,7 @@ listtemperature.push(parseFloat(val.temp.toFixed(2))); listsolarhour.push(parseFloat(val.solarhour.toFixed(2))); listpr.push(parseFloat(val.pr.toFixed(2))); - listkwhkwp.push(parseFloat(val.kwhkwp.toFixed(2))); + listkwhkwp.push(parseFloat(avgdaykwh));//val.kwhkwp } } }) @@ -2866,10 +2886,18 @@ } else { + var avgK = 0; + if (groupType == 3) { + avgK = ALLavgdaykwh / rel.data.length;//(kwhALL / rel.data[0].generatingCapacity / ALLDays).toFixed(2); + } + else { + avgdaykwh = kwhkwp; + } + $('#HistoryTotalTable').append('' + '' + TimestampALL + '' + '' + (toThousands(kwhALL.toFixed(2))) + '' + - '' + (toThousands(kwhkwp)) + '' + + '' + (toThousands(avgK.toFixed(2))) + '' + //'' + irradianceALL.toFixed(2) + '' + // 改成累積日照 by jiahao 2022-04-30 00:444 '' + (toThousands(avgIrr_day.toFixed(2))) + '' + '' + (toThousands(avgPR.toFixed(2))) + '' +