From 09e5635e174d3ee6e8b699f7d0d4f125d3e1c46f Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期一, 06 五月 2024 09:47:26 +0800
Subject: [PATCH] 修复运行分析bug

---
 Yw.Server.Run/02-emws/02-single/EMWSRunAnalySingleJob.cs |  110 +++++++++++++++++++++++-------------------------------
 1 files changed, 47 insertions(+), 63 deletions(-)

diff --git a/Yw.Server.Run/02-emws/02-single/EMWSRunAnalySingleJob.cs b/Yw.Server.Run/02-emws/02-single/EMWSRunAnalySingleJob.cs
index d0bb5d7..7f1ebbd 100644
--- a/Yw.Server.Run/02-emws/02-single/EMWSRunAnalySingleJob.cs
+++ b/Yw.Server.Run/02-emws/02-single/EMWSRunAnalySingleJob.cs
@@ -113,8 +113,8 @@
                         ObjectID = configure.ObjectID,
                         DataTime = DateTime.Now,
                         RSa = Yw.Run.RunStatus.Shut,
-                        ContinueTime = configure.Frequency,
-                        TotalShutTime = configure.Frequency,
+                        ContinueTime = 0,
+                        TotalShutTime = 0,
                         TotalRunTime = 0,
                         BootTimes = 0,
                         AnalyStatus = Yw.Run.AnalyStatus.Normal,
@@ -125,33 +125,6 @@
                     if (lastRunRecord == null)
                     {
                         runRecord.AnalyInfo = "棣栨鍒嗘瀽";
-                        if (lastRecord == null)
-                        {
-                            runRecord.AnalyStatus = Yw.Run.AnalyStatus.Missing;
-                        }
-                        else
-                        {
-                            if (Yw.Monitor.DataStatus.HasError(lastRecord.DataStatus))
-                            {
-                                runRecord.AnalyStatus = Yw.Run.AnalyStatus.Abnormal;
-                            }
-                            else
-                            {
-                                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
                     {
@@ -160,49 +133,60 @@
                         runRecord.TotalShutTime = lastRunRecord.TotalShutTime;
                         runRecord.TotalRunTime = lastRunRecord.TotalRunTime;
                         runRecord.BootTimes = lastRunRecord.BootTimes;
+                    }
 
-                        if (EMWSRunAnalyChangeTimesHelper.HasChanged(configure.ID, configure.ChangeTimes))
+                    var rsa = Yw.Run.RunStatus.Shut;
+                    if (lastRecord == null)
+                    {
+                        runRecord.AnalyStatus = Yw.Run.AnalyStatus.Missing;
+                    }
+                    else
+                    {
+                        if (Yw.Monitor.DataStatus.HasError(lastRecord.DataStatus))
                         {
-                            runRecord.RSa = runRecord.RSa == Yw.Run.RunStatus.Run ? Yw.Run.RunStatus.Shut : Yw.Run.RunStatus.Run;
-                            runRecord.ContinueTime = configure.Frequency;
+                            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))
+                            {
+                                runRecord.AnalyStatus = Yw.Run.AnalyStatus.Interrupt;
+                            }
+                        }
+                        if (int.TryParse(lastRecord.DataValue, out int intDataValue))
+                        {
+                            rsa = intDataValue > Yw.Monitor.RunStatus.Shut ? Yw.Run.RunStatus.Run : Yw.Run.RunStatus.Shut;
+                        }
+                    }
+
+                    //鍙戠敓鏀瑰彉
+                    if (runRecord.RSa != rsa)
+                    {
+                        if (EquipmentRunAnalyChangeTimesHelper.HasChanged(configure.ID, configure.ChangeTimes))
+                        {
+                            runRecord.RSa = rsa;
+                            runRecord.ContinueTime = 0;
                             if (runRecord.RSa == Yw.Run.RunStatus.Run)
                             {
                                 runRecord.BootTimes += 1;
                             }
                         }
-                        else
-                        {
-                            runRecord.ContinueTime += configure.Frequency;
-                        }
+                    }
 
-                        if (runRecord.RSa == Yw.Run.RunStatus.Shut)
-                        {
-                            runRecord.TotalShutTime += configure.Frequency;
-                        }
-                        else
-                        {
-                            runRecord.TotalRunTime += configure.Frequency;
-                        }
+                    //鎸佺画鏃堕棿
+                    runRecord.ContinueTime += configure.Frequency;
 
-                        if (lastRecord == null)
-                        {
-                            runRecord.AnalyStatus = Yw.Run.AnalyStatus.Missing;
-                        }
-                        else
-                        {
-                            if (Yw.Monitor.DataStatus.HasError(lastRecord.DataStatus))
-                            {
-                                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))
-                                {
-                                    runRecord.AnalyStatus = Yw.Run.AnalyStatus.Interrupt;
-                                }
-                            }
-                        }
+                    //鎬诲叧鏈烘椂闂�
+                    if (runRecord.RSa == Yw.Run.RunStatus.Shut)
+                    {
+                        runRecord.TotalShutTime += configure.Frequency;
+                    }
+
+                    //鎬昏繍琛屾椂闂�
+                    if (runRecord.RSa == Yw.Run.RunStatus.Run)
+                    {
+                        runRecord.TotalRunTime += configure.Frequency;
                     }
 
                     #endregion

--
Gitblit v1.9.3