diff --git a/SolarPower/Controllers/MapOverviewController.cs b/SolarPower/Controllers/MapOverviewController.cs index d6c4d74..657ca08 100644 --- a/SolarPower/Controllers/MapOverviewController.cs +++ b/SolarPower/Controllers/MapOverviewController.cs @@ -61,6 +61,12 @@ namespace SolarPower.Controllers mapOverview.Today_carbon = powerStationSummary.Today_carbon; mapOverview.Total_carbon = powerStationSummary.Total_carbon; + var solarTypeMoneys = await overviewRepository.GetSolarTypeMoneys(); + + mapOverview.today_solarTypeMoney_self_built_wholesale = solarTypeMoneys[0].Today_money; + mapOverview.today_solarTypeMoney_tenant_built_wholesale = solarTypeMoneys[1].Today_money; + mapOverview.today_solarTypeMoney_self_build = solarTypeMoneys[2].Today_money; + mapOverview.CapacityDataTables = await overviewRepository.GetCapacityDataTableByPowerStationIds(powerStationIds); var totalPowerStationCount = 0; diff --git a/SolarPower/Models/Overview.cs b/SolarPower/Models/Overview.cs index b698e4d..38d6d6f 100644 --- a/SolarPower/Models/Overview.cs +++ b/SolarPower/Models/Overview.cs @@ -29,9 +29,17 @@ namespace SolarPower.Models public List PowerStations { get; set; } public int TotalPowerStationCount { get; set; } public double TotalCapacity { get; set; } + public double today_solarTypeMoney_self_built_wholesale { get; set; } //自建躉售 + public double today_solarTypeMoney_tenant_built_wholesale { get; set; } //租建 + public double today_solarTypeMoney_self_build { get; set; } //自建自用 public string UpdatedAt { get; set; } //畫面資料更新時間 } + public class SolarTypeMoneys + { + public double Today_money { get; set; } //發電金額 + } + public class CapacityDataTable { public string CityName { get; set; } //城市名稱 diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs index c21e702..6f76dca 100644 --- a/SolarPower/Repository/Implement/OverviewRepository.cs +++ b/SolarPower/Repository/Implement/OverviewRepository.cs @@ -886,5 +886,30 @@ namespace SolarPower.Repository.Implement }; return result; } + + public async Task> GetSolarTypeMoneys() + { + List result = new List(); + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = @$"SELECT + solartype, + sum(today_money) Today_money + FROM power_station + group by solartype + order by solartype + "; + result = (await conn.QueryAsync(sql)).ToList(); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + + } } } diff --git a/SolarPower/Repository/Interface/IOverviewRepository.cs b/SolarPower/Repository/Interface/IOverviewRepository.cs index d594ce5..275b68a 100644 --- a/SolarPower/Repository/Interface/IOverviewRepository.cs +++ b/SolarPower/Repository/Interface/IOverviewRepository.cs @@ -32,5 +32,6 @@ namespace SolarPower.Repository.Interface Task> GetExceptionTable2(ExceptionSent2 post); Task> GetEmailExceptionList(); Task> GetUserListWithPowerstation(int id); + Task> GetSolarTypeMoneys(); } } diff --git a/SolarPower/Views/MapOverview/Index.cshtml b/SolarPower/Views/MapOverview/Index.cshtml index c58849b..e3bde91 100644 --- a/SolarPower/Views/MapOverview/Index.cshtml +++ b/SolarPower/Views/MapOverview/Index.cshtml @@ -36,11 +36,11 @@
-

今日日照度

+

今日累積日照量

0.00

-

平均日照度(30天)

+

日均累積日照量(30天)

0.00

@@ -68,11 +68,11 @@
-

今日日均發電度數(kwh/kwp)

+

日均發電度數(kwh/kwp)

0.00

-

平均日均發電度數 (30天)

+

日均發電度數 (30天)

0.00

@@ -97,6 +97,45 @@
+ @if (ViewBag.myUser.Role.Auths.Contains("ShowMoney")) + { +
+
+

自建躉售

+
NTD
+
+
+
+

今日發電金額

+

0.00

+
+
+
+
+
+

租建躉售

+
NTD
+
+
+
+

今日發電金額

+

0.00

+
+
+
+
+
+

自發自用

+
NTD
+
+
+
+

今日省電金額

+

0.00

+
+
+
+ }
@@ -256,16 +295,24 @@ $("#avg_kwhkwp").html(toThousands(mapOverview.avg_kwhkwp.toFixed(2))); $("#today_carbon").html(toThousands(mapOverview.today_carbon.toFixed(2))); $("#total_carbon").html(toThousands(mapOverview.total_carbon.toFixed(2))); + @if (ViewBag.myUser.Role.Auths.Contains("ShowMoney")) + { + + $('#today_kwh_money_by_myself').html(toThousands(mapOverview.today_solarTypeMoney_self_built_wholesale.toFixed(2))); + $('#today_kwh_money_from_tenant').html(toThousands(mapOverview.today_solarTypeMoney_tenant_built_wholesale.toFixed(2))); + $('#today_kwh_money_save_power').html(toThousands(mapOverview.today_solarTypeMoney_self_build.toFixed(2))); + + } $("#total_power_station_count").html(toThousands(mapOverview.totalPowerStationCount)); $("#total_capacity").html(toThousands(mapOverview.totalCapacity.toFixed(3))); $("#update_at").html(mapOverview.updatedAt); - capacityTable.clear().rows.add(mapOverview.capacityDataTables).draw(); + capacityTable.clear().rows.add(mapOverview.capacityDataTables).draw(); - //#region google map - initMap(); - //#endregion - }); + //#region google map + initMap(); + //#endregion + }); }); function initMap() {