diff --git a/SolarPower/Controllers/StationOverviewController.cs b/SolarPower/Controllers/StationOverviewController.cs index 284911c..caec31c 100644 --- a/SolarPower/Controllers/StationOverviewController.cs +++ b/SolarPower/Controllers/StationOverviewController.cs @@ -356,7 +356,7 @@ namespace SolarPower.Controllers PowerIrradianceChart powerIrradianceTodayChart = new PowerIrradianceChart(); powerIrradianceTodayChart.Labels = powerIrradianceToday.Select(x => x.Label).ToList(); powerIrradianceTodayChart.PowerDatas = powerIrradianceToday.Select(x => x.PowerData).ToList(); - powerIrradianceTodayChart.IrradianceDatas = powerIrradianceToday.Select(x => x.IrradianceData).ToList(); + powerIrradianceTodayChart.IrradianceDatas = powerIrradianceToday.Select(x => x.IrrDayHourData).ToList(); powerIrradianceTodayChart.TemperatureDatas = powerIrradianceToday.Select(x => x.TemperatureData).ToList(); chartUptoDate.ChartToday = powerIrradianceTodayChart; diff --git a/SolarPower/Models/Overview.cs b/SolarPower/Models/Overview.cs index 38d6d6f..f5fc772 100644 --- a/SolarPower/Models/Overview.cs +++ b/SolarPower/Models/Overview.cs @@ -95,6 +95,7 @@ namespace SolarPower.Models public double PowerData { get; set; } public double IrradianceData { get; set; } public double TemperatureData { get; set; } + public double IrrDayHourData { get; set; } } public class PowerIrradianceChart @@ -202,6 +203,7 @@ namespace SolarPower.Models /// 累計日照 /// public double IrrDay { get; set; } + public double IrrDayHour { get; set; } } public class ExceptionEmailInfo diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs index 6f76dca..8dca441 100644 --- a/SolarPower/Repository/Implement/OverviewRepository.cs +++ b/SolarPower/Repository/Implement/OverviewRepository.cs @@ -212,7 +212,7 @@ namespace SolarPower.Repository.Implement { try { - var sql_power = @$"SELECT DATE_FORMAT(ps.timestamp,'%H %p') AS Label, ps.KWH AS PowerData, pyr.Irradiance AS IrradianceData, pyr.Temperature AS TemperatureData + var sql_power = @$"SELECT DATE_FORMAT(ps.timestamp,'%H %p') AS Label, ps.KWH AS PowerData, pyr.IrrDayHour AS IrrDayHourData, pyr.Temperature AS TemperatureData FROM power_station_history_hour ps LEFT JOIN sensor_history_hour pyr ON ps.PowerStationId = pyr.PowerStationId AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d %H') = DATE_FORMAT(pyr.timestamp, '%Y-%m-%d %H') WHERE ps.PowerStationId = @PowerStationId @@ -681,7 +681,7 @@ namespace SolarPower.Repository.Implement { // range 查詢同一天 range2 = @$" AND DATE_FORMAT(C.`TIMESTAMP`,'%Y-%m-%d') BETWEEN '{ d1 }' AND '{ d2 }'"; sql = $@" SELECT C.TIMESTAMP, C.KWH AS KWH,C.SOLARHOUR, C.PR, - P.Irradiance, P.Temperature AS Temp , C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR + P.Irradiance, P.IrrDayHour, P.Temperature AS Temp , C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR FROM power_station_history_hour C LEFT JOIN sensor_history_hour P ON P.`TIMESTAMP` =C.`TIMESTAMP` AND P.PowerStationId = C.PowerStationId WHERE C.PowerStationId = {post.PowerstationId}{range2} "; @@ -696,7 +696,7 @@ namespace SolarPower.Repository.Implement // LEFT JOIN sensor_history_day P ON DATE_FORMAT(P.TIMESTAMP, '%Y-%m-%d') = DATE_FORMAT(C.TIMESTAMP, '%Y-%m-%d') AND P.PowerStationId = C.PowerStationId // join power_station_history_month m on DATE_FORMAT(P.TIMESTAMP, '%Y-%m') = DATE_FORMAT(m.TIMESTAMP, '%Y-%m') AND m.PowerStationId = C.PowerStationId // WHERE C.PowerStationId = {post.PowerstationId}{range} order by C.TIMESTAMP"; - sql = $@" SELECT C.TIMESTAMP, C.TODAYKWH AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR + sql = $@" SELECT C.TIMESTAMP, C.TODAYKWH AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.IrrDayHour, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR FROM power_station_history_day C LEFT JOIN sensor_history_day P ON DATE_FORMAT(P.TIMESTAMP, '%Y-%m-%d') = DATE_FORMAT(C.TIMESTAMP, '%Y-%m-%d') AND P.PowerStationId = C.PowerStationId WHERE C.PowerStationId = {post.PowerstationId}{range} order by C.TIMESTAMP"; break; @@ -704,16 +704,16 @@ namespace SolarPower.Repository.Implement } break; case 1: // day 沒有 dateRange - 月 - sql = $@" SELECT C.TIMESTAMP, {kwh} AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR + sql = $@" SELECT C.TIMESTAMP, {kwh} AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.IrrDayHour, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR FROM {usedb} C LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP, '%Y-%m-%d') = DATE_FORMAT(C.TIMESTAMP, '%Y-%m-%d') AND P.PowerStationId = C.PowerStationId WHERE C.PowerStationId = {post.PowerstationId}{range} order by C.TIMESTAMP"; break; case 2: // month 單月 - //sql = $@" SELECT C.TIMESTAMP, C.MONTHKWH AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR + //sql = $@" SELECT C.TIMESTAMP, C.MONTHKWH AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.IrrDayHour, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR // 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}{range}"; - sql = $@" SELECT C.TIMESTAMP, C.MONTHKWH AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR + sql = $@" SELECT C.TIMESTAMP, C.MONTHKWH AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.IrrDayHour, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR 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}{range}"; diff --git a/SolarPower/Views/AnalysisInverter/Index.cshtml b/SolarPower/Views/AnalysisInverter/Index.cshtml index 0e0d81e..adeba19 100644 --- a/SolarPower/Views/AnalysisInverter/Index.cshtml +++ b/SolarPower/Views/AnalysisInverter/Index.cshtml @@ -11,7 +11,7 @@