diff --git a/SolarPower/Models/Overview.cs b/SolarPower/Models/Overview.cs index 663b031..0fa8512 100644 --- a/SolarPower/Models/Overview.cs +++ b/SolarPower/Models/Overview.cs @@ -221,6 +221,8 @@ namespace SolarPower.Models public int PowerStationId { get; set; }//電站流水號 public string normalTime { get; set; }//賦歸時間 public string errMsgT { get; set; } //errMsgType + public int priority { get; set; }//priority + public int sourceState { get; set; }//異常狀態 } public class UserPowerStationTo diff --git a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs index 86af364..797a454 100644 --- a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs +++ b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs @@ -39,13 +39,25 @@ namespace SolarPower.Quartz.Jobs try { var ExceptionTimes = this.Configuration.GetValue("ExceptionTimes"); + var ExceptionTimes_Priority1 = this.Configuration.GetValue("ExceptionTimes_Priority1"); + var ExceptionTimes_Priority2 = this.Configuration.GetValue("ExceptionTimes_Priority2"); + var ExceptionTimes_Priority3 = this.Configuration.GetValue("ExceptionTimes_Priority3"); var ExceptionList = await overviewRepository.GetEmailExceptionList(); if(ExceptionList.Count > 0 ) { - //var a = ExceptionList.Where(x=>x.id == 39835).Select(x => (DateTime.Now.Subtract(DateTime.Parse(x.dev_time)).TotalSeconds / 60)).ToList(); + var ExceptionListex = ExceptionList.Where(x => x.sourceState == 1 && + x.priority == 1 && + (DateTime.Now.Subtract(DateTime.Parse(x.dev_time)).TotalSeconds / 60) >= ExceptionTimes_Priority1).ToList(); - var ExceptionListex = ExceptionList.Where(x => x.normalTime == "1970-01-01 08:00:00" && (DateTime.Now.Subtract(DateTime.Parse(x.dev_time)).TotalSeconds / 60) >= ExceptionTimes).ToList(); + var ExceptionListex2 = ExceptionList.Where(x => x.sourceState == 1 && + x.priority == 2 && + (DateTime.Now.Subtract(DateTime.Parse(x.dev_time)).TotalSeconds / 60) >= ExceptionTimes_Priority2).ToList(); + var ExceptionListex3 = ExceptionList.Where(x => x.sourceState == 1 && + x.priority == 3 && + (DateTime.Now.Subtract(DateTime.Parse(x.dev_time)).TotalSeconds / 60) >= ExceptionTimes_Priority3).ToList(); + ExceptionListex.AddRange(ExceptionListex2); + ExceptionListex.AddRange(ExceptionListex3); foreach (var Exception in ExceptionListex) { diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs index d187aa1..f84e77b 100644 --- a/SolarPower/Repository/Implement/OverviewRepository.cs +++ b/SolarPower/Repository/Implement/OverviewRepository.cs @@ -834,7 +834,7 @@ namespace SolarPower.Repository.Implement var sql = $@" SELECT a.`*`,ns.Id FROM ( - select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, `timestamp`, + select pr.FormId as FormId, pr.Id as ErrorID, priority, a.id, site_id, `timestamp`, a.sourceState, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time , a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime, a.alarmClass, b.alarmClass as alarmClassName,ps.Name as PowerStationName, ps.Id as PowerStationId,errDevice, err_valueKind, errValue, @@ -861,7 +861,7 @@ namespace SolarPower.Repository.Implement left join power_station ps on ps.`Code` = site_id left join operation_record pr on pr.ErrorCode = a.id where sourceState = 1 and ps.`Code` is not null - ) a LEFT JOIN notice_schedule ns ON ns.ExceptionId = a.id + ) a LEFT JOIN notice_schedule ns ON ns.ExceptionId = a.id WHERE ns.Id IS NULL "; exceptionEmailInfos = (await conn.QueryAsync(sql)).ToList(); } diff --git a/SolarPower/appsettings.Development.json b/SolarPower/appsettings.Development.json index 64c1a8e..61c6373 100644 --- a/SolarPower/appsettings.Development.json +++ b/SolarPower/appsettings.Development.json @@ -33,7 +33,7 @@ // "Password": "y4uPqlH9ncTgR/I07qpwaA==" //}, "BackgroundServiceCron": { - "CalcPowerStationJob": "0 14 * * * ?", + "CalcPowerStationJob": "0 05 * * * ?", "CalcAvgPowerStationJob": "0 12 0 * * ?", "OperationScheduleJob": "0 0 8 * * ?", "CalcInverter15minJob": "0 2/15 * * * ?", @@ -47,7 +47,10 @@ "Password": "wswgnluvoodfexrb", "EnableSsl": true }, - "ExceptionTimes": 240 //`qɶA() + "ExceptionTimes": 240, //`qɶA() + "ExceptionTimes_Priority1": 1440, + "ExceptionTimes_Priority2": 720, + "ExceptionTimes_Priority3": 0 //"SMTPConfig": { // "Host": "smtp.gmail.com", diff --git a/SolarPower/appsettings.json b/SolarPower/appsettings.json index e566fb4..5d1ba96 100644 --- a/SolarPower/appsettings.json +++ b/SolarPower/appsettings.json @@ -49,5 +49,8 @@ "Password": "qwe2015qwe", "EnableSsl": true }, - "ExceptionTimes": 240 //`qɶA() + "ExceptionTimes": 240, //`qɶA() + "ExceptionTimes_Priority1": 1440, + "ExceptionTimes_Priority2": 720, + "ExceptionTimes_Priority3": 0 }