diff --git a/SolarPower/Controllers/PowerStationController.cs b/SolarPower/Controllers/PowerStationController.cs index c751cc8..06597d9 100644 --- a/SolarPower/Controllers/PowerStationController.cs +++ b/SolarPower/Controllers/PowerStationController.cs @@ -230,6 +230,11 @@ namespace SolarPower.Controllers return apiResult; } + /// + /// 取得運維人員 + /// + /// + /// [HttpPost] public async Task>> GetOperationPersonnelSelectOptionList(int powerStationId) { diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs index a578e5f..d7bf653 100644 --- a/SolarPower/Repository/Implement/OverviewRepository.cs +++ b/SolarPower/Repository/Implement/OverviewRepository.cs @@ -314,7 +314,7 @@ namespace SolarPower.Repository.Implement { var sql = @$"SELECT i.Id AS Value, i.InverterName AS Name FROM {db_name}.inverter i LEFT JOIN {db_name}.controller c ON i.ControllerId = c.Id AND c.Deleted = 0 - WHERE i.Deleted = 0 AND c.PowerStationId = @PowerStationId"; + WHERE i.Deleted = 0 AND c.PowerStationId = @PowerStationId order by i.Id "; result = (await conn.QueryAsync(sql, new { PowerStationId = powerStationId })).ToList(); } @@ -439,7 +439,7 @@ namespace SolarPower.Repository.Implement { DateTime start; DateTime end; - var sql = @$"select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time , + var sql = @$"select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, ps.Id PowerStationId, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time , a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime, a.alarmClass, b.alarmClass as alarmClassName,ps.Name as PowerStationName, errDevice, err_valueKind, errValue, FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate, c.errMsg_tw cerrMsg_tw, d.errMsg_tw derrMsg_tw, case when c.errMsg_tw is null then @@ -731,8 +731,10 @@ 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 + 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') = DATE_FORMAT(C.TIMESTAMP, '%Y') AND P.PowerStationId = C.PowerStationId WHERE C.PowerStationId = {post.PowerstationId} group by left(c.`TIMESTAMP`, 4) "; break; diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index b4ca91b..13dc5ad 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -95,6 +95,14 @@ namespace SolarPower.Repository.Implement GROUP BY w.LocationName ) A LEFT JOIN weather_forecast B ON A.aa = B.Id) wf ON c.Name = wf.LocationName"; + //var sql = $@"SELECT ps.*, c.Name AS CityName, wf.Wx + // FROM power_station ps + // LEFT JOIN city c ON ps.CityId = c.Id + // LEFT JOIN ( + // SELECT LocationName, Wx FROM weather_forecast w + // WHERE '{now}' BETWEEN w.StartTime AND w.EndTime + // GROUP BY w.LocationName + // ) wf ON c.Name = wf.LocationName"; if (myUser.Role.Layer == (int)RoleLayerEnum.CompanyAdmin) { //公司管理員 diff --git a/SolarPower/Startup.cs b/SolarPower/Startup.cs index 072a41f..ef4e04d 100644 --- a/SolarPower/Startup.cs +++ b/SolarPower/Startup.cs @@ -141,8 +141,9 @@ namespace SolarPower #endregion services.AddHostedService(); - services.AddApplicationInsightsTelemetry(); #endregion + + services.AddApplicationInsightsTelemetry(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml index 9fae923..b53e5d1 100644 --- a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml +++ b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml @@ -2416,6 +2416,7 @@ var today_format = today.toISOString().slice(0, 10).replace(/-/g, "-"); //$('#DateGet').val(today_format); $('#date-range-history').val(today_format + ' - ' + today_format); + groupType = 0; } else { // 昨天 @@ -2424,6 +2425,7 @@ var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "-"); //$('#DateGet').val(dateLimit_format); $('#date-range-history').val(dateLimit_format + ' - ' + dateLimit_format); + groupType = 0; } historyRange = $('#date-range-history').val(); getTable(); @@ -2466,7 +2468,7 @@ } //#endregion - console.log("date-range-history = " + $('#date-range-history').val()); + //console.log("date-range-history = " + $('#date-range-history').val()); function Historyclick() { switch (groupType) { case 0: @@ -2485,7 +2487,11 @@ case 4: timeAll = $('#date-range-history').val().split('~'); time1 = timeAll[0].trim(); time2 = timeAll[1].trim(); - historyRange = time1 + ' - ' + time2; break; + historyRange = time1 + ' - ' + time2; + if (time1 == time2){ + groupType = 0; + } + break; } getTable(); } @@ -2539,6 +2545,8 @@ var irradianceALL = 0; var pr = 0; var avgPR = 0; + var irr_day = 0; + var avgIrr_day = 0; var tempALL = 0; var listmonth = new Array(0); var listkwh = new Array(0); @@ -2563,7 +2571,9 @@ kwhALL += val.kwh; //diffSOLARHOURALL += val.diffSOLARHOUR; irradianceALL += val.irradiance; + irr_day = val.irrDay; + avgIrr_day += val.irrDay; // 累計日照 pr = val.pr; avgPR += val.pr; //rowCT++; @@ -2589,7 +2599,7 @@ kwhkwp = (ALLkwhkwp / times).toFixed(2); times++; } - console.log(val); + // console.log(val); diffSOLARHOURALL = val.solarhour; $('#HistoryDetailTable').append('' + '' + val.timestamp + '' + @@ -2744,9 +2754,13 @@ }); if (groupType == 0) { + //日(hour) - 顯示當天最後一筆 avgPR = pr; + avgIrr_day = irr_day; } else { + //顯示多日 - 顯示平均值 avgPR = avgPR / rel.data.length; + avgIrr_day = avgIrr_day / rel.data.length; } //alert('avgPR = ' + avgPR + ' rowCT=' + rel.data.length); @@ -2761,7 +2775,7 @@ '' + kwhALL.toFixed(2) + '' + '' + kwhkwp + '' + //'' + irradianceALL.toFixed(2) + '' + // 改成累積日照 by jiahao 2022-04-30 00:444 - '' + irr_day.toFixed(2) + '' + + '' + avgIrr_day.toFixed(2) + '' + '' + avgPR.toFixed(2) + '' + '' + tempALL.toFixed(2) + '' + ''); diff --git a/SolarPower/appsettings.Development.json b/SolarPower/appsettings.Development.json index d477624..6d01b33 100644 --- a/SolarPower/appsettings.Development.json +++ b/SolarPower/appsettings.Development.json @@ -17,21 +17,21 @@ //}, "mySql": "server=210.61.91.43;user=idafenweb;Database=solar_master;Port=10068;password=P@ssw0rd;charset='utf8';pooling=true;sslmode=none;", // - //"DBConfig": { - // "Server": "AVXfxd+IRlLtJ0MCi9HU1g==", - // "port": "CrEmevYrUsSo7Mkb7Gxn8A==", - // "Database": "CEyYZnO8B5+yTXQcFSsiBA==", - // "Root": "Aph7AzoiwAmmBHCfS1rqeQ==", - // "Password": "8WMHBEWuT0XoAB4kzduQHA==" - //}, - // FIC woG "DBConfig": { - "Server": "MWAxcj1mgmbZ8tB6NgApnQ==", - "port": "CY1x+1WYXRCBab3wKnBCOQ==", + "Server": "AVXfxd+IRlLtJ0MCi9HU1g==", + "port": "CrEmevYrUsSo7Mkb7Gxn8A==", "Database": "CEyYZnO8B5+yTXQcFSsiBA==", - "Root": "4koIJVzfp6veImONCwQy3A==", - "Password": "y4uPqlH9ncTgR/I07qpwaA==" + "Root": "Aph7AzoiwAmmBHCfS1rqeQ==", + "Password": "8WMHBEWuT0XoAB4kzduQHA==" }, + // FIC woG + //"DBConfig": { + // "Server": "MWAxcj1mgmbZ8tB6NgApnQ==", + // "port": "CY1x+1WYXRCBab3wKnBCOQ==", + // "Database": "CEyYZnO8B5+yTXQcFSsiBA==", + // "Root": "4koIJVzfp6veImONCwQy3A==", + // "Password": "y4uPqlH9ncTgR/I07qpwaA==" + //}, "BackgroundServiceCron": { "CalcPowerStationJob": "0 5 * * * ?", "CalcAvgPowerStationJob": "0 0 2 * * ?", diff --git a/SolarPower/appsettings.json b/SolarPower/appsettings.json index b3ccdc1..4d4ba38 100644 --- a/SolarPower/appsettings.json +++ b/SolarPower/appsettings.json @@ -19,21 +19,21 @@ // "Password": "y4uPqlH9ncTgR/I07qpwaA==" //}, // FIC woG - "DBConfig": { - "Server": "MWAxcj1mgmbZ8tB6NgApnQ==", - "port": "CY1x+1WYXRCBab3wKnBCOQ==", - "Database": "CEyYZnO8B5+yTXQcFSsiBA==", - "Root": "pBX64+ALGFnLiHGRFXNh7w==", - "Password": "bOlWkSFsV3qNLkZTJ3UPog==" - }, - // //"DBConfig": { - // "Server": "AVXfxd+IRlLtJ0MCi9HU1g==", - // "port": "CrEmevYrUsSo7Mkb7Gxn8A==", + // "Server": "MWAxcj1mgmbZ8tB6NgApnQ==", + // "port": "CY1x+1WYXRCBab3wKnBCOQ==", // "Database": "CEyYZnO8B5+yTXQcFSsiBA==", - // "Root": "Aph7AzoiwAmmBHCfS1rqeQ==", - // "Password": "8WMHBEWuT0XoAB4kzduQHA==" + // "Root": "pBX64+ALGFnLiHGRFXNh7w==", + // "Password": "bOlWkSFsV3qNLkZTJ3UPog==" //}, + // + "DBConfig": { + "Server": "AVXfxd+IRlLtJ0MCi9HU1g==", + "port": "CrEmevYrUsSo7Mkb7Gxn8A==", + "Database": "CEyYZnO8B5+yTXQcFSsiBA==", + "Root": "Aph7AzoiwAmmBHCfS1rqeQ==", + "Password": "8WMHBEWuT0XoAB4kzduQHA==" + }, "BackgroundServiceCron": { "CalcPowerStationJob": "0 5 * * * ?", "CalcAvgPowerStationJob": "0 0 2 * * ?", diff --git a/solarApp/App.config b/solarApp/App.config index 12a99f8..c956531 100644 --- a/solarApp/App.config +++ b/solarApp/App.config @@ -2,8 +2,8 @@ - - + + diff --git a/solarApp/solarApp.csproj b/solarApp/solarApp.csproj index c75fd44..365504e 100644 --- a/solarApp/solarApp.csproj +++ b/solarApp/solarApp.csproj @@ -6,6 +6,13 @@ true + + + + + + + tlbimp