From 73302d48c707a2ceaa824ac03145b9c614453c73 Mon Sep 17 00:00:00 2001 From: yanghongwei Date: Sun, 13 Apr 2025 15:41:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=86=E8=8A=82=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Whitelist.cs | 4 ++++ Program.cs | 2 -- Service/AlarmService.cs | 12 +++--------- Service/WhitListService.cs | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Model/Whitelist.cs b/Model/Whitelist.cs index 963656d..859223f 100644 --- a/Model/Whitelist.cs +++ b/Model/Whitelist.cs @@ -35,6 +35,10 @@ namespace LY.App.Model } public class AddWhitelist { + /// + /// 设备型号 + /// + public string model { get; set; } /// /// 设备序列号 /// diff --git a/Program.cs b/Program.cs index 87d5896..68ed7e9 100644 --- a/Program.cs +++ b/Program.cs @@ -85,8 +85,6 @@ builder.Services.AddTransient(sp => }; //ݿͱִһ //db.DbMaintenance.CreateDatabase(); - db.CodeFirst.SetStringDefaultLength(2000).InitTables(typeof(PositionInfo)); - db.CodeFirst.SetStringDefaultLength(2000).InitTables(typeof(Whitelist)); #endif //д // db.QueryFilter.AddTableFilter(it => it.IsDeleted == false); diff --git a/Service/AlarmService.cs b/Service/AlarmService.cs index ebb66f3..b57e374 100644 --- a/Service/AlarmService.cs +++ b/Service/AlarmService.cs @@ -4,14 +4,9 @@ using LY.App.Common.WebSocket; using LY.App.Extensions.DI; using LY.App.Model; using Mapster; -using Microsoft.AspNetCore.SignalR; using NetTopologySuite.Geometries; -using NetTopologySuite.Index.HPRtree; using NetTopologySuite.IO; using SqlSugar; -using StackExchange.Redis; -using System.Collections.Concurrent; -using System.Reflection; namespace LY.App.Service { @@ -189,18 +184,17 @@ namespace LY.App.Service if (positionId > 0 && lon > 0 && lat > 0) { var key = RedisKeyList.PositioinRegion(positionId); - var geodata = await _redisService.GetAsync(key); + var geodata = await _redisService.GetAsync(key); if (geodata == null) { geodata = await _db.CopyNew().Queryable() .Where(s => s.Id == positionId) - .Select(s => s.Region) .FirstAsync(); - await _redisService.SetAsync(key, geodata); + await _redisService.SetAsync(key, geodata); } WKTReader reader = new WKTReader(); Geometry point = reader.Read($"POINT ({lon} {lat})"); - Geometry multipolygon = reader.Read(geodata); + Geometry multipolygon = reader.Read(geodata.Region); if (multipolygon.Contains(point)) { return 1; diff --git a/Service/WhitListService.cs b/Service/WhitListService.cs index 723bccf..efad679 100644 --- a/Service/WhitListService.cs +++ b/Service/WhitListService.cs @@ -3,7 +3,6 @@ using LY.App.Extensions.DI; using LY.App.Model; using Mapster; using SqlSugar; -using System.Collections.Generic; namespace LY.App.Service { @@ -19,6 +18,7 @@ namespace LY.App.Service /// 构造函数 /// /// + /// public WhitListService(SqlSugarClient sqlSugarClient, RedisService redisService) { _db = sqlSugarClient;