From 06277e6a5d3ec020e42acf68dd1c2c8520e71798 Mon Sep 17 00:00:00 2001 From: zhangbin <460190368@qq.com> Date: Thu, 10 Jul 2025 13:52:27 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Model/mqtt/MqttHostedService.cs | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/OpenAuth.WebApi/Model/mqtt/MqttHostedService.cs b/OpenAuth.WebApi/Model/mqtt/MqttHostedService.cs index 5476411..09bb4c5 100644 --- a/OpenAuth.WebApi/Model/mqtt/MqttHostedService.cs +++ b/OpenAuth.WebApi/Model/mqtt/MqttHostedService.cs @@ -12,6 +12,7 @@ namespace OpenAuth.WebApi.Model.mqtt private readonly MqttMessageCenter _mqttCenter; private readonly AirportMaintenanceApp _app; + public MqttHostedService(IServiceProvider serviceProvider, MqttMessageCenter mqttCenter, AirportMaintenanceApp app) { _serviceProvider = serviceProvider; @@ -23,14 +24,29 @@ namespace OpenAuth.WebApi.Model.mqtt { using var scope = _serviceProvider.CreateScope(); var handlers = scope.ServiceProvider.GetServices(); + // 创建配置构建器 + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .AddJsonFile( + $"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development"}.json", + optional: true) + .AddEnvironmentVariables(); + // 构建配置 + var configuration = builder.Build(); + // 读取连接字符串 + var serverIp = configuration["MQTT:Server"]; + var port = configuration["MQTT:Port"]; + var username = configuration["MQTT:UserName"]; + var password = configuration["MQTT:Password"]; await _mqttCenter.InitializeAsync( handlers, - server: "175.27.168.120", - port: 6011, + server: serverIp, + port: int.Parse(port), clientId: Guid.NewGuid().ToString(), - username: "sdhc", - password: "" + username: username, + password: password ); //查询网关,订阅主题 var topics = new List(); From 5dbafcf2ac47e9e8013980a642fd4eb5da94a52e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=81=20=E4=BB=BB?= Date: Fri, 11 Jul 2025 17:10:12 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/ServiceApp/ManageApp.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenAuth.App/ServiceApp/ManageApp.cs b/OpenAuth.App/ServiceApp/ManageApp.cs index 64933c3..c3bdc56 100644 --- a/OpenAuth.App/ServiceApp/ManageApp.cs +++ b/OpenAuth.App/ServiceApp/ManageApp.cs @@ -1001,7 +1001,7 @@ namespace OpenAuth.App.ServiceApp StringBuilder geomSql = new StringBuilder(); geomSql.AppendFormat( - $" update lasa_shpdata set \"Geom\" = st_geomfromtext('{_wktModel}',4326) where \"Id\" = '{id}'"); + $" update lasa_annotation set \"Geom\" = st_geomfromtext('{_wktModel}',4326) where \"Id\" = '{id}'"); ////更新面积 //StringBuilder sql = new StringBuilder(); @@ -1058,7 +1058,7 @@ namespace OpenAuth.App.ServiceApp StringBuilder geomSql = new StringBuilder(); geomSql.AppendFormat( - $" update lasa_shpdata set \"Geom\" = st_geomfromtext('{_wktModel}',4326) where \"Id\" = '{model.Id}'"); + $" update lasa_annotation set \"Geom\" = st_geomfromtext('{_wktModel}',4326) where \"Id\" = '{model.Id}'"); //使用事务提交数据 var transFlag = await db.UseTranAsync(async () => From 853bb9e5e4321983b0735c206cef1022b1a696b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=81=20=E4=BB=BB?= Date: Sat, 12 Jul 2025 08:56:39 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/ServiceApp/ManageApp.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenAuth.App/ServiceApp/ManageApp.cs b/OpenAuth.App/ServiceApp/ManageApp.cs index c3bdc56..c04049e 100644 --- a/OpenAuth.App/ServiceApp/ManageApp.cs +++ b/OpenAuth.App/ServiceApp/ManageApp.cs @@ -445,6 +445,7 @@ namespace OpenAuth.App.ServiceApp } var list = await db.LasaWorkspace.AsQueryable() + .Where(a=>a.IsDelete==false) .WhereIF(!string.IsNullOrEmpty(key), a => a.WorkspaceName.Contains(key)) .WhereIF(state != 0, a => a.Sate == state) .WhereIF(isjoin == 1, a => ids.Contains(a.Id)) From 6bdbf52b55a43a8635712a9392d6d6e463d2a1cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=81=20=E4=BB=BB?= Date: Sat, 12 Jul 2025 10:55:56 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E6=A0=87=E6=B3=A8?= =?UTF-8?q?=EF=BC=8C=E5=9C=B0=E5=9B=BE=E4=BD=9C=E4=B8=9A=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/ServiceApp/ManageApp.cs | 67 +++++++++++++--------------- 1 file changed, 30 insertions(+), 37 deletions(-) diff --git a/OpenAuth.App/ServiceApp/ManageApp.cs b/OpenAuth.App/ServiceApp/ManageApp.cs index c04049e..b7fdc68 100644 --- a/OpenAuth.App/ServiceApp/ManageApp.cs +++ b/OpenAuth.App/ServiceApp/ManageApp.cs @@ -828,7 +828,8 @@ namespace OpenAuth.App.ServiceApp model.Id = id; //格式化数据 - string _wktModel = _commonDataManager.WktDataConvert(model.Geom, "MULTIPOLYGON ZM", 4); + //string _wktModel = _commonDataManager.WktDataConvert(model.Geom, "MULTIPOLYGON ZM", 4); + string _wktModel = model.Geom; model.Geom = null; @@ -836,15 +837,15 @@ namespace OpenAuth.App.ServiceApp geomSql.AppendFormat( $" update lasa_shpdata set \"Geom\" = st_geomfromtext('{_wktModel}',4326) where \"Id\" = '{id}'"); - //更新面积 - StringBuilder sql = new StringBuilder(); - sql.AppendFormat( - $" update lasa_shpdata set \"Area\" = st_area(st_transform(\"Geom\",4527)) where \"Geom\" is not null and \"Id\" = '{id}'"); + ////更新面积 + //StringBuilder sql = new StringBuilder(); + //sql.AppendFormat( + // $" update lasa_shpdata set \"Area\" = st_area(st_transform(\"Geom\",4527)) where \"Geom\" is not null and \"Id\" = '{id}'"); - //更新周长 - StringBuilder sqlle = new StringBuilder(); - sqlle.AppendFormat( - $" update lasa_shpdata set \"Length\" = ST_Perimeter(st_transform(\"Geom\",4527)) where \"Geom\" is not null and \"Id\" = '{id}'"); + ////更新周长 + //StringBuilder sqlle = new StringBuilder(); + //sqlle.AppendFormat( + // $" update lasa_shpdata set \"Length\" = ST_Perimeter(st_transform(\"Geom\",4527)) where \"Geom\" is not null and \"Id\" = '{id}'"); //使用事务提交数据 var transFlag = await db.UseTranAsync(async () => @@ -855,11 +856,11 @@ namespace OpenAuth.App.ServiceApp //修改图斑数据 var flagGeom = await db.Ado.ExecuteCommandAsync(geomSql.ToString()); - //修改图斑面积 - var flagUpdate = await db.Ado.ExecuteCommandAsync(sql.ToString()); + ////修改图斑面积 + //var flagUpdate = await db.Ado.ExecuteCommandAsync(sql.ToString()); - //修改图斑周长 - var lengthUpdate = await db.Ado.ExecuteCommandAsync(sqlle.ToString()); + ////修改图斑周长 + //var lengthUpdate = await db.Ado.ExecuteCommandAsync(sqlle.ToString()); }); if (transFlag.IsSuccess) return new Response @@ -893,15 +894,15 @@ namespace OpenAuth.App.ServiceApp geomSql.AppendFormat( $" update lasa_shpdata set \"Geom\" = st_geomfromtext('{_wktModel}',4326) where \"Id\" = '{model.Id}'"); - //更新面积 - StringBuilder sql = new StringBuilder(); - sql.AppendFormat( - $" update lasa_shpdata set \"Area\" = st_area(st_transform(\"Geom\",4527)) where \"Geom\" is not null and \"Id\" = '{model.Id}'"); + ////更新面积 + //StringBuilder sql = new StringBuilder(); + //sql.AppendFormat( + // $" update lasa_shpdata set \"Area\" = st_area(st_transform(\"Geom\",4527)) where \"Geom\" is not null and \"Id\" = '{model.Id}'"); - //更新周长 - StringBuilder sqlle = new StringBuilder(); - sqlle.AppendFormat( - $" update lasa_shpdata set \"Length\" = ST_Perimeter(st_transform(\"Geom\",4527)) where \"Geom\" is not null and \"Id\" = '{model.Id}'"); + ////更新周长 + //StringBuilder sqlle = new StringBuilder(); + //sqlle.AppendFormat( + // $" update lasa_shpdata set \"Length\" = ST_Perimeter(st_transform(\"Geom\",4527)) where \"Geom\" is not null and \"Id\" = '{model.Id}'"); //使用事务提交数据 var transFlag = await db.UseTranAsync(async () => @@ -912,11 +913,11 @@ namespace OpenAuth.App.ServiceApp //修改图斑数据 var flagGeom = await db.Ado.ExecuteCommandAsync(geomSql.ToString()); - //修改图斑面积 - var flagUpdate = await db.Ado.ExecuteCommandAsync(sql.ToString()); + ////修改图斑面积 + //var flagUpdate = await db.Ado.ExecuteCommandAsync(sql.ToString()); - //修改图斑周长 - var lengthUpdate = await db.Ado.ExecuteCommandAsync(sqlle.ToString()); + ////修改图斑周长 + //var lengthUpdate = await db.Ado.ExecuteCommandAsync(sqlle.ToString()); }); if (transFlag.IsSuccess) return new Response @@ -996,7 +997,8 @@ namespace OpenAuth.App.ServiceApp model.Id = id; //格式化数据 - string _wktModel = _commonDataManager.WktDataConvert(model.Geom, "MULTIPOLYGON ZM", 4); + //string _wktModel = _commonDataManager.WktDataConvert(model.Geom, "MULTIPOLYGON ZM", 4); + string _wktModel = model.Geom; model.Geom = null; @@ -1004,16 +1006,6 @@ namespace OpenAuth.App.ServiceApp geomSql.AppendFormat( $" update lasa_annotation set \"Geom\" = st_geomfromtext('{_wktModel}',4326) where \"Id\" = '{id}'"); - ////更新面积 - //StringBuilder sql = new StringBuilder(); - //sql.AppendFormat( - // $" update lasa_shpdata set \"Area\" = st_area(st_transform(\"Geom\",4527)) where \"Geom\" is not null and \"Id\" = '{id}'"); - - ////更新周长 - //StringBuilder sqlle = new StringBuilder(); - //sqlle.AppendFormat( - // $" update lasa_shpdata set \"Length\" = ST_Perimeter(st_transform(\"Geom\",4527)) where \"Geom\" is not null and \"Id\" = '{id}'"); - //使用事务提交数据 var transFlag = await db.UseTranAsync(async () => { @@ -1053,7 +1045,8 @@ namespace OpenAuth.App.ServiceApp using (var db = base.UnitWork.CreateContext().Db.CopyNew()) { //格式化数据 - string _wktModel = _commonDataManager.WktDataConvert(model.Geom, "MULTIPOLYGON ZM", 4); + //string _wktModel = _commonDataManager.WktDataConvert(model.Geom, "MULTIPOLYGON ZM", 4); + string _wktModel = model.Geom; model.Geom = null; From c8b6adefdaac966eba40b85c26e60ecf41a7239d Mon Sep 17 00:00:00 2001 From: zhangbin <460190368@qq.com> Date: Sat, 12 Jul 2025 15:03:15 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=9C=BA=E5=9C=BA=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ServiceApp/AirportMaintenanceApp.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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>> { From f24daad03eb544f4c121076283b5bac5a7d4810c Mon Sep 17 00:00:00 2001 From: zhangbin <460190368@qq.com> Date: Sat, 12 Jul 2025 15:07:17 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ServiceApp/AirportMaintenanceApp.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs b/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs index 607514c..6dcc53c 100644 --- a/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs +++ b/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs @@ -14,15 +14,16 @@ using DocumentFormat.OpenXml.EMMA; using NPOI.SS.Formula.Functions; using Infrastructure.Extensions; using DocumentFormat.OpenXml.Math; -using DocumentFormat.OpenXml.Spreadsheet; -using Org.BouncyCastle.Ocsp; +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() @@ -115,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 // 未绑定状态 }; @@ -316,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>> {