diff --git a/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs b/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs index a8b6978..7165f5c 100644 --- a/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs +++ b/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs @@ -14,13 +14,16 @@ using DocumentFormat.OpenXml.EMMA; using NPOI.SS.Formula.Functions; using Infrastructure.Extensions; using DocumentFormat.OpenXml.Math; +using Microsoft.Extensions.Configuration; namespace OpenAuth.App.ServiceApp { public class AirportMaintenanceApp : SqlSugarBaseApp { - public AirportMaintenanceApp(ISugarUnitOfWork unitWork, ISimpleClient repository, IAuth auth) : base(unitWork, repository, auth) + private readonly IConfiguration _configuration; + public AirportMaintenanceApp(ISugarUnitOfWork unitWork, IConfiguration configuration, ISimpleClient repository, IAuth auth) : base(unitWork, repository, auth) { + _configuration = configuration; } //获取设备绑定码 public async Task> GetDeviceBindingCode() @@ -113,15 +116,19 @@ namespace OpenAuth.App.ServiceApp } else { + var serverIp = _configuration.GetSection("MQTT:Server").Value; + var port = _configuration.GetSection("MQTT:Port").Value; + var username = _configuration.GetSection("MQTT:UserName").Value; + var password = _configuration.GetSection("MQTT:Password").Value; //如果网关不存在,则创建一个新的 var newGateway = new LasaGateway { Id = Guid.NewGuid().ToString(), CreateTime = DateTime.Now, - GatewayAccount = "sdhc", + GatewayAccount = username, GatewaySn = Guid.NewGuid().ToString("N").Substring(0, 8).ToUpper(), // 生成一个新的 - MqttGateway = "175.27.168.120:6011", - MqttPassword = "", + MqttGateway = serverIp + ":" + port, + MqttPassword = password, OrgId = "371300", // 默认组织ID BindStatus = 0 // 未绑定状态 }; @@ -314,7 +321,7 @@ namespace OpenAuth.App.ServiceApp 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) + .OrderBy(x => x.CreateTime, OrderByType.Asc) .ToPageListAsync(page, limit, totalCount); return new Response>> {