Merge branch 'master' into Willy
This commit is contained in:
commit
2966e27550
@ -1,4 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Repository.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -6,11 +8,21 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace SolarPower.Controllers
|
||||
{
|
||||
public class AnalysisInverterController : MyBaseController<AnalysisInverterController>
|
||||
public class AnalysisInverterController : MyBaseController<AnalysisInverterController>
|
||||
{
|
||||
|
||||
private readonly IPowerStationRepository powerStationRepository;
|
||||
|
||||
public AnalysisInverterController(IPowerStationRepository powerStationRepository) : base()
|
||||
{
|
||||
this.powerStationRepository = powerStationRepository;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ namespace SolarPower.Controllers
|
||||
HttpContext.Session.SetString("MyAccount", edFunction.AESEncrypt(user.Account)); //將帳號透過AES加密
|
||||
HttpContext.Session.SetString("CompanyId", edFunction.AESEncrypt(user.CompanyId.ToString())); //將公司id透過AES加密
|
||||
|
||||
return RedirectToAction("Index", "User");
|
||||
return RedirectToAction("Index", "MapOverview");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -107,7 +107,6 @@ namespace SolarPower.Controllers
|
||||
|
||||
int stationId = stationId_param == "new" ? 0 : int.Parse(stationId_param);
|
||||
|
||||
|
||||
if (stationId > 0)
|
||||
{
|
||||
var hasSubTagNum = false;
|
||||
@ -133,16 +132,6 @@ namespace SolarPower.Controllers
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//電站管理的新增電站
|
||||
ViewData["SubNum"] = myPowerStationSummaries.Count();
|
||||
ViewData["TagNum"] = 0;
|
||||
}
|
||||
}else if(controllerName == "PowerStation" && actionName == "Index")
|
||||
{
|
||||
ViewData["SubNum"] = myPowerStationSummaries.Count();
|
||||
ViewData["TagNum"] = 0;
|
||||
}
|
||||
|
||||
ViewBag.auths = auth_arr;
|
||||
|
||||
@ -155,8 +155,8 @@ namespace SolarPower.Controllers
|
||||
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_money = overview.Today_money;
|
||||
stationOverview.Total_money = overview.Total_money;
|
||||
stationOverview.Today_carbon = overview.Today_carbon;
|
||||
stationOverview.Total_carbon = overview.Total_carbon;
|
||||
|
||||
@ -169,8 +169,8 @@ namespace SolarPower.Controllers
|
||||
else
|
||||
{
|
||||
stationOverview.IsShowMoney = 0;
|
||||
stationOverview.Today_monery = 0;
|
||||
stationOverview.Total_monery = 0;
|
||||
stationOverview.Today_money = 0;
|
||||
stationOverview.Total_money = 0;
|
||||
}
|
||||
|
||||
var powerStation = await powerStationRepository.GetOneAsync(post.Ids.First());
|
||||
@ -307,8 +307,9 @@ namespace SolarPower.Controllers
|
||||
|
||||
var inverterHistories = await overviewRepository.GetListInverterByPowerStationIdAndDate(powerStation.Id, post.SelectedDate);
|
||||
|
||||
inverterHeatMap.XAxis = inverterHistories.Select(x => x.TIMESTAMP).Distinct().ToList();
|
||||
inverterHeatMap.XAxis = inverterHistories.Select(x => Convert.ToDateTime(x.TIMESTAMP).ToString("HH:mm")).Distinct().ToList();
|
||||
inverterHeatMap.YAxis = inverterHistories.Select(x => x.INVERTERID).Distinct().ToList();
|
||||
inverterHeatMap.XAxisOnTime = new List<string>();
|
||||
|
||||
inverterHeatMap.Series = new Dictionary<string, List<HeatMapSeries>>();
|
||||
|
||||
@ -319,7 +320,7 @@ namespace SolarPower.Controllers
|
||||
foreach (var value in inverterHistory)
|
||||
{
|
||||
HeatMapSeries heatMapSeries = new HeatMapSeries();
|
||||
heatMapSeries.X = inverterHeatMap.XAxis.IndexOf(value.TIMESTAMP);
|
||||
heatMapSeries.X = inverterHeatMap.XAxis.IndexOf(Convert.ToDateTime(value.TIMESTAMP).ToString("HH:mm"));
|
||||
heatMapSeries.Y = inverterHeatMap.YAxis.IndexOf(value.INVERTERID);
|
||||
heatMapSeries.Value = value.KWHKWP;
|
||||
|
||||
@ -329,6 +330,19 @@ namespace SolarPower.Controllers
|
||||
inverterHeatMap.Series.Add(inverterHistory.Key, heats);
|
||||
}
|
||||
|
||||
for (var i = 0; i < inverterHeatMap.XAxis.Count(); i++)
|
||||
{
|
||||
|
||||
if (inverterHeatMap.XAxis[i].Substring(3, 2) != "00")
|
||||
{
|
||||
inverterHeatMap.XAxisOnTime.Add("");
|
||||
}
|
||||
else
|
||||
{
|
||||
inverterHeatMap.XAxisOnTime.Add(inverterHeatMap.XAxis[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = inverterHeatMap;
|
||||
@ -360,7 +374,7 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
if (string.IsNullOrEmpty(a.FormId))
|
||||
{
|
||||
if(a.Err_status == 1)
|
||||
if (a.Err_status == 1)
|
||||
{
|
||||
a.Function = @$"<a href='javascript:;' class='btn btn-success waves-effect waves-themed mb-3 mr-2 add-btn'>填寫表單</a>";
|
||||
}
|
||||
@ -416,10 +430,25 @@ namespace SolarPower.Controllers
|
||||
var inverterHistory_group = inverterHistoriesDay.GroupBy(x => x.INVERTERID).ToList();
|
||||
foreach (var inverterHistory in inverterHistory_group)
|
||||
{
|
||||
|
||||
List<double> values = new List<double>();
|
||||
foreach (var value in inverterHistory)
|
||||
foreach(var lable in inverterkwhBar.Labels)
|
||||
{
|
||||
values.Add(value.KWH);
|
||||
var find = false;
|
||||
foreach (var value in inverterHistory)
|
||||
{
|
||||
if(value.TIMESTAMP == lable)
|
||||
{
|
||||
values.Add(value.KWH);
|
||||
find = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!find)
|
||||
{
|
||||
values.Add(0);
|
||||
}
|
||||
}
|
||||
|
||||
inverterkwhBar.Datasets.Add(inverterHistory.Key, values);
|
||||
@ -436,9 +465,23 @@ namespace SolarPower.Controllers
|
||||
foreach (var inverterHistory in inverterHistoryMonth_group)
|
||||
{
|
||||
List<double> values = new List<double>();
|
||||
foreach (var value in inverterHistory)
|
||||
foreach (var lable in inverterkwhBar.Labels)
|
||||
{
|
||||
values.Add(value.KWH);
|
||||
var find = false;
|
||||
foreach (var value in inverterHistory)
|
||||
{
|
||||
if (value.TIMESTAMP == lable)
|
||||
{
|
||||
values.Add(value.KWH);
|
||||
find = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!find)
|
||||
{
|
||||
values.Add(0);
|
||||
}
|
||||
}
|
||||
|
||||
inverterkwhBar.Datasets.Add(inverterHistory.Key, values);
|
||||
@ -477,9 +520,23 @@ namespace SolarPower.Controllers
|
||||
foreach (var inverterHistory in inverterHistoryQuaryerly_group)
|
||||
{
|
||||
List<double> values = new List<double>();
|
||||
foreach (var value in inverterHistory)
|
||||
foreach (var lable in inverterkwhBar.Labels)
|
||||
{
|
||||
values.Add(value.KWH);
|
||||
var find = false;
|
||||
foreach (var value in inverterHistory)
|
||||
{
|
||||
if (value.TIMESTAMP == lable)
|
||||
{
|
||||
values.Add(value.KWH);
|
||||
find = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!find)
|
||||
{
|
||||
values.Add(0);
|
||||
}
|
||||
}
|
||||
|
||||
inverterkwhBar.Datasets.Add(inverterHistory.Key, values);
|
||||
@ -495,9 +552,23 @@ namespace SolarPower.Controllers
|
||||
foreach (var inverterHistory in inverterHistoryYear_group)
|
||||
{
|
||||
List<double> values = new List<double>();
|
||||
foreach (var value in inverterHistory)
|
||||
foreach (var lable in inverterkwhBar.Labels)
|
||||
{
|
||||
values.Add(value.KWH);
|
||||
var find = false;
|
||||
foreach (var value in inverterHistory)
|
||||
{
|
||||
if (value.TIMESTAMP == lable)
|
||||
{
|
||||
values.Add(value.KWH);
|
||||
find = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!find)
|
||||
{
|
||||
values.Add(0);
|
||||
}
|
||||
}
|
||||
|
||||
inverterkwhBar.Datasets.Add(inverterHistory.Key, values);
|
||||
@ -505,15 +576,6 @@ namespace SolarPower.Controllers
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = inverterkwhBar;
|
||||
}
|
||||
@ -533,11 +595,11 @@ namespace SolarPower.Controllers
|
||||
var History = new List<HistoryTable>();
|
||||
ApiResult<List<HistoryTable>> apiResult = new ApiResult<List<HistoryTable>>();
|
||||
var powerStation = await powerStationRepository.GetOneAsync(post.PowerstationId);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
History = await overviewRepository.GethistoryTable(post);
|
||||
foreach(var a in History)
|
||||
foreach (var a in History)
|
||||
{
|
||||
switch (post.GroupType)
|
||||
{
|
||||
|
||||
@ -424,20 +424,21 @@ INSERT INTO `auth_page` (`AuthCode`, `MainName`, `SubName`, `TagName`, `ControlN
|
||||
('G', '總覽', '電站總覽', '異常記錄', 'StationOverview_Exception'),
|
||||
('H', '總覽', '電站總覽', '運維記錄', 'StationOverview_OperationRecord'),
|
||||
('J', '總覽', '電站總覽', '顯示發電金額', 'ShowMoney'),
|
||||
('K', '電站資訊', '電站管理', NULL, 'PowerStation'),
|
||||
('L', '交叉分析', '合併電站', NULL, 'Setting'),
|
||||
('M', '交叉分析', '電站交叉分析', NULL, 'ASDA'),
|
||||
('N', '交叉分析', '逆變器交叉分析', NULL, 'BBB'),
|
||||
('K', '電站資訊', '電站資訊', NULL, 'PowerStationInfo'),
|
||||
('L', '交叉分析', '合併電站', NULL, 'AnalysisStationCombine'),
|
||||
('M', '交叉分析', '電站交叉分析', NULL, 'AnalysisStationInfo'),
|
||||
('N', '交叉分析', '逆變器交叉分析', NULL, 'AnalysisInverter'),
|
||||
('P', '報表查詢', '電站報表', NULL, 'CCC'),
|
||||
('Q', '報表查詢', '電廠發電效能統計', NULL, 'HHH'),
|
||||
('R', '報表查詢', '輸入台電售電紀錄', NULL, 'JJJ'),
|
||||
('S', '報表查詢', '報告發送設定', NULL, 'JJJ'),
|
||||
('T', '即時告警', '異常事件查詢', NULL, 'KKK'),
|
||||
('U', '運維管理', '定期計畫建立', NULL, 'Operation'),
|
||||
('V', '運維管理', '運維作業記錄', NULL, 'OperationRecord'),
|
||||
('W', '系統管理', '公司管理', NULL, 'Company'),
|
||||
('X', '系統管理', '帳號管理', NULL, 'User,Role'),
|
||||
('Y', '系統管理', '定時任務設定', NULL, 'LLL');
|
||||
('U', '運維管理', '電站管理', NULL, 'PowerStationManager'),
|
||||
('V', '運維管理', '定期計畫建立', NULL, 'Operation'),
|
||||
('W', '運維管理', '運維作業記錄', NULL, 'OperationRecord'),
|
||||
('X', '系統管理', '公司管理', NULL, 'Company'),
|
||||
('Y', '系統管理', '帳號管理', NULL, 'User,Role'),
|
||||
('Z', '系統管理', '定時任務設定', NULL, 'LLL');
|
||||
/*!40000 ALTER TABLE `auth_page` ENABLE KEYS */;
|
||||
|
||||
-- 傾印 資料表 solar_power.city 結構
|
||||
@ -934,9 +935,9 @@ ENGINE=InnoDB
|
||||
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 `today_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '今日金額' AFTER `avg_kwhkwp`,
|
||||
ADD COLUMN `total_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '總金額' AFTER `today_money`,
|
||||
ADD COLUMN `today_PR` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '電站Pr值' AFTER `total_money`,
|
||||
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`,
|
||||
@ -1044,6 +1045,7 @@ CREATE TABLE `inverter_history_hour` (
|
||||
`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`INVERTERID` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
|
||||
`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
|
||||
`Irradiance` DOUBLE NULL DEFAULT NULL,
|
||||
`AC1V` DOUBLE NULL DEFAULT NULL,
|
||||
`AC1A` DOUBLE NULL DEFAULT NULL,
|
||||
`AC1W` DOUBLE NULL DEFAULT NULL,
|
||||
@ -1110,6 +1112,7 @@ CREATE TABLE `inverter_history_day` (
|
||||
`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`INVERTERID` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
|
||||
`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
|
||||
`Irradiance` DOUBLE NULL DEFAULT NULL,
|
||||
`AC1V` DOUBLE NULL DEFAULT NULL,
|
||||
`AC1A` DOUBLE NULL DEFAULT NULL,
|
||||
`AC1W` DOUBLE NULL DEFAULT NULL,
|
||||
@ -1176,6 +1179,7 @@ CREATE TABLE `inverter_history_month` (
|
||||
`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`INVERTERID` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
|
||||
`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
|
||||
`Irradiance` DOUBLE NULL DEFAULT NULL,
|
||||
`AC1V` DOUBLE NULL DEFAULT NULL,
|
||||
`AC1A` DOUBLE NULL DEFAULT NULL,
|
||||
`AC1W` DOUBLE NULL DEFAULT NULL,
|
||||
@ -1770,6 +1774,11 @@ ALTER TABLE `power_station_history_month`
|
||||
ADD COLUMN `TOTALMONEY` DOUBLE NULL DEFAULT NULL AFTER `MONEY`,
|
||||
ADD COLUMN `TOTALCARBON` DOUBLE NULL DEFAULT NULL AFTER `CARBON`;
|
||||
|
||||
-- 修正 欄位名稱 20210720
|
||||
ALTER TABLE `power_station`
|
||||
CHANGE COLUMN `today_monery` `today_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '今日金額' AFTER `avg_kwhkwp`,
|
||||
CHANGE COLUMN `total_monery` `total_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '總金額' AFTER `today_money`;
|
||||
|
||||
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
|
||||
23
SolarPower/Models/AnalysisInverter.cs
Normal file
23
SolarPower/Models/AnalysisInverter.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SolarPower.Models
|
||||
{
|
||||
|
||||
|
||||
public class AnalysisInverter
|
||||
{
|
||||
public List<string> XAxis { get; set; } //時間
|
||||
public List<string> MultipleYaxes { get; set; } //Y軸名稱
|
||||
public Dictionary<string, List<InverterHistoryInfo>> Series { get; set; } //數組
|
||||
}
|
||||
|
||||
public class InverterHistoryInfo
|
||||
{
|
||||
public string Time { get; set; }
|
||||
public string Yaxes { get; set; }
|
||||
public double Value { get; set; }
|
||||
}
|
||||
}
|
||||
@ -16,8 +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_money { get; set; } //今日金額
|
||||
public double Total_money { get; set; } //今日金額
|
||||
public double Today_carbon { get; set; } //今日減碳量
|
||||
public double Total_carbon { get; set; } //累積減碳量
|
||||
}
|
||||
@ -121,6 +121,7 @@ namespace SolarPower.Models
|
||||
public class InverterHeatMap
|
||||
{
|
||||
public List<string> XAxis { get; set; } //時間
|
||||
public List<string> XAxisOnTime { get; set; } //時間(整點)
|
||||
public List<string> YAxis { get; set; } //逆變器名稱
|
||||
public Dictionary<string, List<HeatMapSeries>> Series { get; set; } //數組
|
||||
}
|
||||
|
||||
@ -115,8 +115,8 @@ namespace SolarPower.Models.PowerStation
|
||||
public double kwh { 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_Money { get; set; } //今日發電金額
|
||||
public double Total_Money { get; set; } //總發電金額
|
||||
public double Today_kwhkwp { get; set; }
|
||||
public double Avg_kwhkwp { get; set; }
|
||||
public double Today_PR { get; set; }
|
||||
@ -667,6 +667,7 @@ namespace SolarPower.Models.PowerStation
|
||||
public string TIMESTAMP { get; set; }
|
||||
public int PowerStationId { get; set; }
|
||||
public string INVERTERID { get; set; }
|
||||
public double Irradiance { get; set; }
|
||||
public double AC1V { get; set; }
|
||||
public double AC1A { get; set; }
|
||||
public double AC1W { get; set; }
|
||||
|
||||
@ -36,24 +36,89 @@ namespace SolarPower.Quartz.Jobs
|
||||
|
||||
List<PowerStation> calcAvgPowerStations = new List<PowerStation>();
|
||||
List<PowerStationHistoryDay> powerStationHistoryDays = new List<PowerStationHistoryDay>();
|
||||
|
||||
|
||||
List<PowerStationHistoryMonth> insertPowerStationHistoryMonths = new List<PowerStationHistoryMonth>();
|
||||
List<PowerStationHistoryMonth> updatePowerStationHistoryMonths = new List<PowerStationHistoryMonth>();
|
||||
|
||||
List<PyrheliometerHistory> pyrheliometerHistoryDays = new List<PyrheliometerHistory>();
|
||||
List<PyrheliometerHistory> insertPyrheliometerHistoryMonths = new List<PyrheliometerHistory>();
|
||||
List<PyrheliometerHistory> updatePyrheliometerHistoryMonths = new List<PyrheliometerHistory>();
|
||||
List<string> pyrheliometer_history_properties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"Timestamp",
|
||||
"Irradiance",
|
||||
"Temperature"
|
||||
};
|
||||
|
||||
|
||||
List<InverterHistory> allofInverterHistorDays = new List<InverterHistory>();
|
||||
List<InverterHistory> insertInverterHistoryMonths = new List<InverterHistory>();
|
||||
List<InverterHistory> updateInverterHistoryMonths = new List<InverterHistory>();
|
||||
List<string> inverter_history_properties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"TIMESTAMP",
|
||||
"INVERTERID",
|
||||
"Irradiance",
|
||||
"AC1V",
|
||||
"AC1A",
|
||||
"AC1W",
|
||||
"AC1F",
|
||||
"AC1WH",
|
||||
"AC2V",
|
||||
"AC2A",
|
||||
"AC2W",
|
||||
"AC2F",
|
||||
"AC2WH",
|
||||
"AC3V",
|
||||
"AC3A",
|
||||
"AC3W",
|
||||
"AC3F",
|
||||
"AC3WH",
|
||||
"DC1V",
|
||||
"DC1A",
|
||||
"DC1W",
|
||||
"DC1KW",
|
||||
"DC1WH",
|
||||
"DC2V",
|
||||
"DC2A",
|
||||
"DC2W",
|
||||
"DC2KW",
|
||||
"DC2WH",
|
||||
"DC3V",
|
||||
"DC3A",
|
||||
"DC3W",
|
||||
"DC3KW",
|
||||
"DC3WH",
|
||||
"DC4V",
|
||||
"DC4A",
|
||||
"DC4W",
|
||||
"DC4KW",
|
||||
"DC4WH",
|
||||
"DC5V",
|
||||
"DC5A",
|
||||
"DC5W",
|
||||
"DC5KW",
|
||||
"DC5WH",
|
||||
"PR",
|
||||
"RA1",
|
||||
"RA2",
|
||||
"RA3",
|
||||
"RA4",
|
||||
"RA5",
|
||||
"DCKW",
|
||||
"ACKW",
|
||||
"KWH",
|
||||
"TODAYKWH",
|
||||
"KWHKWP",
|
||||
};
|
||||
|
||||
List<WeatherForecast> weatherForecasts = new List<WeatherForecast>();
|
||||
|
||||
|
||||
|
||||
var DateTimeNow = DateTime.Now;
|
||||
|
||||
var count = 0;
|
||||
|
||||
#region 氣象觀測(取資料)
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始取得氣象觀測】");
|
||||
var client = new HttpClient();
|
||||
@ -73,9 +138,6 @@ namespace SolarPower.Quartz.Jobs
|
||||
|
||||
foreach (var a in location.WeatherElement)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (a.ElementName == "Wx")
|
||||
{
|
||||
foreach (var time in a.Time)
|
||||
@ -139,106 +201,162 @@ namespace SolarPower.Quartz.Jobs
|
||||
};
|
||||
await powerStationRepository.AddWeatherForecast(weatherForecasts, weather_forecast_properties);
|
||||
|
||||
|
||||
|
||||
#region step2. 從電站的DB及電站編號找出該電站的控制器
|
||||
#region step2. 歸檔電站的每日資訊
|
||||
foreach (var powerStation in powerStations)
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var calcPowerStation = new PowerStation();
|
||||
calcPowerStation.Id = powerStation.Id;
|
||||
var dateNowDay = DateTimeNow.AddDays(-1).ToString("yyyy-MM-dd");
|
||||
|
||||
#region step2-1. 計算該電站的30天平均資料
|
||||
var table_name = String.Format("`{0}`.`s{1}01_station`", powerStation.SiteDB, powerStation.Code);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}的30天平均資料】", powerStation.Code, dateNowDay);
|
||||
var history = await powerStationRepository.CalcAvgPowerStationHistory30day(dateNowDay, table_name);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【取得成功電站[{0}]在{1}的30天平均資料】", powerStation.Code, dateNowDay);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【電站[{0}]在{1}的30天平均資料】 - {2}", powerStation.Code, dateNowDay, System.Text.Json.JsonSerializer.Serialize(history));
|
||||
if (history != null)
|
||||
var table_name = String.Format("s{1}01_station", powerStation.SiteDB, powerStation.Code);
|
||||
var full_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, table_name);
|
||||
var exist = await powerStationRepository.ExistTable(powerStation.SiteDB, table_name);
|
||||
if (!string.IsNullOrEmpty(exist))
|
||||
{
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}的30天平均資料】", powerStation.Code, dateNowDay);
|
||||
history.PowerStationId = powerStation.Id;
|
||||
var history = await powerStationRepository.CalcAvgPowerStationHistory30day(dateNowDay, full_table_name);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【取得成功電站[{0}]在{1}的30天平均資料】", powerStation.Code, dateNowDay);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【電站[{0}]在{1}的30天平均資料】 - {2}", powerStation.Code, dateNowDay, System.Text.Json.JsonSerializer.Serialize(history));
|
||||
if (history != null)
|
||||
{
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}的30天平均資料】", powerStation.Code, dateNowDay);
|
||||
history.PowerStationId = powerStation.Id;
|
||||
|
||||
#region 計算電站30天的 kWh/kWp 與 PR 值
|
||||
#region 計算電站30天的 kWh/kWp 與 PR 值
|
||||
|
||||
#region 平均kWh/kWp
|
||||
//直接填寫
|
||||
calcPowerStation.Avg_kwhkwp = history.AvgKWHKWP;
|
||||
#region 平均kWh/kWp
|
||||
//直接填寫
|
||||
calcPowerStation.Avg_kwhkwp = history.AvgKWHKWP;
|
||||
#endregion
|
||||
|
||||
#region 平均PR
|
||||
//直接填寫
|
||||
calcPowerStation.Avg_PR = history.AvgPR;
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}的30天平均資料】", powerStation.Code, dateNowDay);
|
||||
}
|
||||
|
||||
#region step2-2 計算電站30天的日照計平均值
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}的30天日照計平均資料】", powerStation.Code, dateNowDay);
|
||||
var avgPyrheliometerHistory = await powerStationRepository.CalcAvgPyrheliometerHistory30day(dateNowDay, powerStation.Id);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【取得成功電站[{0}]在{1}的30天日照計平均資料】", powerStation.Code, dateNowDay);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【電站[{0}]在{1}的30天日照計平均資料】 - {2}", powerStation.Code, dateNowDay, System.Text.Json.JsonSerializer.Serialize(avgPyrheliometerHistory));
|
||||
if (avgPyrheliometerHistory != null)
|
||||
{
|
||||
calcPowerStation.Avg_irradiance = avgPyrheliometerHistory.AvgIrradiance;
|
||||
}
|
||||
|
||||
calcAvgPowerStations.Add(calcPowerStation);
|
||||
#endregion
|
||||
|
||||
#region 平均PR
|
||||
//直接填寫
|
||||
calcPowerStation.Avg_PR = history.AvgPR;
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}的30天平均資料】", powerStation.Code, dateNowDay);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region step2-2 計算電站30天的日照計平均值
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}的30天日照計平均資料】", powerStation.Code, dateNowDay);
|
||||
var avgPyrheliometerHistory = await powerStationRepository.CalcAvgPyrheliometerHistory30day(dateNowDay, powerStation.Id);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【取得成功電站[{0}]在{1}的30天日照計平均資料】", powerStation.Code, dateNowDay);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【電站[{0}]在{1}的30天日照計平均資料】 - {2}", powerStation.Code, dateNowDay, System.Text.Json.JsonSerializer.Serialize(avgPyrheliometerHistory));
|
||||
if (avgPyrheliometerHistory != null)
|
||||
{
|
||||
calcPowerStation.Avg_irradiance = avgPyrheliometerHistory.AvgIrradiance;
|
||||
}
|
||||
|
||||
calcAvgPowerStations.Add(calcPowerStation);
|
||||
#endregion
|
||||
|
||||
#region step2-3. 計算昨天的所有值總和
|
||||
//電站資訊
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始取得電站[{0}]在{1}的所有值的總和】", powerStation.Code, dateNowDay);
|
||||
var historyDay = await powerStationRepository.GetLastOnePowerStationHistoryByDay(dateNowDay, table_name);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【取得成功電站[{0}]在{1}的所有值的總和】", powerStation.Code, dateNowDay);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【電站[{0}]在{1}的所有值的總和】 - {2}", powerStation.Code, dateNowDay, System.Text.Json.JsonSerializer.Serialize(historyDay));
|
||||
var daynow = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
var moneyandcarbon = await powerStationRepository.GetMoneyAndCarbonWithHistoryHour(powerStation.Id, dateNowDay, 1);
|
||||
var lastmoneyhistory = await powerStationRepository.GetLastMoneyAndCarbonInHour(powerStation.Id, 1,"");
|
||||
if (historyDay != null)
|
||||
if (!string.IsNullOrEmpty(exist))
|
||||
{
|
||||
historyDay.PowerStationId = powerStation.Id;
|
||||
historyDay.CARBON = moneyandcarbon.CARBON;
|
||||
historyDay.MONEY = moneyandcarbon.MONEY;
|
||||
//historyDay.TODAYCARBON = lastmoneyhistory.TODAYCARBON;
|
||||
//historyDay.TODAYMONEY = lastmoneyhistory.TODAYMONEY ;
|
||||
historyDay.TOTALCARBON = lastmoneyhistory.TOTALCARBON + moneyandcarbon.CARBON;
|
||||
historyDay.TOTALMONEY = lastmoneyhistory.TOTALMONEY + moneyandcarbon.MONEY;
|
||||
powerStationHistoryDays.Add(historyDay);
|
||||
}
|
||||
|
||||
//日照計
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}的日照計所有值的平均】", powerStation.Code, dateNowDay);
|
||||
var pyrheliometerHistorDay = await powerStationRepository.CalcPyrheliometerHistoryDayDataByPowerStationId(dateNowDay, powerStation.Id);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}的日照計所有值的平均】", powerStation.Code, dateNowDay);
|
||||
if (pyrheliometerHistorDay != null)
|
||||
{
|
||||
pyrheliometerHistoryDays.Add(pyrheliometerHistorDay);
|
||||
}
|
||||
|
||||
//逆變器
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}的逆變器所有值的平均】", powerStation.Code, dateNowDay);
|
||||
var inverterHistoriesDay = await powerStationRepository.CalcInverterHistoryDayDataByPowerStationId(dateNowDay, powerStation.SiteDB, powerStation.Id);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}的逆變器所有值的平均】", powerStation.Code, dateNowDay);
|
||||
if (inverterHistoriesDay != null)
|
||||
{
|
||||
foreach(var inverterHistoryDay in inverterHistoriesDay)
|
||||
//電站資訊
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始取得電站[{0}]在{1}的所有值的總和】", powerStation.Code, dateNowDay);
|
||||
var historyDay = await powerStationRepository.GetLastOnePowerStationHistoryByDay(dateNowDay, full_table_name);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【取得成功電站[{0}]在{1}的所有值的總和】", powerStation.Code, dateNowDay);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【電站[{0}]在{1}的所有值的總和】 - {2}", powerStation.Code, dateNowDay, System.Text.Json.JsonSerializer.Serialize(historyDay));
|
||||
var daynow = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
var moneyandcarbon = await powerStationRepository.GetMoneyAndCarbonWithHistoryHour(powerStation.Id, dateNowDay, 1);
|
||||
var lastmoneyhistory = await powerStationRepository.GetLastMoneyAndCarbonInHour(powerStation.Id, 1, "");
|
||||
if (historyDay != null)
|
||||
{
|
||||
allofInverterHistorDays.Add(inverterHistoryDay);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
historyDay.PowerStationId = powerStation.Id;
|
||||
historyDay.CARBON = moneyandcarbon.CARBON;
|
||||
historyDay.MONEY = moneyandcarbon.MONEY;
|
||||
//historyDay.TODAYCARBON = lastmoneyhistory.TODAYCARBON;
|
||||
//historyDay.TODAYMONEY = lastmoneyhistory.TODAYMONEY ;
|
||||
historyDay.TOTALCARBON = lastmoneyhistory.TOTALCARBON + moneyandcarbon.CARBON;
|
||||
historyDay.TOTALMONEY = lastmoneyhistory.TOTALMONEY + moneyandcarbon.MONEY;
|
||||
|
||||
#region step2-4. 計算這個月的所有值總和
|
||||
//日期轉換
|
||||
historyDay.Timestamp = Convert.ToDateTime(historyDay.Timestamp + ":00:00").ToString("yyyy-MM-dd");
|
||||
powerStationHistoryDays.Add(historyDay);
|
||||
}
|
||||
|
||||
//日照計
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}的日照計所有值的平均】", powerStation.Code, dateNowDay);
|
||||
var pyrheliometerHistorDay = await powerStationRepository.CalcPyrheliometerHistoryDayDataByPowerStationId(dateNowDay, powerStation.Id);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}的日照計所有值的平均】", powerStation.Code, dateNowDay);
|
||||
if (pyrheliometerHistorDay != null)
|
||||
{
|
||||
pyrheliometerHistoryDays.Add(pyrheliometerHistorDay);
|
||||
}
|
||||
|
||||
//逆變器
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}的逆變器所有值的平均】", powerStation.Code, dateNowDay);
|
||||
var inverterHistoriesDay = await powerStationRepository.CalcInverterHistoryDayDataByPowerStationId(dateNowDay, powerStation.SiteDB, powerStation.Id);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}的逆變器所有值的平均】", powerStation.Code, dateNowDay);
|
||||
if (inverterHistoriesDay != null)
|
||||
{
|
||||
foreach (var inverterHistoryDay in inverterHistoriesDay)
|
||||
{
|
||||
inverterHistoryDay.DC1KW = inverterHistoryDay.DC1W / 1000;
|
||||
inverterHistoryDay.DC2KW = inverterHistoryDay.DC2W / 1000;
|
||||
inverterHistoryDay.DC3KW = inverterHistoryDay.DC3W / 1000;
|
||||
inverterHistoryDay.DC4KW = inverterHistoryDay.DC4W / 1000;
|
||||
inverterHistoryDay.DC5KW = inverterHistoryDay.DC5W / 1000;
|
||||
|
||||
inverterHistoryDay.DCKW = (inverterHistoryDay.DC1W + inverterHistoryDay.DC2W + inverterHistoryDay.DC3W + inverterHistoryDay.DC4W + inverterHistoryDay.DC5W) / 1000;
|
||||
inverterHistoryDay.ACKW = (inverterHistoryDay.AC1W + inverterHistoryDay.AC2W + inverterHistoryDay.AC3W) / 1000;
|
||||
|
||||
allofInverterHistorDays.Add(inverterHistoryDay);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region step3. calcPowerStations UPDATE 到 power_station 資料表
|
||||
List<string> power_station_properties = new List<string>()
|
||||
{
|
||||
"Id",
|
||||
"avg_kwhkwp",
|
||||
"avg_PR",
|
||||
"avg_irradiance"
|
||||
};
|
||||
|
||||
await powerStationRepository.UpdateList(calcAvgPowerStations, power_station_properties);
|
||||
#endregion
|
||||
|
||||
#region step4. 將各電站的每日的資料insert資料表
|
||||
//每日
|
||||
List<string> history_properties_day = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"TIMESTAMP",
|
||||
"SITEID",
|
||||
"SITETYPE",
|
||||
"TODAYKWH",
|
||||
"TOTALKWH",
|
||||
"KWHKWP",
|
||||
"PR",
|
||||
"MP",
|
||||
"SolarHour",
|
||||
"MONEY",
|
||||
"CARBON",
|
||||
"TOTALMONEY",
|
||||
"TOTALCARBON"
|
||||
};
|
||||
await powerStationRepository.AddPowerStationHistoryDayList(powerStationHistoryDays, history_properties_day);
|
||||
|
||||
//每日
|
||||
await powerStationRepository.AddPyrheliometerHistoryDayList(pyrheliometerHistoryDays, pyrheliometer_history_properties);
|
||||
|
||||
//每日
|
||||
await powerStationRepository.AddInverterHistoryDayList(allofInverterHistorDays, inverter_history_properties);
|
||||
|
||||
#region step3. 歸檔電站的每月資訊
|
||||
foreach (var powerStation in powerStations)
|
||||
{
|
||||
//判斷這個月是否已存在
|
||||
var dateNowMonth = DateTimeNow.ToString("yyyy-MM");
|
||||
|
||||
@ -252,7 +370,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
var lastmoneyhistorymonth = await powerStationRepository.GetLastMoneyAndCarbonInHour(powerStation.Id, 2, "");
|
||||
if (historyMonth != null)
|
||||
{
|
||||
|
||||
|
||||
|
||||
historyMonth.Timestamp = Convert.ToDateTime(historyMonth.Timestamp).ToString("yyyy-MM-dd");
|
||||
historyMonth.MONEY = moneyandcarbonMon.MONEY;
|
||||
@ -307,13 +425,22 @@ namespace SolarPower.Quartz.Jobs
|
||||
//電站該月份的的逆變器歷史資料
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}月份的逆變器歷史資料】", powerStation.Code, dateNowMonth);
|
||||
var exist_inverter_histories = await powerStationRepository.GetInverterHistoryByPowerStationIdAndMonth(dateNowMonth, powerStation.Id);
|
||||
if (exist_inverter_histories.Count == 0 )
|
||||
if (exist_inverter_histories.Count == 0)
|
||||
{ //新增
|
||||
var inverterHistoriesMonth = await powerStationRepository.CalcInverterHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.SiteDB, powerStation.Id);
|
||||
if (inverterHistoriesMonth.Count > 0)
|
||||
{
|
||||
foreach(var inverterHistoryMonth in inverterHistoriesMonth)
|
||||
foreach (var inverterHistoryMonth in inverterHistoriesMonth)
|
||||
{
|
||||
inverterHistoryMonth.DC1KW = inverterHistoryMonth.DC1W / 1000;
|
||||
inverterHistoryMonth.DC2KW = inverterHistoryMonth.DC2W / 1000;
|
||||
inverterHistoryMonth.DC3KW = inverterHistoryMonth.DC3W / 1000;
|
||||
inverterHistoryMonth.DC4KW = inverterHistoryMonth.DC4W / 1000;
|
||||
inverterHistoryMonth.DC5KW = inverterHistoryMonth.DC5W / 1000;
|
||||
|
||||
inverterHistoryMonth.DCKW = (inverterHistoryMonth.DC1W + inverterHistoryMonth.DC2W + inverterHistoryMonth.DC3W + inverterHistoryMonth.DC4W + inverterHistoryMonth.DC5W) / 1000;
|
||||
inverterHistoryMonth.ACKW = (inverterHistoryMonth.AC1W + inverterHistoryMonth.AC2W + inverterHistoryMonth.AC3W) / 1000;
|
||||
|
||||
inverterHistoryMonth.TIMESTAMP = Convert.ToDateTime(inverterHistoryMonth.TIMESTAMP).ToString("yyyy-MM-dd");
|
||||
insertInverterHistoryMonths.Add(inverterHistoryMonth);
|
||||
}
|
||||
@ -327,6 +454,15 @@ namespace SolarPower.Quartz.Jobs
|
||||
{
|
||||
foreach (var inverterHistoryMonth in inverterHistoriesMonth)
|
||||
{
|
||||
inverterHistoryMonth.DC1KW = inverterHistoryMonth.DC1W / 1000;
|
||||
inverterHistoryMonth.DC2KW = inverterHistoryMonth.DC2W / 1000;
|
||||
inverterHistoryMonth.DC3KW = inverterHistoryMonth.DC3W / 1000;
|
||||
inverterHistoryMonth.DC4KW = inverterHistoryMonth.DC4W / 1000;
|
||||
inverterHistoryMonth.DC5KW = inverterHistoryMonth.DC5W / 1000;
|
||||
|
||||
inverterHistoryMonth.DCKW = (inverterHistoryMonth.DC1W + inverterHistoryMonth.DC2W + inverterHistoryMonth.DC3W + inverterHistoryMonth.DC4W + inverterHistoryMonth.DC5W) / 1000;
|
||||
inverterHistoryMonth.ACKW = (inverterHistoryMonth.AC1W + inverterHistoryMonth.AC2W + inverterHistoryMonth.AC3W) / 1000;
|
||||
|
||||
inverterHistoryMonth.TIMESTAMP = Convert.ToDateTime(inverterHistoryMonth.TIMESTAMP).ToString("yyyy-MM-dd");
|
||||
updateInverterHistoryMonths.Add(inverterHistoryMonth);
|
||||
}
|
||||
@ -334,45 +470,9 @@ namespace SolarPower.Quartz.Jobs
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的逆變器歷史資料】", powerStation.Code, dateNowMonth);
|
||||
}
|
||||
#endregion
|
||||
|
||||
count++;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region step3. calcPowerStations UPDATE 到 power_station 資料表
|
||||
List<string> power_station_properties = new List<string>()
|
||||
{
|
||||
"Id",
|
||||
"avg_kwhkwp",
|
||||
"avg_PR",
|
||||
"avg_irradiance"
|
||||
};
|
||||
|
||||
await powerStationRepository.UpdateList(calcAvgPowerStations, power_station_properties);
|
||||
#endregion
|
||||
|
||||
#region step4. 將各電站的每日及月的資料insert or update 各資料表
|
||||
//每日
|
||||
List<string> history_properties_day = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"TIMESTAMP",
|
||||
"SITEID",
|
||||
"SITETYPE",
|
||||
"TODAYKWH",
|
||||
"TOTALKWH",
|
||||
"KWHKWP",
|
||||
"PR",
|
||||
"MP",
|
||||
"SolarHour",
|
||||
"MONEY",
|
||||
"CARBON",
|
||||
"TOTALMONEY",
|
||||
"TOTALCARBON"
|
||||
};
|
||||
|
||||
await powerStationRepository.AddPowerStationHistoryDayList(powerStationHistoryDays, history_properties_day);
|
||||
|
||||
//每月
|
||||
List<string> history_properties_month = new List<string>()
|
||||
{
|
||||
@ -401,18 +501,8 @@ namespace SolarPower.Quartz.Jobs
|
||||
{
|
||||
await powerStationRepository.UpdatePowerStationHistoryMonthList(updatePowerStationHistoryMonths);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region step5. 將各電站的每日及月的日照度資料insert or update 各資料表
|
||||
List<string> pyrheliometer_history_properties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"Timestamp",
|
||||
"Irradiance",
|
||||
"Temperature"
|
||||
};
|
||||
//每日
|
||||
await powerStationRepository.AddPyrheliometerHistoryDayList(pyrheliometerHistoryDays, pyrheliometer_history_properties);
|
||||
|
||||
//每月
|
||||
if (insertPyrheliometerHistoryMonths.Count > 0)
|
||||
@ -427,17 +517,6 @@ namespace SolarPower.Quartz.Jobs
|
||||
#endregion
|
||||
|
||||
#region step6. 將各電站的每日及月的逆變器資料insert or update 各資料表
|
||||
List<string> inverter_history_properties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"TIMESTAMP",
|
||||
"INVERTERID",
|
||||
"KWH",
|
||||
"TODAYKWH",
|
||||
"KWHKWP",
|
||||
};
|
||||
//每日
|
||||
await powerStationRepository.AddInverterHistoryDayList(allofInverterHistorDays, inverter_history_properties);
|
||||
|
||||
//每月
|
||||
if (insertInverterHistoryMonths.Count > 0)
|
||||
|
||||
@ -25,6 +25,34 @@ namespace SolarPower.Quartz.Jobs
|
||||
{
|
||||
try
|
||||
{
|
||||
//var day_array = new string[] { "15", "16", "17", "18", "19" };
|
||||
////var day_array = new string[] { "15" };
|
||||
//var time_array = new string[] { "00:02", "00:17", "00:32", "00:47",
|
||||
// "01:02", "01:17", "01:32", "01:47",
|
||||
// "02:02", "02:17", "02:32", "02:47",
|
||||
// "03:02", "03:17", "03:32", "03:47",
|
||||
// "04:02", "04:17", "04:32", "04:47",
|
||||
// "05:02", "05:17", "05:32", "05:47",
|
||||
// "06:02", "06:17", "06:32", "06:47",
|
||||
// "07:02", "07:17", "07:32", "07:47",
|
||||
// "08:02", "08:17", "08:32", "08:47",
|
||||
// "09:02", "09:17", "09:32", "09:47",
|
||||
// "10:02", "10:17", "10:32", "10:47",
|
||||
// "11:02", "11:17", "11:32", "11:47",
|
||||
// "12:02", "12:17", "12:32", "12:47",
|
||||
// "13:02", "13:17", "13:32", "13:47",
|
||||
// "14:02", "14:17", "14:32", "14:47",
|
||||
// "15:02", "15:17", "15:32", "15:47",
|
||||
// "16:02", "16:17", "16:32", "16:47",
|
||||
// "17:02", "17:17", "17:32", "17:47",
|
||||
// "18:02", "18:17", "18:32", "18:47",
|
||||
// "19:02", "19:17", "19:32", "19:47",
|
||||
// "20:02", "20:17", "20:32", "20:47",
|
||||
// "21:02", "21:17", "21:32", "21:47",
|
||||
// "22:02", "22:17", "22:32", "22:47",
|
||||
// "23:02", "23:17", "23:32", "23:47",
|
||||
//};
|
||||
|
||||
#region step1. 找出所有電站
|
||||
logger.LogInformation("【CalcInverter15minJob】【開始取得電站資料】");
|
||||
var powerStations = await powerStationRepository.GetAllAsync();
|
||||
@ -36,59 +64,74 @@ namespace SolarPower.Quartz.Jobs
|
||||
|
||||
var DateTimeNow = DateTime.Now;
|
||||
|
||||
var count = 0;
|
||||
|
||||
#region step2. 從電站的DB及電站編號找出該電站的控制器
|
||||
foreach (var powerStation in powerStations)
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
var dateNowTime = DateTimeNow.ToString("yyyy-MM-dd HH:mm");
|
||||
|
||||
var dateNowTime = DateTimeNow.ToString("yyyy-MM-dd HH:mm");
|
||||
//for (var i = 0; i < day_array.Count(); i++)
|
||||
//{
|
||||
// for (var j = 0; j < time_array.Count(); j++)
|
||||
// {
|
||||
//var dateNowTime = string.Format("2021-07-{0} {1}", day_array[i], time_array[j]);
|
||||
|
||||
//取得所有該電站的逆變器
|
||||
logger.LogInformation("【CalcInverter15minJob】【開始取得電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateNowTime);
|
||||
var controllers = await powerStationRepository.GetAllDeviceControllerId(powerStation.Id, powerStation.SiteDB);
|
||||
var inverters = await powerStationRepository.InverterTable(controllers, powerStation.SiteDB);
|
||||
var inverterIds = inverters.Where(x => x.Enabled == 1 && x.Status != 0).Select(x => x.InverterId).ToList();
|
||||
logger.LogInformation("【CalcInverter15minJob】【取得成功電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateNowTime);
|
||||
|
||||
var calcInverter15min = new InverterHistory();
|
||||
|
||||
#region step2-1. 計算該電站逆變器每15min 的值
|
||||
var table_name = String.Format("`{0}`.`s{1}01_inv`", powerStation.SiteDB, powerStation.Code);
|
||||
logger.LogInformation("【CalcInverter15minJob】【開始計算電站[{0}]在{1}的每15分鐘逆變器資訊】", powerStation.Code, dateNowTime);
|
||||
calcInverter15mins = await powerStationRepository.CalcInverterHisyort15minData(dateNowTime, powerStation.SiteDB, table_name, inverterIds);
|
||||
logger.LogInformation("【CalcInverter15minJob】【計算完成電站[{0}]在{1}的每15分鐘逆變器資訊】", powerStation.Code, dateNowTime);
|
||||
if (calcInverter15mins.Count() > 0)
|
||||
{
|
||||
foreach (var inverterHistory in calcInverter15mins)
|
||||
#region step2. 從電站的DB及電站編號找出該電站的控制器
|
||||
foreach (var powerStation in powerStations)
|
||||
{
|
||||
inverterHistory.TIMESTAMP = Convert.ToDateTime(inverterHistory.TIMESTAMP + ":00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
inverterHistory.PowerStationId = powerStation.Id;
|
||||
|
||||
|
||||
|
||||
//取得所有該電站的逆變器
|
||||
logger.LogInformation("【CalcInverter15minJob】【開始取得電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateNowTime);
|
||||
var controllers = await powerStationRepository.GetAllDeviceControllerId(powerStation.Id, powerStation.SiteDB);
|
||||
var inverters = await powerStationRepository.InverterTable(controllers, powerStation.SiteDB);
|
||||
var inverterIds = inverters.Where(x => x.Enabled == 1 && x.Status != 0).Select(x => x.InverterId).ToList();
|
||||
logger.LogInformation("【CalcInverter15minJob】【取得成功電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateNowTime);
|
||||
|
||||
var calcInverter15min = new InverterHistory();
|
||||
|
||||
#region step2-1. 計算該電站逆變器每15min 的值
|
||||
var table_name = String.Format("s{1}01_inv", powerStation.SiteDB, powerStation.Code);
|
||||
var full_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, table_name);
|
||||
var exist = await powerStationRepository.ExistTable(powerStation.SiteDB, table_name);
|
||||
|
||||
if (!string.IsNullOrEmpty(exist))
|
||||
{
|
||||
logger.LogInformation("【CalcInverter15minJob】【開始計算電站[{0}]在{1}的每15分鐘逆變器資訊】", powerStation.Code, dateNowTime);
|
||||
calcInverter15mins = await powerStationRepository.CalcInverterHisyort15minData(dateNowTime, powerStation.SiteDB, full_table_name, inverterIds);
|
||||
logger.LogInformation("【CalcInverter15minJob】【計算完成電站[{0}]在{1}的每15分鐘逆變器資訊】", powerStation.Code, dateNowTime);
|
||||
if (calcInverter15mins.Count() > 0)
|
||||
{
|
||||
foreach (var inverterHistory in calcInverter15mins)
|
||||
{
|
||||
inverterHistory.TIMESTAMP = Convert.ToDateTime(inverterHistory.TIMESTAMP + ":00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
inverterHistory.PowerStationId = powerStation.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
count++;
|
||||
}
|
||||
#endregion
|
||||
#region step3. 將 inverter INSERT 到 inverter_history_hour 資料表
|
||||
List<string> inverter_history_properties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"INVERTERID",
|
||||
"TIMESTAMP",
|
||||
"KWH",
|
||||
"TODAYKWH",
|
||||
"KWHKWP",
|
||||
};
|
||||
|
||||
await powerStationRepository.AddInverter15minHistory(calcInverter15mins, inverter_history_properties);
|
||||
#endregion
|
||||
// }
|
||||
//}
|
||||
|
||||
#region step3. 將 inverter INSERT 到 inverter_history_hour 資料表
|
||||
List<string> inverter_history_properties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"INVERTERID",
|
||||
"TIMESTAMP",
|
||||
"KWH",
|
||||
"TODAYKWH",
|
||||
"KWHKWP",
|
||||
};
|
||||
|
||||
await powerStationRepository.AddInverter15minHistory(calcInverter15mins, inverter_history_properties);
|
||||
#endregion
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
||||
@ -29,6 +29,10 @@ namespace SolarPower.Quartz.Jobs
|
||||
{
|
||||
try
|
||||
{
|
||||
var DateTimeNow = DateTime.Now;
|
||||
var dateTime = DateTimeNow.AddHours(-1).ToString("yyyy-MM-dd HH");
|
||||
logger.LogInformation("【CalcPowerStationJob】【任務開始】");
|
||||
|
||||
#region step1. 找出所有電站
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始取得電站資料】");
|
||||
var powerStations = await powerStationRepository.GetAllAsync();
|
||||
@ -43,9 +47,6 @@ namespace SolarPower.Quartz.Jobs
|
||||
List<PowerStation> calcPowerStations = new List<PowerStation>();
|
||||
List<WeatherObservation> weatherObservations = new List<WeatherObservation>();
|
||||
|
||||
var DateTimeNow = DateTime.Now;
|
||||
|
||||
var count = 0;
|
||||
#region 氣象觀測(取資料)
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始取得氣象觀測】");
|
||||
var client = new HttpClient();
|
||||
@ -56,164 +57,165 @@ namespace SolarPower.Quartz.Jobs
|
||||
logger.LogInformation("【CalcPowerStationJob】【取得成功氣象觀測】");
|
||||
#endregion
|
||||
|
||||
|
||||
#region step2. 從電站的DB及電站編號找出該電站的控制器
|
||||
foreach (var powerStation in powerStations)
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var calcPowerStation = new PowerStation();
|
||||
calcPowerStation.Id = powerStation.Id;
|
||||
|
||||
var dateTime = DateTimeNow.AddHours(-3).ToString("yyyy-MM-dd HH");
|
||||
|
||||
#region step2-1. 取得該電站的當前這小時的歷史資料
|
||||
var table_name = String.Format("`{0}`.s{1}01_station", powerStation.SiteDB, powerStation.Code);
|
||||
var table_name = String.Format("s{1}01_station", powerStation.SiteDB, powerStation.Code);
|
||||
var full_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, table_name);
|
||||
var exist = await powerStationRepository.ExistTable(powerStation.SiteDB, table_name);
|
||||
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
||||
var history = await powerStationRepository.GetPowerStationHistoryPerHour(dateTime, table_name);
|
||||
logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
||||
logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的每小時歷史資料】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(history));
|
||||
var lastmoneyhistorybyhour = await powerStationRepository.GetLastMoneyAndCarbonInHour(powerStation.Id,0,dateTime);
|
||||
|
||||
if (history != null)
|
||||
if (!string.IsNullOrEmpty(exist))
|
||||
{
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
||||
history.PowerStationId = powerStation.Id;
|
||||
history.Timestamp = Convert.ToDateTime(history.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
||||
var history = await powerStationRepository.GetPowerStationHistoryPerHour(dateTime, full_table_name);
|
||||
logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
||||
logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的每小時歷史資料】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(history));
|
||||
var lastmoneyhistorybyhour = await powerStationRepository.GetLastMoneyAndCarbonInHour(powerStation.Id, 0, dateTime);
|
||||
|
||||
#region 計算單一電站每小時發電量、發電金額等資料
|
||||
|
||||
#region 發電量
|
||||
//每小時發電量(直接填寫
|
||||
calcPowerStation.kwh = history.KWH;
|
||||
//今日發電量(直接填寫
|
||||
calcPowerStation.Today_kWh = history.TodayKWh;
|
||||
//總發電量(直接填寫
|
||||
calcPowerStation.Total_kWh = history.TotalKWH;
|
||||
#endregion
|
||||
|
||||
#region 發電金額
|
||||
//發電金額
|
||||
switch (powerStation.SolarType)
|
||||
if (history != null)
|
||||
{
|
||||
case (int)SolarTypeEnum.SelfSold: //自建躉售
|
||||
//今日發電金額 計算方式:todaykWh * 授電費率
|
||||
calcPowerStation.Today_Monery = history.TodayKWh * powerStation.PowerRate;
|
||||
history.MONEY = history.KWH * powerStation.PowerRate;
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
||||
history.PowerStationId = powerStation.Id;
|
||||
history.Timestamp = Convert.ToDateTime(history.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
//總發電金額 計算方式: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;
|
||||
#region 計算單一電站每小時發電量、發電金額等資料
|
||||
|
||||
foreach (var landBuilding in landBuildings)
|
||||
{
|
||||
sumLeaseRate += landBuilding.LeaseRate;
|
||||
}
|
||||
avgLeaseRate = sumLeaseRate / landBuildings.Count();
|
||||
#region 發電量
|
||||
//每小時發電量(直接填寫
|
||||
calcPowerStation.kwh = history.KWH;
|
||||
//今日發電量(直接填寫
|
||||
calcPowerStation.Today_kWh = history.TodayKWh;
|
||||
//總發電量(直接填寫
|
||||
calcPowerStation.Total_kWh = history.TotalKWH;
|
||||
#endregion
|
||||
|
||||
//今日發電金額計算方式:todaykWh * 出借費率(各個土地房屋租借比率平均)
|
||||
calcPowerStation.Today_Monery = history.TodayKWh * avgLeaseRate;
|
||||
#region 發電金額
|
||||
//發電金額
|
||||
switch (powerStation.SolarType)
|
||||
{
|
||||
case (int)SolarTypeEnum.SelfSold: //自建躉售
|
||||
//今日發電金額 計算方式:todaykWh * 授電費率
|
||||
calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate;
|
||||
history.MONEY = history.KWH * powerStation.PowerRate;
|
||||
|
||||
history.MONEY = history.KWH * avgLeaseRate;
|
||||
//總發電金額 計算方式:totalkWh * 授電費率
|
||||
calcPowerStation.Total_Monery = history.TotalKWH * avgLeaseRate;
|
||||
break;
|
||||
case (int)SolarTypeEnum.SelfUse: //自建自用
|
||||
//今日發電金額 計算方式:todaykWh * 授電費率
|
||||
calcPowerStation.Today_Monery = history.TodayKWh * powerStation.PowerRate;
|
||||
//總發電金額 計算方式:totalkWh * 授電費率
|
||||
calcPowerStation.Total_Money = 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;
|
||||
|
||||
history.MONEY = history.KWH * powerStation.PowerRate;
|
||||
foreach (var landBuilding in landBuildings)
|
||||
{
|
||||
sumLeaseRate += landBuilding.LeaseRate;
|
||||
}
|
||||
avgLeaseRate = sumLeaseRate / landBuildings.Count();
|
||||
|
||||
//總發電金額 計算方式:totalkWh * 授電費率
|
||||
calcPowerStation.Total_Monery = history.TotalKWH * powerStation.PowerRate;
|
||||
break;
|
||||
//今日發電金額計算方式:todaykWh * 出借費率(各個土地房屋租借比率平均)
|
||||
calcPowerStation.Today_Money = history.TodayKWh * avgLeaseRate;
|
||||
|
||||
history.MONEY = history.KWH * avgLeaseRate;
|
||||
//總發電金額 計算方式:totalkWh * 授電費率
|
||||
calcPowerStation.Total_Money = history.TotalKWH * avgLeaseRate;
|
||||
break;
|
||||
case (int)SolarTypeEnum.SelfUse: //自建自用
|
||||
//今日發電金額 計算方式:todaykWh * 授電費率
|
||||
calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate;
|
||||
|
||||
history.MONEY = history.KWH * powerStation.PowerRate;
|
||||
|
||||
//總發電金額 計算方式:totalkWh * 授電費率
|
||||
calcPowerStation.Total_Money = 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;
|
||||
|
||||
history.CARBON = history.KWH * carbonRate;
|
||||
//總減碳量(總發電量 * (0.554/1000)[抓資料庫值]
|
||||
calcPowerStation.Total_Carbon = history.TotalKWH * carbonRate;
|
||||
history.TODAYCARBON = lastmoneyhistorybyhour.TODAYCARBON + history.KWH * carbonRate;
|
||||
history.TOTALCARBON = lastmoneyhistorybyhour.TOTALCARBON + history.KWH * carbonRate;
|
||||
history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate;
|
||||
history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate;
|
||||
#endregion
|
||||
|
||||
#region 發電時間
|
||||
calcPowerStation.SolarHour = history.SolarHour;
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
powerStationHistoriesHour.Add(history);
|
||||
|
||||
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region kWh/kWp
|
||||
//直接填寫
|
||||
calcPowerStation.Today_kwhkwp = history.KWHKWP;
|
||||
#endregion
|
||||
#region step2-2. 取得該電站的當前這小時的日照度歷史資料
|
||||
//1. 找出該電站所有日照計設備(包含共享
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的日照計設備資訊】", powerStation.Code, dateTime);
|
||||
var deviceInfos = await powerStationRepository.GetListPyrheliometerByPowerStationId(powerStation.Id, powerStation.SiteDB);
|
||||
logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的日照計設備資訊】", powerStation.Code, dateTime);
|
||||
logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的日照計設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(deviceInfos));
|
||||
|
||||
#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;
|
||||
|
||||
history.CARBON = history.KWH * carbonRate;
|
||||
//總減碳量(總發電量 * (0.554/1000)[抓資料庫值]
|
||||
calcPowerStation.Total_Carbon = history.TotalKWH * carbonRate;
|
||||
#endregion
|
||||
history.TODAYCARBON = lastmoneyhistorybyhour.TODAYCARBON + history.KWH * carbonRate;
|
||||
history.TOTALCARBON = lastmoneyhistorybyhour.TOTALCARBON + history.KWH * carbonRate;
|
||||
history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate;
|
||||
history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate;
|
||||
#endregion
|
||||
|
||||
powerStationHistoriesHour.Add(history);
|
||||
|
||||
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region step2-2. 取得該電站的當前這小時的日照度歷史資料
|
||||
//1. 找出該電站所有日照計設備(包含共享
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的日照計設備資訊】", powerStation.Code, dateTime);
|
||||
var deviceInfos = await powerStationRepository.GetListPyrheliometerByPowerStationId(powerStation.Id, powerStation.SiteDB);
|
||||
logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的日照計設備資訊】", powerStation.Code, dateTime);
|
||||
logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的日照計設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(deviceInfos));
|
||||
|
||||
if (deviceInfos != null)
|
||||
{
|
||||
//2. 計算該電站所有日照計設的每小時的平均在依照日照計數量平均
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的日照計的日照度】", powerStation.Code, dateTime);
|
||||
var pyrheliometerHistory = await powerStationRepository.GetPyrheliometerHistoryPerHour(dateTime, deviceInfos, 0);
|
||||
|
||||
if (pyrheliometerHistory != null)
|
||||
if (deviceInfos != null)
|
||||
{
|
||||
calcPowerStation.Today_irradiance = pyrheliometerHistory.Irradiance;
|
||||
//2. 計算該電站所有日照計設的每小時的平均在依照日照計數量平均
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的日照計的日照度】", powerStation.Code, dateTime);
|
||||
var pyrheliometerHistory = await powerStationRepository.GetPyrheliometerHistoryPerHour(dateTime, deviceInfos, 0);
|
||||
|
||||
pyrheliometerHistory.Timestamp = Convert.ToDateTime(pyrheliometerHistory.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
pyrheliometerHistory.PowerStationId = powerStation.Id;
|
||||
pyrheliometerHistoriesHour.Add(pyrheliometerHistory);
|
||||
if (pyrheliometerHistory != null)
|
||||
{
|
||||
calcPowerStation.Today_irradiance = pyrheliometerHistory.Irradiance;
|
||||
|
||||
pyrheliometerHistory.Timestamp = Convert.ToDateTime(pyrheliometerHistory.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
pyrheliometerHistory.PowerStationId = powerStation.Id;
|
||||
pyrheliometerHistoriesHour.Add(pyrheliometerHistory);
|
||||
}
|
||||
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的日照計的日照度】", powerStation.Code, dateTime);
|
||||
}
|
||||
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的日照計的日照度】", powerStation.Code, dateTime);
|
||||
}
|
||||
//2. 計算該電站所有溫度計設的每小時的平均在依照溫度計數量平均
|
||||
// 找出該電站所有溫度計設備(包含共享
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的溫度計設備資訊】", powerStation.Code, dateTime);
|
||||
var tempdeviceInfos = await powerStationRepository.GetListTempByPowerStationId(powerStation.Id, powerStation.SiteDB);
|
||||
logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的溫度計設備資訊】", powerStation.Code, dateTime);
|
||||
logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的溫度計設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(tempdeviceInfos));
|
||||
if (tempdeviceInfos != null)
|
||||
{
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的溫度計的平均溫度】", powerStation.Code, dateTime);
|
||||
var tempHistory = await powerStationRepository.GetPyrheliometerHistoryPerHour(dateTime, tempdeviceInfos, 1);
|
||||
if (tempHistory != null)
|
||||
//2. 計算該電站所有溫度計設的每小時的平均在依照溫度計數量平均
|
||||
// 找出該電站所有溫度計設備(包含共享
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的溫度計設備資訊】", powerStation.Code, dateTime);
|
||||
var tempdeviceInfos = await powerStationRepository.GetListTempByPowerStationId(powerStation.Id, powerStation.SiteDB);
|
||||
logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的溫度計設備資訊】", powerStation.Code, dateTime);
|
||||
logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的溫度計設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(tempdeviceInfos));
|
||||
if (tempdeviceInfos != null)
|
||||
{
|
||||
tempHistory.Timestamp = Convert.ToDateTime(tempHistory.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
tempHistory.PowerStationId = powerStation.Id;
|
||||
TempHistoriesHour.Add(tempHistory);
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的溫度計的平均溫度】", powerStation.Code, dateTime);
|
||||
var tempHistory = await powerStationRepository.GetPyrheliometerHistoryPerHour(dateTime, tempdeviceInfos, 1);
|
||||
if (tempHistory != null)
|
||||
{
|
||||
tempHistory.Timestamp = Convert.ToDateTime(tempHistory.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
tempHistory.PowerStationId = powerStation.Id;
|
||||
TempHistoriesHour.Add(tempHistory);
|
||||
|
||||
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的溫度計的平均溫度】", powerStation.Code, dateTime);
|
||||
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的溫度計的平均溫度】", powerStation.Code, dateTime);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region step2-3. 計算該電站所有逆變器每小時值
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateTime);
|
||||
@ -223,25 +225,34 @@ namespace SolarPower.Quartz.Jobs
|
||||
logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateTime);
|
||||
logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的逆變器設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(inverterIds));
|
||||
|
||||
var inverter_table_name = String.Format("`{0}`.s{1}01_inv", powerStation.SiteDB, powerStation.Code);
|
||||
var inverter_table_name = String.Format("s{0}01_inv", powerStation.Code);
|
||||
var full_inverter_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, inverter_table_name);
|
||||
var exist_inverter_table = await powerStationRepository.ExistTable(powerStation.SiteDB, full_inverter_table_name);
|
||||
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的逆變器的資訊】", powerStation.Code, dateTime);
|
||||
inverterHistories = await powerStationRepository.CalcInverterHisyortHourData(dateTime, powerStation.SiteDB, inverter_table_name, inverterIds);
|
||||
foreach (var inverterHistory in inverterHistories)
|
||||
if (!string.IsNullOrEmpty(exist_inverter_table))
|
||||
{
|
||||
inverterHistory.DC1KW = inverterHistory.DC1W / 1000;
|
||||
inverterHistory.DC2KW = inverterHistory.DC2W / 1000;
|
||||
inverterHistory.DC3KW = inverterHistory.DC3W / 1000;
|
||||
inverterHistory.DC4KW = inverterHistory.DC4W / 1000;
|
||||
inverterHistory.DC5KW = inverterHistory.DC5W / 1000;
|
||||
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的逆變器的資訊】", powerStation.Code, dateTime);
|
||||
inverterHistories = await powerStationRepository.CalcInverterHisyortHourData(dateTime, powerStation.SiteDB, full_inverter_table_name, inverterIds);
|
||||
//取得日照計要找的欄位資訊
|
||||
var pyrheliometer = await powerStationRepository.GetFirstPyrheliometerInfo(powerStation.Id, powerStation.SiteDB);
|
||||
var pyrheliometerValue = await powerStationRepository.GetFirstPyrheliometerValue(dateTime, pyrheliometer.DBName, pyrheliometer.TableName, pyrheliometer.ColName);
|
||||
foreach (var inverterHistory in inverterHistories)
|
||||
{
|
||||
inverterHistory.Irradiance = pyrheliometerValue;
|
||||
inverterHistory.DC1KW = inverterHistory.DC1W / 1000;
|
||||
inverterHistory.DC2KW = inverterHistory.DC2W / 1000;
|
||||
inverterHistory.DC3KW = inverterHistory.DC3W / 1000;
|
||||
inverterHistory.DC4KW = inverterHistory.DC4W / 1000;
|
||||
inverterHistory.DC5KW = inverterHistory.DC5W / 1000;
|
||||
|
||||
inverterHistory.DCKW = (inverterHistory.DC1W + inverterHistory.DC2W + inverterHistory.DC3W + inverterHistory.DC4W + inverterHistory.DC5W) / 1000;
|
||||
inverterHistory.ACKW = (inverterHistory.AC1W + inverterHistory.AC2W + inverterHistory.AC3W) / 1000;
|
||||
inverterHistory.DCKW = (inverterHistory.DC1W + inverterHistory.DC2W + inverterHistory.DC3W + inverterHistory.DC4W + inverterHistory.DC5W) / 1000;
|
||||
inverterHistory.ACKW = (inverterHistory.AC1W + inverterHistory.AC2W + inverterHistory.AC3W) / 1000;
|
||||
|
||||
inverterHistory.TIMESTAMP = Convert.ToDateTime(inverterHistory.TIMESTAMP + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
inverterHistory.PowerStationId = powerStation.Id;
|
||||
inverterHistory.TIMESTAMP = Convert.ToDateTime(inverterHistory.TIMESTAMP + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
inverterHistory.PowerStationId = powerStation.Id;
|
||||
}
|
||||
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的逆變器的資訊】", powerStation.Code, dateTime);
|
||||
}
|
||||
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的逆變器的資訊】", powerStation.Code, dateTime);
|
||||
#endregion
|
||||
|
||||
#region 確認是否有觀測站(沒有則新增)
|
||||
@ -293,8 +304,6 @@ namespace SolarPower.Quartz.Jobs
|
||||
|
||||
weatherObservations.Add(weatherObservation);
|
||||
calcPowerStations.Add(calcPowerStation);
|
||||
|
||||
count++;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -351,12 +360,13 @@ namespace SolarPower.Quartz.Jobs
|
||||
"Today_kwh",
|
||||
"Total_kwh",
|
||||
"today_kwhkwp",
|
||||
"today_monery",
|
||||
"total_monery",
|
||||
"today_money",
|
||||
"total_money",
|
||||
"today_PR",
|
||||
"today_carbon",
|
||||
"total_carbon",
|
||||
"today_irradiance",
|
||||
"SolarHour",
|
||||
"WeathersStationId",
|
||||
"TodayWeatherTemp",
|
||||
"TodayWeather",
|
||||
@ -372,6 +382,55 @@ namespace SolarPower.Quartz.Jobs
|
||||
"PowerStationId",
|
||||
"INVERTERID",
|
||||
"TIMESTAMP",
|
||||
"Irradiance",
|
||||
"AC1V",
|
||||
"AC1A",
|
||||
"AC1W",
|
||||
"AC1F",
|
||||
"AC1WH",
|
||||
"AC2V",
|
||||
"AC2A",
|
||||
"AC2W",
|
||||
"AC2F",
|
||||
"AC2WH",
|
||||
"AC3V",
|
||||
"AC3A",
|
||||
"AC3W",
|
||||
"AC3F",
|
||||
"AC3WH",
|
||||
"DC1V",
|
||||
"DC1A",
|
||||
"DC1W",
|
||||
"DC1KW",
|
||||
"DC1WH",
|
||||
"DC2V",
|
||||
"DC2A",
|
||||
"DC2W",
|
||||
"DC2KW",
|
||||
"DC2WH",
|
||||
"DC3V",
|
||||
"DC3A",
|
||||
"DC3W",
|
||||
"DC3KW",
|
||||
"DC3WH",
|
||||
"DC4V",
|
||||
"DC4A",
|
||||
"DC4W",
|
||||
"DC4KW",
|
||||
"DC4WH",
|
||||
"DC5V",
|
||||
"DC5A",
|
||||
"DC5W",
|
||||
"DC5KW",
|
||||
"DC5WH",
|
||||
"PR",
|
||||
"RA1",
|
||||
"RA2",
|
||||
"RA3",
|
||||
"RA4",
|
||||
"RA5",
|
||||
"DCKW",
|
||||
"ACKW",
|
||||
"KWH",
|
||||
"TODAYKWH",
|
||||
"KWHKWP",
|
||||
@ -387,6 +446,8 @@ namespace SolarPower.Quartz.Jobs
|
||||
"Temp"
|
||||
};
|
||||
await powerStationRepository.AddWeatherObservation(weatherObservations, weather_observation_properties);
|
||||
|
||||
logger.LogInformation("【CalcPowerStationJob】【任務完成】");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
||||
@ -578,8 +578,8 @@ namespace SolarPower.Repository.Implement
|
||||
`Total_kwh` DECIMAL(10,3) UNSIGNED NOT NULL DEFAULT '0.000' COMMENT '總發電量',
|
||||
`today_kwhkwp` DECIMAL(10,3) NULL DEFAULT NULL COMMENT '今日kwhkwp',
|
||||
`avg_kwhkwp` DECIMAL(10,3) NULL DEFAULT NULL COMMENT '30天平均kwhkwp',
|
||||
`today_monery` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '今日金額',
|
||||
`total_monery` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '總金額',
|
||||
`today_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '今日金額',
|
||||
`total_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '總金額',
|
||||
`today_PR` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '電站Pr值',
|
||||
`avg_PR` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '平均Pr值',
|
||||
`today_carbon` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '今日減碳量',
|
||||
|
||||
@ -53,8 +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_money) AS today_money,
|
||||
SUM(ps.total_money) AS total_money,
|
||||
SUM(ps.today_carbon) AS today_carbon,
|
||||
SUM(ps.total_carbon) AS total_carbon
|
||||
FROM power_station ps
|
||||
@ -198,9 +198,9 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql_power = @$"SELECT DATE_FORMAT(ps.timestamp, '%Y-%m-%d %H') AS Label, ps.KWH AS PowerData, pyr.Irradiance AS IrradianceData
|
||||
var sql_power = @$"SELECT DATE_FORMAT(ps.timestamp,'%H %p') AS Label, ps.KWH AS PowerData, pyr.Irradiance AS IrradianceData
|
||||
FROM power_station_history_hour ps
|
||||
LEFT JOIN sensor_history_hour pyr ON ps.PowerStationId = pyr.PowerStationId AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d %H') = DATE_FORMAT(pyr.timestamp, '%Y-%m-%d %H')
|
||||
LEFT JOIN sensor_history_hour pyr ON ps.PowerStationId = pyr.PowerStationId AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d %H') = DATE_FORMAT(pyr.timestamp, '%Y-%m-%d %H')
|
||||
WHERE ps.PowerStationId = @PowerStationId
|
||||
AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d') = @NowDay";
|
||||
|
||||
@ -224,7 +224,7 @@ namespace SolarPower.Repository.Implement
|
||||
|
||||
var sql_power = @$"SELECT DATE_FORMAT(ps.timestamp, '%Y-%m-%d') AS Label, ps.TODAYKWH AS PowerData, pyr.Irradiance AS IrradianceData
|
||||
FROM power_station_history_day ps
|
||||
LEFT JOIN sensor_history_day pyr ON ps.PowerStationId = pyr.PowerStationId AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d') = DATE_FORMAT(FROM_UNIXTIME(pyr.timestamp), '%Y-%m-%d')
|
||||
LEFT JOIN sensor_history_day pyr ON ps.PowerStationId = pyr.PowerStationId AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d') = DATE_FORMAT(pyr.timestamp, '%Y-%m-%d')
|
||||
WHERE ps.PowerStationId = @PowerStationId
|
||||
AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d') BETWEEN @StartDay AND @NowDay";
|
||||
|
||||
@ -248,7 +248,7 @@ namespace SolarPower.Repository.Implement
|
||||
|
||||
var sql_power = @$"SELECT DATE_FORMAT(ps.timestamp, '%Y-%m-%d') AS Label, ps.TODAYKWH AS PowerData, pyr.Irradiance AS IrradianceData
|
||||
FROM power_station_history_day ps
|
||||
LEFT JOIN sensor_history_day pyr ON ps.PowerStationId = pyr.PowerStationId AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d') = DATE_FORMAT(FROM_UNIXTIME(pyr.timestamp), '%Y-%m-%d')
|
||||
LEFT JOIN sensor_history_day pyr ON ps.PowerStationId = pyr.PowerStationId AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d') = DATE_FORMAT(pyr.timestamp, '%Y-%m-%d')
|
||||
WHERE ps.PowerStationId = @PowerStationId
|
||||
AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d') BETWEEN @StartDay AND @NowDay";
|
||||
|
||||
@ -273,7 +273,7 @@ namespace SolarPower.Repository.Implement
|
||||
|
||||
var sql_power = @$"SELECT DATE_FORMAT(ps.timestamp, '%Y-%m') AS Label, ps.MONTHKWH AS PowerData, pyr.Irradiance AS IrradianceData
|
||||
FROM power_station_history_month ps
|
||||
LEFT JOIN sensor_history_month pyr ON ps.PowerStationId = pyr.PowerStationId AND DATE_FORMAT(ps.timestamp, '%Y-%m') = DATE_FORMAT(FROM_UNIXTIME(pyr.timestamp), '%Y-%m')
|
||||
LEFT JOIN sensor_history_month pyr ON ps.PowerStationId = pyr.PowerStationId AND DATE_FORMAT(ps.timestamp, '%Y-%m') = DATE_FORMAT(pyr.timestamp, '%Y-%m')
|
||||
WHERE ps.PowerStationId = @PowerStationId
|
||||
AND DATE_FORMAT(ps.timestamp, '%Y') = @Year";
|
||||
|
||||
@ -315,9 +315,12 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = @$"SELECT * FROM inverter_history_15min WHERE PowerStationId = @PowerStationId AND DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') = @DateTime";
|
||||
var startDateTime = dateTime + " 05:00";
|
||||
var endDataTime = dateTime + " 19:00";
|
||||
|
||||
result = (await conn.QueryAsync<InverterHistory>(sql, new { PowerStationId = powerStationId, DateTime = dateTime })).ToList();
|
||||
var sql = @$"SELECT * FROM inverter_history_15min WHERE PowerStationId = @PowerStationId AND DATE_FORMAT(TIMESTAMP, '%Y-%m-%d %H:%i') BETWEEN @StartDateTime AND @EndDateTime";
|
||||
|
||||
result = (await conn.QueryAsync<InverterHistory>(sql, new { PowerStationId = powerStationId, StartDateTime = startDateTime, EndDateTime = endDataTime })).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -385,7 +388,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql_power = @$"SELECT DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d %H') AS TIMESTAMP,
|
||||
var sql_power = @$"SELECT DATE_FORMAT(inv.TIMESTAMP, '%H %p') AS TIMESTAMP,
|
||||
inv.INVERTERID,
|
||||
inv.KWH
|
||||
FROM inverter_history_hour inv
|
||||
@ -485,7 +488,8 @@ namespace SolarPower.Repository.Implement
|
||||
var pyrdb = "";
|
||||
var timeGroup = "";
|
||||
var range = "";
|
||||
switch(post.GroupType)
|
||||
var range2 = "";
|
||||
switch (post.GroupType)
|
||||
{
|
||||
case 0:
|
||||
kwh = "C.KWH";
|
||||
@ -493,6 +497,8 @@ namespace SolarPower.Repository.Implement
|
||||
pyrdb = "sensor_history_hour";
|
||||
timeGroup = "%Y-%m-%d %H:%M:%S";
|
||||
range = $" WHERE DATE_FORMAT(V.TIMESTAMP,'%Y-%m-%d') = '{post.HistoryRange}'";
|
||||
range2 = $" AND DATE_FORMAT(C.TIMESTAMP,'%Y-%m-%d') = '{post.HistoryRange}'";
|
||||
|
||||
break;
|
||||
case 1:
|
||||
kwh = "C.TODAYKWH";
|
||||
@ -500,6 +506,8 @@ namespace SolarPower.Repository.Implement
|
||||
pyrdb = "sensor_history_day";
|
||||
timeGroup = "%Y-%m-%d";
|
||||
range = $" WHERE DATE_FORMAT(V.TIMESTAMP,'%Y-%m') = '{post.HistoryRange}'";
|
||||
//range2 = $" DATE_FORMAT(C.TIMESTAMP,'%Y-%m') = '{post.HistoryRange}'";
|
||||
|
||||
break;
|
||||
case 2:
|
||||
kwh = "C.MONTHKWH";
|
||||
@ -507,6 +515,7 @@ namespace SolarPower.Repository.Implement
|
||||
pyrdb = "sensor_history_month";
|
||||
timeGroup = "%Y-%m";
|
||||
range = $" WHERE DATE_FORMAT(V.TIMESTAMP,'%Y') = '{post.HistoryRange}'";
|
||||
//range2 = $" DATE_FORMAT(C.TIMESTAMP,'%Y') = '{post.HistoryRange}'";
|
||||
break;
|
||||
case 3:
|
||||
kwh = "C.TOTALKWH";
|
||||
@ -530,7 +539,7 @@ namespace SolarPower.Repository.Implement
|
||||
C.TIMESTAMP,{kwh} AS KWH,C.SOLARHOUR,C.PR,P.Irradiance,P.Temperature AS Temp
|
||||
FROM {usedb} C
|
||||
LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP,'{timeGroup}') = DATE_FORMAT(C.TIMESTAMP,'{timeGroup}')
|
||||
WHERE C.PowerStationId = {post.PowerstationId} GROUP BY C.TIMESTAMP ORDER BY C.TIMESTAMP
|
||||
WHERE C.PowerStationId = {post.PowerstationId}{range2} GROUP BY C.TIMESTAMP ORDER BY C.TIMESTAMP
|
||||
) A
|
||||
RIGHT OUTER JOIN
|
||||
(
|
||||
@ -539,7 +548,7 @@ namespace SolarPower.Repository.Implement
|
||||
C.TIMESTAMP,{kwh} AS KWH,C.SOLARHOUR,C.PR,P.Irradiance,P.Temperature AS Temp
|
||||
FROM {usedb} C
|
||||
LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP,'{timeGroup}') = DATE_FORMAT(C.TIMESTAMP,'{timeGroup}')
|
||||
WHERE C.PowerStationId = {post.PowerstationId} GROUP BY C.TIMESTAMP ORDER BY C.TIMESTAMP
|
||||
WHERE C.PowerStationId = {post.PowerstationId}{range2} GROUP BY C.TIMESTAMP ORDER BY C.TIMESTAMP
|
||||
) B
|
||||
ON A.ROWID = B.PreROWID
|
||||
) V {range}" ;
|
||||
|
||||
@ -2630,7 +2630,7 @@ namespace SolarPower.Repository.Implement
|
||||
LEFT JOIN (
|
||||
SELECT MAX(FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i')) AS TIMESTAMP,
|
||||
sub_inv.INVERTERID,
|
||||
SUM(sub_inv.WH)/1000 AS KWH
|
||||
AVG(sub_inv.WH)/1000 AS KWH
|
||||
FROM {table_name} sub_inv
|
||||
WHERE FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') BETWEEN @StartDateTime AND @EndDateTime
|
||||
AND sub_inv.INVERTERID IN @InverterIds
|
||||
@ -2703,7 +2703,6 @@ namespace SolarPower.Repository.Implement
|
||||
AVG(s.AC3W) AS AC3W,
|
||||
AVG(s.AC3F) AS AC3F,
|
||||
AVG(s.AC3WH) AS AC3WH,
|
||||
AVG(s.ACRUNTIME) AS ACRUNTIME,
|
||||
AVG(s.DC1V) AS DC1V,
|
||||
AVG(s.DC1A) AS DC1A,
|
||||
AVG(s.DC1W) AS DC1W,
|
||||
@ -2739,7 +2738,7 @@ namespace SolarPower.Repository.Implement
|
||||
SELECT
|
||||
FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H') AS TIMESTAMP,
|
||||
inv.INVERTERID,
|
||||
SUM(inv.WH)/1000 AS KWH
|
||||
AVG(inv.WH)/1000 AS KWH
|
||||
FROM {table_name} inv
|
||||
WHERE DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP/1000), '%Y-%m-%d %H') = @DateTime
|
||||
AND inv.INVERTERID IN @InverterIds
|
||||
@ -2761,6 +2760,51 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<DeviceInfo> GetFirstPyrheliometerInfo(int powerStationId, string db_name)
|
||||
{
|
||||
DeviceInfo result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $@"SELECT d.*
|
||||
FROM {db_name}.device d
|
||||
LEFT JOIN {db_name}.controller c ON d.ControllerId = c.Id AND c.Deleted = 0
|
||||
WHERE d.Enabled = 1 AND d.`Status` != 0 AND d.`Type` = 'PYR'
|
||||
AND d.PowerStationId = @PowerStationId
|
||||
ORDER BY d.ColName";
|
||||
|
||||
result = await conn.QueryFirstAsync<DeviceInfo>(sql, new { PowerStationId = powerStationId });
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<double> GetFirstPyrheliometerValue(string dateTime, string db_name, string table_name, string col_name)
|
||||
{
|
||||
double result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $@"SELECT AVG({col_name})
|
||||
FROM {db_name}.{table_name}
|
||||
WHERE FROM_UNIXTIME(TIMESTAMP/1000, '%Y-%m-%d %H') = @DateTime";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<double>(sql, new { DateTime = dateTime });
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<InverterHistory>> CalcInverterHistoryDayDataByPowerStationId(string nowDay, string db_name, int powerStationId)
|
||||
{
|
||||
List<InverterHistory> result;
|
||||
@ -2772,6 +2816,7 @@ namespace SolarPower.Repository.Implement
|
||||
inv.PowerStationId,
|
||||
DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP,
|
||||
inv.INVERTERID,
|
||||
AVG(inv.Irradiance) AS Irradiance,
|
||||
AVG(inv.AC1V) AS AC1V,
|
||||
AVG(inv.AC1A) AS AC1A,
|
||||
AVG(inv.AC1W) AS AC1W,
|
||||
@ -2787,7 +2832,6 @@ namespace SolarPower.Repository.Implement
|
||||
AVG(inv.AC3W) AS AC3W,
|
||||
AVG(inv.AC3F) AS AC3F,
|
||||
AVG(inv.AC3WH) AS AC3WH,
|
||||
AVG(inv.ACRUNTIME) AS ACRUNTIME,
|
||||
AVG(inv.DC1V) AS DC1V,
|
||||
AVG(inv.DC1A) AS DC1A,
|
||||
AVG(inv.DC1W) AS DC1W,
|
||||
@ -2893,6 +2937,48 @@ namespace SolarPower.Repository.Implement
|
||||
inv.PowerStationId,
|
||||
DATE_FORMAT(inv.TIMESTAMP, '%Y-%m') AS TIMESTAMP,
|
||||
inv.INVERTERID,
|
||||
AVG(inv.Irradiance) AS Irradiance,
|
||||
AVG(inv.AC1V) AS AC1V,
|
||||
AVG(inv.AC1A) AS AC1A,
|
||||
AVG(inv.AC1W) AS AC1W,
|
||||
AVG(inv.AC1F) AS AC1F,
|
||||
AVG(inv.AC1WH) AS AC1WH,
|
||||
AVG(inv.AC2V) AS AC2V,
|
||||
AVG(inv.AC2A) AS AC2A,
|
||||
AVG(inv.AC2W) AS AC2W,
|
||||
AVG(inv.AC2F) AS AC2F,
|
||||
AVG(inv.AC2WH) AS AC2WH,
|
||||
AVG(inv.AC3V) AS AC3V,
|
||||
AVG(inv.AC3A) AS AC3A,
|
||||
AVG(inv.AC3W) AS AC3W,
|
||||
AVG(inv.AC3F) AS AC3F,
|
||||
AVG(inv.AC3WH) AS AC3WH,
|
||||
AVG(inv.DC1V) AS DC1V,
|
||||
AVG(inv.DC1A) AS DC1A,
|
||||
AVG(inv.DC1W) AS DC1W,
|
||||
AVG(inv.DC1WH) AS DC1WH,
|
||||
AVG(inv.DC2V) AS DC2V,
|
||||
AVG(inv.DC2A) AS DC2A,
|
||||
AVG(inv.DC2W) AS DC2W,
|
||||
AVG(inv.DC2WH) AS DC2WH,
|
||||
AVG(inv.DC3V) AS DC3V,
|
||||
AVG(inv.DC3A) AS DC3A,
|
||||
AVG(inv.DC3W) AS DC3W,
|
||||
AVG(inv.DC3WH) AS DC3WH,
|
||||
AVG(inv.DC4V) AS DC4V,
|
||||
AVG(inv.DC4A) AS DC4A,
|
||||
AVG(inv.DC4W) AS DC4W,
|
||||
AVG(inv.DC4WH) AS DC4WH,
|
||||
AVG(inv.DC5V) AS DC5V,
|
||||
AVG(inv.DC5A) AS DC5A,
|
||||
AVG(inv.DC5W) AS DC5W,
|
||||
AVG(inv.DC5WH) AS DC5WH,
|
||||
AVG(inv.PR) AS PR,
|
||||
AVG(inv.RA1) AS RA1,
|
||||
AVG(inv.RA2) AS RA2,
|
||||
AVG(inv.RA3) AS RA3,
|
||||
AVG(inv.RA4) AS RA4,
|
||||
AVG(inv.RA5) AS RA5,
|
||||
SUM(inv.KWH) AS KWH,
|
||||
SUM(inv.TODAYKWH) AS TODAYKWH,
|
||||
SUM(inv.TODAYKWH) / i.Capacity AS KWHKWP
|
||||
@ -3142,7 +3228,7 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<MoneyAndCarbon> GetMoneyAndCarbonWithHistoryHour (int powerstationId , string dateTime ,int type)
|
||||
public async Task<MoneyAndCarbon> GetMoneyAndCarbonWithHistoryHour(int powerstationId, string dateTime, int type)
|
||||
{
|
||||
MoneyAndCarbon result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
@ -3217,5 +3303,24 @@ namespace SolarPower.Repository.Implement
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string> ExistTable(string db_name,string table_name)
|
||||
{
|
||||
string result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = @DBName AND TABLE_NAME = @TableName;";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<string>(sql, new { DBName = db_name, TableName = table_name });
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -521,6 +521,8 @@ namespace SolarPower.Repository.Interface
|
||||
Task<List<InverterHistory>> CalcInverterHisyort15minData(string dateTime, string db_name, string table_name, List<string> inverterIds);
|
||||
Task<int> AddInverter15minHistory(List<InverterHistory> entity, List<string> properties);
|
||||
Task<List<InverterHistory>> CalcInverterHisyortHourData(string dateTime, string db_name, string table_name, List<string> inverterIds);
|
||||
Task<DeviceInfo> GetFirstPyrheliometerInfo(int powerStationId, string db_name);
|
||||
Task<double> GetFirstPyrheliometerValue(string dateTime, string db_name, string table_name, string col_name);
|
||||
Task<int> AddInverterHistory(List<InverterHistory> entity, List<string> properties);
|
||||
Task<List<InverterHistory>> CalcInverterHistoryDayDataByPowerStationId(string nowDay, string db_name, int powerStationId);
|
||||
Task<int> AddInverterHistoryDayList(List<InverterHistory> entity, List<string> properties);
|
||||
@ -535,5 +537,6 @@ namespace SolarPower.Repository.Interface
|
||||
Task<NowWeather> SelectNowWeather(int CityId);
|
||||
Task<MoneyAndCarbon> GetMoneyAndCarbonWithHistoryHour(int powerstationId, string dateTime, int type);
|
||||
Task<MoneyAndCarbon> GetLastMoneyAndCarbonInHour(int powerstationId,int type,string time);
|
||||
Task<string> ExistTable(string db_name, string table_name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,7 +252,7 @@
|
||||
}
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
@ -341,7 +341,7 @@
|
||||
}
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
|
||||
@ -198,7 +198,7 @@
|
||||
"data": "subTotalCapacity"
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
@{
|
||||
ViewData["MainNum"] = "6";
|
||||
ViewData["SubNum"] = "1";
|
||||
ViewData["SubNum"] = "2";
|
||||
ViewData["Title"] = "運維管理";
|
||||
}
|
||||
@using SolarPower.Models.Role
|
||||
@ -330,7 +330,7 @@
|
||||
"data": "function"
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
@{
|
||||
ViewData["MainNum"] = "6";
|
||||
ViewData["SubNum"] = "2";
|
||||
ViewData["SubNum"] = "3";
|
||||
ViewData["Title"] = "運維作業記錄";
|
||||
}
|
||||
@using SolarPower.Models.Role
|
||||
@ -413,7 +413,7 @@
|
||||
'visible': @(ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.CompanyUser ? "false" : "true")
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
@{
|
||||
ViewData["MainNum"] = "2";
|
||||
ViewData["MainNum"] = "6";
|
||||
ViewData["SubNum"] = "1";
|
||||
ViewData["Title"] = "電站管理";
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
@{
|
||||
ViewData["MainNum"] = "2";
|
||||
ViewData["MainNum"] = "6";
|
||||
ViewData["SubNum"] = "1";
|
||||
ViewData["Title"] = "電站管理";
|
||||
}
|
||||
|
||||
@ -194,7 +195,7 @@
|
||||
"data": "function"
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
@ -281,7 +282,7 @@
|
||||
"data": "function"
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
@ -350,7 +351,7 @@
|
||||
"data": "function"
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
@ -438,7 +439,7 @@
|
||||
"data": "function"
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
@ -526,7 +527,7 @@
|
||||
"data": "function"
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
@ -602,7 +603,7 @@
|
||||
"data": "function"
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
|
||||
@ -177,7 +177,7 @@
|
||||
</li>
|
||||
}
|
||||
<!-- Example of open and active states -->
|
||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStation"))
|
||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStationInfo"))
|
||||
{
|
||||
<li class="@(ViewData["MainNum"] == "2" ? "active open" : "")">
|
||||
<a href="javascript:void(0);" title="Category" data-filter-tags="category">
|
||||
@ -200,7 +200,7 @@
|
||||
<li class="@(ViewData["MainNum"].ToString() == "2" &&
|
||||
ViewData["SubNum"].ToString() == ViewBag.myPowerStationSummaries.IndexOf(myPowerStationSummary).ToString() &&
|
||||
ViewData["TagNum"].ToString() == myPowerStationSummary.MyPowerStations.IndexOf(myPowerStation).ToString() ? "active" : "")">
|
||||
<a asp-controller="PowerStation" asp-action="Edit" asp-route-stationId="@myPowerStation.PowerStationId" title="Sublevel Item" data-filter-tags="utilities menu child sublevel item">
|
||||
<a asp-controller="StationOverview" asp-action="Info" asp-route-stationId="@myPowerStation.PowerStationId" title="Sublevel Item" data-filter-tags="utilities menu child sublevel item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_menu_child_sublevel_item">@myPowerStation.PowerStationName</span>
|
||||
</a>
|
||||
</li>
|
||||
@ -209,15 +209,16 @@
|
||||
</ul>
|
||||
</li>
|
||||
}
|
||||
<li class="@(ViewData["MainNum"] == "2" && ViewData["SubNum"].ToString() == ViewBag.myPowerStationSummaries.Count.ToString() ? "active" : "")">
|
||||
<a asp-controller="PowerStation" asp-action="Index" title="電站管理" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">電站管理</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@*<li class="@(ViewData["MainNum"] == "2" && ViewData["SubNum"].ToString() == ViewBag.myPowerStationSummaries.Count.ToString() ? "active" : "")">
|
||||
<a asp-controller="PowerStation" asp-action="Index" title="電站管理" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">電站管理</span>
|
||||
</a>
|
||||
</li>*@
|
||||
</ul>
|
||||
</li>
|
||||
}
|
||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStation"))@*TODO:修改成交叉分析的權限*@
|
||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("AnalysisStationCombine") || ViewBag.auths.Contains("AnalysisStationInfo") || ViewBag.auths.Contains("AnalysisInverter"))
|
||||
{
|
||||
<li class="@(ViewData["MainNum"] == "3" ? "active open" : "")">
|
||||
<a href="#" title="Category" data-filter-tags="category">
|
||||
@ -225,21 +226,30 @@
|
||||
<span class="nav-link-text" data-i18n="nav.category">交叉分析</span>
|
||||
</a>
|
||||
<ul>
|
||||
<li class="@(ViewData["MainNum"] == "3" && ViewData["SubNum"] == "1" ? "active" : "")">
|
||||
<a asp-controller="AnalysisStationCombine" asp-action="Index" title="合併電站" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">合併電站</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="@(ViewData["MainNum"] == "3" && ViewData["SubNum"] == "2" ? "active" : "")">
|
||||
<a asp-controller="AnalysisStationInfo" asp-action="Index" title="電站交叉分析" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">電站交叉分析</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="@(ViewData["MainNum"] == "3" && ViewData["SubNum"] == "3" ? "active" : "")">
|
||||
<a asp-controller="AnalysisInverter" asp-action="Index" title="逆變器交叉分析" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">逆變器交叉分析</span>
|
||||
</a>
|
||||
</li>
|
||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("AnalysisStationCombine"))
|
||||
{
|
||||
<li class="@(ViewData["MainNum"] == "3" && ViewData["SubNum"] == "1" ? "active" : "")">
|
||||
<a asp-controller="AnalysisStationCombine" asp-action="Index" title="合併電站" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">合併電站</span>
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("AnalysisStationInfo"))
|
||||
{
|
||||
<li class="@(ViewData["MainNum"] == "3" && ViewData["SubNum"] == "2" ? "active" : "")">
|
||||
<a asp-controller="AnalysisStationInfo" asp-action="Index" title="電站交叉分析" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">電站交叉分析</span>
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("AnalysisInverter"))
|
||||
{
|
||||
<li class="@(ViewData["MainNum"] == "3" && ViewData["SubNum"] == "3" ? "active" : "")">
|
||||
<a asp-controller="AnalysisInverter" asp-action="Index" title="逆變器交叉分析" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">逆變器交叉分析</span>
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</li>
|
||||
}
|
||||
@ -287,7 +297,7 @@
|
||||
</li>
|
||||
}
|
||||
|
||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("Operation") || ViewBag.auths.Contains("OperationRecord"))
|
||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStation") || ViewBag.auths.Contains("Operation") || ViewBag.auths.Contains("OperationRecord"))
|
||||
{
|
||||
<li class="@(ViewData["MainNum"] == "6" ? "active open" : "")">
|
||||
<a href="#" title="Category" data-filter-tags="category">
|
||||
@ -295,9 +305,17 @@
|
||||
<span class="nav-link-text" data-i18n="nav.category">運維管理</span>
|
||||
</a>
|
||||
<ul>
|
||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStationManager"))
|
||||
{
|
||||
<li class="@(ViewData["MainNum"] == "6" && ViewData["SubNum"].ToString() == "1" ? "active" : "")">
|
||||
<a asp-controller="PowerStation" asp-action="Index" title="電站管理" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">電站管理</span>
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("Operation"))
|
||||
{
|
||||
<li class="@(ViewData["MainNum"] == "6" && ViewData["SubNum"] == "1" ? "active" : "")">
|
||||
<li class="@(ViewData["MainNum"] == "6" && ViewData["SubNum"] == "2" ? "active" : "")">
|
||||
<a asp-controller="Operation" asp-action="Index" title="定期計畫建立" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">定期計畫建立</span>
|
||||
</a>
|
||||
@ -305,7 +323,7 @@
|
||||
}
|
||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("OperationRecord"))
|
||||
{
|
||||
<li class="@(ViewData["MainNum"] == "6" && ViewData["SubNum"] == "2" ? "active" : "")">
|
||||
<li class="@(ViewData["MainNum"] == "6" && ViewData["SubNum"] == "3" ? "active" : "")">
|
||||
<a asp-controller="Operation" asp-action="Record" title="運維作業記錄" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">運維作業記錄</span>
|
||||
</a>
|
||||
|
||||
@ -400,8 +400,8 @@
|
||||
var time = new Date(val.createdAt);
|
||||
$('#card_' + val.id).find('#editSolarUrl').attr('href', localurl + '/Info?stationId=' + val.id);
|
||||
$('#card_' + val.id).find('#date').html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes());
|
||||
$('#card_' + val.id).find('#Capacity').html(val.today_kWh);
|
||||
$('#card_' + val.id).find('#PowerRate').html(val.today_kWh * val.powerRate);
|
||||
$('#card_' + val.id).find('#Capacity').html(val.today_kWh.toFixed(2));
|
||||
$('#card_' + val.id).find('#PowerRate').html((val.today_kWh * val.powerRate).toFixed(2));
|
||||
$('#card_' + val.id).find('#PR').html(val.today_PR);
|
||||
$('#card_' + val.id).find('#aria').attr('aria-valuenow', val.today_PR);
|
||||
$('#card_' + val.id).find('#aria').attr('style', "width:" + val.today_PR + "%;");
|
||||
@ -424,13 +424,13 @@
|
||||
'<td>' + val.code + '</td>' +
|
||||
'<td>' + val.name + '</td>' +
|
||||
'<td>' + val.generatingCapacity + '</td>' +
|
||||
'<td>' + val.total_kWh + '</td>' +
|
||||
'<td>' + val.today_kWh + '</td>' +
|
||||
'<td>' + val.solarHour + '</td>' +
|
||||
'<td>' + val.total_kWh.toFixed(2) + '</td>' +
|
||||
'<td>' + val.today_kWh.toFixed(2) + '</td>' +
|
||||
'<td>' + val.solarHour.toFixed(2) + '</td>' +
|
||||
'<td>' + val.today_PR + '</td>' +
|
||||
'<td>' + val.today_irradiance + '</td>' +
|
||||
'<td>' + val.avg_irradiance + '</td>' +
|
||||
'<td>' + val.today_Monery + '</td>' +
|
||||
'<td>' + val.today_irradiance.toFixed(2) + '</td>' +
|
||||
'<td>' + val.avg_irradiance.toFixed(2) + '</td>' +
|
||||
'<td>' + val.today_Money.toFixed(2) + '</td>' +
|
||||
'<td>' + statusName + '</td>' +
|
||||
'<td><button type="button" class="btn btn-primary btn-pills waves-effect waves-themed" onclick="location.href=\'' + localurl + '/Info?stationId=' + val.id + '\'">選擇</button></td>' +
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<div id="panel-5" class="panel">
|
||||
<div class="panel-container show">
|
||||
<div class="panel-content">
|
||||
<div class="row subheader">
|
||||
<div class="row subheader d-flex justify-content-between">
|
||||
<div class="col-xl-2">
|
||||
<h1 class="subheader-title">
|
||||
<span class="icon-stack fa-1x">
|
||||
@ -157,6 +157,7 @@
|
||||
var groupType = 0; //0:日 1:月 2:年 3:歷年
|
||||
var historyRange = "";
|
||||
var selectInverterkwhBarType = 0;
|
||||
var HeapMapXAxis = [];
|
||||
|
||||
$(function () {
|
||||
var url = new URL(location.href);
|
||||
@ -276,17 +277,16 @@
|
||||
type: 'bar',
|
||||
label: '輸出功率',
|
||||
yAxisID: 'A',
|
||||
backgroundColor: color.primary._300,
|
||||
borderColor: color.primary._500,
|
||||
backgroundColor: 'rgb(103, 180, 172)',
|
||||
order: 2,
|
||||
data: chartToday.powerDatas
|
||||
}, {
|
||||
type: 'line',
|
||||
label: '日照度',
|
||||
yAxisID: 'B',
|
||||
borderColor: color.danger._300,
|
||||
pointBackgroundColor: color.danger._500,
|
||||
pointBorderColor: color.danger._500,
|
||||
borderColor: 'rgb(190, 45, 45)',
|
||||
pointBackgroundColor: 'rgb(190, 45, 45)',
|
||||
pointBorderColor: 'rgb(190, 45, 45)',
|
||||
pointBorderWidth: 1,
|
||||
borderWidth: 2,
|
||||
pointRadius: 4,
|
||||
@ -344,16 +344,15 @@
|
||||
type: 'bar',
|
||||
label: '輸出功率',
|
||||
yAxisID: 'A',
|
||||
backgroundColor: color.primary._300,
|
||||
borderColor: color.primary._500,
|
||||
backgroundColor: 'rgb(103, 180, 172)',
|
||||
data: chart7day.powerDatas
|
||||
}, {
|
||||
type: 'line',
|
||||
label: '日照度',
|
||||
yAxisID: 'B',
|
||||
borderColor: color.danger._300,
|
||||
pointBackgroundColor: color.danger._500,
|
||||
pointBorderColor: color.danger._500,
|
||||
borderColor: 'rgb(190, 45, 45)',
|
||||
pointBackgroundColor: 'rgb(190, 45, 45)',
|
||||
pointBorderColor: 'rgb(190, 45, 45)',
|
||||
pointBorderWidth: 1,
|
||||
borderWidth: 2,
|
||||
pointRadius: 4,
|
||||
@ -410,16 +409,15 @@
|
||||
type: 'bar',
|
||||
label: '輸出功率',
|
||||
yAxisID: 'A',
|
||||
backgroundColor: color.primary._300,
|
||||
borderColor: color.primary._500,
|
||||
backgroundColor: 'rgb(103, 180, 172)',
|
||||
data: chartMonth.powerDatas
|
||||
}, {
|
||||
type: 'line',
|
||||
label: '日照度',
|
||||
yAxisID: 'B',
|
||||
borderColor: color.danger._300,
|
||||
pointBackgroundColor: color.danger._500,
|
||||
pointBorderColor: color.danger._500,
|
||||
borderColor: 'rgb(190, 45, 45)',
|
||||
pointBackgroundColor: 'rgb(190, 45, 45)',
|
||||
pointBorderColor: 'rgb(190, 45, 45)',
|
||||
pointBorderWidth: 1,
|
||||
borderWidth: 2,
|
||||
pointRadius: 4,
|
||||
@ -476,16 +474,15 @@
|
||||
type: 'bar',
|
||||
label: '輸出功率',
|
||||
yAxisID: 'A',
|
||||
backgroundColor: color.primary._300,
|
||||
borderColor: color.primary._500,
|
||||
backgroundColor: 'rgb(103, 180, 172)',
|
||||
data: chartYear.powerDatas
|
||||
}, {
|
||||
type: 'line',
|
||||
label: '日照度',
|
||||
yAxisID: 'B',
|
||||
borderColor: color.danger._300,
|
||||
pointBackgroundColor: color.danger._500,
|
||||
pointBorderColor: color.danger._500,
|
||||
borderColor: 'rgb(190, 45, 45)',
|
||||
pointBackgroundColor: 'rgb(190, 45, 45)',
|
||||
pointBorderColor: 'rgb(190, 45, 45)',
|
||||
pointBorderWidth: 1,
|
||||
borderWidth: 2,
|
||||
pointRadius: 4,
|
||||
@ -719,7 +716,7 @@
|
||||
}
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
@ -891,7 +888,7 @@
|
||||
"data": "function"
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
@ -1780,6 +1777,7 @@
|
||||
}
|
||||
|
||||
HeatMap = rel.data;
|
||||
HeapMapXAxis = HeatMap.xAxis
|
||||
|
||||
|
||||
myseries = Object.keys(HeatMap.series).map(function (key) {
|
||||
@ -1797,14 +1795,14 @@
|
||||
Highcharts.chart('container', {
|
||||
chart: {
|
||||
type: 'heatmap',
|
||||
height: 600
|
||||
},
|
||||
|
||||
title: {
|
||||
text: '逆變器單日kWhkWp'
|
||||
},
|
||||
|
||||
xAxis: {
|
||||
categories: HeatMap.xAxis
|
||||
categories: HeatMap.xAxisOnTime
|
||||
},
|
||||
yAxis: {
|
||||
categories: HeatMap.yAxis,
|
||||
@ -1812,6 +1810,7 @@
|
||||
},
|
||||
colorAxis: {
|
||||
min: 0,
|
||||
max: 1,
|
||||
minColor: '#0000FF',
|
||||
maxColor: '#FF0000',
|
||||
stops: [
|
||||
@ -1826,11 +1825,11 @@
|
||||
verticalAlign: 'top',
|
||||
|
||||
},*@
|
||||
|
||||
tooltip: {
|
||||
formatter: function () {
|
||||
return '<b>' + getPointCategoryName(this.point, 'x') + '</b> sold <br><b>' +
|
||||
this.point.value + '</b> items on <br><b>' + getPointCategoryName(this.point, 'y') + '</b>';
|
||||
return '<b>' + getPointCategoryName(this.point, 'y') + '</b><br>' +
|
||||
'<span>' + getPointCategoryName(this.point, 'x') + '</span><br>' +
|
||||
'<b style = "color:rgb(103, 180, 172);" >' + this.point.value + '</b>';
|
||||
}
|
||||
},
|
||||
|
||||
@ -1847,6 +1846,10 @@
|
||||
var series = point.series,
|
||||
isY = dimension === 'y',
|
||||
axis = series[isY ? 'yAxis' : 'xAxis'];
|
||||
|
||||
if (!isY) {
|
||||
axis.categories = HeapMapXAxis;
|
||||
}
|
||||
return axis.categories[point[isY ? 'y' : 'x']];
|
||||
}
|
||||
|
||||
@ -2139,7 +2142,7 @@
|
||||
HistoryRange: historyRange,
|
||||
PowerstationId: stationId
|
||||
}
|
||||
|
||||
//0:日 1:月 2:年 3:歷年
|
||||
var Nurl = "/StationOverview/GetTotalTableToHistory";
|
||||
$.post(Nurl, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
@ -2164,24 +2167,53 @@
|
||||
$.each(rel.data, function (index, val) {
|
||||
TimestampALL = val.totaltime;
|
||||
kwhALL += val.kwh;
|
||||
diffSOLARHOURALL += val.diffSOLARHOUR;
|
||||
//diffSOLARHOURALL += val.diffSOLARHOUR;
|
||||
irradianceALL += val.irradiance;
|
||||
prALL = val.pr;
|
||||
tempALL += val.temp;
|
||||
|
||||
|
||||
|
||||
if (val.length != 0) {
|
||||
$('#HistoryDetailTable').append('<tr>' +
|
||||
'<td>' + val.timestamp + '</td>' +
|
||||
'<td>' + val.kwh.toFixed(2) + '</td>' +
|
||||
'<td>' + val.diffSOLARHOUR.toFixed(2) + '</td>' +
|
||||
'<td>' + val.irradiance.toFixed(2) + '</td>' +
|
||||
'<td>' + val.pr.toFixed(2) + '</td>' +
|
||||
'<td>' + val.temp.toFixed(2) + '</td>' +
|
||||
'</tr>');
|
||||
listmonth.push(val.timestamp);
|
||||
listkwh.push(val.kwh);
|
||||
listcolor.push(color);
|
||||
listcolor2.push(color2);
|
||||
listirradiance.push(val.irradiance);
|
||||
if (groupType != 0) {
|
||||
diffSOLARHOURALL += val.solarhour;
|
||||
$('#HistoryDetailTable').append('<tr>' +
|
||||
'<td>' + val.timestamp + '</td>' +
|
||||
'<td>' + val.kwh.toFixed(2) + '</td>' +
|
||||
'<td>' + val.solarhour.toFixed(2) + '</td>' +
|
||||
|
||||
'<td>' + val.irradiance.toFixed(2) + '</td>' +
|
||||
'<td>' + val.pr.toFixed(2) + '</td>' +
|
||||
'<td>' + val.temp.toFixed(2) + '</td>' +
|
||||
'</tr>');
|
||||
listmonth.push(val.timestamp);
|
||||
listkwh.push(val.kwh);
|
||||
listcolor.push(color);
|
||||
listcolor2.push(color2);
|
||||
listirradiance.push(val.irradiance);
|
||||
}
|
||||
else
|
||||
{
|
||||
diffSOLARHOURALL += val.diffSOLARHOUR;
|
||||
$('#HistoryDetailTable').append('<tr>' +
|
||||
'<td>' + val.timestamp + '</td>' +
|
||||
'<td>' + val.kwh.toFixed(2) + '</td>' +
|
||||
'<td>' + val.diffSOLARHOUR.toFixed(2) + '</td>' +
|
||||
|
||||
'<td>' + val.irradiance.toFixed(2) + '</td>' +
|
||||
'<td>' + val.pr.toFixed(2) + '</td>' +
|
||||
'<td>' + val.temp.toFixed(2) + '</td>' +
|
||||
'</tr>');
|
||||
listmonth.push(val.timestamp);
|
||||
listkwh.push(val.kwh);
|
||||
listcolor.push(color);
|
||||
listcolor2.push(color2);
|
||||
listirradiance.push(val.irradiance);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
@ -2204,8 +2236,7 @@
|
||||
data: listirradiance
|
||||
}, {
|
||||
type: 'bar',
|
||||
borderColor: 'rgba(103, 180, 172, 1)',
|
||||
backgroundColor: 'rgba(103, 180, 172, 0.2)',
|
||||
backgroundColor: 'rgba(103, 180, 172, 1)',
|
||||
borderWidth: 1,
|
||||
label: '發電量(kWh)',
|
||||
yAxisID: 'A',
|
||||
|
||||
@ -188,7 +188,7 @@
|
||||
}
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
@ -264,7 +264,7 @@
|
||||
}
|
||||
],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
@ -352,7 +352,7 @@
|
||||
}
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
@ -436,7 +436,7 @@
|
||||
}
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user