diff --git a/SolarPower/Controllers/MapOverviewController.cs b/SolarPower/Controllers/MapOverviewController.cs index e1d6a87..fe2a568 100644 --- a/SolarPower/Controllers/MapOverviewController.cs +++ b/SolarPower/Controllers/MapOverviewController.cs @@ -1,19 +1,92 @@ using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; using SolarPower.Models; +using SolarPower.Models.PowerStation; +using SolarPower.Repository.Interface; using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Net; using System.Threading.Tasks; +using System.Xml.Linq; namespace SolarPower.Controllers { - public class MapOverviewController : Controller + public class MapOverviewController : MyBaseController { + private readonly IOverviewRepository overviewRepository; + private readonly IPowerStationRepository powerStationRepository; + + public MapOverviewController( + IOverviewRepository overviewRepository, + IPowerStationRepository powerStationRepository) : base() + { + this.overviewRepository = overviewRepository; + this.powerStationRepository = powerStationRepository; + } + + public IActionResult Index() { return View(); } + [HttpPost] + public async Task> GetMapOverview() + { + ApiResult apiResult = new ApiResult(); + + MapOverview mapOverview = new MapOverview(); + try + { + List powerStationIds = new List() { 1, 2, 3}; + var overview = await overviewRepository.GetOverviewByPowerStationIds(powerStationIds); + 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(powerStationIds); + + 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; + } + //public async Task> GetAllDate() //{ // ApiResult apiResult = new ApiResult(); diff --git a/SolarPower/DBSchema/solar_power_schema.sql b/SolarPower/DBSchema/solar_power_schema.sql index 995cc26..49abf99 100644 --- a/SolarPower/DBSchema/solar_power_schema.sql +++ b/SolarPower/DBSchema/solar_power_schema.sql @@ -894,6 +894,88 @@ COMMENT='運維紀錄 檔案 or 圖片' COLLATE='utf8_general_ci' ENGINE=InnoDB; +-- 創建 電站每小時歷史資料 20210702 +CREATE TABLE `power_station_history_hour` ( + `Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號', + `TIMESTAMP` BIGINT(20) NULL DEFAULT NULL, + `SITEID` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci', + `SITETYPE` INT(11) NULL DEFAULT NULL, + `KWH` DOUBLE NULL DEFAULT NULL, + `TODAYKWH` DOUBLE NULL DEFAULT NULL, + `TOTALKWH` DOUBLE NULL DEFAULT NULL, + `KWHKWP` DOUBLE NULL DEFAULT NULL, + `PR` DOUBLE NULL DEFAULT NULL, + `MP` DOUBLE NULL DEFAULT NULL, + `SOLARHOUR` DOUBLE NULL DEFAULT NULL, + PRIMARY KEY (`Id`) USING BTREE, + INDEX `IDX_01` (`PowerStationId`) USING BTREE +) +COMMENT='各電站每小時的歷史記錄' +COLLATE='utf8mb4_unicode_ci' +ENGINE=InnoDB +; + + +-- 修改 power_station 欄位 20210702 +ALTER TABLE `power_station` + ADD COLUMN `today_kwhkwp` DECIMAL(10,3) NULL DEFAULT NULL COMMENT '今日kwhkwp' AFTER `Total_kwh`, + ADD COLUMN `avg_kwhkwp` DECIMAL(10,3) NULL DEFAULT NULL COMMENT '30天平均kwhkwp' AFTER `today_kwhkwp`, + ADD COLUMN `today_monery` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '今日金額' AFTER `avg_kwhkwp`, + ADD COLUMN `total_monery` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '總金額' AFTER `today_monery`, + ADD COLUMN `today_PR` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '電站Pr值' AFTER `total_monery`, + ADD COLUMN `avg_PR` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '平均Pr值' AFTER `today_PR`, + ADD COLUMN `today_carbon` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '今日減碳量' AFTER `avg_PR`, + ADD COLUMN `total_carbon` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '總減碳量' AFTER `today_carbon`, + ADD COLUMN `today_irradiance` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '今日日照度' AFTER `total_carbon`, + ADD COLUMN `avg_irradiance` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '平均日照度' AFTER `today_irradiance`, + DROP COLUMN `kwhkwp`, + DROP COLUMN `PR`, + DROP COLUMN `MP`; + +-- 創建 電站每天歷史資料 20210706 +CREATE TABLE `power_station_history_day` ( + `Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號', + `TIMESTAMP` TIMESTAMP NULL DEFAULT NULL, + `SITEID` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci', + `SITETYPE` INT(11) NULL DEFAULT NULL, + `TODAYKWH` DOUBLE NULL DEFAULT NULL, + `TOTALKWH` DOUBLE NULL DEFAULT NULL, + `KWHKWP` DOUBLE NULL DEFAULT NULL, + `PR` DOUBLE NULL DEFAULT NULL, + `MP` DOUBLE NULL DEFAULT NULL, + `SOLARHOUR` DOUBLE NULL DEFAULT NULL, + PRIMARY KEY (`Id`) USING BTREE, + INDEX `IDX_01` (`PowerStationId`) USING BTREE +) +COMMENT='各電站每天的歷史記錄' +COLLATE='utf8mb4_unicode_ci' +ENGINE=InnoDB +; + +-- 創建 電站每月歷史資料 20210706 +CREATE TABLE `power_station_history_month` ( + `Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號', + `TIMESTAMP` TIMESTAMP NULL DEFAULT NULL, + `SITEID` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci', + `SITETYPE` INT(11) NULL DEFAULT NULL, + `MONTHKWH` DOUBLE NULL DEFAULT NULL, + `TOTALKWH` DOUBLE NULL DEFAULT NULL, + `KWHKWP` DOUBLE NULL DEFAULT NULL, + `PR` DOUBLE NULL DEFAULT NULL, + `MP` DOUBLE NULL DEFAULT NULL, + `SOLARHOUR` DOUBLE NULL DEFAULT NULL, + PRIMARY KEY (`Id`) USING BTREE, + INDEX `IDX_01` (`PowerStationId`) USING BTREE +) +COMMENT='各電站每月的歷史記錄' +COLLATE='utf8mb4_unicode_ci' +ENGINE=InnoDB +; + + -- 修改 電站資料 更新時間預設值 ALTER TABLE `power_station` CHANGE COLUMN `UpdatedAt` `UpdatedAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP COMMENT '修改時間' AFTER `UpdatedBy`; diff --git a/SolarPower/Models/MapOverview.cs b/SolarPower/Models/MapOverview.cs deleted file mode 100644 index 959535b..0000000 --- a/SolarPower/Models/MapOverview.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace SolarPower.Models -{ - public class MapOverview - { - } -} diff --git a/SolarPower/Models/Overview.cs b/SolarPower/Models/Overview.cs index b08f419..34bfb3c 100644 --- a/SolarPower/Models/Overview.cs +++ b/SolarPower/Models/Overview.cs @@ -2,12 +2,38 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using SolarPower.Models.PowerStation; namespace SolarPower.Models { public class Overview { - public int PR; + public double Today_kwh { get; set; } //今日總發電量 + public double Total_kwh { get; set; } //累計總發電量 + public double Today_irradiance { get; set; } //即時平均日照度 + public double Avg_irradiance { get; set; } //平均日照度(30天) + public double Today_PR { get; set; } //即時平均 PR 值 + 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_carbon { get; set; } //今日減碳量 + public double Total_carbon { get; set; } //累積減碳量 + } + + public class MapOverview : Overview + { + public List CapacityDataTables { get; set; } + public List PowerStations { get; set; } + public int TotalPowerStationCount { get; set; } + public double TotalCapacity { get; set; } + public string UpdatedAt { get; set; } //畫面資料更新時間 + } + + public class CapacityDataTable + { + public string CityName { get; set; } //城市名稱 + public int SubPowerStationCount { get; set; } //電站數量 + public double SubTotalCapacity { get; set; } //總裝置容量 } public class UseStatusCityGetPowerStation @@ -15,4 +41,5 @@ namespace SolarPower.Models public List CityId; //都市 public List Status; //狀態 } + } diff --git a/SolarPower/Models/PowerStation.cs b/SolarPower/Models/PowerStation.cs index a900ae4..c243ffd 100644 --- a/SolarPower/Models/PowerStation.cs +++ b/SolarPower/Models/PowerStation.cs @@ -6,6 +6,12 @@ using System.Threading.Tasks; namespace SolarPower.Models.PowerStation { + public enum SolarTypeEnum : byte + { + SelfSold = 0, //自建躉售 + HireSold = 1, //租建躉售 + SelfUse = 2 //自建自用 + } public class PowerStation : Created { private string electricityMeterAt = "", tpcContractAt = "", tpcPurchaseElectricityAt = "", tpcSellElectricityAt = ""; @@ -16,6 +22,7 @@ namespace SolarPower.Models.PowerStation public int CityId { get; set; } //縣市 public string CityName { get; set; } //縣市名稱 public int AreaId { get; set; } //地區 + public string AreaName { get; set; } //地區 public string Address { get; set; } //地址 public string Name { get; set; } //名稱 public string MainDisplay { get; set; } //主要顯示圖片 @@ -106,11 +113,16 @@ namespace SolarPower.Models.PowerStation public List LandBuildings { get; set; } //土地房屋資料 public byte SolarType { get; set; } //電站類型 public double kwh { get; set; } // - public double Today_kwh { get; set; } //今日發電量 - public double Total_kwh { get; set; } //總發電量 - public double kwhkwp { get; set; } - public double PR { get; set; } - public double MP { get; set; } + public double Today_kWh { get; set; } //今日發電量 + public double Total_kWh { get; set; } //總發電量 + public double Today_Monery { get; set; } //今日發電金額 + public double Total_Monery { get; set; } //總發電金額 + public double Today_kwhkwp { get; set; } + public double Avg_kwhkwp { get; set; } + public double Today_PR { get; set; } + public double Avg_PR { get; set; } + public double Today_Carbon { get; set; } //今日減碳量 + public double Total_Carbon { get; set; } //總減碳量 public double SolarHour { get; set; } //總運轉小時 public string SiteDB { get; set; } //電站 DB name: solar_com public string TodayWeather { get; set; } //今日天氣 @@ -553,4 +565,58 @@ namespace SolarPower.Models.PowerStation public int PowerStationId { get; set; } public int DeviceId { get; set; } } + + public class PowerStationHistory + { + public int PowerStationId { get; set; } + public Int64 Timestamp { get; set; } + public string SITEID { get; set; } + public string SiteType { get; set; } + public double KWH { get; set; } + public double TodayKWh { get; set; } + public double TotalKWH { get; set; } + public double KWHKWP { get; set; } + public double PR { get; set; } + public double MP { get; set; } + public double SolarHour { get; set; } + } + + public class AvgPowerStationHistory + { + public int PowerStationId { get; set; } + public double AvgKWHKWP { get; set; } + public double AvgPR { get; set; } + + } + + public class PowerStationHistoryDay + { + public int PowerStationId { get; set; } + public string Timestamp { get; set; } + public string SITEID { get; set; } + public string SiteType { get; set; } + public double TodayKWh { get; set; } + public double TotalKWH { get; set; } + public double KWHKWP { get; set; } + public double PR { get; set; } + public double MP { get; set; } + public double SolarHour { get; set; } + } + + public class PowerStationHistoryMonth + { + public int PowerStationId { get; set; } + public string Timestamp { get; set; } + public string SITEID { get; set; } + public string SiteType { get; set; } + public double MONTHKWH { get; set; } + public double TotalKWH { get; set; } + public double KWHKWP { get; set; } + public double PR { get; set; } + public double MP { get; set; } + public double SolarHour { get; set; } + } + + + } diff --git a/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs b/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs new file mode 100644 index 0000000..02e38cd --- /dev/null +++ b/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs @@ -0,0 +1,175 @@ +using Microsoft.Extensions.Logging; +using Quartz; +using SolarPower.Models.PowerStation; +using SolarPower.Repository.Interface; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace SolarPower.Quartz.Jobs +{ + [DisallowConcurrentExecution] + public class CalcAvgPowerStationJob : IJob + { + private readonly ILogger logger; + private readonly IPowerStationRepository powerStationRepository; + + public CalcAvgPowerStationJob(ILogger logger, IPowerStationRepository powerStationRepository) + { + this.logger = logger; + this.powerStationRepository = powerStationRepository; + } + + public async Task Execute(IJobExecutionContext context) + { + try + { + #region step1. 找出所有電站 + var powerStations = await powerStationRepository.GetAllAsync(); + #endregion + + List powerStationHistoryDays = new List(); + List calcAvgPowerStations = new List(); + + List insertPowerStationHistoryMonths = new List(); + List updatePowerStationHistoryMonths = new List(); + + var DateTimeNow = DateTime.Now; + + #region step2. 從電站的DB及電站編號找出該電站的控制器 + foreach (var powerStation in powerStations) + { + #region step2-1. 取得該電站的30天平均資料 + var table_name = String.Format("`{0}`.`{1}01_ficstationhistory`", powerStation.SiteDB, powerStation.Code); + var dateNowDay = DateTimeNow.AddDays(-1).ToString("yyyy-MM-dd"); + + dateNowDay = "2021-06-24"; + var history = await powerStationRepository.GetAvgPowerStationHistory30day(dateNowDay, table_name); + + if (history != null) + { + history.PowerStationId = powerStation.Id; + + #region 計算電站30天的 kWh/kWp 與 PR 值 + var calcPowerStation = new PowerStation(); + calcPowerStation.Id = powerStation.Id; + + #region 平均kWh/kWp + //直接填寫 + calcPowerStation.Avg_kwhkwp = history.AvgKWHKWP; + #endregion + + #region 平均PR + //直接填寫 + calcPowerStation.Avg_PR = history.AvgPR; + #endregion + + + #endregion + + calcAvgPowerStations.Add(calcPowerStation); + } + #endregion + + #region step2-2. 計算昨天的所有值總和 + var historyDay = await powerStationRepository.GetLastOnePowerStationHistoryByDay(dateNowDay, table_name); + if(historyDay != null) + { + historyDay.PowerStationId = powerStation.Id; + powerStationHistoryDays.Add(historyDay); + } + #endregion + + #region step2-3. 計算這個月的所有值總和 + //判斷這個月是否已存在 + var dateNowMonth = DateTimeNow.ToString("yyyy-MM"); + dateNowMonth = "2021-06"; + + var exist = await powerStationRepository.GetOnePowerStationHistoryByPowerStationIdAndMonth(powerStation.Id, dateNowMonth); + + if (exist == null) + { //新增 + var historyMonth = await powerStationRepository.GetPowerStationHistoryMonthDataByPowerStationId(powerStation.Id, dateNowMonth); + if(historyMonth != null) + { + historyMonth.Timestamp = Convert.ToDateTime(historyMonth.Timestamp).ToString("yyyy-MM-dd"); + + insertPowerStationHistoryMonths.Add(historyMonth); + } + } + else + { //修改 + var historyMonth = await powerStationRepository.GetPowerStationHistoryMonthDataByPowerStationId(powerStation.Id, dateNowMonth); + if (historyMonth != null) + { + updatePowerStationHistoryMonths.Add(historyMonth); + } + } + #endregion + } + #endregion + + //TODO 日照 + #region step3. calcPowerStations UPDATE 到 power_station 資料表 + List power_station_properties = new List() + { + "Id", + "avg_kwhkwp", + "avg_PR", + }; + + await powerStationRepository.UpdateList(calcAvgPowerStations, power_station_properties); + #endregion + + #region step4. 將各電站的每日及月的資料insert or update 個資料表 + //每日 + List history_properties_day = new List() + { + "PowerStationId", + "TIMESTAMP", + "SITEID", + "SITETYPE", + "TODAYKWH", + "TOTALKWH", + "KWHKWP", + "PR", + "MP", + "SolarHour" + }; + + await powerStationRepository.AddPowerStationHistoryDayList(powerStationHistoryDays, history_properties_day); + + List history_properties_month = new List() + { + "PowerStationId", + "TIMESTAMP", + "SITEID", + "SITETYPE", + "MonthKWh", + "TOTALKWH", + "KWHKWP", + "PR", + "MP", + "SolarHour" + }; + + if(insertPowerStationHistoryMonths.Count > 0) + { + await powerStationRepository.AddPowerStationHistoryMonthList(insertPowerStationHistoryMonths, history_properties_month); + } + + if (updatePowerStationHistoryMonths.Count > 0) + { + await powerStationRepository.UpdatePowerStationHistoryMonthList(updatePowerStationHistoryMonths); + } + #endregion + + } + catch (Exception exception) + { + logger.LogError("【{0}】{1}", "CalcAvgPowerStationJob", exception.Message); + } + } + } +} diff --git a/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs new file mode 100644 index 0000000..eece056 --- /dev/null +++ b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs @@ -0,0 +1,192 @@ +using Microsoft.Extensions.Logging; +using Quartz; +using SolarPower.Models.PowerStation; +using SolarPower.Repository.Interface; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace SolarPower.Quartz.Jobs +{ + [DisallowConcurrentExecution] + public class CalcPowerStationJob : IJob + { + private readonly ILogger logger; + private readonly IPowerStationRepository powerStationRepository; + + private double carbonRate; + + public CalcPowerStationJob(ILogger logger, IPowerStationRepository powerStationRepository) + { + this.logger = logger; + this.powerStationRepository = powerStationRepository; + } + + public async Task Execute(IJobExecutionContext context) + { + try + { + #region step1. 找出所有電站 + var powerStations = await powerStationRepository.GetAllAsync(); + #endregion + + List powerStationHistoriesHour = new List(); + List calcPowerStations = new List(); + + var DateTimeNow = DateTime.Now; + + #region step2. 從電站的DB及電站編號找出該電站的控制器 + var count = 0; + foreach (var powerStation in powerStations) + { + if(count > 0) + { + break; + } + #region step2-1. 取得該電站的當前這小時的歷史資料 + var table_name = String.Format("`{0}`.{1}01_ficstationhistory", powerStation.SiteDB, powerStation.Code); + var dateTime = DateTimeNow.AddHours(-1).ToString("yyyy-MM-dd HH"); + + dateTime = "2021-06-24 18"; + var history = await powerStationRepository.GetPowerStationHistoryPerHour(dateTime, table_name); + + if (history != null) + { + history.PowerStationId = powerStation.Id; + + #region 計算單一電站每小時發電量、發電金額等資料 + var calcPowerStation = new PowerStation(); + calcPowerStation.Id = powerStation.Id; + + calcPowerStation.kwh = history.KWH; + + #region 發電量 + //今日發電量(直接填寫 + calcPowerStation.Today_kWh = history.TodayKWh; + //總發電量(直接填寫 + calcPowerStation.Total_kWh = history.TotalKWH; + #endregion + + //TODO + #region 日照度 + //1. 找出該電站所有日照計設備(包還共享 + //2. 透過該DB、col取得到是哪一個sensor + #endregion + + #region 發電金額 + //發電金額 + switch (powerStation.SolarType) + { + case (int)SolarTypeEnum.SelfSold: //自建躉售 + //今日發電金額 計算方式:todaykWh * 授電費率 + calcPowerStation.Today_Monery = history.TodayKWh * powerStation.PowerRate; + + //總發電金額 計算方式:totalkWh * 授電費率 + calcPowerStation.Total_Monery = history.TotalKWH * powerStation.PowerRate; + break; + case (int)SolarTypeEnum.HireSold: //租建躉售 + //找出該電站的所有土地房屋資訊 + var landBuildings = await powerStationRepository.GetAllLandBuildingInfoByPowerStationId(powerStation.Id, powerStation.SiteDB); + var sumLeaseRate = 0.00; + var avgLeaseRate = 0.00; + + foreach (var landBuilding in landBuildings) + { + sumLeaseRate += landBuilding.LeaseRate; + } + avgLeaseRate = sumLeaseRate / landBuildings.Count(); + + //今日發電金額計算方式:todaykWh * 出借費率(各個土地房屋租借比率平均) + calcPowerStation.Today_Monery = history.TodayKWh * avgLeaseRate; + + //總發電金額 計算方式:totalkWh * 授電費率 + calcPowerStation.Total_Monery = history.TotalKWH * avgLeaseRate; + break; + case (int)SolarTypeEnum.SelfUse: //自建自用 + //今日發電金額 計算方式:todaykWh * 授電費率 + calcPowerStation.Today_Monery = history.TodayKWh * powerStation.PowerRate; + + //總發電金額 計算方式:totalkWh * 授電費率 + calcPowerStation.Total_Monery = history.TotalKWH * powerStation.PowerRate; + break; + } + #endregion + + #region kWh/kWp + //直接填寫 + calcPowerStation.Today_kwhkwp = history.KWHKWP; + #endregion + + #region PR + //直接填寫 + calcPowerStation.Today_PR = history.PR; + #endregion + + #region 減碳量 + carbonRate = Convert.ToDouble(await powerStationRepository.GetOneVariableByName("CarbonRate")); + + //今日減碳量( 今日發電量 * (0.554/1000)[抓資料庫值] + calcPowerStation.Today_Carbon = history.TodayKWh * carbonRate; + //總減碳量(總發電量 * (0.554/1000)[抓資料庫值] + calcPowerStation.Total_Carbon = history.TotalKWH * carbonRate; + #endregion + + #endregion + + powerStationHistoriesHour.Add(history); + calcPowerStations.Add(calcPowerStation); + } + #endregion + + count++; + } + #endregion + + #region step3. 將historiers INSERT 到 power_station_history_hour 資料表 + + List history_properties = new List() + { + "PowerStationId", + "TIMESTAMP", + "SITEID", + "SITETYPE", + "KWH", + "TODAYKWH", + "TOTALKWH", + "KWHKWP", + "PR", + "MP", + "SolarHour" + }; + + await powerStationRepository.AddPowerStationHistory(powerStationHistoriesHour, history_properties); + #endregion + + //TODO 日照 + #region step4. calcPowerStations UPDATE 到 power_station 資料表 + List power_station_properties = new List() + { + "Id", + "kwh", + "Today_kwh", + "Total_kwh", + "today_kwhkwp", + "today_monery", + "total_monery", + "today_PR", + "today_carbon", + "total_carbon", + }; + + await powerStationRepository.UpdateList(calcPowerStations, power_station_properties); + #endregion + + } + catch (Exception exception) + { + logger.LogError("【{0}】{1}", "CalcPowerStationJob", exception.Message); + } + } + } +} diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs index ed065da..1620e6b 100644 --- a/SolarPower/Repository/Implement/OverviewRepository.cs +++ b/SolarPower/Repository/Implement/OverviewRepository.cs @@ -18,6 +18,106 @@ namespace SolarPower.Repository.Implement tableName = "power_station"; } + public async Task> GetAllCityIdAsync() + { + List result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = $"SELECT Id FROM city"; + + result = (await conn.QueryAsync(sql)).ToList(); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + + public async Task GetOverviewByPowerStationIds(List powerStationIds) + { + Overview result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = @$"SELECT + SUM(ps.Today_kwh) AS Today_kwh, + SUM(ps.Total_kwh) AS Total_kwh, + AVG(ps.Today_irradiance) AS today_irradiance, + AVG(ps.avg_irradiance) AS avg_irradiance, + AVG(ps.today_PR) AS today_PR, + AVG(ps.avg_PR) AS avg_PR, + AVG(ps.today_kwhkwp) AS today_kwhkwp, + AVG(ps.avg_kwhkwp) AS avg_kwhkwp, + SUM(ps.today_carbon) AS today_carbon, + SUM(ps.total_carbon) AS total_carbon + FROM power_station ps + WHERE ps.Id IN @PowerStationIds + "; + + result = await conn.QueryFirstOrDefaultAsync(sql, new { PowerStationIds = powerStationIds }); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + + } + + public async Task> GetCapacityDataTableByPowerStationIds(List powerStationIds) + { + List result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = @$"SELECT + ps.CityId, + c.Name AS CityName, + COUNT(*) AS SubPowerStationCount, + SUM(ps.GeneratingCapacity) AS SubTotalCapacity + FROM power_station ps + LEFT JOIN city c ON ps.CityId = c.Id + WHERE ps.Id IN @PowerStationIds + GROUP BY ps.CityId + "; + + result = (await conn.QueryAsync(sql, new { PowerStationIds = powerStationIds })).ToList(); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + + public async Task> GetListPowerStationByPowerStationIds(List powerStationIds) + { + List result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = @$"SELECT * FROM power_station ps WHERE ps.Id IN @PowerStationIds + "; + + result = (await conn.QueryAsync(sql, new { PowerStationIds = powerStationIds })).ToList(); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + public async Task> GetSolarByCity(MyUser User, UseStatusCityGetPowerStation post) { using IDbConnection conn = _databaseHelper.GetConnection(); diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index cb6caaf..181a1ba 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -168,6 +168,25 @@ namespace SolarPower.Repository.Implement } } + public override async Task> GetAllAsync() + { + List result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = $"SELECT * FROM {tableName} WHERE Deleted = 0"; + + result = (await conn.QueryAsync(sql)).ToList(); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + /// /// 透過電站編號,取得單一電站資訊(覆寫) /// @@ -342,6 +361,33 @@ namespace SolarPower.Repository.Implement } } + /// + /// 透過電站編號,取得所有土地房屋資訊 + /// + /// + /// + /// + public async Task> GetAllLandBuildingInfoByPowerStationId(int id, string db_name) + { + List result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = @$"SELECT lb.*, u.Name AS CreatorName FROM {db_name}.land_building lb + LEFT JOIN user u ON lb.CreatedBy = u.Id + WHERE lb.Deleted = 0 AND PowerStationId = @PowerStationId"; + + result = (await conn.QueryAsync(sql, new { PowerStationId = id })).ToList(); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + /// /// 取得 土地房屋資訊 /// @@ -659,7 +705,7 @@ namespace SolarPower.Repository.Implement var trans = conn.BeginTransaction(); try { - + string sql = GenerateInsertQueryWithCustomDBNameAndTable(properties, db_name, "device"); await conn.ExecuteAsync(sql, DeviceInfo); trans.Commit(); @@ -674,7 +720,7 @@ namespace SolarPower.Repository.Implement conn.Close(); } } - + } /// @@ -773,7 +819,7 @@ namespace SolarPower.Repository.Implement conn.Open(); try { - string sql = GenerateInsertQueryWithCustomDBNameAndTable(properties,db_name,"power_station_exception"); + string sql = GenerateInsertQueryWithCustomDBNameAndTable(properties, db_name, "power_station_exception"); await conn.ExecuteAsync(sql, Exception); @@ -856,7 +902,7 @@ namespace SolarPower.Repository.Implement var trans = conn.BeginTransaction(); try { - var updateQuery = GenerateUpdateQueryWithCustomDBNameAndTable(properties,db_name,"power_station_exception"); + var updateQuery = GenerateUpdateQueryWithCustomDBNameAndTable(properties, db_name, "power_station_exception"); await conn.ExecuteAsync(updateQuery.ToString(), Exception, trans); trans.Commit(); } @@ -1163,7 +1209,7 @@ namespace SolarPower.Repository.Implement "MainDisplay" }; - if(image.IsMainDisplay == 1) + if (image.IsMainDisplay == 1) { //修改主資料庫 sql_MainDispalyImg = GenerateUpdateQuery(powerStationMainDispalyImg); @@ -1351,7 +1397,7 @@ namespace SolarPower.Repository.Implement try { var ids = ""; - foreach(var id in CityId) + foreach (var id in CityId) { ids = ids + id + ","; } @@ -1361,19 +1407,33 @@ namespace SolarPower.Repository.Implement } if (User.Role.Layer == 0 || User.Role.Layer == 1) { - var sql = "SELECT * FROM power_station WHERE CityId IN @IDs"; + var sql = @"SELECT ps.* , c.Name AS CityName, a.Name AS AreaName + FROM power_station ps + LEFT JOIN city c ON ps.CityId = c.Id + LEFT JOIN area a ON ps.AreaId = a.Id + WHERE ps.CityId IN @IDs"; powerstation = (await conn.QueryAsync(sql, new { IDs = CityId })).ToList(); trans.Commit(); } else if (User.Role.Layer == 2) { - var sql = "SELECT * FROM power_station WHERE CityId IN @IDs AND CompanyId=@CompanyId"; - powerstation = (await conn.QueryAsync(sql, new { IDs = CityId,CompanyId = User.CompanyId })).ToList(); + var sql = @"SELECT ps.* , c.Name AS CityName, a.Name AS AreaName + FROM power_station ps + LEFT JOIN city c ON ps.CityId = c.Id + LEFT JOIN area a ON ps.AreaId = a.Id + WHERE ps.CityId IN @IDs + AND ps.CompanyId=@CompanyId"; + powerstation = (await conn.QueryAsync(sql, new { IDs = CityId, CompanyId = User.CompanyId })).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"; + var sql = @"SELECT ps.* , c.Name AS CityName, a.Name AS AreaName + FROM power_station ps + LEFT JOIN city c ON ps.CityId = c.Id + LEFT JOIN area a ON ps.AreaId = a.Id + LEFT JOIN power_station_operation_personnel psop ON ps.Id = psop.PowerStationId + WHERE ps.CityId IN @IDs AND psop.Userid = @UserId"; powerstation = (await conn.QueryAsync(sql, new { IDs = CityId, UserId = User.Id })).ToList(); trans.Commit(); } @@ -1510,7 +1570,7 @@ namespace SolarPower.Repository.Implement /// /// /// - public async Task> GetAllDeviceControllerId(int stationId,string db_name) + public async Task> GetAllDeviceControllerId(int stationId, string db_name) { using (IDbConnection conn = _databaseHelper.GetConnection()) { @@ -1532,6 +1592,36 @@ namespace SolarPower.Repository.Implement return count; } } + + /// + /// 透過電站Id,取得所有控制器編碼 + /// + /// + /// + /// + public async Task> GetAllDeviceControllerByPowerStationId(int stationId, string db_name) + { + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + List result; + conn.Open(); + try + { + string sql = $"SELECT ControllerId FROM {db_name}.controller WHERE PowerStationId = {stationId}"; + result = (await conn.QueryAsync(sql)).ToList(); + } + catch (Exception exception) + { + throw exception; + } + finally + { + conn.Close(); + } + return result; + } + } + /// /// 逆變器DataTable /// @@ -1572,7 +1662,7 @@ namespace SolarPower.Repository.Implement /// 其餘電站列表 /// /// - public async Task> GetPowerstationOptionAsync(string db_name,int stationId) + public async Task> GetPowerstationOptionAsync(string db_name, int stationId) { List result; using (IDbConnection conn = this._databaseHelper.GetConnection()) @@ -1721,5 +1811,325 @@ namespace SolarPower.Repository.Implement return result; } } + + public async Task GetPowerStationHistoryPerHour(string dateTime, string table_name) + { + PowerStationHistory result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = $@" + SELECT * FROM {table_name} WHERE DATE_FORMAT(FROM_UNIXTIME(timestamp / 1000), '%Y-%m-%d %H') = @DateTime +"; + + result = await conn.QueryFirstOrDefaultAsync(sql, new { DateTime = dateTime }); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + + public async Task GetAvgPowerStationHistory30day(string nowDay, string table_name) + { + AvgPowerStationHistory result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var startDay = Convert.ToDateTime(nowDay).AddDays(-30).ToString("yyyy-MM-dd"); + + var sql = $@"SELECT AVG(s.KWHKWP) AS AvgKWHKWP, AVG(s.PR) AS AvgPR + FROM {table_name} s + WHERE DATE_FORMAT(FROM_UNIXTIME(s.TIMESTAMP/1000), '%Y-%m-%d %H') IN ( + SELECT MAX(DATE_FORMAT(FROM_UNIXTIME(s.TIMESTAMP/1000), '%Y-%m-%d %H')) FROM {table_name} s + WHERE DATE_FORMAT(FROM_UNIXTIME(s.TIMESTAMP/1000), '%Y-%m-%d') BETWEEN @StartDay AND @EndDay + GROUP BY DATE_FORMAT(FROM_UNIXTIME(s.TIMESTAMP/1000), '%Y-%m-%d')) + "; + + result = await conn.QueryFirstOrDefaultAsync(sql, new { StartDay = startDay, EndDay = nowDay }); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + + public async Task AddPowerStationHistory(List entity, List properties) + { + int count; + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + conn.Open(); + using (var trans = conn.BeginTransaction()) + { + try + { + string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_history_hour"); + + count = await conn.ExecuteAsync(sql, entity, trans); + + trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + + return count; + } + } + + public async Task UpdateList(List entity, List properties) + { + int count; + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + conn.Open(); + using (var trans = conn.BeginTransaction()) + { + try + { + string sql = GenerateUpdateQuery(properties); + + count = await conn.ExecuteAsync(sql, entity, trans); + + trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + + return count; + } + } + + /// + /// 透過日期,取得最後一筆資料 + /// + /// + /// + /// + public async Task GetLastOnePowerStationHistoryByDay(string day, string table_name) + { + PowerStationHistoryDay result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = $@"SELECT + DATE_FORMAT(FROM_UNIXTIME(s.TIMESTAMP/1000), '%Y-%m-%d %H') AS TIMESTAMP, + s.SITEID, + s.SITETYPE, + s.TodayKWh, + s.TotalKWH, + s.KWHKWP, + s.PR, + s.MP, + s.SolarHour + FROM {table_name} s + WHERE DATE_FORMAT(FROM_UNIXTIME(s.TIMESTAMP/1000), '%Y-%m-%d') = @Day + ORDER BY TIMESTAMP DESC + LIMIT 1 + "; + + result = await conn.QueryFirstOrDefaultAsync(sql, new { Day = day }); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + + /// + /// 新增資料,至每日的電站歷史記錄 + /// + /// + /// + /// + public async Task AddPowerStationHistoryDayList(List entity, List properties) + { + int count; + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + conn.Open(); + using (var trans = conn.BeginTransaction()) + { + try + { + string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_history_day"); + + count = await conn.ExecuteAsync(sql, entity, trans); + + trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + + return count; + } + } + + public async Task GetOnePowerStationHistoryByPowerStationIdAndMonth(int powerStationId, string month) + { + PowerStationHistoryMonth result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = $@"SELECT * + FROM power_station_history_month s + WHERE PowerStationId = @PowerStationId + AND DATE_FORMAT(s.TIMESTAMP, '%Y-%m')= @Month + "; + + result = await conn.QueryFirstOrDefaultAsync(sql, new { PowerStationId = powerStationId, Month = month }); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + + public async Task GetPowerStationHistoryMonthDataByPowerStationId(int powerStationId, string month) + { + PowerStationHistoryMonth result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = $@"SELECT + PowerStationId, + DATE_FORMAT(s.TIMESTAMP, '%Y-%m') AS TIMESTAMP, + s.SITEID, + s.SITETYPE, + SUM(s.TODAYKWH) AS MONTHKWH, + MAX(s.TOTALKWH) AS TOTALKWH, + AVG(s.KWHKWP) AS KWHKWP, + AVG(s.PR) AS PR, + AVG(s.MP) AS MP, + SUM(s.SOLARHOUR) AS SOLARHOUR + FROM power_station_history_day s + WHERE DATE_FORMAT(s.TIMESTAMP, '%Y-%m') = @Month + AND PowerStationId = @PowerStationId + GROUP BY PowerStationId,DATE_FORMAT(s.TIMESTAMP, '%Y-%m') + "; + + result = await conn.QueryFirstOrDefaultAsync(sql, new { PowerStationId = powerStationId, Month = month }); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + + /// + /// 新增資料,至每月的電站歷史記錄 + /// + /// + /// + /// + public async Task AddPowerStationHistoryMonthList(List entity, List properties) + { + int count; + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + conn.Open(); + using (var trans = conn.BeginTransaction()) + { + try + { + string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_history_month"); + + count = await conn.ExecuteAsync(sql, entity, trans); + + trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + + return count; + } + } + + public async Task UpdatePowerStationHistoryMonthList(List entity) + { + int count; + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + conn.Open(); + using (var trans = conn.BeginTransaction()) + { + try + { + string sql = @"UPDATE power_station_history_month SET + MonthKWh=@MonthKWh, + TOTALKWH=@TOTALKWH, + KWHKWP=@KWHKWP, + PR=@PR, + MP=@MP, + SolarHour=@SolarHour + WHERE PowerStationId = @PowerStationId + AND TIMESTAMP LIKE CONCAT(@TIMESTAMP, '%') +"; + + count = await conn.ExecuteAsync(sql, entity, trans); + + trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + + return count; + } + } } } diff --git a/SolarPower/Repository/Implement/RepositoryBase.cs b/SolarPower/Repository/Implement/RepositoryBase.cs index 6341e07..b5f44ff 100644 --- a/SolarPower/Repository/Implement/RepositoryBase.cs +++ b/SolarPower/Repository/Implement/RepositoryBase.cs @@ -417,7 +417,7 @@ namespace SolarPower.Repository.Implement { try { - var sql = $"SELECT * FROM variable WHERE Name = @Name"; + var sql = $"SELECT Value FROM variable WHERE Name = @Name"; result = await conn.QueryFirstOrDefaultAsync(sql, new { Name = name }); } diff --git a/SolarPower/Repository/Interface/IOverviewRepository.cs b/SolarPower/Repository/Interface/IOverviewRepository.cs index fa035a2..b116d04 100644 --- a/SolarPower/Repository/Interface/IOverviewRepository.cs +++ b/SolarPower/Repository/Interface/IOverviewRepository.cs @@ -10,6 +10,11 @@ namespace SolarPower.Repository.Interface { public interface IOverviewRepository : IRepositoryBase { + + Task> GetAllCityIdAsync(); + Task GetOverviewByPowerStationIds(List powerStationIds); + Task> GetCapacityDataTableByPowerStationIds(List powerStationIds); + Task> GetListPowerStationByPowerStationIds(List powerStationIds); Task> GetSolarByCity(MyUser User, UseStatusCityGetPowerStation post); } } diff --git a/SolarPower/Repository/Interface/IPowerStationRepository.cs b/SolarPower/Repository/Interface/IPowerStationRepository.cs index 1c257e2..b8960a9 100644 --- a/SolarPower/Repository/Interface/IPowerStationRepository.cs +++ b/SolarPower/Repository/Interface/IPowerStationRepository.cs @@ -85,6 +85,14 @@ namespace SolarPower.Repository.Interface /// Task UpdateBoETPCInfo(UpdateBoETPCInfo entity, List properties, string db_name); + /// + /// 透過電站編號,取得所有土地房屋資訊 + /// + /// + /// + /// + Task> GetAllLandBuildingInfoByPowerStationId(int id, string db_name); + /// /// 取得 土地房屋資訊 /// @@ -416,6 +424,69 @@ namespace SolarPower.Repository.Interface /// /// Task GetoneData(string where, string db_name, string table_name); + + /// + /// 透過電站Id,取得所有控制器編碼 + /// + /// + /// + /// + Task> GetAllDeviceControllerByPowerStationId(int stationId, string db_name); + + /// + /// 透過當前時間,取得電站歷史資料 + /// + /// + /// + /// + Task GetPowerStationHistoryPerHour(string dateTime, string table_name); + + /// + /// 透過當前日期,取得往前推算30天的平均值 + /// + /// + /// + /// + Task GetAvgPowerStationHistory30day(string nowDay, string table_name); + + Task AddPowerStationHistory(List entity, List properties); + + Task UpdateList(List entity, List properties); + + /// + /// 透過日期,取得最後一筆資料 + /// + /// + /// + /// + Task GetLastOnePowerStationHistoryByDay(string day, string table_name); + + /// + /// 新增資料,至每日的電站歷史記錄 + /// + /// + /// + /// + Task AddPowerStationHistoryDayList(List entity, List properties); + + /// + /// 透過月份,取得單一筆資料 + /// + /// + /// + /// + Task GetOnePowerStationHistoryByPowerStationIdAndMonth(int powerStationId, string month); + + /// + /// 透過電站編號、月份,取得該月份資訊 + /// + /// + /// + /// + Task GetPowerStationHistoryMonthDataByPowerStationId(int powerStationId, string month); + + Task AddPowerStationHistoryMonthList(List entity, List properties); + Task UpdatePowerStationHistoryMonthList(List entity); /// /// 電站日照計列表 /// diff --git a/SolarPower/Startup.cs b/SolarPower/Startup.cs index 303a330..be27dd2 100644 --- a/SolarPower/Startup.cs +++ b/SolarPower/Startup.cs @@ -90,11 +90,27 @@ namespace SolarPower //K[QuartzA services.AddSingleton(); services.AddSingleton(); - //K[ڭ̪Job - services.AddSingleton(); + //K[Job + #region wpe + //services.AddSingleton(); + //services.AddSingleton( + // new JobSchedule(jobType: typeof(OperationScheduleJob), cronExpression: "0/5 * * * * ?") + //); + #endregion + + #region pqoqqT(CI5) + services.AddSingleton(); services.AddSingleton( - new JobSchedule(jobType: typeof(OperationScheduleJob), cronExpression: "0/5 * * * * ?") + new JobSchedule(jobType: typeof(CalcPowerStationJob), cronExpression: "0 5 * * * ?") ); + #endregion + + #region pqӶqBPRBkWP 30饭B(Cѭ2I) + services.AddSingleton(); + services.AddSingleton( + new JobSchedule(jobType: typeof(CalcAvgPowerStationJob), cronExpression: "0 0 2 * * ?") + ); + #endregion services.AddHostedService(); #endregion } diff --git a/SolarPower/Views/Company/Index.cshtml b/SolarPower/Views/Company/Index.cshtml index be3aefa..d7d63c2 100644 --- a/SolarPower/Views/Company/Index.cshtml +++ b/SolarPower/Views/Company/Index.cshtml @@ -129,7 +129,7 @@
- +
diff --git a/SolarPower/Views/MapOverview/Index.cshtml b/SolarPower/Views/MapOverview/Index.cshtml index 051055e..91096e2 100644 --- a/SolarPower/Views/MapOverview/Index.cshtml +++ b/SolarPower/Views/MapOverview/Index.cshtml @@ -5,13 +5,161 @@ }
+ + +
+
+
+
+

發電量

+
+
+
+

總發電量

+

126,161.72 kWh

+
+
+

平均發電量

+

4,069.73 kWh

+
+
+
+
+
+

日照度

+
+
+
+

即時平均日照度

+

126,161.72 kW/m2

+
+
+

平均日照度(30天)

+

4,069.73 kW/m2

+
+
+
+
+
+

PR值

+
+
+
+

即時平均 PR 值

+

119.04 hr

+
+
+

平均 PR 值(30天)

+

3.84 hr

+
+
+
+
+
+

kWh / kWp

+
+
+
+

即時平均 kWh / kWp

+

140.39 kW/m2

+
+
+

平均 kWh / kWp (30天)

+

4.53 kW/m2

+
+
+
+
+
+

減碳量

+
+
+
+

總減碳量

+

6,091.78 KG

+
+
+

今日減碳量

+

985.98 KG

+
+
+
+
+
+ +
+
+
+
+

電站分佈圖

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

電站總數

+
+
+

52

+

+
+
+
+ +
+
+
+

總裝置容量

+
+
+

1288.63

+

MWp

+
+
+
+
+
+
+

電站分佈小計

+
+
+
+ + + + + + + + + + +
縣市電站數量裝置容量 MWp
+
+
+
+
+
+
+
+
-
+
@@ -22,48 +170,27 @@ }