1. 每小時 檢查DB 是否存在
This commit is contained in:
parent
1be7aebc1e
commit
32df22a687
@ -101,7 +101,11 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
var full_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, table_name);
|
var full_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, table_name);
|
||||||
var exist = await powerStationRepository.ExistTable(powerStation.SiteDB, table_name);
|
var exist = await powerStationRepository.ExistTable(powerStation.SiteDB, table_name);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(exist))
|
if (string.IsNullOrEmpty(exist))
|
||||||
|
{
|
||||||
|
logger.LogError("【CalcPowerStationJob】【查無電站[0]的s{0}01_station資料表】", powerStation.Code);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
||||||
var history = await powerStationRepository.GetPowerStationHistoryPerHour(dateTime, full_table_name);
|
var history = await powerStationRepository.GetPowerStationHistoryPerHour(dateTime, full_table_name);
|
||||||
@ -219,6 +223,15 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region step2-2. 取得該電站的當前這小時的設備歷史資料
|
#region step2-2. 取得該電站的當前這小時的設備歷史資料
|
||||||
|
var sensoravg_table_name = String.Format("s{1}01_sensoravg", powerStation.SiteDB, powerStation.Code);
|
||||||
|
var full_sensoravg_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, sensoravg_table_name);
|
||||||
|
var sensoravg_table_exist = await powerStationRepository.ExistTable(powerStation.SiteDB, sensoravg_table_name);
|
||||||
|
if (string.IsNullOrEmpty(sensoravg_table_exist))
|
||||||
|
{
|
||||||
|
logger.LogError("【CalcPowerStationJob】【查無電站[0]的s{0}01_sensoravg資料表】", powerStation.Code);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的設備資訊】", powerStation.Code, dateTime);
|
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的設備資訊】", powerStation.Code, dateTime);
|
||||||
PyrheliometerHistory sensorHistory = new PyrheliometerHistory();
|
PyrheliometerHistory sensorHistory = new PyrheliometerHistory();
|
||||||
sensorHistory.PowerStationId = powerStation.Id;
|
sensorHistory.PowerStationId = powerStation.Id;
|
||||||
@ -382,10 +395,22 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
}
|
}
|
||||||
|
|
||||||
sensorHistoriesHour.Add(sensorHistory);
|
sensorHistoriesHour.Add(sensorHistory);
|
||||||
|
}
|
||||||
|
|
||||||
calcPowerStations.Add(calcPowerStation);
|
calcPowerStations.Add(calcPowerStation);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region step2-3. 計算該電站所有逆變器每小時值
|
#region step2-3. 計算該電站所有逆變器每小時值
|
||||||
|
|
||||||
|
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 inverter_exist = await powerStationRepository.ExistTable(powerStation.SiteDB, inverter_table_name);
|
||||||
|
if (string.IsNullOrEmpty(inverter_exist))
|
||||||
|
{
|
||||||
|
logger.LogError("【CalcPowerStationJob】【查無電站[0]的s{0}01_inv資料表】", powerStation.Code);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateTime);
|
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateTime);
|
||||||
@ -395,11 +420,7 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateTime);
|
logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateTime);
|
||||||
logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的逆變器設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(inverterIds));
|
logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的逆變器設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(inverterIds));
|
||||||
|
|
||||||
var inverter_table_name = String.Format("s{0}01_inv", powerStation.Code);
|
if (inverterIds != null && inverterIds.Count() > 0)
|
||||||
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) && inverterIds != null && inverterIds.Count() > 0)
|
|
||||||
{
|
{
|
||||||
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的逆變器的資訊】", powerStation.Code, dateTime);
|
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的逆變器的資訊】", powerStation.Code, dateTime);
|
||||||
var inverterHistories = await powerStationRepository.CalcInverterHisyortHourData(dateTime, powerStation.SiteDB, full_inverter_table_name, inverterIds);
|
var inverterHistories = await powerStationRepository.CalcInverterHisyortHourData(dateTime, powerStation.SiteDB, full_inverter_table_name, inverterIds);
|
||||||
@ -431,19 +452,21 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的逆變器的資訊】", powerStation.Code, dateTime);
|
logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的逆變器的資訊】", powerStation.Code, dateTime);
|
||||||
logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message);
|
logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region step2-4. 計算該電站所有sensoravg
|
#region step2-4. 計算該電站所有sensoravg
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
var seneoravg_table_name = String.Format("s{0}01_sensoravg", powerStation.Code);
|
//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 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);
|
//var exist_seneoravg_table = await powerStationRepository.ExistTable(powerStation.SiteDB, seneoravg_table_name);
|
||||||
if (!string.IsNullOrEmpty(exist_seneoravg_table))
|
|
||||||
|
if (!string.IsNullOrEmpty(sensoravg_table_exist))
|
||||||
{
|
{
|
||||||
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的sensor avg的資訊】", powerStation.Code, dateTime);
|
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的sensor avg的資訊】", powerStation.Code, dateTime);
|
||||||
var sensorAvgHistory = await powerStationRepository.CalcSensorAvgHistory(dateTime, full_seneoravg_table_name);
|
var sensorAvgHistory = await powerStationRepository.CalcSensorAvgHistory(dateTime, full_sensoravg_table_name);
|
||||||
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的sensor avg的資訊】", powerStation.Code, dateTime);
|
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的sensor avg的資訊】", powerStation.Code, dateTime);
|
||||||
|
|
||||||
if (sensorAvgHistory != null)
|
if (sensorAvgHistory != null)
|
||||||
@ -468,7 +491,11 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
var meter_table_name = String.Format("s{0}01_meter", powerStation.Code);
|
var meter_table_name = String.Format("s{0}01_meter", powerStation.Code);
|
||||||
var full_meter_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, meter_table_name);
|
var full_meter_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, meter_table_name);
|
||||||
var exist_meter_table = await powerStationRepository.ExistTable(powerStation.SiteDB, meter_table_name);
|
var exist_meter_table = await powerStationRepository.ExistTable(powerStation.SiteDB, meter_table_name);
|
||||||
if (!string.IsNullOrEmpty(exist_meter_table))
|
if (string.IsNullOrEmpty(exist_meter_table))
|
||||||
|
{
|
||||||
|
logger.LogError("【CalcPowerStationJob】【查無電站[0]的s{0}01_meter資料表】", powerStation.Code);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的meter的資訊】", powerStation.Code, dateTime);
|
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的meter的資訊】", powerStation.Code, dateTime);
|
||||||
var meterHistory = await powerStationRepository.CalcMeterHistory(dateTime, full_meter_table_name);
|
var meterHistory = await powerStationRepository.CalcMeterHistory(dateTime, full_meter_table_name);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user