From 997a98ef8b2cf3e23cd97e917188f5208823b23b Mon Sep 17 00:00:00 2001 From: gwbvipvip Date: Thu, 22 Feb 2024 15:32:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Device/DevicePushRecodeServices.cs | 3 +- .../Service/Device/Dtos/Class1.cs | 12 ------ .../Services/DevicePushRecodeService.cs | 41 ++++++++++++++----- .../Services/IDevicePushRecodeService.cs | 3 +- 4 files changed, 34 insertions(+), 25 deletions(-) delete mode 100644 BPA.KitChen.StoreManagement.Application/Service/Device/Dtos/Class1.cs diff --git a/BPA.KitChen.StoreManagement.Application/Service/Device/DevicePushRecodeServices.cs b/BPA.KitChen.StoreManagement.Application/Service/Device/DevicePushRecodeServices.cs index ec717fd..d442187 100644 --- a/BPA.KitChen.StoreManagement.Application/Service/Device/DevicePushRecodeServices.cs +++ b/BPA.KitChen.StoreManagement.Application/Service/Device/DevicePushRecodeServices.cs @@ -1,4 +1,5 @@ -using BPA.KitChen.StoreManagement.Application.BaseDto; + +using BPA.KitChen.StoreManagement.Application.BaseDto; using BPA.KitChen.StoreManagement.Application.Service.Device; using BPA.KitChen.StoreManagement.Application.Service.Device.Dtos; using Furion.DynamicApiController; diff --git a/BPA.KitChen.StoreManagement.Application/Service/Device/Dtos/Class1.cs b/BPA.KitChen.StoreManagement.Application/Service/Device/Dtos/Class1.cs deleted file mode 100644 index d737fbf..0000000 --- a/BPA.KitChen.StoreManagement.Application/Service/Device/Dtos/Class1.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPA.KitChen.StoreManagement.Application.Service.Device.Dtos -{ - internal class Class1 - { - } -} diff --git a/BPA.KitChen.StoreManagement.Application/Service/Device/Services/DevicePushRecodeService.cs b/BPA.KitChen.StoreManagement.Application/Service/Device/Services/DevicePushRecodeService.cs index eb4c65f..cb5ab4c 100644 --- a/BPA.KitChen.StoreManagement.Application/Service/Device/Services/DevicePushRecodeService.cs +++ b/BPA.KitChen.StoreManagement.Application/Service/Device/Services/DevicePushRecodeService.cs @@ -1,5 +1,4 @@ - -using BPA.KitChen.StoreManagement.Application.BaseDto; +using BPA.KitChen.StoreManagement.Application.BaseDto; using BPA.KitChen.StoreManagement.Application.Service.Device.Dtos; using BPA.KitChen.StoreManagement.Core.Entity; using BPA.KitChen.StoreManagement.Core.Enum; @@ -31,7 +30,7 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Device public DevicePushRecodeService(ISqlSugarClient db, IMqttClient mqttClient) { _db = db; - _mqttClient = mqttClient; + _mqttClient=mqttClient; } /// /// 分页 @@ -43,7 +42,7 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Device RefAsync total = 0; var res = await _db.Queryable().Where(x => x.Type == input.Type) .WhereIF(!string.IsNullOrWhiteSpace(input.DeviceName), x => x.DeviceName.Contains(input.DeviceName)) - .WhereIF(!string.IsNullOrWhiteSpace(input.Status), x => x.Status == (CommonStatus)Convert.ToInt32(input.Status) ) + .WhereIF(!string.IsNullOrWhiteSpace(input.Status), x => x.Status == (CommonStatus)Convert.ToInt32(input.Status)) .Select(t => new { CreateAt = t.CreateAt, @@ -81,20 +80,42 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Device data.Topic= Topic; data.Status = CommonStatus.ENABLE; data.DataResore = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(input.Data.ToString())); - var res=await Push(Topic, new PushData() { Data=input.Data, DeviceId= input.DeviceAutoKey }); - data.Status = res == "success" ? CommonStatus.ENABLE : CommonStatus.DISABLE; - await _db.Insertable(data).CallEntityMethod(t => t.Create()).ExecuteCommandAsync(); - - return res == "success"; + data.DeviceAutoKey= input.DeviceAutoKey; + data.Description = "成功"; + if (input.TopicsData.Count > 0) + { + var chaeck = input.TopicsData.Any(x => x.Topics.Trim() == topstr.Trim()); + if (!chaeck) + { + data.Status = CommonStatus.DISABLE; + data.Description = "下发数据失败,该产品还未配置对应的topic,请联系管理员进行配置"; + } + } + else + { + data.Status = CommonStatus.DISABLE; + data.Description = "下发数据失败,该产品还未配置对应的topic,请联系管理员进行配置"; + } + if (data.Status == CommonStatus.ENABLE) + { + var respush = await Push(Topic, new PushData() { Data = data.DataResore, DeviceId = input.DeviceAutoKey }); + if (respush != "success") + { + data.Description = respush; + data.Status = CommonStatus.DISABLE; + } + } + var res = await _db.Insertable(data).CallEntityMethod(t => t.Create()).ExecuteCommandAsync(); + return res>0; } public async Task Update(string id) { var data = _db.Queryable().Where(x => x.Id == id).First(); data.Status = CommonStatus.ENABLE; var respush = await Push(data.Topic, new PushData() { Data = data.DataResore, DeviceId = data.DeviceAutoKey }); - data.Description = respush; if (respush!= "success") { + data.Description = respush; data.Status = CommonStatus.DISABLE; } var res = await _db.Updateable(data).ExecuteCommandAsync(); diff --git a/BPA.KitChen.StoreManagement.Application/Service/Device/Services/IDevicePushRecodeService.cs b/BPA.KitChen.StoreManagement.Application/Service/Device/Services/IDevicePushRecodeService.cs index 8672fec..4534063 100644 --- a/BPA.KitChen.StoreManagement.Application/Service/Device/Services/IDevicePushRecodeService.cs +++ b/BPA.KitChen.StoreManagement.Application/Service/Device/Services/IDevicePushRecodeService.cs @@ -1,5 +1,4 @@ - -using BPA.KitChen.StoreManagement.Application.BaseDto; +using BPA.KitChen.StoreManagement.Application.BaseDto; using BPA.KitChen.StoreManagement.Application.Service.Device.Dtos; using System; using System.Collections.Generic;