From 09889ee15a3a42abc651ff9912091c394e404b9e Mon Sep 17 00:00:00 2001 From: zhangbin <460190368@qq.com> Date: Fri, 4 Jul 2025 14:53:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E8=AE=BE=E5=A4=87sn=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E5=AE=9E=E6=97=B6=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ServiceApp/AirportMaintenanceApp.cs | 28 ++++++++- OpenAuth.Repository/Domain/LasaLog.cs | 2 +- .../AirportMaintenanceController.cs | 61 ++++++++++++++----- OpenAuth.WebApi/Model/mqtt/ThingOsdHandler.cs | 2 +- 4 files changed, 74 insertions(+), 19 deletions(-) diff --git a/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs b/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs index 4bbf4b2..a8b6978 100644 --- a/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs +++ b/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs @@ -186,7 +186,7 @@ namespace OpenAuth.App.ServiceApp { var uavinfo = await db.LasaUav.AsQueryable().Where(r => r.IsDelete == false).Select(r => r.Sn).ToListAsync(); var dockinfo = await db.LasaDronePort.AsQueryable().Where(r => r.IsDelete == false).Select(r => r.Sn).ToListAsync(); - + if (dockinfo != null) { return dockinfo.Union(uavinfo).ToList(); @@ -296,6 +296,32 @@ namespace OpenAuth.App.ServiceApp return false; } } + /// + /// 获取日志 + /// + /// + /// + /// + /// + /// + /// + public async Task>>> GetLogList(string sn, DateTime startTime, DateTime endTime, int page, int limit) + { + RefAsync totalCount = 0; + using (var db = UnitWork.CreateContext()) + { + var topic = $"thing/product/{sn}/osd"; + var list = await db.LasaLog.AsQueryable() + .Where(x => x.CreateTime >= startTime && x.CreateTime <= endTime) + .Where(x => x.Topic == topic) + .OrderBy(x => x.CreateTime, OrderByType.Asc) + .ToPageListAsync(page, limit, totalCount); + return new Response>> + { + Result = new PageInfo> { Items = list, Total = totalCount } + }; + } + } #endregion } } diff --git a/OpenAuth.Repository/Domain/LasaLog.cs b/OpenAuth.Repository/Domain/LasaLog.cs index aa45588..a88bab3 100644 --- a/OpenAuth.Repository/Domain/LasaLog.cs +++ b/OpenAuth.Repository/Domain/LasaLog.cs @@ -45,6 +45,6 @@ namespace OpenAuth.Repository.Domain /// Nullable:True /// [SugarColumn(IsJson = true)] - public JsonObject Data { get; set; } + public string Data { get; set; } } } diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs index 7bd7e50..bbee816 100644 --- a/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs @@ -362,25 +362,27 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), data = new { - output = new { - bucket= "test", - credentials= new { - access_key_id= "minioadmin", - access_key_secret = "minioadmin", - expire= 3600, - security_token= "security_token" + output = new + { + bucket = "test", + credentials = new + { + access_key_id = "minioadmin", + access_key_secret = "minioadmin", + expire = 3600, + security_token = "security_token" - }, - endpoint = "175.27.168.120:6013", - object_key_prefix= "", - provider = "ali", - region= "hz" - - }, - result= 0 + }, + endpoint = "175.27.168.120:6013", + object_key_prefix = "", + provider = "ali", + region = "hz" + + }, + result = 0 } }; - + response.Result = 0; @@ -592,5 +594,32 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers return result; } #endregion + + #region 日志信息 + /// + /// 根据设备sn读取实时数据 + /// + /// 设备sn + /// + /// + /// + /// + /// + [HttpGet] + public async Task>>> GetLogList(string sn, DateTime startTime, DateTime endTime, int page, int limit) + { + var result = new Response>>(); + try + { + result = await _app.GetLogList(sn, startTime, endTime, page, limit); + } + catch (Exception ex) + { + result.Code = 500; + result.Message = ex.Message; + } + return result; + } + #endregion } } diff --git a/OpenAuth.WebApi/Model/mqtt/ThingOsdHandler.cs b/OpenAuth.WebApi/Model/mqtt/ThingOsdHandler.cs index 2cbe1ba..106563b 100644 --- a/OpenAuth.WebApi/Model/mqtt/ThingOsdHandler.cs +++ b/OpenAuth.WebApi/Model/mqtt/ThingOsdHandler.cs @@ -34,7 +34,7 @@ namespace OpenAuth.WebApi.Model.mqtt Topic = topic, Method = root["method"]?.ToString() ?? "", CreateTime = DateTime.Now, - Data = root + Data = root.ToString() }); var sub_device = root["data"]?["sub_device"]?.ToString() ?? ""; if (!string.IsNullOrEmpty(sub_device))