From eaf46c835148a96ac6fd43e03acbf89f37598e5e Mon Sep 17 00:00:00 2001 From: fyf Date: Mon, 16 May 2022 16:08:22 +0800 Subject: [PATCH] ere --- DataVAPI/UpAndDown/ProcessServer.cs | 78 ++++++++++++++++++----------- 1 file changed, 49 insertions(+), 29 deletions(-) diff --git a/DataVAPI/UpAndDown/ProcessServer.cs b/DataVAPI/UpAndDown/ProcessServer.cs index e15522f..ae25a0c 100644 --- a/DataVAPI/UpAndDown/ProcessServer.cs +++ b/DataVAPI/UpAndDown/ProcessServer.cs @@ -26,6 +26,7 @@ namespace DataVAPI.UpAndDown public ScreenController screenController { get; set; } public AlarmController alarmController { get; set; } public OrderProvider orderProvider { get; set; } + public List devStatuses { get; set; }=new List(); #region 不需要监听 private static ProcessServer _instance; public static ProcessServer Instance @@ -173,41 +174,60 @@ namespace DataVAPI.UpAndDown { try { + devStatuses = devModel.operatingDeviceStatus.data; ConsoleHelper.WriteSuccessLine("加载店铺集合中."); JsonMsg> jsonMsg = deviceController.Query("", "", DateTime.MinValue, DateTime.MinValue); - jsonMsg?.obj?.data?.ForEach(par => + if (jsonMsg?.obj?.data.Count > 0) { - int chid = 0; - try - { - chid = int.Parse(par.ClientId); - } - catch (Exception ex) - { - chid = 0; - } - if (chid > 0) + if (devStatuses.Count != devModel.operatingDeviceStatus.data.Count) { - DevStatus devStatus = new DevStatus() - { - deviceName = par.devicename, - gmtCreate = par.devicesecret, - productKey = par.productkey, - DeviceMC = par.devtype, - DeviceMS = par.remark, - DeviceSJ = par.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), - DeviceZT = "离线", - clientId = par.ClientId, - deviceId = par.DeviceId - }; - if (devModel.operatingDeviceStatus.data.Find(o => o.gmtCreate == par.devicesecret) == null) + devModel.operatingDeviceStatus.data.Clear(); + jsonMsg?.obj?.data?.ForEach(par => { - ConsoleHelper.WriteSuccessLine($"加载设备.{par.devtype} {par.remark}"); - devModel.operatingDeviceStatus.data.Insert(0, devStatus); - } + int chid = 0; + try + { + chid = int.Parse(par.ClientId); + } + catch (Exception ex) + { + chid = 0; + } + if (chid > 0) + { + DevStatus devStatus = new DevStatus() + { + deviceName = par.devicename, + gmtCreate = par.devicesecret, + productKey = par.productkey, + DeviceMC = par.devtype, + DeviceMS = par.remark, + DeviceSJ = par.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), + DeviceZT = "离线", + clientId = par.ClientId, + deviceId = par.DeviceId + }; + ConsoleHelper.WriteSuccessLine($"加载设备.{par.devtype} {par.remark}"); + devModel.operatingDeviceStatus.data.Insert(0, devStatus); + + DevStatus dev= devStatuses?.Find(k => k.deviceName == par.devicename); + + if (dev != null && dev.DeviceZT == "在线") + { + OnOrOffline(dev.DeviceZT, devModel.operatingDeviceStatus.data, devStatus); + } + } + }); + ConsoleHelper.WriteSuccessLine($"加载设备数[ {jsonMsg?.obj?.data?.Count} ]台..."); } - }); - ConsoleHelper.WriteSuccessLine($"加载设备数[ {jsonMsg?.obj?.data?.Count} ]台..."); + } + else + { + ConsoleHelper.WriteSuccessLine("查询店铺集合为空."); + } + + + } catch (Exception ex) {