diff --git a/SolarPower/Controllers/StationOverviewController.cs b/SolarPower/Controllers/StationOverviewController.cs index f996e83..b6827f0 100644 --- a/SolarPower/Controllers/StationOverviewController.cs +++ b/SolarPower/Controllers/StationOverviewController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; using SolarPower.Models; using SolarPower.Models.PowerStation; using SolarPower.Repository.Interface; @@ -24,11 +25,16 @@ namespace SolarPower.Controllers { return View(); } + public IActionResult Info() + { + return View("~/Views/StationOverview/StationOverviewInfo.cshtml"); + } /// /// 取得該使用者可看的所有電站分佈縣市以及各縣市電站數量 /// /// + [HttpPost] public async Task>> GetSolarByCity(UseStatusCityGetPowerStation post) { ApiResult> apiResult = new ApiResult>(); @@ -53,5 +59,68 @@ namespace SolarPower.Controllers return apiResult; } + + [HttpPost] + public async Task> GetStationCard(StationIds post) + { + ApiResult apiResult = new ApiResult(); + + 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; + mapOverview.Today_irradiance = overview.Today_irradiance; + mapOverview.Avg_irradiance = overview.Avg_irradiance; + mapOverview.Today_PR = overview.Today_PR; + mapOverview.Avg_PR = overview.Avg_PR; + mapOverview.Today_kwhkwp = overview.Today_kwhkwp; + mapOverview.Avg_kwhkwp = overview.Avg_kwhkwp; + mapOverview.Today_carbon = overview.Today_carbon; + mapOverview.Total_carbon = overview.Total_carbon; + + mapOverview.CapacityDataTables = await overviewRepository.GetCapacityDataTableByPowerStationIds(post.Ids); + + var totalPowerStationCount = 0; + var totalCapacity = 0.0; + + foreach (var capacity in mapOverview.CapacityDataTables) + { + totalPowerStationCount += capacity.SubPowerStationCount; + totalCapacity += capacity.SubTotalCapacity; + } + + mapOverview.TotalPowerStationCount = totalPowerStationCount; + mapOverview.TotalCapacity = totalCapacity; + + mapOverview.PowerStations = await overviewRepository.GetListPowerStationByPowerStationIds(powerStationIds); + + mapOverview.UpdatedAt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + + + apiResult.Code = "0000"; + apiResult.Data = mapOverview; + + } + 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 34bfb3c..481a73f 100644 --- a/SolarPower/Models/Overview.cs +++ b/SolarPower/Models/Overview.cs @@ -38,8 +38,12 @@ namespace SolarPower.Models public class UseStatusCityGetPowerStation { - public List CityId; //都市 - public List Status; //狀態 + public List Cityid { get; set; } //都市 + public List Status { get; set; } //狀態 } + public class StationIds + { + public List Ids { get; set; } + } } diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs index 1620e6b..03fb6aa 100644 --- a/SolarPower/Repository/Implement/OverviewRepository.cs +++ b/SolarPower/Repository/Implement/OverviewRepository.cs @@ -120,6 +120,7 @@ namespace SolarPower.Repository.Implement public async Task> GetSolarByCity(MyUser User, UseStatusCityGetPowerStation post) { + using IDbConnection conn = _databaseHelper.GetConnection(); List powerstation = new List(); conn.Open(); @@ -127,7 +128,7 @@ namespace SolarPower.Repository.Implement try { var ids = ""; - foreach (var id in post.CityId) + foreach (var id in post.Cityid) { ids = ids + id + ","; } @@ -138,19 +139,19 @@ namespace SolarPower.Repository.Implement if (User.Role.Layer == 0 || User.Role.Layer == 1) { var sql = "SELECT * FROM power_station WHERE CityId IN @IDs AND HealthStatus IN @Status"; - powerstation = (await conn.QueryAsync(sql, new { IDs = post.CityId , Status = post.Status})).ToList(); + powerstation = (await conn.QueryAsync(sql, new { IDs = post.Cityid, Status = post.Status})).ToList(); trans.Commit(); } else if (User.Role.Layer == 2) { var sql = "SELECT * FROM power_station WHERE CityId IN @IDs AND CompanyId=@CompanyId AND HealthStatus IN @Status"; - powerstation = (await conn.QueryAsync(sql, new { IDs = post.CityId, CompanyId = User.CompanyId , Status = post.Status })).ToList(); + powerstation = (await conn.QueryAsync(sql, new { IDs = post.Cityid, CompanyId = User.CompanyId , Status = post.Status })).ToList(); trans.Commit(); } else { var sql = "SELECT power_station.* FROM power_station LEFT JOIN power_station_operation_personnel ON power_station.Id = power_station_operation_personnel.PowerStationId WHERE CityId IN @IDs AND Userid = @UserId AND HealthStatus IN @Status"; - powerstation = (await conn.QueryAsync(sql, new { IDs = post.CityId, UserId = User.Id , Status = post.Status })).ToList(); + powerstation = (await conn.QueryAsync(sql, new { IDs = post.Cityid, UserId = User.Id , Status = post.Status })).ToList(); trans.Commit(); } } diff --git a/SolarPower/Views/MapOverview/Index.cshtml b/SolarPower/Views/MapOverview/Index.cshtml index 91096e2..8957e97 100644 --- a/SolarPower/Views/MapOverview/Index.cshtml +++ b/SolarPower/Views/MapOverview/Index.cshtml @@ -79,11 +79,11 @@
-

總減碳量

+

今日減碳量

6,091.78 KG

-

今日減碳量

+

總減碳量

985.98 KG

diff --git a/SolarPower/Views/StationOverview/Index.cshtml b/SolarPower/Views/StationOverview/Index.cshtml index 66454e5..1edc79b 100644 --- a/SolarPower/Views/StationOverview/Index.cshtml +++ b/SolarPower/Views/StationOverview/Index.cshtml @@ -84,11 +84,11 @@

今日發電量

-

126,161.72 kWh

+

126,161.72 kWh

累積發電量

-

4,069.73 kWh

+

4,069.73 kWh

@@ -99,11 +99,11 @@

即時平均日照度

-

126,161.72 kW/m2

+

126,161.72 kW/m2

平均日照度(30天)

-

4,069.73 kW/m2

+

4,069.73 kW/m2

@@ -114,11 +114,11 @@

即時平均 PR 值

-

119.04

+

119.04

平均 PR 值(30天)

-

3.84

+

3.84

@@ -129,11 +129,11 @@

即時平均 kWh / kWp

-

140.39

+

140.39

平均 kWh / kWp (30天)

-

4.53

+

4.53

@@ -144,11 +144,11 @@

今日減碳量

-

6,091.78 kG

+

6,091.78 kG

累積減碳量

-

985.98 kG

+

985.98 kG

@@ -259,12 +259,21 @@ @section Scripts{ +} \ No newline at end of file diff --git a/SolarPower/Views/StationOverview/_Exception.cshtml b/SolarPower/Views/StationOverview/_Exception.cshtml new file mode 100644 index 0000000..3b919e6 --- /dev/null +++ b/SolarPower/Views/StationOverview/_Exception.cshtml @@ -0,0 +1 @@ +

1

\ No newline at end of file diff --git a/SolarPower/Views/StationOverview/_History.cshtml b/SolarPower/Views/StationOverview/_History.cshtml new file mode 100644 index 0000000..0838d1a --- /dev/null +++ b/SolarPower/Views/StationOverview/_History.cshtml @@ -0,0 +1 @@ +

2

\ No newline at end of file diff --git a/SolarPower/Views/StationOverview/_Info.cshtml b/SolarPower/Views/StationOverview/_Info.cshtml new file mode 100644 index 0000000..e75769b --- /dev/null +++ b/SolarPower/Views/StationOverview/_Info.cshtml @@ -0,0 +1 @@ +

3

\ No newline at end of file diff --git a/SolarPower/Views/StationOverview/_Inverter.cshtml b/SolarPower/Views/StationOverview/_Inverter.cshtml new file mode 100644 index 0000000..026ce36 --- /dev/null +++ b/SolarPower/Views/StationOverview/_Inverter.cshtml @@ -0,0 +1 @@ +

4

\ No newline at end of file diff --git a/SolarPower/Views/StationOverview/_OperationRecord.cshtml b/SolarPower/Views/StationOverview/_OperationRecord.cshtml new file mode 100644 index 0000000..94571ea --- /dev/null +++ b/SolarPower/Views/StationOverview/_OperationRecord.cshtml @@ -0,0 +1 @@ +

5

\ No newline at end of file diff --git a/SolarPower/Views/StationOverview/_UpToDate.cshtml b/SolarPower/Views/StationOverview/_UpToDate.cshtml new file mode 100644 index 0000000..2759cb4 --- /dev/null +++ b/SolarPower/Views/StationOverview/_UpToDate.cshtml @@ -0,0 +1 @@ +

6

\ No newline at end of file