From 190197c2ec9f69a377296b31be128ed837ade56a Mon Sep 17 00:00:00 2001 From: Kai Date: Thu, 8 Jul 2021 10:11:29 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E9=9B=BB=E7=AB=99=E7=B8=BD=E8=A6=BD=20?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E8=B3=87=E6=96=99=202.=20=E5=8D=B3=E6=99=82?= =?UTF-8?q?=E8=B3=87=E8=A8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StationOverviewController.cs | 59 +++- SolarPower/Models/Overview.cs | 8 + SolarPower/Properties/launchSettings.json | 2 +- .../Implement/OverviewRepository.cs | 2 + .../Implement/PowerStationRepository.cs | 3 +- SolarPower/Views/MapOverview/Index.cshtml | 3 +- .../Views/PowerStation/_StationInfo.cshtml | 52 +-- SolarPower/Views/Shared/_Layout.cshtml | 12 +- .../StationOverviewInfo.cshtml | 329 +++++++++++++++++- SolarPower/Views/StationOverview/_Info.cshtml | 269 +++++++++++++- .../Views/StationOverview/_UpToDate.cshtml | 141 +++++++- .../08d2e127-759a-4ecb-a64a-2bb33de96fe1.png | Bin 0 -> 907 bytes .../39c4a5c6-991a-4afa-9d05-490150f035b9.png | Bin 0 -> 907 bytes .../405a06c2-9a39-4b22-b577-af09cfa2e6dc.png | Bin 0 -> 12006 bytes .../e9b17558-c72f-43a4-b3db-cecc6337633a.png | Bin 0 -> 275652 bytes 15 files changed, 826 insertions(+), 54 deletions(-) create mode 100644 SolarPower/wwwroot/upload/power_station/1/08d2e127-759a-4ecb-a64a-2bb33de96fe1.png create mode 100644 SolarPower/wwwroot/upload/power_station/1/39c4a5c6-991a-4afa-9d05-490150f035b9.png create mode 100644 SolarPower/wwwroot/upload/power_station/1/405a06c2-9a39-4b22-b577-af09cfa2e6dc.png create mode 100644 SolarPower/wwwroot/upload/power_station/1/e9b17558-c72f-43a4-b3db-cecc6337633a.png diff --git a/SolarPower/Controllers/StationOverviewController.cs b/SolarPower/Controllers/StationOverviewController.cs index b6827f0..8c4e0f1 100644 --- a/SolarPower/Controllers/StationOverviewController.cs +++ b/SolarPower/Controllers/StationOverviewController.cs @@ -68,7 +68,6 @@ namespace SolarPower.Controllers MapOverview mapOverview = new MapOverview(); try { - List powerStationIds = new List() { 1, 2, 3 }; var overview = await overviewRepository.GetOverviewByPowerStationIds(post.Ids); mapOverview.Today_kwh = overview.Today_kwh; mapOverview.Total_kwh = overview.Total_kwh; @@ -95,8 +94,6 @@ namespace SolarPower.Controllers mapOverview.TotalPowerStationCount = totalPowerStationCount; mapOverview.TotalCapacity = totalCapacity; - mapOverview.PowerStations = await overviewRepository.GetListPowerStationByPowerStationIds(powerStationIds); - mapOverview.UpdatedAt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); @@ -116,11 +113,55 @@ namespace SolarPower.Controllers } + [HttpPost] + public async Task> GetOneStationUpToDateInfo(StationIds post) + { + ApiResult apiResult = new ApiResult(); + + StationOverview stationOverview = new StationOverview(); + try + { + var overview = await overviewRepository.GetOverviewByPowerStationIds(post.Ids); + stationOverview.Today_kwh = overview.Today_kwh; + stationOverview.Total_kwh = overview.Total_kwh; + stationOverview.Today_irradiance = overview.Today_irradiance; + stationOverview.Avg_irradiance = overview.Avg_irradiance; + stationOverview.Today_PR = overview.Today_PR; + stationOverview.Avg_PR = overview.Avg_PR; + stationOverview.Today_kwhkwp = overview.Today_kwhkwp; + stationOverview.Avg_kwhkwp = overview.Avg_kwhkwp; + stationOverview.Today_monery = overview.Today_monery; + stationOverview.Total_monery = overview.Total_monery; + stationOverview.Today_carbon = overview.Today_carbon; + stationOverview.Total_carbon = overview.Total_carbon; + + stationOverview.UpdatedAt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + + if (myUser.Role.Auths.Contains("ShowMoney")) + { + stationOverview.IsShowMoney = 1; + } + else + { + stationOverview.IsShowMoney = 0; + stationOverview.Today_monery = 0; + stationOverview.Total_monery = 0; + } + + + apiResult.Code = "0000"; + apiResult.Data = stationOverview; + + } + catch (Exception exception) + { + apiResult.Code = "9999"; + Logger.LogError("【" + controllerName + "/" + actionName + "】"); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } } - - - - - } - diff --git a/SolarPower/Models/Overview.cs b/SolarPower/Models/Overview.cs index 481a73f..c7614b4 100644 --- a/SolarPower/Models/Overview.cs +++ b/SolarPower/Models/Overview.cs @@ -16,6 +16,8 @@ namespace SolarPower.Models public double Avg_PR { get; set; } //平均 PR 值(30天) public double Today_kwhkwp { get; set; } //即時平均 kWh / kWp public double Avg_kwhkwp { get; set; } //平均 kWh / kWp (30天) + public double Today_monery { get; set; } //今日金額 + public double Total_monery { get; set; } //今日金額 public double Today_carbon { get; set; } //今日減碳量 public double Total_carbon { get; set; } //累積減碳量 } @@ -46,4 +48,10 @@ namespace SolarPower.Models { public List Ids { get; set; } } + + public class StationOverview : Overview + { + public byte IsShowMoney { get; set; } //是否顯示發電金額 + public string UpdatedAt { get; set; } //畫面資料更新時間 + } } diff --git a/SolarPower/Properties/launchSettings.json b/SolarPower/Properties/launchSettings.json index ee7c7f9..5191b82 100644 --- a/SolarPower/Properties/launchSettings.json +++ b/SolarPower/Properties/launchSettings.json @@ -8,7 +8,7 @@ }, "iisExpress": { "applicationUrl": "http://localhost:63003", - "sslPort": 44398 + "sslPort": 0 } }, "profiles": { diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs index 03fb6aa..6e8c790 100644 --- a/SolarPower/Repository/Implement/OverviewRepository.cs +++ b/SolarPower/Repository/Implement/OverviewRepository.cs @@ -53,6 +53,8 @@ namespace SolarPower.Repository.Implement AVG(ps.avg_PR) AS avg_PR, AVG(ps.today_kwhkwp) AS today_kwhkwp, AVG(ps.avg_kwhkwp) AS avg_kwhkwp, + SUM(ps.today_monery) AS today_monery, + SUM(ps.total_monery) AS total_monery, SUM(ps.today_carbon) AS today_carbon, SUM(ps.total_carbon) AS total_carbon FROM power_station ps diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index cd25e12..2c86a4f 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -202,9 +202,10 @@ namespace SolarPower.Repository.Implement conn.Open(); try { - var sql = @$"SELECT ps.*, c.Name AS CityName, u.Name AS CreatorName FROM {tableName} ps + var sql = @$"SELECT ps.*, c.Name AS CityName, a.Name AS AreaName, u.Name AS CreatorName FROM {tableName} ps LEFT JOIN user u ON ps.CreatedBy = u.Id LEFT JOIN city c ON ps.CityId = c.Id + LEFT JOIN area a ON ps.AreaId = a.Id WHERE ps.Deleted = 0 AND ps.Id = @Id"; result = await conn.QueryFirstOrDefaultAsync(sql, new { Id = id }); diff --git a/SolarPower/Views/MapOverview/Index.cshtml b/SolarPower/Views/MapOverview/Index.cshtml index 8957e97..acc04ea 100644 --- a/SolarPower/Views/MapOverview/Index.cshtml +++ b/SolarPower/Views/MapOverview/Index.cshtml @@ -30,7 +30,7 @@
-

日照度

+

日照度

@@ -236,6 +236,7 @@ $("#today_kwhkwp").html(mapOverview.today_kwhkwp); $("#avg_kwhkwp").html(mapOverview.avg_kwhkwp); $("#today_carbon").html(mapOverview.today_carbon); + $("#total_carbon").html(mapOverview.total_carbon); $("#total_power_station_count").html(mapOverview.totalPowerStationCount); $("#total_capacity").html(mapOverview.totalCapacity); $("#update_at").html(mapOverview.updatedAt); diff --git a/SolarPower/Views/PowerStation/_StationInfo.cshtml b/SolarPower/Views/PowerStation/_StationInfo.cshtml index c5bf32b..e7a262a 100644 --- a/SolarPower/Views/PowerStation/_StationInfo.cshtml +++ b/SolarPower/Views/PowerStation/_StationInfo.cshtml @@ -148,32 +148,34 @@
-
-
逆變器
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
+ @* +
+
逆變器
+
+
+ +
+ +
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ *@
光電板
@@ -325,8 +327,6 @@
- -
diff --git a/SolarPower/Views/Shared/_Layout.cshtml b/SolarPower/Views/Shared/_Layout.cshtml index 33a7096..d7a6a8e 100644 --- a/SolarPower/Views/Shared/_Layout.cshtml +++ b/SolarPower/Views/Shared/_Layout.cshtml @@ -90,7 +90,7 @@ -->
  • - + 總覽