From 3d518658c37fcd051146a237b48c6f9249f2e8d6 Mon Sep 17 00:00:00 2001 From: "wanling040@gmail.com" Date: Thu, 18 Aug 2022 19:31:52 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B6=B2=E9=A0=81=E8=83=8C=E6=99=AF=E5=9F=B7?= =?UTF-8?q?=E8=A1=8C:=20=20=E8=AE=93=E7=95=B0=E5=B8=B8=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E6=A0=B9=E6=93=9Apriority=E9=80=81=E9=80=B2=E5=AF=84=E4=BF=A1?= =?UTF-8?q?=E7=9A=84=E8=B3=87=E6=96=99=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Models/Overview.cs | 2 ++ SolarPower/Quartz/Jobs/ExceptionSchedule.cs | 16 ++++++++++++++-- .../Repository/Implement/OverviewRepository.cs | 4 ++-- SolarPower/appsettings.Development.json | 7 +++++-- SolarPower/appsettings.json | 5 ++++- 5 files changed, 27 insertions(+), 7 deletions(-) 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 }