1. 修改地圖總覽天氣
2. bug fix
This commit is contained in:
parent
d206d8c38a
commit
35a4402937
@ -15,6 +15,13 @@ namespace SolarPower.Controllers
|
||||
private readonly IPowerStationRepository powerStationRepository;
|
||||
private double carbonRate;
|
||||
|
||||
private enum tableType
|
||||
{
|
||||
hour = 0,
|
||||
day = 1,
|
||||
month = 2
|
||||
}
|
||||
|
||||
public DataBackFillController(IPowerStationRepository powerStationRepository) : base()
|
||||
{
|
||||
this.powerStationRepository = powerStationRepository;
|
||||
@ -32,40 +39,15 @@ namespace SolarPower.Controllers
|
||||
|
||||
try
|
||||
{
|
||||
var targetDay = 7; //預計範圍天數
|
||||
var targetDay = 1; //預計範圍天數
|
||||
|
||||
var now = DateTime.Now;
|
||||
//var now = DateTime.Now;
|
||||
var now = new DateTime(2021, 7, 26);
|
||||
var endDate = now.AddDays(-1);
|
||||
var endDateStr = endDate.ToString(dateTimeFormat);
|
||||
var startDate = endDate.AddDays(-1 * targetDay);
|
||||
//var startDate = endDate.AddDays(-1 * targetDay);
|
||||
var startDate = now.AddDays(-1 * targetDay);
|
||||
var startDateStr = startDate.ToString(dateTimeFormat);
|
||||
var timeArray = new List<string>()
|
||||
{
|
||||
"00:05",
|
||||
"01:05",
|
||||
"02:05",
|
||||
"03:05",
|
||||
"04:05",
|
||||
"05:05",
|
||||
"06:05",
|
||||
"07:05",
|
||||
"08:05",
|
||||
"09:05",
|
||||
"10:05",
|
||||
"11:05",
|
||||
"12:05",
|
||||
"13:05",
|
||||
"14:05",
|
||||
"15:05",
|
||||
"16:05",
|
||||
"17:05",
|
||||
"18:05",
|
||||
"19:05",
|
||||
"20:05",
|
||||
"21:05",
|
||||
"22:05",
|
||||
"23:05"
|
||||
};
|
||||
|
||||
#region step1. 找出所有電站
|
||||
var powerStations = await powerStationRepository.GetAllAsync();
|
||||
@ -76,184 +58,22 @@ namespace SolarPower.Controllers
|
||||
List<PyrheliometerHistory> pyrheliometerHistoriesHour = new List<PyrheliometerHistory>();
|
||||
List<PyrheliometerHistory> TempHistoriesHour = new List<PyrheliometerHistory>();
|
||||
|
||||
//逆變器歷史資料
|
||||
List<InverterHistory> inverterHistories = new List<InverterHistory>();
|
||||
|
||||
//5分鐘Sensor平均歷史資料
|
||||
List<SensorAvgHistory> sensorAvgHistoryHour = new List<SensorAvgHistory>();
|
||||
|
||||
#region 每小時歷史資料回填
|
||||
for (var i = 0; i < targetDay; i++)
|
||||
{
|
||||
var currentDateStr = startDate.AddDays(i).ToString(dateTimeFormat);
|
||||
for (var j = 0; j < 24; j++)
|
||||
{
|
||||
var time = string.Format("{0}", j.ToString().PadLeft(2, '0'));
|
||||
|
||||
var all_time = string.Format("{0} {1}", currentDateStr, time);
|
||||
|
||||
foreach (var powerStation in powerStations)
|
||||
{
|
||||
#region step2. 電站歷史資料彙整(每小時)
|
||||
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))
|
||||
{
|
||||
#region step2-1. 電站歷史資料
|
||||
var history = await powerStationRepository.GetPowerStationHistoryPerHour(all_time, full_table_name);
|
||||
var lastmoneyhistorybyhour = await powerStationRepository.GetLastMoneyAndCarbonInHour(powerStation.Id, 0, all_time);
|
||||
|
||||
if (history != null)
|
||||
{
|
||||
history.PowerStationId = powerStation.Id;
|
||||
history.Timestamp = Convert.ToDateTime(history.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
carbonRate = Convert.ToDouble(await powerStationRepository.GetOneVariableByName("CarbonRate"));
|
||||
|
||||
history.CARBON = history.KWH * 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;
|
||||
|
||||
powerStationHistoriesHour.Add(history);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region step2-2. 取得該電站的當前這小時的日照度歷史資料
|
||||
//step2-2 1. 找出該電站所有日照計設備(包含共享
|
||||
var deviceInfos = await powerStationRepository.GetListPyrheliometerByPowerStationId(powerStation.Id, powerStation.SiteDB);
|
||||
if (deviceInfos != null)
|
||||
{
|
||||
//step2-2 2. 計算該電站所有日照計設的每小時的平均在依照日照計數量平均
|
||||
var pyrheliometerHistory = await powerStationRepository.GetPyrheliometerHistoryPerHour(all_time, deviceInfos, 0);
|
||||
|
||||
if (pyrheliometerHistory != null)
|
||||
{
|
||||
pyrheliometerHistory.Timestamp = Convert.ToDateTime(pyrheliometerHistory.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
pyrheliometerHistory.PowerStationId = powerStation.Id;
|
||||
pyrheliometerHistoriesHour.Add(pyrheliometerHistory);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region step2-3. 取得該電站的當前這小時的溫度計歷史資料
|
||||
//step2-3 1. 找出該電站所有溫度計設備(包含共享
|
||||
var tempdeviceInfos = await powerStationRepository.GetListTempByPowerStationId(powerStation.Id, powerStation.SiteDB);
|
||||
if (tempdeviceInfos != null)
|
||||
{
|
||||
//step2-3 2. 計算該電站所有溫度計設的每小時的平均在依照溫度計數量平均
|
||||
var tempHistory = await powerStationRepository.GetPyrheliometerHistoryPerHour(all_time, 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);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region step3. 逆變器歷史資料彙整(每小時)
|
||||
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();
|
||||
|
||||
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, inverter_table_name);
|
||||
|
||||
if (!string.IsNullOrEmpty(exist_inverter_table))
|
||||
{
|
||||
inverterHistories = await powerStationRepository.CalcInverterHisyortHourData(all_time, powerStation.SiteDB, full_inverter_table_name, inverterIds);
|
||||
//取得日照計要找的欄位資訊
|
||||
var pyrheliometer = await powerStationRepository.GetFirstPyrheliometerInfo(powerStation.Id, powerStation.SiteDB);
|
||||
var pyrheliometerValue = await powerStationRepository.GetFirstPyrheliometerValue(all_time, 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.TIMESTAMP = Convert.ToDateTime(inverterHistory.TIMESTAMP + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
inverterHistory.PowerStationId = powerStation.Id;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region step4. 計算該電站所有sensoravg
|
||||
var seneoravg_table_name = String.Format("s{0}01_sensoravg", powerStation.Code);
|
||||
var full_seneoravg_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, seneoravg_table_name);
|
||||
var exist_seneoravg_table = await powerStationRepository.ExistTable(powerStation.SiteDB, seneoravg_table_name);
|
||||
if (!string.IsNullOrEmpty(exist_seneoravg_table))
|
||||
{
|
||||
var sensorAvgHistory = await powerStationRepository.CalcSensorAvgHistory(all_time, full_seneoravg_table_name);
|
||||
|
||||
if (sensorAvgHistory != null)
|
||||
{
|
||||
sensorAvgHistory.PowerStationId = powerStation.Id;
|
||||
sensorAvgHistory.TIMESTAMP = Convert.ToDateTime(sensorAvgHistory.TIMESTAMP + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
sensorAvgHistoryHour.Add(sensorAvgHistory);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region 刪除後新增該時間區間的電站歷史紀錄
|
||||
List<string> history_properties = new List<string>()
|
||||
List<PowerStationHistoryDay> powerStationHistoryDays = new List<PowerStationHistoryDay>();
|
||||
List<PowerStationHistoryMonth> insertPowerStationHistoryMonths = new List<PowerStationHistoryMonth>();
|
||||
List<PyrheliometerHistory> pyrheliometerHistoryDays = new List<PyrheliometerHistory>();
|
||||
List<PyrheliometerHistory> insertPyrheliometerHistoryMonths = new List<PyrheliometerHistory>();
|
||||
List<string> pyrheliometer_history_day_month_properties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"TIMESTAMP",
|
||||
"SITEID",
|
||||
"SITETYPE",
|
||||
"KWH",
|
||||
"TODAYKWH",
|
||||
"TOTALKWH",
|
||||
"KWHKWP",
|
||||
"PR",
|
||||
"MP",
|
||||
"SolarHour",
|
||||
"MONEY",
|
||||
"CARBON",
|
||||
"TODAYMONEY",
|
||||
"TOTALMONEY",
|
||||
"TODAYCARBON",
|
||||
"TOTALCARBON"
|
||||
};
|
||||
await powerStationRepository.AddAfterPurgePowerStationHistoryHour(startDateStr, endDateStr, powerStationHistoriesHour, history_properties);
|
||||
#endregion
|
||||
|
||||
#region 刪除後新增該時間區間的日照溫度歷史紀錄
|
||||
List<string> pyrheliometer_history_properties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"TIMESTAMP",
|
||||
"Irradiance"
|
||||
};
|
||||
await powerStationRepository.AddAfterPurgePyrheliometerHistoryHour(startDateStr, endDateStr, pyrheliometerHistoriesHour, pyrheliometer_history_properties);
|
||||
|
||||
List<string> Temp_history_properties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"TIMESTAMP",
|
||||
"Timestamp",
|
||||
"Irradiance",
|
||||
"Temperature"
|
||||
};
|
||||
await powerStationRepository.AddTempHistory(TempHistoriesHour, Temp_history_properties);
|
||||
#endregion
|
||||
|
||||
#region 刪除後新增該時間區間的逆變器歷史紀錄
|
||||
//逆變器歷史資料
|
||||
List<InverterHistory> inverterHistoriesHour = new List<InverterHistory>();
|
||||
List<InverterHistory> inverterHistorDays = new List<InverterHistory>();
|
||||
List<InverterHistory> insertInverterHistoryMonths = new List<InverterHistory>();
|
||||
List<string> inverter_history_properties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
@ -313,69 +133,620 @@ namespace SolarPower.Controllers
|
||||
"TOTALKWH",
|
||||
"KWHKWP",
|
||||
};
|
||||
await powerStationRepository.AddAfterPurgeInverterHistoryHour(startDateStr, endDateStr, inverterHistories, inverter_history_properties);
|
||||
#endregion
|
||||
|
||||
#region 刪除後新增該時間區間的SensorAvg歷史紀錄
|
||||
List<string> sensoravg_history_properties = new List<string>()
|
||||
//5分鐘Sensor平均歷史資料
|
||||
List<SensorAvgHistory> sensorAvgHistoryHour = new List<SensorAvgHistory>();
|
||||
List<SensorAvgHistory> sensorAvgHistoryDays = new List<SensorAvgHistory>();
|
||||
List<SensorAvgHistory> insertSensorAvgHistoryMonths = new List<SensorAvgHistory>();
|
||||
|
||||
//#region step2. 每小時歷史資料回填
|
||||
//for (var i = 0; i < targetDay; i++)
|
||||
//{
|
||||
// var currentDateStr = startDate.AddDays(i).ToString(dateTimeFormat);
|
||||
// var temp_start_time = DateTime.Now;
|
||||
// for (var j = 0; j < 24; j++)
|
||||
// {
|
||||
// var time = string.Format("{0}", j.ToString().PadLeft(2, '0'));
|
||||
|
||||
// var all_time = string.Format("{0} {1}", currentDateStr, time);
|
||||
|
||||
// var count = 0;
|
||||
// foreach (var powerStation in powerStations)
|
||||
// {
|
||||
// if (count > 0)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
|
||||
// #region step2-1. 電站歷史資料彙整(每小時)
|
||||
// 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))
|
||||
// {
|
||||
// #region step2-1-1. 電站歷史資料
|
||||
// var history = await powerStationRepository.GetPowerStationHistoryPerHour(all_time, full_table_name);
|
||||
// var lastmoneyhistorybyhour = await powerStationRepository.GetLastMoneyAndCarbonInHour(powerStation.Id, 0, all_time);
|
||||
|
||||
// if (history != null)
|
||||
// {
|
||||
// history.PowerStationId = powerStation.Id;
|
||||
// history.Timestamp = Convert.ToDateTime(history.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
// carbonRate = Convert.ToDouble(await powerStationRepository.GetOneVariableByName("CarbonRate"));
|
||||
|
||||
// history.CARBON = history.KWH * 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;
|
||||
|
||||
// powerStationHistoriesHour.Add(history);
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
// #region step2-1-2. 取得該電站的當前這小時的日照度歷史資料
|
||||
// //step2-1-2 1. 找出該電站所有日照計設備(包含共享
|
||||
// var deviceInfos = await powerStationRepository.GetListPyrheliometerByPowerStationId(powerStation.Id, powerStation.SiteDB);
|
||||
// if (deviceInfos != null)
|
||||
// {
|
||||
// //step2-1-2 2. 計算該電站所有日照計設的每小時的平均在依照日照計數量平均
|
||||
// var pyrheliometerHistory = await powerStationRepository.GetPyrheliometerHistoryPerHour(all_time, deviceInfos, 0);
|
||||
|
||||
// if (pyrheliometerHistory != null)
|
||||
// {
|
||||
// pyrheliometerHistory.Timestamp = Convert.ToDateTime(pyrheliometerHistory.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
// pyrheliometerHistory.PowerStationId = powerStation.Id;
|
||||
// pyrheliometerHistoriesHour.Add(pyrheliometerHistory);
|
||||
// }
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
// #region step2-1-3. 取得該電站的當前這小時的溫度計歷史資料
|
||||
// //step2-1-3 1. 找出該電站所有溫度計設備(包含共享
|
||||
// var tempdeviceInfos = await powerStationRepository.GetListTempByPowerStationId(powerStation.Id, powerStation.SiteDB);
|
||||
// if (tempdeviceInfos != null)
|
||||
// {
|
||||
// //step2-1-3 2. 計算該電站所有溫度計設的每小時的平均在依照溫度計數量平均
|
||||
// var tempHistory = await powerStationRepository.GetPyrheliometerHistoryPerHour(all_time, 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);
|
||||
// }
|
||||
// }
|
||||
// #endregion
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
// #region step2-2. 逆變器歷史資料彙整(每小時)
|
||||
// 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();
|
||||
|
||||
// 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, inverter_table_name);
|
||||
|
||||
// if (!string.IsNullOrEmpty(exist_inverter_table))
|
||||
// {
|
||||
// inverterHistoriesHour = await powerStationRepository.CalcInverterHisyortHourData(all_time, powerStation.SiteDB, full_inverter_table_name, inverterIds);
|
||||
// //取得日照計要找的欄位資訊
|
||||
// var pyrheliometer = await powerStationRepository.GetFirstPyrheliometerInfo(powerStation.Id, powerStation.SiteDB);
|
||||
// var pyrheliometerValue = await powerStationRepository.GetFirstPyrheliometerValue(all_time, pyrheliometer.DBName, pyrheliometer.TableName, pyrheliometer.ColName);
|
||||
// foreach (var inverterHistory in inverterHistoriesHour)
|
||||
// {
|
||||
// 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.TIMESTAMP = Convert.ToDateTime(inverterHistory.TIMESTAMP + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
// inverterHistory.PowerStationId = powerStation.Id;
|
||||
// }
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
// #region step2-3. 計算該電站所有sensoravg
|
||||
// var seneoravg_table_name = String.Format("s{0}01_sensoravg", powerStation.Code);
|
||||
// var full_seneoravg_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, seneoravg_table_name);
|
||||
// var exist_seneoravg_table = await powerStationRepository.ExistTable(powerStation.SiteDB, seneoravg_table_name);
|
||||
// if (!string.IsNullOrEmpty(exist_seneoravg_table))
|
||||
// {
|
||||
// var sensorAvgHistory = await powerStationRepository.CalcSensorAvgHistory(all_time, full_seneoravg_table_name);
|
||||
|
||||
// if (sensorAvgHistory != null)
|
||||
// {
|
||||
// sensorAvgHistory.PowerStationId = powerStation.Id;
|
||||
// sensorAvgHistory.TIMESTAMP = Convert.ToDateTime(sensorAvgHistory.TIMESTAMP + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
// sensorAvgHistoryHour.Add(sensorAvgHistory);
|
||||
// }
|
||||
// }
|
||||
// #endregion
|
||||
// count++;
|
||||
// }
|
||||
// }
|
||||
// var temp_end_time = DateTime.Now;
|
||||
|
||||
// var runtime = temp_end_time.Subtract(temp_start_time).TotalSeconds;
|
||||
// Logger.LogInformation("單一天執行小時回填運行時間{0}", runtime.ToString());
|
||||
//}
|
||||
|
||||
//#region 刪除後新增該時間區間的電站歷史紀錄(小時資料表)
|
||||
//List<string> history_properties = new List<string>()
|
||||
//{
|
||||
// "PowerStationId",
|
||||
// "TIMESTAMP",
|
||||
// "SITEID",
|
||||
// "SITETYPE",
|
||||
// "KWH",
|
||||
// "TODAYKWH",
|
||||
// "TOTALKWH",
|
||||
// "KWHKWP",
|
||||
// "PR",
|
||||
// "MP",
|
||||
// "SolarHour",
|
||||
// "MONEY",
|
||||
// "CARBON",
|
||||
// "TODAYMONEY",
|
||||
// "TOTALMONEY",
|
||||
// "TODAYCARBON",
|
||||
// "TOTALCARBON"
|
||||
//};
|
||||
//await powerStationRepository.AddAfterPurgePowerStationHistoryHour(startDateStr, endDateStr, powerStationHistoriesHour, history_properties);
|
||||
//#endregion
|
||||
|
||||
//#region 刪除後新增該時間區間的日照溫度歷史紀錄(小時資料表)
|
||||
//List<string> pyrheliometer_history_properties = new List<string>()
|
||||
//{
|
||||
// "PowerStationId",
|
||||
// "TIMESTAMP",
|
||||
// "Irradiance"
|
||||
//};
|
||||
//await powerStationRepository.AddAfterPurgePyrheliometerHistory(startDateStr, endDateStr, (byte)tableType.hour, pyrheliometerHistoriesHour, pyrheliometer_history_properties);
|
||||
|
||||
//List<string> Temp_history_properties = new List<string>()
|
||||
//{
|
||||
// "PowerStationId",
|
||||
// "TIMESTAMP",
|
||||
// "Temperature"
|
||||
//};
|
||||
//await powerStationRepository.AddTempHistory(TempHistoriesHour, Temp_history_properties);
|
||||
//#endregion
|
||||
|
||||
//#region 刪除後新增該時間區間的逆變器歷史紀錄(小時資料表)
|
||||
|
||||
//await powerStationRepository.AddAfterPurgeInverterHistory(startDateStr, endDateStr, (byte)tableType.hour, inverterHistoriesHour, inverter_history_properties);
|
||||
//#endregion
|
||||
|
||||
//#region 刪除後新增該時間區間的SensorAvg歷史紀錄(小時資料表)
|
||||
//List<string> sensoravg_history_properties = new List<string>()
|
||||
//{
|
||||
// "PowerStationId",
|
||||
// "TIMESTAMP",
|
||||
// "SENSORAVG01",
|
||||
// "SENSORAVG02",
|
||||
// "SENSORAVG03",
|
||||
// "SENSORAVG04",
|
||||
// "SENSORAVG05",
|
||||
// "SENSORAVG06",
|
||||
// "SENSORAVG07",
|
||||
// "SENSORAVG08",
|
||||
// "SENSORAVG09",
|
||||
// "SENSORAVG10",
|
||||
// "SENSORAVG11",
|
||||
// "SENSORAVG12",
|
||||
// "SENSORAVG13",
|
||||
// "SENSORAVG14",
|
||||
// "SENSORAVG15",
|
||||
// "SENSORAVG16",
|
||||
// "SENSORAVG17",
|
||||
// "SENSORAVG18",
|
||||
// "SENSORAVG19",
|
||||
// "SENSORAVG20",
|
||||
// "SENSORAVG21",
|
||||
// "SENSORAVG22",
|
||||
// "SENSORAVG23",
|
||||
// "SENSORAVG24",
|
||||
// "SENSORAVG25",
|
||||
// "SENSORAVG26",
|
||||
// "SENSORAVG27",
|
||||
// "SENSORAVG28",
|
||||
// "SENSORAVG29",
|
||||
// "SENSORAVG30",
|
||||
// "SENSORAVG31",
|
||||
// "SENSORAVG32",
|
||||
// "SENSORAVG33",
|
||||
// "SENSORAVG34",
|
||||
// "SENSORAVG35",
|
||||
// "SENSORAVG36",
|
||||
// "SENSORAVG37",
|
||||
// "SENSORAVG38",
|
||||
// "SENSORAVG39",
|
||||
// "SENSORAVG40",
|
||||
// "SENSORAVG41",
|
||||
// "SENSORAVG42",
|
||||
// "SENSORAVG43",
|
||||
// "SENSORAVG44",
|
||||
// "SENSORAVG45",
|
||||
// "SENSORAVG46",
|
||||
// "SENSORAVG47",
|
||||
// "SENSORAVG48",
|
||||
// "SENSORAVG49",
|
||||
// "SENSORAVG50",
|
||||
//};
|
||||
//await powerStationRepository.AddAfterPurgeSensorAvgHistory(startDateStr, endDateStr, (byte)tableType.hour, sensorAvgHistoryHour, sensoravg_history_properties);
|
||||
//#endregion
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region step3. 每天歷史資料回填
|
||||
//for (var i = 0; i < targetDay; i++)
|
||||
//{
|
||||
// var currentDateStr = startDate.AddDays(i).ToString(dateTimeFormat);
|
||||
// var temp_start_time = DateTime.Now;
|
||||
|
||||
// var count = 0;
|
||||
// foreach (var powerStation in powerStations)
|
||||
// {
|
||||
// if (count > 0)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
|
||||
// #region step3-1. 電站歷史資料彙整(每天)
|
||||
// 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))
|
||||
// {
|
||||
// var historyDay = await powerStationRepository.GetLastOnePowerStationHistoryByDay(currentDateStr, full_table_name);
|
||||
// var moneyandcarbon = await powerStationRepository.GetMoneyAndCarbonWithHistoryHour(powerStation.Id, currentDateStr, 1);
|
||||
// var lastmoneyhistory = await powerStationRepository.GetLastMoneyAndCarbonInHour(powerStation.Id, 1, "");
|
||||
// if (historyDay != null)
|
||||
// {
|
||||
// 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;
|
||||
|
||||
// //日期轉換
|
||||
// historyDay.Timestamp = Convert.ToDateTime(historyDay.Timestamp + ":00:00").ToString("yyyy-MM-dd");
|
||||
// powerStationHistoryDays.Add(historyDay);
|
||||
// }
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
// #region step3-2. 電站日照計溫度歷史資料彙整(每天)
|
||||
// var pyrheliometerHistorDay = await powerStationRepository.CalcPyrheliometerHistoryDayDataByPowerStationId(currentDateStr, powerStation.Id);
|
||||
// if (pyrheliometerHistorDay != null)
|
||||
// {
|
||||
// pyrheliometerHistoryDays.Add(pyrheliometerHistorDay);
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
// #region step3-3. 逆變器歷史資料彙整(每天)
|
||||
// var inverterHistoriesDay = await powerStationRepository.CalcInverterHistoryDayDataByPowerStationId(currentDateStr, powerStation.SiteDB, powerStation.Id);
|
||||
// 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;
|
||||
|
||||
// inverterHistorDays.Add(inverterHistoryDay);
|
||||
// }
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
// #region step3-4. 計算該電站所有sensoravg(每天)
|
||||
// var sensorAvgHistoryDay = await powerStationRepository.CalcSensorAvgDayDataByPowerStationId(currentDateStr, powerStation.Id);
|
||||
// if (sensorAvgHistoryDay != null)
|
||||
// {
|
||||
// sensorAvgHistoryDays.Add(sensorAvgHistoryDay);
|
||||
// }
|
||||
// #endregion
|
||||
// count++;
|
||||
// }
|
||||
|
||||
// var temp_end_time = DateTime.Now;
|
||||
|
||||
// var runtime = temp_end_time.Subtract(temp_start_time).TotalSeconds;
|
||||
// Logger.LogInformation("單一天執行天回填運行時間{0}", runtime.ToString());
|
||||
//}
|
||||
|
||||
//#region 刪除後新增該時間區間的電站歷史紀錄(天資料表)
|
||||
//List<string> history_properties_day = new List<string>()
|
||||
//{
|
||||
// "PowerStationId",
|
||||
// "TIMESTAMP",
|
||||
// "SITEID",
|
||||
// "SITETYPE",
|
||||
// "TODAYKWH",
|
||||
// "TOTALKWH",
|
||||
// "KWHKWP",
|
||||
// "PR",
|
||||
// "MP",
|
||||
// "SolarHour",
|
||||
// "MONEY",
|
||||
// "CARBON",
|
||||
// "TOTALMONEY",
|
||||
// "TOTALCARBON"
|
||||
//};
|
||||
//await powerStationRepository.AddAfterPurgePowerStationHistoryDay(startDateStr, endDateStr, powerStationHistoryDays, history_properties_day);
|
||||
//#endregion
|
||||
|
||||
//#region 刪除後新增該時間區間的日照溫度歷史紀錄(天資料表)
|
||||
//await powerStationRepository.AddAfterPurgePyrheliometerHistory(startDateStr, endDateStr, (byte)tableType.day, pyrheliometerHistoryDays, pyrheliometer_history_day_month_properties);
|
||||
//#endregion
|
||||
|
||||
//#region 刪除後新增該時間區間的逆變器歷史紀錄(天資料表)
|
||||
//await powerStationRepository.AddAfterPurgeInverterHistory(startDateStr, endDateStr, (byte)tableType.day, inverterHistorDays, inverter_history_properties);
|
||||
//#endregion
|
||||
|
||||
//#region 刪除後新增該時間區間的SensorAvg歷史紀錄(天資料表)
|
||||
//await powerStationRepository.AddAfterPurgeSensorAvgHistory(startDateStr, endDateStr, (byte)tableType.day, sensorAvgHistoryDays, sensoravg_history_properties);
|
||||
//#endregion
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region step4. 每月歷史資料回填
|
||||
//var tempMonth = "";
|
||||
//for (var i = 0; i < targetDay; i++)
|
||||
//{
|
||||
// var currentDateStr = startDate.AddDays(i).ToString("yyyy-MM");
|
||||
// if (string.Compare(tempMonth, currentDateStr) == 0)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// tempMonth = currentDateStr;
|
||||
|
||||
// foreach (var powerStation in powerStations)
|
||||
// {
|
||||
// #region step4-1. 電站歷史資料彙整(每月)
|
||||
// var historyMonth = await powerStationRepository.ClacPowerStationHistoryMonthDataByPowerStationId(powerStation.Id, currentDateStr);
|
||||
// var moneyandcarbonMon = await powerStationRepository.GetMoneyAndCarbonWithHistoryHour(powerStation.Id, currentDateStr, 0);
|
||||
// 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;
|
||||
// historyMonth.CARBON = moneyandcarbonMon.CARBON;
|
||||
// historyMonth.TOTALCARBON = lastmoneyhistorymonth.TOTALCARBON + moneyandcarbonMon.CARBON;
|
||||
// historyMonth.TOTALMONEY = lastmoneyhistorymonth.TOTALMONEY + moneyandcarbonMon.MONEY;
|
||||
|
||||
// insertPowerStationHistoryMonths.Add(historyMonth);
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
// #region step4-2. 電站日照計溫度歷史資料彙整(每月)
|
||||
// var pyrheliometerHistoryMonth = await powerStationRepository.CalcPyrheliometerHistoryMonthDataByPowerStationId(currentDateStr, powerStation.Id);
|
||||
// if (pyrheliometerHistoryMonth != null)
|
||||
// {
|
||||
// pyrheliometerHistoryMonth.Timestamp = Convert.ToDateTime(pyrheliometerHistoryMonth.Timestamp).ToString("yyyy-MM-dd");
|
||||
// insertPyrheliometerHistoryMonths.Add(pyrheliometerHistoryMonth);
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
// #region step4-3. 逆變器歷史資料彙整(每月)
|
||||
// var inverterHistoriesMonth = await powerStationRepository.CalcInverterHistoryMonthDataByPowerStationId(currentDateStr, powerStation.SiteDB, powerStation.Id);
|
||||
// if (inverterHistoriesMonth.Count > 0)
|
||||
// {
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
// #region step4-4. 計算該電站所有sensoravg(每月)
|
||||
// var sensorAvgHistoryMonth = await powerStationRepository.CalcSensorAvgHistoryMonthDataByPowerStationId(currentDateStr, powerStation.Id);
|
||||
// if (sensorAvgHistoryMonth != null)
|
||||
// {
|
||||
// sensorAvgHistoryMonth.TIMESTAMP = Convert.ToDateTime(sensorAvgHistoryMonth.TIMESTAMP).ToString("yyyy-MM-dd");
|
||||
// insertSensorAvgHistoryMonths.Add(sensorAvgHistoryMonth);
|
||||
// }
|
||||
// #endregion
|
||||
// }
|
||||
//}
|
||||
|
||||
//#region 刪除後新增該時間區間的電站歷史紀錄(月資料表)
|
||||
//List<string> history_properties_month = new List<string>()
|
||||
//{
|
||||
// "PowerStationId",
|
||||
// "TIMESTAMP",
|
||||
// "SITEID",
|
||||
// "SITETYPE",
|
||||
// "MonthKWh",
|
||||
// "TOTALKWH",
|
||||
// "KWHKWP",
|
||||
// "PR",
|
||||
// "MP",
|
||||
// "SolarHour",
|
||||
// "MONEY",
|
||||
// "CARBON",
|
||||
// "TOTALMONEY",
|
||||
// "TOTALCARBON"
|
||||
//};
|
||||
//await powerStationRepository.AddAfterPurgePowerStationHistoryMonth(startDateStr, endDateStr, insertPowerStationHistoryMonths, history_properties_month);
|
||||
//#endregion
|
||||
|
||||
//#region 刪除後新增該時間區間的日照溫度歷史紀錄(月資料表)
|
||||
//await powerStationRepository.AddAfterPurgePyrheliometerHistory(startDateStr, endDateStr, (byte)tableType.month, insertPyrheliometerHistoryMonths, pyrheliometer_history_day_month_properties);
|
||||
//#endregion
|
||||
|
||||
//#region 刪除後新增該時間區間的逆變器歷史紀錄(月資料表)
|
||||
//await powerStationRepository.AddAfterPurgeInverterHistory(startDateStr, endDateStr, (byte)tableType.month, insertInverterHistoryMonths, inverter_history_properties);
|
||||
//#endregion
|
||||
|
||||
//#region 刪除後新增該時間區間的SensorAvg歷史紀錄(月資料表)
|
||||
//await powerStationRepository.AddAfterPurgeSensorAvgHistory(startDateStr, endDateStr, (byte)tableType.month, insertSensorAvgHistoryMonths, sensoravg_history_properties);
|
||||
//#endregion
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region step5. 每15分鐘逆變器歷史資料回填
|
||||
|
||||
//var calcInverter15mins = new List<InverterHistory>();
|
||||
//for (var i = 0; i < targetDay; i++)
|
||||
//{
|
||||
// var currentDateStr = startDate.AddDays(i).ToString("yyyy-MM-dd");
|
||||
|
||||
// var temp_start_time = DateTime.Now;
|
||||
|
||||
// for (var j = 0; j < 24; j++)
|
||||
// {
|
||||
// var time = string.Format("{0}", j.ToString().PadLeft(2, '0'));
|
||||
// var min_interval = new List<string>() { "02", "17", "32", "47" };
|
||||
|
||||
// for (var k = 0; k < min_interval.Count(); k++)
|
||||
// {
|
||||
// if(i == 0 && j == 0 && k== 0)
|
||||
// { //第一迴圈是跑開始日期的昨天最後一筆,故不執行
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// var all_time = string.Format("{0} {1}:{2}", currentDateStr, time, min_interval[k]);
|
||||
// var count = 0;
|
||||
// foreach (var powerStation in powerStations)
|
||||
// {
|
||||
// if (count > 0)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
|
||||
// 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();
|
||||
|
||||
// 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))
|
||||
// {
|
||||
// var calcInverter15min = await powerStationRepository.CalcInverterHisyort15minData(all_time, powerStation.SiteDB, full_table_name, inverterIds);
|
||||
// if (calcInverter15min.Count() > 0)
|
||||
// {
|
||||
// foreach (var inverterHistory in calcInverter15min)
|
||||
// {
|
||||
// inverterHistory.TIMESTAMP = Convert.ToDateTime(inverterHistory.TIMESTAMP + ":00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
// inverterHistory.PowerStationId = powerStation.Id;
|
||||
|
||||
// calcInverter15mins.Add(inverterHistory);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// count++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// var temp_end_time = DateTime.Now;
|
||||
|
||||
// var runtime = temp_end_time.Subtract(temp_start_time).TotalSeconds;
|
||||
// Logger.LogInformation("單一天執行15回填運行時間{0}", runtime.ToString());
|
||||
//}
|
||||
|
||||
////需再針對最後一天的最後一個時段補上資料
|
||||
//var last_all_time = string.Format("{0} {1}", endDate.AddDays(1).ToString(dateTimeFormat), "00:02");
|
||||
//foreach (var powerStation in powerStations)
|
||||
//{
|
||||
// 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();
|
||||
|
||||
// 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))
|
||||
// {
|
||||
// var calcInverter15min = await powerStationRepository.CalcInverterHisyort15minData(last_all_time, powerStation.SiteDB, full_table_name, inverterIds);
|
||||
// if (calcInverter15min.Count() > 0)
|
||||
// {
|
||||
// foreach (var inverterHistory in calcInverter15min)
|
||||
// {
|
||||
// inverterHistory.TIMESTAMP = Convert.ToDateTime(inverterHistory.TIMESTAMP + ":00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
// inverterHistory.PowerStationId = powerStation.Id;
|
||||
|
||||
// calcInverter15mins.Add(inverterHistory);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//List<string> inverter_history_15min_properties = new List<string>()
|
||||
// {
|
||||
// "PowerStationId",
|
||||
// "INVERTERID",
|
||||
// "TIMESTAMP",
|
||||
// "KWH",
|
||||
// "TODAYKWH",
|
||||
// "KWHKWP",
|
||||
// };
|
||||
|
||||
//await powerStationRepository.AddAfterPurgeInverterHistory15min(startDateStr, endDateStr, calcInverter15mins, inverter_history_15min_properties);
|
||||
//#endregion
|
||||
|
||||
var calcInverter15mins = new List<InverterHistory>();
|
||||
//抓出inverter row data
|
||||
for (var i = 0; i < targetDay; i++)
|
||||
{
|
||||
"PowerStationId",
|
||||
"TIMESTAMP",
|
||||
"SENSORAVG01",
|
||||
"SENSORAVG02",
|
||||
"SENSORAVG03",
|
||||
"SENSORAVG04",
|
||||
"SENSORAVG05",
|
||||
"SENSORAVG06",
|
||||
"SENSORAVG07",
|
||||
"SENSORAVG08",
|
||||
"SENSORAVG09",
|
||||
"SENSORAVG10",
|
||||
"SENSORAVG11",
|
||||
"SENSORAVG12",
|
||||
"SENSORAVG13",
|
||||
"SENSORAVG14",
|
||||
"SENSORAVG15",
|
||||
"SENSORAVG16",
|
||||
"SENSORAVG17",
|
||||
"SENSORAVG18",
|
||||
"SENSORAVG19",
|
||||
"SENSORAVG20",
|
||||
"SENSORAVG21",
|
||||
"SENSORAVG22",
|
||||
"SENSORAVG23",
|
||||
"SENSORAVG24",
|
||||
"SENSORAVG25",
|
||||
"SENSORAVG26",
|
||||
"SENSORAVG27",
|
||||
"SENSORAVG28",
|
||||
"SENSORAVG29",
|
||||
"SENSORAVG30",
|
||||
"SENSORAVG31",
|
||||
"SENSORAVG32",
|
||||
"SENSORAVG33",
|
||||
"SENSORAVG34",
|
||||
"SENSORAVG35",
|
||||
"SENSORAVG36",
|
||||
"SENSORAVG37",
|
||||
"SENSORAVG38",
|
||||
"SENSORAVG39",
|
||||
"SENSORAVG40",
|
||||
"SENSORAVG41",
|
||||
"SENSORAVG42",
|
||||
"SENSORAVG43",
|
||||
"SENSORAVG44",
|
||||
"SENSORAVG45",
|
||||
"SENSORAVG46",
|
||||
"SENSORAVG47",
|
||||
"SENSORAVG48",
|
||||
"SENSORAVG49",
|
||||
"SENSORAVG50",
|
||||
};
|
||||
await powerStationRepository.AddAfterPurgeSensorAvgHistoryHour(startDateStr, endDateStr, sensorAvgHistoryHour, sensoravg_history_properties);
|
||||
#endregion
|
||||
var currentDateStr = startDate.AddDays(i).ToString("yyyy-MM-dd");
|
||||
|
||||
#endregion
|
||||
var count = 0;
|
||||
foreach (var powerStation in powerStations)
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
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))
|
||||
{
|
||||
var inverter_row_data = await powerStationRepository.GetAllInverterRowData(currentDateStr, full_table_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
apiResult.Code = "0000";
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
||||
@ -58,7 +58,7 @@ namespace SolarPower.Controllers
|
||||
var companyId = 0;
|
||||
var powerStation = await powerStationRepository.GetOneAsync(powerStationId);
|
||||
|
||||
if(powerStation == null)
|
||||
if (powerStation == null)
|
||||
{
|
||||
companyId = myUser.CompanyId;
|
||||
}
|
||||
@ -66,10 +66,53 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
companyId = powerStation.CompanyId;
|
||||
}
|
||||
var userSelectItemLists = await userRepository.GetUserSelectOptionListAsync(companyId);
|
||||
|
||||
var margeUserSelectItemLists = new List<UserSelectItemList>();
|
||||
|
||||
if (companyId == 1)
|
||||
{
|
||||
var userSelectItemLists = await userRepository.GetUserSelectOptionListAsync(companyId);
|
||||
|
||||
foreach (var userSelectItem in userSelectItemLists)
|
||||
{
|
||||
userSelectItem.CanBeSelected = 1;
|
||||
}
|
||||
|
||||
margeUserSelectItemLists.AddRange(userSelectItemLists);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var platformUserSelectItemLists = await userRepository.GetUserSelectOptionListAsync(1);
|
||||
|
||||
if (IsPlatformLayer(myUser.Role.Layer))
|
||||
{
|
||||
foreach (var userSelectItem in platformUserSelectItemLists)
|
||||
{
|
||||
userSelectItem.CanBeSelected = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var userSelectItem in platformUserSelectItemLists)
|
||||
{
|
||||
userSelectItem.CanBeSelected = 0;
|
||||
}
|
||||
}
|
||||
|
||||
margeUserSelectItemLists.AddRange(platformUserSelectItemLists);
|
||||
|
||||
var userSelectItemLists = await userRepository.GetUserSelectOptionListAsync(companyId);
|
||||
foreach (var userSelectItem in userSelectItemLists)
|
||||
{
|
||||
userSelectItem.CanBeSelected = 1;
|
||||
}
|
||||
|
||||
margeUserSelectItemLists.AddRange(userSelectItemLists);
|
||||
}
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = userSelectItemLists;
|
||||
apiResult.Data = margeUserSelectItemLists;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -259,7 +302,7 @@ namespace SolarPower.Controllers
|
||||
|
||||
var tempSerialNumber = GetLastSerialNumber(currentSerialNumber);
|
||||
|
||||
var codeFormat = "s{0}{1}{2}";
|
||||
var codeFormat = "{0}{1}{2}";
|
||||
|
||||
powerStation = new PowerStation()
|
||||
{
|
||||
@ -1294,7 +1337,7 @@ namespace SolarPower.Controllers
|
||||
"Type",
|
||||
"UpperLimit",
|
||||
};
|
||||
await powerStationRepository.AddException(Exception, properties,powerStation.SiteDB);
|
||||
await powerStationRepository.AddException(Exception, properties, powerStation.SiteDB);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "新增成功";
|
||||
@ -1321,7 +1364,7 @@ namespace SolarPower.Controllers
|
||||
"Type",
|
||||
"UpperLimit",
|
||||
};
|
||||
await powerStationRepository.UpdateException(Exception, properties,powerStation.SiteDB);
|
||||
await powerStationRepository.UpdateException(Exception, properties, powerStation.SiteDB);
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "儲存成功";
|
||||
}
|
||||
@ -1350,7 +1393,7 @@ namespace SolarPower.Controllers
|
||||
PowerStation powerStation = null;
|
||||
powerStation = await powerStationRepository.GetOneAsync(stationId);
|
||||
apiResult.Code = "0000";
|
||||
exceptionTable = await powerStationRepository.ExceptionTable(stationId,powerStation.SiteDB);
|
||||
exceptionTable = await powerStationRepository.ExceptionTable(stationId, powerStation.SiteDB);
|
||||
foreach (ExceptionTable a in exceptionTable)
|
||||
{
|
||||
a.Function = @"
|
||||
@ -1394,7 +1437,7 @@ namespace SolarPower.Controllers
|
||||
PowerStation powerStation = null;
|
||||
powerStation = await powerStationRepository.GetOneAsync(id.PowerStationId);
|
||||
apiResult.Code = "0000";
|
||||
Exception = await powerStationRepository.OneException(id.SelectedId,powerStation.SiteDB);
|
||||
Exception = await powerStationRepository.OneException(id.SelectedId, powerStation.SiteDB);
|
||||
apiResult.Data = Exception;
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -1421,7 +1464,7 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
PowerStation powerStation = null;
|
||||
powerStation = await powerStationRepository.GetOneAsync(id.PowerStationId);
|
||||
Exception = await powerStationRepository.OneException(id.SelectedId,powerStation.SiteDB);
|
||||
Exception = await powerStationRepository.OneException(id.SelectedId, powerStation.SiteDB);
|
||||
|
||||
if (Exception == null)
|
||||
{
|
||||
@ -1474,7 +1517,7 @@ namespace SolarPower.Controllers
|
||||
else
|
||||
{
|
||||
|
||||
if(!IsPlatformLayer(myUser.Role.Layer) && powerStation.CompanyId != myUser.CompanyId)
|
||||
if (!IsPlatformLayer(myUser.Role.Layer) && powerStation.CompanyId != myUser.CompanyId)
|
||||
{
|
||||
apiResult.Code = "9993";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
@ -1696,7 +1739,7 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
updata = new UpdataPowerStationImage()
|
||||
{
|
||||
Id=origMainDisplay.Id,
|
||||
Id = origMainDisplay.Id,
|
||||
IsMainDisplay = 0,
|
||||
UpdatedBy = myUser.Id
|
||||
};
|
||||
@ -1988,14 +2031,14 @@ namespace SolarPower.Controllers
|
||||
apiResult.Code = "0000";
|
||||
solaramount = await powerStationRepository.GetSolarByCity(myUser, cityid);
|
||||
|
||||
foreach(var solar in solaramount)
|
||||
foreach (var solar in solaramount)
|
||||
{
|
||||
solar.MainDisplay = Path.Combine(stationImageFilePath, solar.Id.ToString()) + "/" + solar.MainDisplay;
|
||||
List<int> deviceControllerid = await powerStationRepository.GetAllDeviceControllerId(solar.Id, solar.SiteDB);
|
||||
var InverterTable = await powerStationRepository.InverterTable(deviceControllerid, solar.SiteDB);
|
||||
solar.InverterAmount = InverterTable.Count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
apiResult.Data = solaramount;
|
||||
@ -2021,7 +2064,7 @@ namespace SolarPower.Controllers
|
||||
powerStation = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||
|
||||
var tableName = powerStation.SiteDB + ".controller";
|
||||
try
|
||||
try
|
||||
{
|
||||
for (var i = 0; i < post.Count; i++)
|
||||
{
|
||||
@ -2064,7 +2107,7 @@ namespace SolarPower.Controllers
|
||||
/// </summary>
|
||||
/// <param name="stationId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ActionResult> DeviceControllerControllerTable (int stationId)
|
||||
public async Task<ActionResult> DeviceControllerControllerTable(int stationId)
|
||||
{
|
||||
List<DeviceControllerTable> deviceControllerTable = new List<DeviceControllerTable>();
|
||||
ApiResult<List<DeviceControllerTable>> apiResult = new ApiResult<List<DeviceControllerTable>>();
|
||||
@ -2113,7 +2156,7 @@ namespace SolarPower.Controllers
|
||||
powerStation = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||
|
||||
var deviceController = await powerStationRepository.GetOneWithCustomDBNameAndTableAsync<DeviceController>(post.SelectedId, powerStation.SiteDB, "controller");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -2171,7 +2214,7 @@ namespace SolarPower.Controllers
|
||||
var tableName = powerStation.SiteDB + ".inverter";
|
||||
try
|
||||
{
|
||||
if(post.Id == 0)
|
||||
if (post.Id == 0)
|
||||
{
|
||||
var Num = await powerStationRepository.GetCurrentSerialNumber(tableName, "ControllerId =" + post.ControllerId);
|
||||
var Newnum = GetLastSerialNumber(Num);
|
||||
@ -2212,7 +2255,7 @@ namespace SolarPower.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
if(inverter1 == null)
|
||||
if (inverter1 == null)
|
||||
{
|
||||
apiResult.Msg = "找不到資料";
|
||||
apiResult.Code = "0001";
|
||||
@ -2279,7 +2322,7 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
|
||||
powerStation = await powerStationRepository.GetOneAsync(stationId);
|
||||
List<int> deviceControllerid = await powerStationRepository.GetAllDeviceControllerId(stationId,powerStation.SiteDB);
|
||||
List<int> deviceControllerid = await powerStationRepository.GetAllDeviceControllerId(stationId, powerStation.SiteDB);
|
||||
List<InverterTable> InverterTable = new List<InverterTable>();
|
||||
InverterTable = await powerStationRepository.InverterTable(deviceControllerid, powerStation.SiteDB);
|
||||
|
||||
@ -2312,7 +2355,7 @@ namespace SolarPower.Controllers
|
||||
a.EnabledName = "無資料";
|
||||
break;
|
||||
}
|
||||
if(a.PyrheliometerName == null)
|
||||
if (a.PyrheliometerName == null)
|
||||
{
|
||||
a.PyrheliometerName = "無設備";
|
||||
}
|
||||
@ -2387,7 +2430,7 @@ namespace SolarPower.Controllers
|
||||
try
|
||||
{
|
||||
var powerStation = await powerStationRepository.GetOneAsync(stationId);
|
||||
var PowerstationOption = await powerStationRepository.GetPowerstationOptionAsync(powerStation.SiteDB,stationId);
|
||||
var PowerstationOption = await powerStationRepository.GetPowerstationOptionAsync(powerStation.SiteDB, stationId);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = PowerstationOption;
|
||||
@ -2634,7 +2677,7 @@ namespace SolarPower.Controllers
|
||||
List<PowerStationImage> ALLpowerStationImages = new List<PowerStationImage>();
|
||||
try
|
||||
{
|
||||
foreach(var ones in powerStationId)
|
||||
foreach (var ones in powerStationId)
|
||||
{
|
||||
var powerStation = await powerStationRepository.GetOneAsync(ones);
|
||||
|
||||
|
||||
@ -1181,7 +1181,7 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "report", Datename));
|
||||
}
|
||||
var n = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "report", "FIC太陽能監控平台" + "_" + name + "報表" + "_" + postObject.Userid + Datename + ".xlsx");
|
||||
var n = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "report", Datename, "FIC太陽能監控平台" + "_" + name + "報表" + "_" + postObject.Userid + Datename + ".xlsx");
|
||||
FileStream FS = new FileStream(n, FileMode.Create, FileAccess.Write);
|
||||
workbook.Write(FS);
|
||||
FS.Close();
|
||||
|
||||
@ -24,14 +24,17 @@ namespace SolarPower.Controllers
|
||||
private readonly IUserRepository userRepository;
|
||||
private readonly ISendEmailService sendEmailService;
|
||||
private readonly IPowerStationRepository powerStationRepository;
|
||||
private readonly IRoleRepository roleRepository;
|
||||
private string logoPath = "/upload/company_logo/";
|
||||
public UserController(IUserRepository userRepository,
|
||||
ISendEmailService sendEmailService,
|
||||
IPowerStationRepository powerStationRepository) : base()
|
||||
IPowerStationRepository powerStationRepository,
|
||||
IRoleRepository roleRepository) : base()
|
||||
{
|
||||
this.userRepository = userRepository;
|
||||
this.sendEmailService = sendEmailService;
|
||||
this.powerStationRepository = powerStationRepository;
|
||||
this.roleRepository = roleRepository;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
@ -302,7 +305,7 @@ namespace SolarPower.Controllers
|
||||
#region 新增使用者
|
||||
//判斷帳號 是否已存在
|
||||
var exist = await userRepository.GetOneByAccountAsync(post.Account);
|
||||
if(exist != null)
|
||||
if (exist != null)
|
||||
{
|
||||
apiResult.Code = "9986";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
@ -520,7 +523,9 @@ namespace SolarPower.Controllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
var companyPowerStation = await userRepository.GetCompanyPowerStationAsync(user.CompanyId, user.Id);
|
||||
var role = await roleRepository.GetOneAsync(user.RoleId);
|
||||
|
||||
var companyPowerStation = await userRepository.GetCompanyPowerStationAsync(user.CompanyId, user.Id, IsPlatformLayer(role.Layer));
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = companyPowerStation;
|
||||
@ -556,8 +561,8 @@ namespace SolarPower.Controllers
|
||||
|
||||
if (!IsPlatformLayer(myUser.Role.Layer))
|
||||
{ //如果身分為公司管理員 或 公司使用者,就只能改自己公司的資料
|
||||
|
||||
if(user.CompanyId != myUser.CompanyId)
|
||||
|
||||
if (user.CompanyId != myUser.CompanyId)
|
||||
{
|
||||
apiResult.Code = "9993";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
|
||||
@ -456,7 +456,7 @@ DELETE FROM `city`;
|
||||
/*!40000 ALTER TABLE `city` DISABLE KEYS */;
|
||||
INSERT INTO `city` (`Id`, `Name`, `ZipCode`, `Priority`) VALUES
|
||||
(1, '基隆市', '020', 1),
|
||||
(2, '台北市', '021', 2),
|
||||
(2, '臺北市', '021', 2),
|
||||
(3, '新北市', '022', 3),
|
||||
(4, '桃園縣', '030', 4),
|
||||
(5, '新竹市', '031', 5),
|
||||
@ -464,13 +464,13 @@ INSERT INTO `city` (`Id`, `Name`, `ZipCode`, `Priority`) VALUES
|
||||
(7, '宜蘭縣', '033', 19),
|
||||
(8, '花蓮縣', '034', 18),
|
||||
(9, '苗栗縣', '037', 7),
|
||||
(10, '台中市', '040', 8),
|
||||
(10, '臺中市', '040', 8),
|
||||
(11, '彰化縣', '041', 9),
|
||||
(12, '南投縣', '049', 10),
|
||||
(13, '雲林縣', '050', 11),
|
||||
(14, '嘉義市', '051', 12),
|
||||
(15, '嘉義縣', '052', 13),
|
||||
(16, '台南市', '060', 14),
|
||||
(16, '臺南市', '060', 14),
|
||||
(17, '高雄市', '070', 15),
|
||||
(18, '屏東縣', '080', 16),
|
||||
(19, '臺東縣', '089', 17),
|
||||
|
||||
@ -8,6 +8,7 @@ namespace SolarPower.Models
|
||||
{
|
||||
public class Overview
|
||||
{
|
||||
public string Wx { get; set; }
|
||||
public double Today_kwh { get; set; } //今日總發電量
|
||||
public double Total_kwh { get; set; } //累計總發電量
|
||||
public double Today_irradiance { get; set; } //即時平均日照度
|
||||
|
||||
@ -134,6 +134,7 @@ namespace SolarPower.Models.PowerStation
|
||||
public string line_token { get; set; }//line_token
|
||||
public double Estimate_kwh { get; set; }//預估發電度數
|
||||
public double EstimateEfficacy { get; set; }//預估發電效能
|
||||
public string Wx { get; set; } //天氣預估
|
||||
public string CreatorName { get; set; } //創建者名稱
|
||||
}
|
||||
|
||||
|
||||
@ -132,6 +132,7 @@ namespace SolarPower.Models.User
|
||||
|
||||
public class UserSelectItemList
|
||||
{
|
||||
public byte CanBeSelected { get; set; }
|
||||
public string Text { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
@ -421,8 +421,16 @@ namespace SolarPower.Quartz.Jobs
|
||||
historyDay.MONEY = moneyandcarbon.MONEY;
|
||||
//historyDay.TODAYCARBON = lastmoneyhistory.TODAYCARBON;
|
||||
//historyDay.TODAYMONEY = lastmoneyhistory.TODAYMONEY ;
|
||||
historyDay.TOTALCARBON = lastmoneyhistory.TOTALCARBON + moneyandcarbon.CARBON;
|
||||
historyDay.TOTALMONEY = lastmoneyhistory.TOTALMONEY + moneyandcarbon.MONEY;
|
||||
if(lastmoneyhistory != null)
|
||||
{
|
||||
historyDay.TOTALCARBON = lastmoneyhistory.TOTALCARBON + moneyandcarbon.CARBON;
|
||||
historyDay.TOTALMONEY = lastmoneyhistory.TOTALMONEY + moneyandcarbon.MONEY;
|
||||
}
|
||||
else
|
||||
{
|
||||
historyDay.TOTALCARBON = moneyandcarbon.CARBON;
|
||||
historyDay.TOTALMONEY = moneyandcarbon.MONEY;
|
||||
}
|
||||
|
||||
//日期轉換
|
||||
historyDay.Timestamp = Convert.ToDateTime(historyDay.Timestamp + ":00:00").ToString("yyyy-MM-dd");
|
||||
@ -530,8 +538,16 @@ namespace SolarPower.Quartz.Jobs
|
||||
historyMonth.Timestamp = Convert.ToDateTime(historyMonth.Timestamp).ToString("yyyy-MM-dd");
|
||||
historyMonth.MONEY = moneyandcarbonMon.MONEY;
|
||||
historyMonth.CARBON = moneyandcarbonMon.CARBON;
|
||||
historyMonth.TOTALCARBON = lastmoneyhistorymonth.TOTALCARBON + moneyandcarbonMon.CARBON;
|
||||
historyMonth.TOTALMONEY = lastmoneyhistorymonth.TOTALMONEY + moneyandcarbonMon.MONEY;
|
||||
if(lastmoneyhistorymonth != null)
|
||||
{
|
||||
historyMonth.TOTALCARBON = lastmoneyhistorymonth.TOTALCARBON + moneyandcarbonMon.CARBON;
|
||||
historyMonth.TOTALMONEY = lastmoneyhistorymonth.TOTALMONEY + moneyandcarbonMon.MONEY;
|
||||
}
|
||||
else
|
||||
{
|
||||
historyMonth.TOTALCARBON = moneyandcarbonMon.CARBON;
|
||||
historyMonth.TOTALMONEY = moneyandcarbonMon.MONEY;
|
||||
}
|
||||
|
||||
insertPowerStationHistoryMonths.Add(historyMonth);
|
||||
}
|
||||
@ -546,8 +562,16 @@ namespace SolarPower.Quartz.Jobs
|
||||
{
|
||||
historyMonth.MONEY = historyMonth.MONEY + moneyandcarbonMon.MONEY;
|
||||
historyMonth.CARBON = historyMonth.CARBON + moneyandcarbonMon.CARBON;
|
||||
historyMonth.TOTALCARBON = lastmoneyhistorymonth.TOTALCARBON + moneyandcarbonMon.CARBON;
|
||||
historyMonth.TOTALMONEY = lastmoneyhistorymonth.TOTALMONEY + moneyandcarbonMon.MONEY;
|
||||
if (lastmoneyhistorymonth != null)
|
||||
{
|
||||
historyMonth.TOTALCARBON = lastmoneyhistorymonth.TOTALCARBON + moneyandcarbonMon.CARBON;
|
||||
historyMonth.TOTALMONEY = lastmoneyhistorymonth.TOTALMONEY + moneyandcarbonMon.MONEY;
|
||||
}
|
||||
else
|
||||
{
|
||||
historyMonth.TOTALCARBON = moneyandcarbonMon.CARBON;
|
||||
historyMonth.TOTALMONEY = moneyandcarbonMon.MONEY;
|
||||
}
|
||||
updatePowerStationHistoryMonths.Add(historyMonth);
|
||||
}
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的歷史資料總和】", powerStation.Code, dateNowMonth);
|
||||
|
||||
@ -85,8 +85,6 @@ namespace SolarPower.Quartz.Jobs
|
||||
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);
|
||||
@ -95,15 +93,17 @@ namespace SolarPower.Quartz.Jobs
|
||||
if (!string.IsNullOrEmpty(exist))
|
||||
{
|
||||
logger.LogInformation("【CalcInverter15minJob】【開始計算電站[{0}]在{1}的每15分鐘逆變器資訊】", powerStation.Code, dateNowTime);
|
||||
calcInverter15mins = await powerStationRepository.CalcInverterHisyort15minData(dateNowTime, powerStation.SiteDB, full_table_name, inverterIds);
|
||||
var calcInverter15min = await powerStationRepository.CalcInverterHisyort15minData(dateNowTime, powerStation.SiteDB, full_table_name, inverterIds);
|
||||
logger.LogInformation("【CalcInverter15minJob】【計算完成電站[{0}]在{1}的每15分鐘逆變器資訊】", powerStation.Code, dateNowTime);
|
||||
logger.LogInformation("【CalcInverter15minJob】【計算結果】 - {0}", System.Text.Json.JsonSerializer.Serialize(calcInverter15mins));
|
||||
if (calcInverter15mins.Count() > 0)
|
||||
if (calcInverter15min.Count() > 0)
|
||||
{
|
||||
foreach (var inverterHistory in calcInverter15mins)
|
||||
foreach (var inverterHistory in calcInverter15min)
|
||||
{
|
||||
inverterHistory.TIMESTAMP = Convert.ToDateTime(inverterHistory.TIMESTAMP + ":00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
inverterHistory.PowerStationId = powerStation.Id;
|
||||
|
||||
calcInverter15mins.Add(inverterHistory);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -115,7 +115,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region step3. 將 inverter INSERT 到 inverter_history_hour 資料表
|
||||
#region step3. 將 inverter INSERT 到 inverter_history_15min 資料表
|
||||
List<string> inverter_history_properties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
|
||||
@ -103,7 +103,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
foreach(var attachment in attachments)
|
||||
{
|
||||
var directoryBase = Directory.GetCurrentDirectory();
|
||||
var filePath = @$"{directoryBase}/wwwroot{attachment}";
|
||||
var filePath = @$"{directoryBase}\wwwroot{attachment}";
|
||||
|
||||
var data = new Attachment(filePath);
|
||||
MyMail.Attachments.Add(data);
|
||||
|
||||
@ -107,10 +107,18 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = @$"SELECT * FROM power_station ps WHERE ps.Id IN @PowerStationIds
|
||||
var dateNow = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
var sql = @$"SELECT
|
||||
w.Wx,
|
||||
ps.*
|
||||
FROM power_station ps
|
||||
LEFT JOIN city c ON ps.CityId = c.Id
|
||||
LEFT JOIN weather_forecast w ON c.Name = w.LocationName AND w.StartTime < @DateNow AND w.EndTime > @DateNow
|
||||
WHERE ps.Id IN @PowerStationIds
|
||||
";
|
||||
|
||||
result = (await conn.QueryAsync<PowerStation>(sql, new { PowerStationIds = powerStationIds })).ToList();
|
||||
result = (await conn.QueryAsync<PowerStation>(sql, new { PowerStationIds = powerStationIds, DateNow = dateNow })).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
||||
@ -2263,7 +2263,7 @@ namespace SolarPower.Repository.Implement
|
||||
LEFT JOIN {db_name}.device d ON sd.DeviceId = d.Id
|
||||
WHERE sd.PowerStationId = @PowerStationId AND d.`Type` = 'PYR' AND d.Deleted = 0 AND d.Enabled = 1 AND d.Status != 0
|
||||
) temp
|
||||
ORDER BY temp.ColName LIMIT 1
|
||||
ORDER BY temp.ColName
|
||||
";
|
||||
|
||||
result = (await conn.QueryAsync<DeviceInfo>(sql, new { PowerStationId = powerStationId })).ToList();
|
||||
@ -2813,7 +2813,7 @@ namespace SolarPower.Repository.Implement
|
||||
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'
|
||||
WHERE d.Deleted = 0 AND d.Enabled = 1 AND d.`Status` != 0 AND d.`Type` = 'PYR'
|
||||
AND d.PowerStationId = @PowerStationId
|
||||
ORDER BY d.ColName";
|
||||
|
||||
@ -4352,11 +4352,12 @@ namespace SolarPower.Repository.Implement
|
||||
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var purge_sql = $"DELET FROM power_station_history_hour WHERE TIMESTAMP BETWEEN @StartDate AND @EndDate";
|
||||
var purge_sql = $"DELETE FROM power_station_history_hour WHERE DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') BETWEEN @StartDate AND @EndDate";
|
||||
await conn.ExecuteAsync(purge_sql, new { StartDate = startDate, EndDate = endDate}, trans);
|
||||
|
||||
var insert_sql = GenerateInsertQueryWithCustomTable(properties, "power_station_history_hour");
|
||||
@ -4378,20 +4379,21 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AddAfterPurgePyrheliometerHistoryHour(string startDate, string endDate, List<PyrheliometerHistory> entity, List<string> properties)
|
||||
public async Task AddAfterPurgePowerStationHistoryDay(string startDate, string endDate, List<PowerStationHistoryDay> entity, List<string> properties)
|
||||
{
|
||||
int count;
|
||||
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var purge_sql = $"DELET FROM sensor_history_hour WHERE TIMESTAMP BETWEEN @StartDate AND @EndDate";
|
||||
var purge_sql = $"DELETE FROM power_station_history_day WHERE DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') BETWEEN @StartDate AND @EndDate";
|
||||
await conn.ExecuteAsync(purge_sql, new { StartDate = startDate, EndDate = endDate }, trans);
|
||||
|
||||
var insert_sql = GenerateInsertQueryWithCustomTable(properties, "sensor_history_hour");
|
||||
var insert_sql = GenerateInsertQueryWithCustomTable(properties, "power_station_history_day");
|
||||
count = await conn.ExecuteAsync(insert_sql, entity, trans);
|
||||
|
||||
trans.Commit();
|
||||
@ -4410,20 +4412,21 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AddAfterPurgeInverterHistoryHour(string startDate, string endDate, List<InverterHistory> entity, List<string> properties)
|
||||
public async Task AddAfterPurgePowerStationHistoryMonth(string startDate, string endDate, List<PowerStationHistoryMonth> entity, List<string> properties)
|
||||
{
|
||||
int count;
|
||||
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var purge_sql = $"DELET FROM inverter_history_hour WHERE TIMESTAMP BETWEEN @StartDate AND @EndDate";
|
||||
var purge_sql = $"DELETE FROM power_station_history_month WHERE DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') BETWEEN @StartDate AND @EndDate";
|
||||
await conn.ExecuteAsync(purge_sql, new { StartDate = startDate, EndDate = endDate }, trans);
|
||||
|
||||
var insert_sql = GenerateInsertQueryWithCustomTable(properties, "inverter_history_hour");
|
||||
var insert_sql = GenerateInsertQueryWithCustomTable(properties, "power_station_history_month");
|
||||
count = await conn.ExecuteAsync(insert_sql, entity, trans);
|
||||
|
||||
trans.Commit();
|
||||
@ -4442,20 +4445,164 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AddAfterPurgeSensorAvgHistoryHour(string startDate, string endDate, List<SensorAvgHistory> entity, List<string> properties)
|
||||
public async Task AddAfterPurgePyrheliometerHistory(string startDate, string endDate, byte type, List<PyrheliometerHistory> entity, List<string> properties)
|
||||
{
|
||||
int count;
|
||||
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var purge_sql = $"DELET FROM sensoravg_history_hour WHERE TIMESTAMP BETWEEN @StartDate AND @EndDate";
|
||||
var table_name = "";
|
||||
switch (type)
|
||||
{
|
||||
case 0: //小時
|
||||
table_name = "sensor_history_hour";
|
||||
break;
|
||||
case 1:
|
||||
table_name = "sensor_history_day";
|
||||
break;
|
||||
case 2:
|
||||
table_name = "sensor_history_month";
|
||||
break;
|
||||
}
|
||||
|
||||
var purge_sql = $"DELETE FROM {table_name} WHERE DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') BETWEEN @StartDate AND @EndDate";
|
||||
await conn.ExecuteAsync(purge_sql, new { StartDate = startDate, EndDate = endDate }, trans);
|
||||
|
||||
var insert_sql = GenerateInsertQueryWithCustomTable(properties, "sensoravg_history_hour");
|
||||
var insert_sql = GenerateInsertQueryWithCustomTable(properties, table_name);
|
||||
count = await conn.ExecuteAsync(insert_sql, entity, trans);
|
||||
|
||||
trans.Commit();
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AddAfterPurgeInverterHistory(string startDate, string endDate, byte type, List<InverterHistory> entity, List<string> properties)
|
||||
{
|
||||
int count;
|
||||
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var table_name = "";
|
||||
switch (type)
|
||||
{
|
||||
case 0: //小時
|
||||
table_name = "inverter_history_hour";
|
||||
break;
|
||||
case 1:
|
||||
table_name = "inverter_history_day";
|
||||
break;
|
||||
case 2:
|
||||
table_name = "inverter_history_month";
|
||||
break;
|
||||
}
|
||||
|
||||
var purge_sql = $"DELETE FROM {table_name} WHERE DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') BETWEEN @StartDate AND @EndDate";
|
||||
await conn.ExecuteAsync(purge_sql, new { StartDate = startDate, EndDate = endDate }, trans);
|
||||
|
||||
var insert_sql = GenerateInsertQueryWithCustomTable(properties, table_name);
|
||||
count = await conn.ExecuteAsync(insert_sql, entity, trans);
|
||||
|
||||
trans.Commit();
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AddAfterPurgeInverterHistory15min(string startDate, string endDate, List<InverterHistory> entity, List<string> properties)
|
||||
{
|
||||
int count;
|
||||
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var table_name = "inverter_history_15min";
|
||||
|
||||
var purge_sql = $"DELETE FROM {table_name} WHERE DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') BETWEEN @StartDate AND @EndDate";
|
||||
await conn.ExecuteAsync(purge_sql, new { StartDate = startDate, EndDate = endDate }, trans);
|
||||
|
||||
var insert_sql = GenerateInsertQueryWithCustomTable(properties, table_name);
|
||||
count = await conn.ExecuteAsync(insert_sql, entity, trans);
|
||||
|
||||
trans.Commit();
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AddAfterPurgeSensorAvgHistory(string startDate, string endDate, byte type, List<SensorAvgHistory> entity, List<string> properties)
|
||||
{
|
||||
int count;
|
||||
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var table_name = "";
|
||||
switch (type)
|
||||
{
|
||||
case 0: //小時
|
||||
table_name = "sensoravg_history_hour";
|
||||
break;
|
||||
case 1:
|
||||
table_name = "sensoravg_history_day";
|
||||
break;
|
||||
case 2:
|
||||
table_name = "sensoravg_history_month";
|
||||
break;
|
||||
}
|
||||
|
||||
var purge_sql = $"DELETE FROM {table_name} WHERE DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') BETWEEN @StartDate AND @EndDate";
|
||||
await conn.ExecuteAsync(purge_sql, new { StartDate = startDate, EndDate = endDate }, trans);
|
||||
|
||||
var insert_sql = GenerateInsertQueryWithCustomTable(properties, table_name);
|
||||
count = await conn.ExecuteAsync(insert_sql, entity, trans);
|
||||
|
||||
trans.Commit();
|
||||
@ -4509,5 +4656,29 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<List<InverterHistory>> GetAllInverterRowData(string date, string table_name)
|
||||
{
|
||||
List<InverterHistory> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = @$"SELECT FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') AS TIMESTAMP,
|
||||
inv.WH / 1000 AS KWH,
|
||||
inv.TODAYKWH,
|
||||
inv.TOTALKWH
|
||||
FROM {table_name} inv
|
||||
WHERE FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = $Date";
|
||||
|
||||
result = (await conn.QueryAsync<InverterHistory>(sql, new { Date = date })).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,6 +300,7 @@ namespace SolarPower.Repository.Implement
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT Id AS Value, Name AS Text FROM `{tableName}` WHERE Deleted = 0";
|
||||
|
||||
if (companyId != 0)
|
||||
{
|
||||
sql += @" AND CompanyId=@companyId";
|
||||
@ -420,7 +421,7 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<UserPowerStation>> GetCompanyPowerStationAsync(int companyId, int userId)
|
||||
public async Task<List<UserPowerStation>> GetCompanyPowerStationAsync(int companyId, int userId, bool isPlatformLayer)
|
||||
{
|
||||
List<UserPowerStation> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
@ -436,7 +437,13 @@ namespace SolarPower.Repository.Implement
|
||||
END AS EscrowName
|
||||
FROM power_station ps
|
||||
LEFT JOIN company c ON ps.CompanyId = c.Id
|
||||
WHERE ps.CompanyId = @CompanyId AND ps.Id NOT IN (SELECT psop.PowerStationId FROM power_station_operation_personnel psop WHERE psop.UserId = @UserId AND psop.Deleted = 0)";
|
||||
WHERE ps.Id NOT IN (SELECT psop.PowerStationId FROM power_station_operation_personnel psop WHERE psop.UserId = @UserId AND psop.Deleted = 0)";
|
||||
|
||||
if (!isPlatformLayer)
|
||||
{
|
||||
sql += " AND ps.CompanyId = @CompanyId";
|
||||
}
|
||||
|
||||
|
||||
result = (await conn.QueryAsync<UserPowerStation>(sql, new { CompanyId = companyId, UserId = userId })).ToList();
|
||||
}
|
||||
|
||||
@ -563,9 +563,13 @@ namespace SolarPower.Repository.Interface
|
||||
Task<List<PowerStationHistory>> GetPowerStationHistoryByDateRange(string startDate, string endDate);
|
||||
|
||||
Task AddAfterPurgePowerStationHistoryHour(string startDate, string endDate, List<PowerStationHistory> entity, List<string> properties);
|
||||
Task AddAfterPurgePyrheliometerHistoryHour(string startDate, string endDate, List<PyrheliometerHistory> entity, List<string> properties);
|
||||
Task AddAfterPurgeInverterHistoryHour(string startDate, string endDate, List<InverterHistory> entity, List<string> properties);
|
||||
Task AddAfterPurgeSensorAvgHistoryHour(string startDate, string endDate, List<SensorAvgHistory> entity, List<string> properties);
|
||||
Task AddAfterPurgePowerStationHistoryDay(string startDate, string endDate, List<PowerStationHistoryDay> entity, List<string> properties);
|
||||
Task AddAfterPurgePowerStationHistoryMonth(string startDate, string endDate, List<PowerStationHistoryMonth> entity, List<string> properties);
|
||||
Task AddAfterPurgePyrheliometerHistory(string startDate, string endDate, byte type, List<PyrheliometerHistory> entity, List<string> properties);
|
||||
Task AddAfterPurgeInverterHistory(string startDate, string endDate, byte type, List<InverterHistory> entity, List<string> properties);
|
||||
Task AddAfterPurgeInverterHistory15min(string startDate, string endDate, List<InverterHistory> entity, List<string> properties);
|
||||
Task AddAfterPurgeSensorAvgHistory(string startDate, string endDate, byte type, List<SensorAvgHistory> entity, List<string> properties);
|
||||
Task<bool> CheckShowMoney(int userid);
|
||||
Task<List<InverterHistory>> GetAllInverterRowData(string date, string table_name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ namespace SolarPower.Repository.Interface
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<UserPowerStation>> GetCompanyPowerStationAsync(int companyId, int userId);
|
||||
Task<List<UserPowerStation>> GetCompanyPowerStationAsync(int companyId, int userId, bool isPlatformLayer);
|
||||
|
||||
Task DeleteOneGetEmail(IdAndTypeByEmail post);
|
||||
}
|
||||
|
||||
@ -65,6 +65,7 @@
|
||||
</div>
|
||||
<div class="pr-3">
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="GetAnalysisStationInfo()">查詢</button>
|
||||
@*<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="DataBackFill()">回填</button>*@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -734,5 +735,20 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function DataBackFill() {
|
||||
var url = "/DataBackFill/BackFillHistory"
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'post',
|
||||
beforSend: function (XMLHttpRequest) {
|
||||
|
||||
},
|
||||
success: function (rel) {
|
||||
alert("123")
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
}
|
||||
@ -268,13 +268,12 @@
|
||||
'<div>即時平均日照度:' + item.today_irradiance + '</div>'+
|
||||
'<div>發電小時:' + item.solarHour + '</div>' +
|
||||
'<div>裝置容量:' + item.generatingCapacity + '</div>' +
|
||||
'<div>天氣:' + + '</div>'+
|
||||
'<div>天氣:' + item.wx + '</div>'+
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
||||
|
||||
if (item.coordinate != null) {
|
||||
var split = item.coordinate.split(',');
|
||||
if (split[0] == undefined || split[0] == null) {
|
||||
|
||||
@ -765,7 +765,12 @@
|
||||
$("#power_station_operation_personnel").empty();
|
||||
|
||||
$.each(rel.data, function (index, val) {
|
||||
$("#power_station_operation_personnel").append($("<option />").val(val.value).text(val.text));
|
||||
if (val.canBeSelected == 1) {
|
||||
$("#power_station_operation_personnel").append($("<option />").val(val.value).text(val.text).attr({ "disabled": false, "data-canBeSelected": val.canBeSelected }));
|
||||
}
|
||||
else {
|
||||
$("#power_station_operation_personnel").append($("<option />").val(val.value).text(val.text).attr({ "disabled": true, "data-canBeSelected": val.canBeSelected }));
|
||||
}
|
||||
});
|
||||
|
||||
if (powerStationData) {
|
||||
@ -950,6 +955,19 @@
|
||||
|
||||
//#region 儲存電站基本資料資訊
|
||||
function SaveStationInfo() {
|
||||
|
||||
$(".select2-selection__choice").each(function () {
|
||||
$(this).children(".select2-selection__choice__remove").show();
|
||||
})
|
||||
|
||||
$("#power_station_operation_personnel > option").each(function () {
|
||||
$(this).attr("disabled", false);
|
||||
});
|
||||
|
||||
$("#power_station_operation_personnel").select2();
|
||||
|
||||
|
||||
|
||||
var url = "/PowerStation/SavePowerStationInfo";
|
||||
|
||||
var send_data = {
|
||||
@ -1222,6 +1240,40 @@
|
||||
$("#coordinate").show();
|
||||
$("#power_station_operation_personnel").attr("disabled", false);
|
||||
|
||||
$("#power_station_operation_personnel > option").each(function () {
|
||||
var canBeSelected = $(this).attr('data-canBeSelected');
|
||||
var val = $(this).text();
|
||||
if (canBeSelected == 1) {
|
||||
$(this).attr("disabled", false);
|
||||
|
||||
} else {
|
||||
$(this).attr("disabled", true);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$("#power_station_operation_personnel").select2();
|
||||
|
||||
$(".select2-selection__choice").each(function () {
|
||||
var select2_text = this.title;
|
||||
var select2 = this;
|
||||
|
||||
$("#power_station_operation_personnel > option").each(function () {
|
||||
var xxx = $(this).text();
|
||||
var canBeSelected = $(this).attr('data-canBeSelected');
|
||||
|
||||
if (select2_text == xxx) {
|
||||
if (canBeSelected == "1") {
|
||||
$(select2).children(".select2-selection__choice__remove").show();
|
||||
|
||||
} else {
|
||||
$(select2).children(".select2-selection__choice__remove").hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$("#line_token").show();
|
||||
$("#estimate_kwh").show();
|
||||
$("#estimate_efficacy").show();
|
||||
@ -1416,6 +1468,27 @@
|
||||
}
|
||||
//#endregion
|
||||
|
||||
$('#power_station_operation_personnel').on('select2:closing', function (e) {
|
||||
$(".select2-selection__choice").each(function () {
|
||||
var select2_text = this.title;
|
||||
var select2 = this;
|
||||
|
||||
$("#power_station_operation_personnel > option").each(function () {
|
||||
var xxx = $(this).text();
|
||||
var canBeSelected = $(this).attr('data-canBeSelected');
|
||||
|
||||
if (select2_text == xxx) {
|
||||
if (canBeSelected == "1") {
|
||||
$(select2).children(".select2-selection__choice__remove").show();
|
||||
|
||||
} else {
|
||||
$(select2).children(".select2-selection__choice__remove").hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
//#region 設定電站基本資料
|
||||
function SetStationInfo() {
|
||||
|
||||
|
||||
@ -6,27 +6,27 @@
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"LoginExpireMinute": 60, //?n?J???????A???(??)
|
||||
"DBConfig": {
|
||||
"Server": "MVgHWzR3rGDgD57TUoFunA==",
|
||||
"port": "r4AoXMUDodcQjIzofGNCcg==",
|
||||
"Database": "z8TVtiXZ6MwgWbUEAOXA/fiHzd7c0iUhFqn1mHzxhKo=",
|
||||
"Root": "mWlR2HshQNhRRE34jg4kdg==",
|
||||
"Password": "y4uPqlH9ncTgR/I07qpwaA=="
|
||||
},
|
||||
"LoginExpireMinute": 60, //µn¤J¨ì´Á®É¶¡¡A³æ¦ì(¤À)
|
||||
//"DBConfig": {
|
||||
// "Server": "AVXfxd+IRlLtJ0MCi9HU1g==",
|
||||
// "port": "CrEmevYrUsSo7Mkb7Gxn8A==",
|
||||
// "Database": "CEyYZnO8B5+yTXQcFSsiBA==",
|
||||
// "Root": "Aph7AzoiwAmmBHCfS1rqeQ==",
|
||||
// "Password": "8WMHBEWuT0XoAB4kzduQHA=="
|
||||
// "Server": "MVgHWzR3rGDgD57TUoFunA==",
|
||||
// "port": "r4AoXMUDodcQjIzofGNCcg==",
|
||||
// "Database": "z8TVtiXZ6MwgWbUEAOXA/fiHzd7c0iUhFqn1mHzxhKo=",
|
||||
// "Root": "mWlR2HshQNhRRE34jg4kdg==",
|
||||
// "Password": "y4uPqlH9ncTgR/I07qpwaA=="
|
||||
//},
|
||||
"DBConfig": {
|
||||
"Server": "AVXfxd+IRlLtJ0MCi9HU1g==",
|
||||
"port": "CrEmevYrUsSo7Mkb7Gxn8A==",
|
||||
"Database": "CEyYZnO8B5+yTXQcFSsiBA==",
|
||||
"Root": "Aph7AzoiwAmmBHCfS1rqeQ==",
|
||||
"Password": "8WMHBEWuT0XoAB4kzduQHA=="
|
||||
},
|
||||
"BackgroundServiceCron": {
|
||||
"CalcPowerStationJob": "0 5 * * * ?",
|
||||
"CalcAvgPowerStationJob": "0 0 2 * * ?",
|
||||
"OperationScheduleJob": "0 0 2 * * ?",
|
||||
"CalcInverter15minJob": "0 2/15 * * * ?",
|
||||
"SendEmailJob": "0 15 2 * * ?"
|
||||
"SendEmailJob": "0/10 * * * * ?"
|
||||
},
|
||||
"SMTPConfig": {
|
||||
"Host": "smtp.gmail.com",
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user