From bd4a8487a21ef740fcfaf1f87b67f85001fc1a3d Mon Sep 17 00:00:00 2001 From: fyf Date: Fri, 10 Jun 2022 17:21:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=80=E6=96=B0=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DataVAPI/Controllers/DeviceStatsController.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/DataVAPI/Controllers/DeviceStatsController.cs b/DataVAPI/Controllers/DeviceStatsController.cs index 48f274c..ffa258f 100644 --- a/DataVAPI/Controllers/DeviceStatsController.cs +++ b/DataVAPI/Controllers/DeviceStatsController.cs @@ -153,10 +153,22 @@ namespace DataVAPI.Controllers } List list = new List(); int? count = log?.FindAll(par => par.LogMessage.Contains("设备在线了")).Count; - list.Add(new { Name = "运行次数", Count = count?.ToString()}); - list.Add(new { Name = "故障次数", Count = alarm?.Count.ToString() }); - list.Add(new { Name = "故障率", Count = $"{(alarm?.Count * 100) / 400}%" }); + //LogTable log1 = log?.Find(par => par.LogMessage.Contains("设备在线了")); + //LogTable log2 = log?.Find(par => par.LogMessage.Contains("设备离线了")); + + list.Add(new { Name = "运行次数", Count = count?.ToString()}); + //if (log1 != null && log2 != null) + //{ + // double dob = Math.Abs((log1.CreateTime - log2.CreateTime).TotalMinutes); + // list.Add(new { Name = "故障次数", Count = 0 }); + // list.Add(new { Name = "故障率", Count = $"{(dob / 120)*100/100}%" }); + //} + //else + { + list.Add(new { Name = "故障次数", Count = 0 }); + list.Add(new { Name = "故障率", Count = $"0%" }); + } return JsonMsg.OK(list, st); } catch (Exception ex)