From 6dfe4deccaa34303880acd1782a7ea58ba70991c Mon Sep 17 00:00:00 2001 From: fyf Date: Wed, 1 Jun 2022 12:01:57 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E6=9B=B4=E6=96=B0=E4=B8=8A=E4=B8=8B?= =?UTF-8?q?=E7=BA=BF=E8=BD=AC=E5=AD=98"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 60172250cac4810fb78b1ae95108fd850ddd786e. --- DataVAPI/Controllers/DeviceController.cs | 2 +- DataVAPI/UpAndDown/ProcessServer.cs | 102 +++++++---------------- 2 files changed, 33 insertions(+), 71 deletions(-) diff --git a/DataVAPI/Controllers/DeviceController.cs b/DataVAPI/Controllers/DeviceController.cs index dc58ad9..1a1b058 100644 --- a/DataVAPI/Controllers/DeviceController.cs +++ b/DataVAPI/Controllers/DeviceController.cs @@ -227,7 +227,7 @@ namespace DataVAPI.Controllers st = System.Reflection.MethodBase.GetCurrentMethod().Name; try { - ProcessServer.Instance.LoadingShopInformationNew(); + ProcessServer.Instance.LoadingShopInformation(); return JsonMsg.OK("success!", st); } catch (Exception ex) diff --git a/DataVAPI/UpAndDown/ProcessServer.cs b/DataVAPI/UpAndDown/ProcessServer.cs index a129ced..f8e9b6a 100644 --- a/DataVAPI/UpAndDown/ProcessServer.cs +++ b/DataVAPI/UpAndDown/ProcessServer.cs @@ -58,7 +58,7 @@ namespace DataVAPI.UpAndDown devModel.infoMessage = new InfoMessage(); devModel.infoMessage.data = new List();//通知消息 //加载店铺信息 //加载店铺信息 - LoadingShopInformationNew(); + LoadingShopInformation(); //MQTT 数据接收处理 ConsoleHelper.WriteInfoLine("尝试连接阿里云."); //设置变量 @@ -163,29 +163,6 @@ namespace DataVAPI.UpAndDown }); } - public void LoadingShopInformationNew() - { - devModel.operatingDeviceStatus.data.Clear(); - var jsonMsg = deviceController.Query("", "", DateTime.MinValue, DateTime.MinValue); - jsonMsg.obj?.data?.ForEach(par => - { - 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}"); - }); - ConsoleHelper.WriteSuccessLine($"加载设备数[ {jsonMsg?.obj?.data?.Count} ]台..."); - } - /// /// 加载店铺信息 /// @@ -284,53 +261,38 @@ namespace DataVAPI.UpAndDown { if (receiveModel?.deviceContext != null && receiveModel?.status != null)//状态变更消息 { - var k= devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName); - logController.Create(new LogTable + devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName)?.SetStatus(receiveModel.status.value); + //devModel?.infoMessage?.data?.Add(new DeviceBase { DeviceMC = receiveModel.deviceContext.deviceName, DeviceMS = $"设备{receiveModel.status.value}了!", DeviceSJ = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); + + DevStatus dev = devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName); + if (dev == null) { LoadingShopInformation(); } + dev = devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName); + if (dev != null) + { + logController.Create(new LogTable + { + devicename = receiveModel.deviceContext.deviceName, + ClientId = dev.clientId, + DeviceId = dev.deviceId, + LogTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + LogType = "提示", + LogMessage = $"设备{receiveModel.status.value}了!", + LogVla = "通知" + }); + OnOrOffline(receiveModel.status.value, devModel.operatingDeviceStatus.data, dev); + } + else { - devicename = receiveModel.deviceContext.deviceName, - ClientId = k.clientId, - DeviceId = k.deviceId, - LogTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), - LogType = "提示", - LogMessage = $"设备{receiveModel.status.value}了!", - LogVla = "通知" - }); + LoadingShopInformation(); + } } - - //if (receiveModel?.deviceContext != null && receiveModel?.status != null)//状态变更消息 - //{ - // devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName)?.SetStatus(receiveModel.status.value); - // //devModel?.infoMessage?.data?.Add(new DeviceBase { DeviceMC = receiveModel.deviceContext.deviceName, DeviceMS = $"设备{receiveModel.status.value}了!", DeviceSJ = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); - - // DevStatus dev = devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName); - // if (dev == null) { LoadingShopInformation(); } - // dev = devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName); - // if (dev != null) - // { - // logController.Create(new LogTable - // { - // devicename = receiveModel.deviceContext.deviceName, - // ClientId = dev.clientId, - // DeviceId = dev.deviceId, - // LogTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), - // LogType = "提示", - // LogMessage = $"设备{receiveModel.status.value}了!", - // LogVla = "通知" - // }); - // OnOrOffline(receiveModel.status.value, devModel.operatingDeviceStatus.data, dev); - // } - // else - // { - // LoadingShopInformation(); - // } - //} //devModel.OrderLine = orderProvider.OrderLine(new DataVApi.Order.RequestModel.FullScreenBasic()); //devModel.OrderDataState = orderProvider.GetAllOrderDataState(new DataVApi.Order.RequestModel.FullScreenInput()); ////devModel.LocSale = orderProvider.GetLocSale(); //object obj = orderProvider.OrderNumber(new DataVApi.Order.RequestModel.FullScreenBasic()); //devModel.OrderNumber = Tools.JsonToObjectTools(Tools.JsonConvertTools(obj)); - // ScreenMonitorModel screen1Monitor = Tools.JsonToObjectTools(devModel.ToJSON()); + ScreenMonitorModel screen1Monitor = Tools.JsonToObjectTools(devModel.ToJSON()); #region 1.设置data默认值 //if (screen1Monitor.operatingDeviceStatus.data.Count == 0) //{ @@ -342,12 +304,12 @@ namespace DataVAPI.UpAndDown //} #endregion - //string JSON = screen1Monitor.ToJSON(); - //if (!string.IsNullOrEmpty(JSON)) - //{ - // //screenController.CreateOrUpdate(new LargeScreenTable() { json = JSON, devicename = "Transit", ClientId = "-10", DeviceId = "-10" }); - // IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.ScreenShowPubTopic, JSON); - //} + string JSON = screen1Monitor.ToJSON(); + if (!string.IsNullOrEmpty(JSON)) + { + //screenController.CreateOrUpdate(new LargeScreenTable() { json = JSON, devicename = "Transit", ClientId = "-10", DeviceId = "-10" }); + IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.ScreenShowPubTopic, JSON); + } //if (devModel.infoMessage.data != null && devModel.infoMessage.data.Count > 0) //{ @@ -456,7 +418,7 @@ namespace DataVAPI.UpAndDown } else if (message == "刷新店铺列表") { - LoadingShopInformationNew(); + LoadingShopInformation(); } } //else if (topic == IOTDevServer.TargetStatusSubTopic)//属性变更