1. 修改背景執行
This commit is contained in:
parent
e09c908071
commit
97938fca68
@ -388,7 +388,8 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//#region step2-2. 計算該電站昨天的所有值總和
|
#region step2-2. 計算該電站昨天的所有值總和
|
||||||
|
/*因修改為補償 而註解*/
|
||||||
//if (!string.IsNullOrEmpty(exist))
|
//if (!string.IsNullOrEmpty(exist))
|
||||||
//{
|
//{
|
||||||
// //電站資訊
|
// //電站資訊
|
||||||
@ -460,7 +461,7 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
// sensorAvgHistoryDays.Add(sensorAvgHistoryDay);
|
// sensorAvgHistoryDays.Add(sensorAvgHistoryDay);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
////meter
|
//meter
|
||||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}的meter_hour所有值的平均】", powerStation.Code, dateNowDay);
|
logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}的meter_hour所有值的平均】", powerStation.Code, dateNowDay);
|
||||||
var meterHistoriesDay = await powerStationRepository.CalcMeterDayDataByPowerStationId(dateNowDay, powerStation.Id);
|
var meterHistoriesDay = await powerStationRepository.CalcMeterDayDataByPowerStationId(dateNowDay, powerStation.Id);
|
||||||
logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}的meter_hour所有值的平均】", powerStation.Code, dateNowDay);
|
logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}的meter_hour所有值的平均】", powerStation.Code, dateNowDay);
|
||||||
@ -468,7 +469,7 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
{
|
{
|
||||||
meterHistoriesDays.AddRange(meterHistoriesDay);
|
meterHistoriesDays.AddRange(meterHistoriesDay);
|
||||||
}
|
}
|
||||||
//#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -487,23 +488,24 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
|
|
||||||
#region step4. 將各電站的每日的資料insert資料表
|
#region step4. 將各電站的每日的資料insert資料表
|
||||||
//每日 - 電站歷史資料
|
//每日 - 電站歷史資料
|
||||||
//List<string> history_properties_day = new List<string>()
|
List<string> history_properties_day = new List<string>()
|
||||||
//{
|
{
|
||||||
// "PowerStationId",
|
"PowerStationId",
|
||||||
// "TIMESTAMP",
|
"TIMESTAMP",
|
||||||
// "SITEID",
|
"SITEID",
|
||||||
// "SITETYPE",
|
"SITETYPE",
|
||||||
// "TODAYKWH",
|
"TODAYKWH",
|
||||||
// "TOTALKWH",
|
"TOTALKWH",
|
||||||
// "KWHKWP",
|
"KWHKWP",
|
||||||
// "PR",
|
"PR",
|
||||||
// "MP",
|
"MP",
|
||||||
// "SolarHour",
|
"SolarHour",
|
||||||
// "MONEY",
|
"MONEY",
|
||||||
// "CARBON",
|
"CARBON",
|
||||||
// "TOTALMONEY",
|
"TOTALMONEY",
|
||||||
// "TOTALCARBON"
|
"TOTALCARBON"
|
||||||
//};
|
};
|
||||||
|
/*因修改為補償 而註解*/
|
||||||
//await powerStationRepository.AddPowerStationHistoryDayList(powerStationHistoryDays, history_properties_day);
|
//await powerStationRepository.AddPowerStationHistoryDayList(powerStationHistoryDays, history_properties_day);
|
||||||
|
|
||||||
////每日 - 日照溫度歷史資料
|
////每日 - 日照溫度歷史資料
|
||||||
@ -515,210 +517,210 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
////每日 - sensor avg
|
////每日 - sensor avg
|
||||||
//await powerStationRepository.AddSensorAvgHistoryDayList(sensorAvgHistoryDays, sensoravg_history_properties);
|
//await powerStationRepository.AddSensorAvgHistoryDayList(sensorAvgHistoryDays, sensoravg_history_properties);
|
||||||
|
|
||||||
//每日 - meter
|
////每日 - meter
|
||||||
await powerStationRepository.AddMeterHistoryDayList(meterHistoriesDays, meter_history_properties);
|
//await powerStationRepository.AddMeterHistoryDayList(meterHistoriesDays, meter_history_properties);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region step5. 歸檔電站的每月資訊
|
#region step5. 歸檔電站的每月資訊
|
||||||
//foreach (var powerStation in powerStations)
|
foreach (var powerStation in powerStations)
|
||||||
//{
|
{
|
||||||
// //電站該月份的歷史資料
|
////電站該月份的歷史資料
|
||||||
// logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}月份的歷史資料總和】", powerStation.Code, dateNowMonth);
|
//logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}月份的歷史資料總和】", powerStation.Code, dateNowMonth);
|
||||||
// var exist_history = await powerStationRepository.GetOnePowerStationHistoryByPowerStationIdAndMonth(powerStation.Id, dateNowMonth);
|
//var exist_history = await powerStationRepository.GetOnePowerStationHistoryByPowerStationIdAndMonth(powerStation.Id, dateNowMonth);
|
||||||
// if (exist_history == null)
|
//if (exist_history == null)
|
||||||
// { //新增
|
//{ //新增
|
||||||
// var historyMonth = await powerStationRepository.ClacPowerStationHistoryMonthDataByPowerStationId(powerStation.Id, dateNowMonth);
|
// var historyMonth = await powerStationRepository.ClacPowerStationHistoryMonthDataByPowerStationId(powerStation.Id, dateNowMonth);
|
||||||
// var moneyandcarbonMon = await powerStationRepository.GetMoneyAndCarbonWithHistoryHour(powerStation.Id, dateNowMonth, 0);
|
// var moneyandcarbonMon = await powerStationRepository.GetMoneyAndCarbonWithHistoryHour(powerStation.Id, dateNowMonth, 0);
|
||||||
// var lastmoneyhistorymonth = await powerStationRepository.GetLastMoneyAndCarbonInHour(powerStation.Id, 2, "");
|
// var lastmoneyhistorymonth = await powerStationRepository.GetLastMoneyAndCarbonInHour(powerStation.Id, 2, "");
|
||||||
// if (historyMonth != null)
|
// if (historyMonth != null)
|
||||||
// {
|
// {
|
||||||
// historyMonth.Timestamp = Convert.ToDateTime(historyMonth.Timestamp).ToString("yyyy-MM-dd");
|
// historyMonth.Timestamp = Convert.ToDateTime(historyMonth.Timestamp).ToString("yyyy-MM-dd");
|
||||||
// historyMonth.MONEY = moneyandcarbonMon.MONEY;
|
// historyMonth.MONEY = moneyandcarbonMon.MONEY;
|
||||||
// historyMonth.CARBON = moneyandcarbonMon.CARBON;
|
// historyMonth.CARBON = moneyandcarbonMon.CARBON;
|
||||||
// if (lastmoneyhistorymonth != null)
|
// if (lastmoneyhistorymonth != null)
|
||||||
// {
|
// {
|
||||||
// historyMonth.TOTALCARBON = lastmoneyhistorymonth.TOTALCARBON + moneyandcarbonMon.CARBON;
|
// historyMonth.TOTALCARBON = lastmoneyhistorymonth.TOTALCARBON + moneyandcarbonMon.CARBON;
|
||||||
// historyMonth.TOTALMONEY = lastmoneyhistorymonth.TOTALMONEY + moneyandcarbonMon.MONEY;
|
// historyMonth.TOTALMONEY = lastmoneyhistorymonth.TOTALMONEY + moneyandcarbonMon.MONEY;
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
// historyMonth.TOTALCARBON = moneyandcarbonMon.CARBON;
|
// historyMonth.TOTALCARBON = moneyandcarbonMon.CARBON;
|
||||||
// historyMonth.TOTALMONEY = moneyandcarbonMon.MONEY;
|
// historyMonth.TOTALMONEY = moneyandcarbonMon.MONEY;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// insertPowerStationHistoryMonths.Add(historyMonth);
|
// insertPowerStationHistoryMonths.Add(historyMonth);
|
||||||
// }
|
// }
|
||||||
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的歷史資料總和】", powerStation.Code, dateNowMonth);
|
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的歷史資料總和】", powerStation.Code, dateNowMonth);
|
||||||
// }
|
//}
|
||||||
// else
|
//else
|
||||||
// { //修改
|
//{ //修改
|
||||||
// var historyMonth = await powerStationRepository.ClacPowerStationHistoryMonthDataByPowerStationId(powerStation.Id, dateNowMonth);
|
// var historyMonth = await powerStationRepository.ClacPowerStationHistoryMonthDataByPowerStationId(powerStation.Id, dateNowMonth);
|
||||||
// var moneyandcarbonMon = await powerStationRepository.GetMoneyAndCarbonWithHistoryHour(powerStation.Id, dateNowMonth, 0);
|
// var moneyandcarbonMon = await powerStationRepository.GetMoneyAndCarbonWithHistoryHour(powerStation.Id, dateNowMonth, 0);
|
||||||
// var lastmoneyhistorymonth = await powerStationRepository.GetLastMoneyAndCarbonInHour(powerStation.Id, 2, "");
|
// var lastmoneyhistorymonth = await powerStationRepository.GetLastMoneyAndCarbonInHour(powerStation.Id, 2, "");
|
||||||
// if (historyMonth != null)
|
// if (historyMonth != null)
|
||||||
// {
|
// {
|
||||||
// historyMonth.MONEY = historyMonth.MONEY + moneyandcarbonMon.MONEY;
|
// historyMonth.MONEY = historyMonth.MONEY + moneyandcarbonMon.MONEY;
|
||||||
// historyMonth.CARBON = historyMonth.CARBON + moneyandcarbonMon.CARBON;
|
// historyMonth.CARBON = historyMonth.CARBON + moneyandcarbonMon.CARBON;
|
||||||
// if (lastmoneyhistorymonth != null)
|
// if (lastmoneyhistorymonth != null)
|
||||||
// {
|
// {
|
||||||
// historyMonth.TOTALCARBON = lastmoneyhistorymonth.TOTALCARBON + moneyandcarbonMon.CARBON;
|
// historyMonth.TOTALCARBON = lastmoneyhistorymonth.TOTALCARBON + moneyandcarbonMon.CARBON;
|
||||||
// historyMonth.TOTALMONEY = lastmoneyhistorymonth.TOTALMONEY + moneyandcarbonMon.MONEY;
|
// historyMonth.TOTALMONEY = lastmoneyhistorymonth.TOTALMONEY + moneyandcarbonMon.MONEY;
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
// historyMonth.TOTALCARBON = moneyandcarbonMon.CARBON;
|
// historyMonth.TOTALCARBON = moneyandcarbonMon.CARBON;
|
||||||
// historyMonth.TOTALMONEY = moneyandcarbonMon.MONEY;
|
// historyMonth.TOTALMONEY = moneyandcarbonMon.MONEY;
|
||||||
// }
|
// }
|
||||||
// updatePowerStationHistoryMonths.Add(historyMonth);
|
// updatePowerStationHistoryMonths.Add(historyMonth);
|
||||||
// }
|
// }
|
||||||
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的歷史資料總和】", powerStation.Code, dateNowMonth);
|
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的歷史資料總和】", powerStation.Code, dateNowMonth);
|
||||||
// }
|
//}
|
||||||
|
|
||||||
// //電站該月份的的日照度歷史資料
|
////電站該月份的的日照度歷史資料
|
||||||
// logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}月份的日照度歷史資料】", powerStation.Code, dateNowMonth);
|
//logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}月份的日照度歷史資料】", powerStation.Code, dateNowMonth);
|
||||||
// var exist_pyrheliometer_history = await powerStationRepository.GetOnePyrheliometerHistoryByMonth(dateNowMonth, powerStation.Id);
|
//var exist_pyrheliometer_history = await powerStationRepository.GetOnePyrheliometerHistoryByMonth(dateNowMonth, powerStation.Id);
|
||||||
// if (exist_pyrheliometer_history == null)
|
//if (exist_pyrheliometer_history == null)
|
||||||
// { //新增
|
//{ //新增
|
||||||
// var pyrheliometerHistoryMonth = await powerStationRepository.CalcPyrheliometerHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.Id);
|
// var pyrheliometerHistoryMonth = await powerStationRepository.CalcPyrheliometerHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.Id);
|
||||||
// if (pyrheliometerHistoryMonth != null)
|
// if (pyrheliometerHistoryMonth != null)
|
||||||
// {
|
// {
|
||||||
// pyrheliometerHistoryMonth.Timestamp = Convert.ToDateTime(pyrheliometerHistoryMonth.Timestamp).ToString("yyyy-MM-dd");
|
// pyrheliometerHistoryMonth.Timestamp = Convert.ToDateTime(pyrheliometerHistoryMonth.Timestamp).ToString("yyyy-MM-dd");
|
||||||
// insertPyrheliometerHistoryMonths.Add(pyrheliometerHistoryMonth);
|
// insertPyrheliometerHistoryMonths.Add(pyrheliometerHistoryMonth);
|
||||||
// }
|
// }
|
||||||
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的日照度歷史資料】", powerStation.Code, dateNowMonth);
|
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的日照度歷史資料】", powerStation.Code, dateNowMonth);
|
||||||
// }
|
//}
|
||||||
// else
|
//else
|
||||||
// { //修改
|
//{ //修改
|
||||||
// var pyrheliometerHistoryMonth = await powerStationRepository.CalcPyrheliometerHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.Id);
|
// var pyrheliometerHistoryMonth = await powerStationRepository.CalcPyrheliometerHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.Id);
|
||||||
// if (pyrheliometerHistoryMonth != null)
|
// if (pyrheliometerHistoryMonth != null)
|
||||||
// {
|
// {
|
||||||
// updatePyrheliometerHistoryMonths.Add(pyrheliometerHistoryMonth);
|
// updatePyrheliometerHistoryMonths.Add(pyrheliometerHistoryMonth);
|
||||||
// }
|
// }
|
||||||
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的日照度歷史資料】", powerStation.Code, dateNowMonth);
|
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的日照度歷史資料】", powerStation.Code, dateNowMonth);
|
||||||
// }
|
//}
|
||||||
|
|
||||||
// //電站該月份的的逆變器歷史資料
|
////電站該月份的的逆變器歷史資料
|
||||||
// logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}月份的逆變器歷史資料】", powerStation.Code, dateNowMonth);
|
//logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}月份的逆變器歷史資料】", powerStation.Code, dateNowMonth);
|
||||||
// var exist_inverter_histories = await powerStationRepository.GetInverterHistoryByPowerStationIdAndMonth(dateNowMonth, powerStation.Id);
|
//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);
|
// var inverterHistoriesMonth = await powerStationRepository.CalcInverterHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.SiteDB, powerStation.Id);
|
||||||
// if (inverterHistoriesMonth.Count > 0)
|
// if (inverterHistoriesMonth.Count > 0)
|
||||||
// {
|
// {
|
||||||
// foreach (var inverterHistoryMonth in inverterHistoriesMonth)
|
// foreach (var inverterHistoryMonth in inverterHistoriesMonth)
|
||||||
// {
|
// {
|
||||||
// inverterHistoryMonth.DC1KW = inverterHistoryMonth.DC1W / 1000;
|
// inverterHistoryMonth.DC1KW = inverterHistoryMonth.DC1W / 1000;
|
||||||
// inverterHistoryMonth.DC2KW = inverterHistoryMonth.DC2W / 1000;
|
// inverterHistoryMonth.DC2KW = inverterHistoryMonth.DC2W / 1000;
|
||||||
// inverterHistoryMonth.DC3KW = inverterHistoryMonth.DC3W / 1000;
|
// inverterHistoryMonth.DC3KW = inverterHistoryMonth.DC3W / 1000;
|
||||||
// inverterHistoryMonth.DC4KW = inverterHistoryMonth.DC4W / 1000;
|
// inverterHistoryMonth.DC4KW = inverterHistoryMonth.DC4W / 1000;
|
||||||
// inverterHistoryMonth.DC5KW = inverterHistoryMonth.DC5W / 1000;
|
// inverterHistoryMonth.DC5KW = inverterHistoryMonth.DC5W / 1000;
|
||||||
|
|
||||||
// inverterHistoryMonth.DCKW = (inverterHistoryMonth.DC1W + inverterHistoryMonth.DC2W + inverterHistoryMonth.DC3W + inverterHistoryMonth.DC4W + 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.ACKW = (inverterHistoryMonth.AC1W + inverterHistoryMonth.AC2W + inverterHistoryMonth.AC3W) / 1000;
|
||||||
|
|
||||||
// inverterHistoryMonth.TIMESTAMP = Convert.ToDateTime(inverterHistoryMonth.TIMESTAMP).ToString("yyyy-MM-dd");
|
// inverterHistoryMonth.TIMESTAMP = Convert.ToDateTime(inverterHistoryMonth.TIMESTAMP).ToString("yyyy-MM-dd");
|
||||||
// insertInverterHistoryMonths.Add(inverterHistoryMonth);
|
// insertInverterHistoryMonths.Add(inverterHistoryMonth);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的逆變器歷史資料】", powerStation.Code, dateNowMonth);
|
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的逆變器歷史資料】", powerStation.Code, dateNowMonth);
|
||||||
// }
|
//}
|
||||||
// else
|
//else
|
||||||
// { //修改
|
//{ //修改
|
||||||
// var inverterHistoriesMonth = await powerStationRepository.CalcInverterHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.SiteDB, powerStation.Id);
|
// var inverterHistoriesMonth = await powerStationRepository.CalcInverterHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.SiteDB, powerStation.Id);
|
||||||
// if (inverterHistoriesMonth.Count > 0)
|
// if (inverterHistoriesMonth.Count > 0)
|
||||||
// {
|
// {
|
||||||
// foreach (var inverterHistoryMonth in inverterHistoriesMonth)
|
// foreach (var inverterHistoryMonth in inverterHistoriesMonth)
|
||||||
// {
|
// {
|
||||||
// inverterHistoryMonth.DC1KW = inverterHistoryMonth.DC1W / 1000;
|
// inverterHistoryMonth.DC1KW = inverterHistoryMonth.DC1W / 1000;
|
||||||
// inverterHistoryMonth.DC2KW = inverterHistoryMonth.DC2W / 1000;
|
// inverterHistoryMonth.DC2KW = inverterHistoryMonth.DC2W / 1000;
|
||||||
// inverterHistoryMonth.DC3KW = inverterHistoryMonth.DC3W / 1000;
|
// inverterHistoryMonth.DC3KW = inverterHistoryMonth.DC3W / 1000;
|
||||||
// inverterHistoryMonth.DC4KW = inverterHistoryMonth.DC4W / 1000;
|
// inverterHistoryMonth.DC4KW = inverterHistoryMonth.DC4W / 1000;
|
||||||
// inverterHistoryMonth.DC5KW = inverterHistoryMonth.DC5W / 1000;
|
// inverterHistoryMonth.DC5KW = inverterHistoryMonth.DC5W / 1000;
|
||||||
|
|
||||||
// inverterHistoryMonth.DCKW = (inverterHistoryMonth.DC1W + inverterHistoryMonth.DC2W + inverterHistoryMonth.DC3W + inverterHistoryMonth.DC4W + 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.ACKW = (inverterHistoryMonth.AC1W + inverterHistoryMonth.AC2W + inverterHistoryMonth.AC3W) / 1000;
|
||||||
|
|
||||||
// inverterHistoryMonth.TIMESTAMP = Convert.ToDateTime(inverterHistoryMonth.TIMESTAMP).ToString("yyyy-MM-dd");
|
// inverterHistoryMonth.TIMESTAMP = Convert.ToDateTime(inverterHistoryMonth.TIMESTAMP).ToString("yyyy-MM-dd");
|
||||||
// updateInverterHistoryMonths.Add(inverterHistoryMonth);
|
// updateInverterHistoryMonths.Add(inverterHistoryMonth);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的逆變器歷史資料】", powerStation.Code, dateNowMonth);
|
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的逆變器歷史資料】", powerStation.Code, dateNowMonth);
|
||||||
// }
|
//}
|
||||||
|
|
||||||
// //電站該月份的的sensoravg歷史資料
|
////電站該月份的的sensoravg歷史資料
|
||||||
// logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}月份的Sensor Avg table所有值的平均資料】", powerStation.Code, dateNowMonth);
|
//logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}月份的Sensor Avg table所有值的平均資料】", powerStation.Code, dateNowMonth);
|
||||||
// var exist_sensoravg_history = await powerStationRepository.GetSensorAvgHistoryByPowerStationIdAndMonth(dateNowMonth, powerStation.Id);
|
//var exist_sensoravg_history = await powerStationRepository.GetSensorAvgHistoryByPowerStationIdAndMonth(dateNowMonth, powerStation.Id);
|
||||||
// if (exist_sensoravg_history == null)
|
//if (exist_sensoravg_history == null)
|
||||||
// { //新增
|
//{ //新增
|
||||||
// var sensorAvgHistoryMonth = await powerStationRepository.CalcSensorAvgHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.Id);
|
// var sensorAvgHistoryMonth = await powerStationRepository.CalcSensorAvgHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.Id);
|
||||||
// if (sensorAvgHistoryMonth != null)
|
// if (sensorAvgHistoryMonth != null)
|
||||||
// {
|
// {
|
||||||
// sensorAvgHistoryMonth.TIMESTAMP = Convert.ToDateTime(sensorAvgHistoryMonth.TIMESTAMP).ToString("yyyy-MM-dd");
|
// sensorAvgHistoryMonth.TIMESTAMP = Convert.ToDateTime(sensorAvgHistoryMonth.TIMESTAMP).ToString("yyyy-MM-dd");
|
||||||
// insertSensorAvgHistoryMonths.Add(sensorAvgHistoryMonth);
|
// insertSensorAvgHistoryMonths.Add(sensorAvgHistoryMonth);
|
||||||
// }
|
// }
|
||||||
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的Sensor Avg table所有值的平均資料】", powerStation.Code, dateNowMonth);
|
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的Sensor Avg table所有值的平均資料】", powerStation.Code, dateNowMonth);
|
||||||
// }
|
//}
|
||||||
// else
|
//else
|
||||||
// { //修改
|
//{ //修改
|
||||||
// var sensorAvgHistoryMonth = await powerStationRepository.CalcSensorAvgHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.Id);
|
// var sensorAvgHistoryMonth = await powerStationRepository.CalcSensorAvgHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.Id);
|
||||||
// if (sensorAvgHistoryMonth != null)
|
// if (sensorAvgHistoryMonth != null)
|
||||||
// {
|
// {
|
||||||
// sensorAvgHistoryMonth.TIMESTAMP = Convert.ToDateTime(sensorAvgHistoryMonth.TIMESTAMP).ToString("yyyy-MM-dd");
|
// sensorAvgHistoryMonth.TIMESTAMP = Convert.ToDateTime(sensorAvgHistoryMonth.TIMESTAMP).ToString("yyyy-MM-dd");
|
||||||
// updateSensorAvgHistoryMonths.Add(sensorAvgHistoryMonth);
|
// updateSensorAvgHistoryMonths.Add(sensorAvgHistoryMonth);
|
||||||
// }
|
// }
|
||||||
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的Sensor Avg table所有值的平均資料】", powerStation.Code, dateNowMonth);
|
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的Sensor Avg table所有值的平均資料】", powerStation.Code, dateNowMonth);
|
||||||
// }
|
//}
|
||||||
|
|
||||||
// //電站該月份的的meter歷史資料
|
//電站該月份的的meter歷史資料
|
||||||
// logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}月份的meter table所有值的平均資料】", powerStation.Code, dateNowMonth);
|
logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}月份的meter table所有值的平均資料】", powerStation.Code, dateNowMonth);
|
||||||
// var exist_meter_history = await powerStationRepository.GetMeterHistoryByPowerStationIdAndMonth(dateNowMonth, powerStation.Id);
|
var exist_meter_history = await powerStationRepository.GetMeterHistoryByPowerStationIdAndMonth(dateNowMonth, powerStation.Id);
|
||||||
// if (exist_meter_history.Count() == 0)
|
if (exist_meter_history.Count() == 0)
|
||||||
// { //新增
|
{ //新增
|
||||||
// var meterHistoriesMonth = await powerStationRepository.CalcMeterHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.Id);
|
var meterHistoriesMonth = await powerStationRepository.CalcMeterHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.Id);
|
||||||
// if (meterHistoriesMonth != null && meterHistoriesMonth.Count() > 0)
|
if (meterHistoriesMonth != null && meterHistoriesMonth.Count() > 0)
|
||||||
// {
|
{
|
||||||
// foreach (var meterHistoryMonth in meterHistoriesMonth)
|
foreach (var meterHistoryMonth in meterHistoriesMonth)
|
||||||
// {
|
{
|
||||||
// meterHistoryMonth.TIMESTAMP = Convert.ToDateTime(meterHistoryMonth.TIMESTAMP).ToString("yyyy-MM-dd");
|
meterHistoryMonth.TIMESTAMP = Convert.ToDateTime(meterHistoryMonth.TIMESTAMP).ToString("yyyy-MM-dd");
|
||||||
// insertmeterHistoryMonths.Add(meterHistoryMonth);
|
insertmeterHistoryMonths.Add(meterHistoryMonth);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的meter table所有值的平均資料】", powerStation.Code, dateNowMonth);
|
logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的meter table所有值的平均資料】", powerStation.Code, dateNowMonth);
|
||||||
// }
|
}
|
||||||
// else
|
else
|
||||||
// { //修改
|
{ //修改
|
||||||
// var meterHistoriesMonth = await powerStationRepository.CalcMeterHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.Id);
|
var meterHistoriesMonth = await powerStationRepository.CalcMeterHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.Id);
|
||||||
// if (meterHistoriesMonth != null && meterHistoriesMonth.Count() > 0)
|
if (meterHistoriesMonth != null && meterHistoriesMonth.Count() > 0)
|
||||||
// {
|
{
|
||||||
// foreach (var meterHistoryMonth in meterHistoriesMonth)
|
foreach (var meterHistoryMonth in meterHistoriesMonth)
|
||||||
// {
|
{
|
||||||
// meterHistoryMonth.TIMESTAMP = Convert.ToDateTime(meterHistoryMonth.TIMESTAMP).ToString("yyyy-MM-dd");
|
meterHistoryMonth.TIMESTAMP = Convert.ToDateTime(meterHistoryMonth.TIMESTAMP).ToString("yyyy-MM-dd");
|
||||||
// updatemeterHistoryMonths.Add(meterHistoryMonth);
|
updatemeterHistoryMonths.Add(meterHistoryMonth);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的meter table所有值的平均資料】", powerStation.Code, dateNowMonth);
|
logger.LogInformation("【CalcAvgPowerStationJob】【計算完成電站[{0}]在{1}月份的meter table所有值的平均資料】", powerStation.Code, dateNowMonth);
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//每月
|
//每月
|
||||||
//List<string> history_properties_month = new List<string>()
|
List<string> history_properties_month = new List<string>()
|
||||||
//{
|
{
|
||||||
// "PowerStationId",
|
"PowerStationId",
|
||||||
// "TIMESTAMP",
|
"TIMESTAMP",
|
||||||
// "SITEID",
|
"SITEID",
|
||||||
// "SITETYPE",
|
"SITETYPE",
|
||||||
// "MonthKWh",
|
"MonthKWh",
|
||||||
// "TOTALKWH",
|
"TOTALKWH",
|
||||||
// "KWHKWP",
|
"KWHKWP",
|
||||||
// "PR",
|
"PR",
|
||||||
// "MP",
|
"MP",
|
||||||
// "SolarHour",
|
"SolarHour",
|
||||||
// "MONEY",
|
"MONEY",
|
||||||
// "CARBON",
|
"CARBON",
|
||||||
// "TOTALMONEY",
|
"TOTALMONEY",
|
||||||
// "TOTALCARBON"
|
"TOTALCARBON"
|
||||||
//};
|
};
|
||||||
|
|
||||||
//if (insertPowerStationHistoryMonths.Count > 0)
|
//if (insertPowerStationHistoryMonths.Count > 0)
|
||||||
//{
|
//{
|
||||||
@ -730,9 +732,9 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
// await powerStationRepository.UpdatePowerStationHistoryMonthList(updatePowerStationHistoryMonths);
|
// await powerStationRepository.UpdatePowerStationHistoryMonthList(updatePowerStationHistoryMonths);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
#region step5. 將各電站的每月的日照度資料insert or update 各資料表
|
//#region step5. 將各電站的每月的日照度資料insert or update 各資料表
|
||||||
|
|
||||||
//每月
|
////每月
|
||||||
//if (insertPyrheliometerHistoryMonths.Count > 0)
|
//if (insertPyrheliometerHistoryMonths.Count > 0)
|
||||||
//{
|
//{
|
||||||
// await powerStationRepository.AddPyrheliometerHistoryMonthList(insertPyrheliometerHistoryMonths, pyrheliometer_history_properties);
|
// await powerStationRepository.AddPyrheliometerHistoryMonthList(insertPyrheliometerHistoryMonths, pyrheliometer_history_properties);
|
||||||
@ -742,10 +744,10 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
//{
|
//{
|
||||||
// await powerStationRepository.UpdatePyrheliometerHistoryMonthList(updatePyrheliometerHistoryMonths);
|
// await powerStationRepository.UpdatePyrheliometerHistoryMonthList(updatePyrheliometerHistoryMonths);
|
||||||
//}
|
//}
|
||||||
#endregion
|
//#endregion
|
||||||
|
|
||||||
#region step6. 將各電站的每月的逆變器資料insert or update 各資料表
|
//#region step6. 將各電站的每月的逆變器資料insert or update 各資料表
|
||||||
//每月
|
////每月
|
||||||
//if (insertInverterHistoryMonths.Count > 0)
|
//if (insertInverterHistoryMonths.Count > 0)
|
||||||
//{
|
//{
|
||||||
// await powerStationRepository.AddInverterHistoryMonthList(insertInverterHistoryMonths, inverter_history_properties);
|
// await powerStationRepository.AddInverterHistoryMonthList(insertInverterHistoryMonths, inverter_history_properties);
|
||||||
@ -755,10 +757,10 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
//{
|
//{
|
||||||
// await powerStationRepository.UpdateInverterHistoryMonthList(updateInverterHistoryMonths);
|
// await powerStationRepository.UpdateInverterHistoryMonthList(updateInverterHistoryMonths);
|
||||||
//}
|
//}
|
||||||
#endregion
|
//#endregion
|
||||||
|
|
||||||
#region step7. 將各電站的每月的Sensor Avg資料insert or update 各資料表
|
//#region step7. 將各電站的每月的Sensor Avg資料insert or update 各資料表
|
||||||
//每月
|
////每月
|
||||||
//if (insertSensorAvgHistoryMonths.Count > 0)
|
//if (insertSensorAvgHistoryMonths.Count > 0)
|
||||||
//{
|
//{
|
||||||
// await powerStationRepository.AddSensorAvgHistoryMonthList(insertSensorAvgHistoryMonths, sensoravg_history_properties);
|
// await powerStationRepository.AddSensorAvgHistoryMonthList(insertSensorAvgHistoryMonths, sensoravg_history_properties);
|
||||||
@ -768,7 +770,7 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
//{
|
//{
|
||||||
// await powerStationRepository.UpdateSensorAvgHistoryMonthList(updateSensorAvgHistoryMonths);
|
// await powerStationRepository.UpdateSensorAvgHistoryMonthList(updateSensorAvgHistoryMonths);
|
||||||
//}
|
//}
|
||||||
#endregion
|
//#endregion
|
||||||
|
|
||||||
#region step8. 將各電站的每月的meter資料insert or update 各資料表
|
#region step8. 將各電站的每月的meter資料insert or update 各資料表
|
||||||
//每月
|
//每月
|
||||||
@ -788,15 +790,16 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
var Connection_string = Configuration.GetValue<string>("mySql");
|
var Connection_string = Configuration.GetValue<string>("mySql");
|
||||||
var start_date = DateTimeNow.AddDays(-1 * gobackDay);
|
var start_date = DateTimeNow.AddDays(-1 * gobackDay);
|
||||||
var end_date = DateTimeNow.AddDays(-1);
|
var end_date = DateTimeNow.AddDays(-1);
|
||||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始補償機制】");
|
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行補償機制】");
|
||||||
procSensorSvc sensorSvc = new procSensorSvc(Connection_string);
|
procSensorSvc sensorSvc = new procSensorSvc(Connection_string);
|
||||||
procInvSvc invSvc = new procInvSvc(Connection_string);
|
procInvSvc invSvc = new procInvSvc(Connection_string);
|
||||||
procStationSvc siteSvc = new procStationSvc(Connection_string);
|
procStationSvc siteSvc = new procStationSvc(Connection_string);
|
||||||
foreach (var powerStation in powerStations)
|
foreach (var powerStation in powerStations)
|
||||||
{
|
{
|
||||||
foreach (DateTime day in EachDay(start_date, end_date))
|
|
||||||
|
for (; start_date <= end_date; start_date = start_date.AddDays(1))
|
||||||
{
|
{
|
||||||
var day_str = day.ToString("yyyy-MM-dd");
|
var day_str = start_date.ToString("yyyy-MM-dd");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Sensor補償機制】", powerStation.Code, day_str);
|
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Sensor補償機制】", powerStation.Code, day_str);
|
||||||
@ -816,7 +819,7 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str);
|
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str);
|
||||||
invSvc.archiveData(powerStation.Code, day_str);
|
//invSvc.archiveData(powerStation.Code, day_str);
|
||||||
logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str);
|
logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str);
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
@ -832,7 +835,7 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str);
|
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str);
|
||||||
siteSvc.archiveData(powerStation.Code, day_str);
|
//siteSvc.archiveData(powerStation.Code, day_str);
|
||||||
logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str);
|
logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str);
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
@ -846,6 +849,7 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logger.LogInformation("【CalcAvgPowerStationJob】【執行完成補償機制】");
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 寄送日月報
|
#region 寄送日月報
|
||||||
@ -1021,10 +1025,10 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message);
|
logger.LogError("【CalcAvgPowerStationJob - main】[Exception] - {0}", exception.Message);
|
||||||
if(exception.InnerException != null)
|
if(exception.InnerException != null)
|
||||||
{
|
{
|
||||||
logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
|
logger.LogError("【CalcAvgPowerStationJob - main】[InnerException] - {0}", exception.InnerException.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
"Root": "mWlR2HshQNhRRE34jg4kdg==",
|
"Root": "mWlR2HshQNhRRE34jg4kdg==",
|
||||||
"Password": "y4uPqlH9ncTgR/I07qpwaA=="
|
"Password": "y4uPqlH9ncTgR/I07qpwaA=="
|
||||||
},
|
},
|
||||||
"mySql": "server=210.61.91.43;user=idafenweb;Database=solar_power_test;Port=10068;password=P@ssw0rd;charset='utf8';pooling=true;sslmode=none;",
|
"mySql": "server=210.61.91.43;user=idafenweb;Database=solar_master;Port=10068;password=P@ssw0rd;charset='utf8';pooling=true;sslmode=none;",
|
||||||
//"DBConfig": {
|
//"DBConfig": {
|
||||||
// "Server": "AVXfxd+IRlLtJ0MCi9HU1g==",
|
// "Server": "AVXfxd+IRlLtJ0MCi9HU1g==",
|
||||||
// "port": "CrEmevYrUsSo7Mkb7Gxn8A==",
|
// "port": "CrEmevYrUsSo7Mkb7Gxn8A==",
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"LoginExpireMinute": 60, //登入到期時間,單位(分)
|
"LoginExpireMinute": 60, //登入到期時間,單位(分)
|
||||||
|
"GoBackDay": 3, //補償機制(背景執行(每天)),回推天數
|
||||||
"mySql": "server=60.251.164.103;user=webuser;Database=solar_master;Port=11306;password=FICadmin99;charset='utf8';pooling=true;sslmode=none;",
|
"mySql": "server=60.251.164.103;user=webuser;Database=solar_master;Port=11306;password=FICadmin99;charset='utf8';pooling=true;sslmode=none;",
|
||||||
//"DBConfig": {
|
//"DBConfig": {
|
||||||
// "Server": "MVgHWzR3rGDgD57TUoFunA==",
|
// "Server": "MVgHWzR3rGDgD57TUoFunA==",
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user