From b4db153d2e28d451592811fea29c6d1bab71887b Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期二, 30 四月 2024 13:52:53 +0800 Subject: [PATCH] 优化运行分析,运行记录结构更改,运行服务新增监测中断判断 --- Yw.Server.Run/01-equipment/02-single/EquipmentRunAnalySingleJob.cs | 132 +++++++++++++++++++++++++------------------- 1 files changed, 75 insertions(+), 57 deletions(-) diff --git a/Yw.Server.Run/01-equipment/02-single/EquipmentRunAnalySingleJob.cs b/Yw.Server.Run/01-equipment/02-single/EquipmentRunAnalySingleJob.cs index ca16e42..968ffa3 100644 --- a/Yw.Server.Run/01-equipment/02-single/EquipmentRunAnalySingleJob.cs +++ b/Yw.Server.Run/01-equipment/02-single/EquipmentRunAnalySingleJob.cs @@ -1,4 +1,7 @@ -锘縩amespace Yw.Server +锘縰sing Yw.Service.Basic; +using Yw.Service.Monitor; + +namespace Yw.Server { /// <summary> /// 璁惧杩愯鍒嗘瀽鍗曚换鍔� @@ -68,37 +71,37 @@ #region 杩愯娴嬬偣 - var monitorList = allMonitorList.Where(x => x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.杩愯鐘舵��)).ToList(); - if (monitorList == null || monitorList.Count < 1) + var signal = allMonitorList.Matching(Yw.Monitor.SignalType.杩愯鐘舵��, new List<string>() { Yw.Run.Flags.榛樿 }); + if (signal == null) + { + signal = allMonitorList.Matching(Yw.Monitor.SignalType.杩愯鐘舵��, null); + } + if (signal == null) { LogHelper.Info($"璁惧杩愯鍒嗘瀽鍗曚换鍔′腑锛岃澶噄d:{configure.ObjectID} 妫�绱㈣繍琛岀姸鎬佹祴鐐瑰け璐ワ紒"); return; } - var monitor = monitorList.Find(x => x.Flags.Contains(Yw.Monitor.Flags.榛樿)); - if (monitor == null) - { - monitor = monitorList.First(); - } - + var monitor = allMonitorList.Find(x => x.ID == signal.MonitorPointID); #endregion #region 杩炵画缂撳瓨 - var lastRecord = new Yw.Service.MonitorRealRecord().GetLastRecord(monitor.SignalList.First().ID); - EquipmentRunAnalyChangeTimesHelper.Set(configure.ID, configure.ChangeTimes, lastRecord); + var lastRecord = new Yw.Service.MonitorRealRecord().GetLastRecord(signal.ID); + EquipmentRunAnalyChangeTimesHelper.Set(configure.ID, configure.ChangeTimes, monitor, lastRecord); #endregion - #region 鏁版嵁鍒嗘瀽 + #region 杩愯鍒嗘瀽 - var run_record = new Yw.Model.RunRealRecord() + var runRecord = new Yw.Model.RunRealRecord() { ObjectType = configure.ObjectType, ObjectID = configure.ObjectID, DataTime = DateTime.Now, - RSa = Yw.Run.RunStatus.Stop, - ContinueRunTime = 0, + RSa = Yw.Run.RunStatus.Shut, + ContinueTime = configure.Frequency, + TotalShutTime = configure.Frequency, TotalRunTime = 0, BootTimes = 0, AnalyStatus = Yw.Run.AnalyStatus.Normal, @@ -108,69 +111,84 @@ var lastRunRecord = new Yw.Service.RunRealRecord().GetLastRecord(configure.ObjectType, configure.ObjectID); if (lastRunRecord == null) { - run_record.AnalyInfo = "棣栨鍒嗘瀽"; + runRecord.AnalyInfo = "棣栨鍒嗘瀽"; if (lastRecord == null) { - run_record.AnalyStatus = Yw.Run.AnalyStatus.Missing; + runRecord.AnalyStatus = Yw.Run.AnalyStatus.Missing; } else { - if (double.TryParse(lastRecord.DataValue, out double outDataValue)) + if (Yw.Monitor.DataStatus.HasError(lastRecord.DataStatus)) { - if (outDataValue > 0) - { - run_record.RSa = Yw.Run.RunStatus.Run; - run_record.ContinueRunTime += configure.Frequency; - run_record.TotalRunTime += configure.Frequency; - run_record.BootTimes += 1; - } + runRecord.AnalyStatus = Yw.Run.AnalyStatus.Abnormal; } else { - run_record.AnalyStatus = Yw.Run.AnalyStatus.Abnormal; + if (int.TryParse(lastRecord.DataValue, out int intDataValue)) + { + if (intDataValue > Yw.Monitor.RunStatus.Shut) + { + runRecord.RSa = Yw.Run.RunStatus.Run; + runRecord.BootTimes += 1; + runRecord.TotalRunTime += configure.Frequency; + } + } + else + { + runRecord.AnalyStatus = Yw.Run.AnalyStatus.Error; + } } } } else { - run_record.RSa = lastRunRecord.RSa; - run_record.ContinueRunTime = lastRunRecord.ContinueRunTime; - run_record.TotalRunTime = lastRunRecord.TotalRunTime; - run_record.BootTimes = lastRunRecord.BootTimes; - if (lastRecord == null) + runRecord.RSa = lastRunRecord.RSa; + runRecord.ContinueTime = lastRunRecord.ContinueTime; + runRecord.TotalShutTime = lastRunRecord.TotalShutTime; + runRecord.TotalRunTime = lastRunRecord.TotalRunTime; + runRecord.BootTimes = lastRunRecord.BootTimes; + + if (EquipmentRunAnalyChangeTimesHelper.HasChanged(configure.ID, configure.ChangeTimes)) { - run_record.AnalyStatus = Yw.Run.AnalyStatus.Missing; + runRecord.RSa = runRecord.RSa == Yw.Run.RunStatus.Run ? Yw.Run.RunStatus.Shut : Yw.Run.RunStatus.Run; + runRecord.ContinueTime = configure.Frequency; + if (runRecord.RSa == Yw.Run.RunStatus.Run) + { + runRecord.BootTimes += 1; + } } else { - if (double.TryParse(lastRecord.DataValue, out double outDataValue)) + runRecord.ContinueTime += configure.Frequency; + } + + if (runRecord.RSa == Yw.Run.RunStatus.Shut) + { + runRecord.TotalShutTime += configure.Frequency; + } + else + { + runRecord.TotalRunTime += configure.Frequency; + } + + if (lastRecord == null) + { + runRecord.AnalyStatus = Yw.Run.AnalyStatus.Missing; + } + else + { + if (Yw.Monitor.DataStatus.HasError(lastRecord.DataStatus)) { - var run_status = outDataValue > 0 ? Yw.Run.RunStatus.Run : Yw.Run.RunStatus.Stop; - if (run_status != run_record.RSa) + runRecord.AnalyStatus = Yw.Run.AnalyStatus.Abnormal; + } + var enable_interrupt = Yw.Run.SysParas.EnableMonitorInterruptJudgement.GetPValue<bool?>(); + if (enable_interrupt.HasValue && enable_interrupt.Value) + { + if (monitor.IsInterrupt(lastRecord)) { - if (EquipmentRunAnalyChangeTimesHelper.HasChanged(configure.ID, configure.ChangeTimes)) - { - run_record.RSa = run_status; - if (run_status == Yw.Run.RunStatus.Run) - { - run_record.BootTimes += 1; - } - if (run_record.RSa == Yw.Run.RunStatus.Stop) - { - run_record.ContinueRunTime = 0; - } - } + runRecord.AnalyStatus = Yw.Run.AnalyStatus.Interrupt; } } - else - { - run_record.AnalyStatus = Yw.Run.AnalyStatus.Abnormal; - } - } - if (run_record.RSa == Yw.Run.RunStatus.Run) - { - run_record.TotalRunTime += configure.Frequency; - run_record.ContinueRunTime += configure.Frequency; } } @@ -178,7 +196,7 @@ #region 鏁版嵁瀛樺偍 - var bol = new Yw.Service.RunRealRecord().InsertLastRecord(run_record); + var bol = new Yw.Service.RunRealRecord().InsertLastRecord(runRecord); if (bol) { LogHelper.Info($"璁惧杩愯鍒嗘瀽鍗曚换鍔′腑锛岃澶噄d:{configure.ObjectID} 杩愯璁板綍鍒嗘瀽鎴愬姛锛�"); -- Gitblit v1.9.3