網頁背景執行: 讓異常通知根據priority送進寄信的資料表

This commit is contained in:
wanling040@gmail.com 2022-08-18 19:31:52 +08:00
parent 19f6a8e1df
commit 3d518658c3
5 changed files with 27 additions and 7 deletions

View File

@ -221,6 +221,8 @@ namespace SolarPower.Models
public int PowerStationId { get; set; }//電站流水號 public int PowerStationId { get; set; }//電站流水號
public string normalTime { get; set; }//賦歸時間 public string normalTime { get; set; }//賦歸時間
public string errMsgT { get; set; } //errMsgType public string errMsgT { get; set; } //errMsgType
public int priority { get; set; }//priority
public int sourceState { get; set; }//異常狀態
} }
public class UserPowerStationTo public class UserPowerStationTo

View File

@ -39,13 +39,25 @@ namespace SolarPower.Quartz.Jobs
try try
{ {
var ExceptionTimes = this.Configuration.GetValue<int>("ExceptionTimes"); var ExceptionTimes = this.Configuration.GetValue<int>("ExceptionTimes");
var ExceptionTimes_Priority1 = this.Configuration.GetValue<int>("ExceptionTimes_Priority1");
var ExceptionTimes_Priority2 = this.Configuration.GetValue<int>("ExceptionTimes_Priority2");
var ExceptionTimes_Priority3 = this.Configuration.GetValue<int>("ExceptionTimes_Priority3");
var ExceptionList = await overviewRepository.GetEmailExceptionList(); var ExceptionList = await overviewRepository.GetEmailExceptionList();
if(ExceptionList.Count > 0 ) 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) foreach (var Exception in ExceptionListex)
{ {

View File

@ -834,7 +834,7 @@ namespace SolarPower.Repository.Implement
var sql = $@" var sql = $@"
SELECT a.`*`,ns.Id FROM 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 , 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.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, a.alarmClass, b.alarmClass as alarmClassName,ps.Name as PowerStationName, ps.Id as PowerStationId,errDevice, err_valueKind, errValue,

View File

@ -33,7 +33,7 @@
// "Password": "y4uPqlH9ncTgR/I07qpwaA==" // "Password": "y4uPqlH9ncTgR/I07qpwaA=="
//}, //},
"BackgroundServiceCron": { "BackgroundServiceCron": {
"CalcPowerStationJob": "0 14 * * * ?", "CalcPowerStationJob": "0 05 * * * ?",
"CalcAvgPowerStationJob": "0 12 0 * * ?", "CalcAvgPowerStationJob": "0 12 0 * * ?",
"OperationScheduleJob": "0 0 8 * * ?", "OperationScheduleJob": "0 0 8 * * ?",
"CalcInverter15minJob": "0 2/15 * * * ?", "CalcInverter15minJob": "0 2/15 * * * ?",
@ -47,7 +47,10 @@
"Password": "wswgnluvoodfexrb", "Password": "wswgnluvoodfexrb",
"EnableSsl": true "EnableSsl": true
}, },
"ExceptionTimes": 240 //() "ExceptionTimes": 240, //()
"ExceptionTimes_Priority1": 1440,
"ExceptionTimes_Priority2": 720,
"ExceptionTimes_Priority3": 0
//"SMTPConfig": { //"SMTPConfig": {
// "Host": "smtp.gmail.com", // "Host": "smtp.gmail.com",

View File

@ -49,5 +49,8 @@
"Password": "qwe2015qwe", "Password": "qwe2015qwe",
"EnableSsl": true "EnableSsl": true
}, },
"ExceptionTimes": 240 //() "ExceptionTimes": 240, //()
"ExceptionTimes_Priority1": 1440,
"ExceptionTimes_Priority2": 720,
"ExceptionTimes_Priority3": 0
} }