细节调整
This commit is contained in:
parent
6514d4824c
commit
73302d48c7
|
|
@ -35,6 +35,10 @@ namespace LY.App.Model
|
|||
}
|
||||
public class AddWhitelist
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备型号
|
||||
/// </summary>
|
||||
public string model { get; set; }
|
||||
/// <summary>
|
||||
/// 设备序列号
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -85,8 +85,6 @@ builder.Services.AddTransient<SqlSugarClient>(sp =>
|
|||
};
|
||||
//创建数据库和表的语句仅执行一次
|
||||
//db.DbMaintenance.CreateDatabase();
|
||||
db.CodeFirst.SetStringDefaultLength(2000).InitTables(typeof(PositionInfo));
|
||||
db.CodeFirst.SetStringDefaultLength(2000).InitTables(typeof(Whitelist));
|
||||
#endif
|
||||
//过滤器写在这儿就行了
|
||||
// db.QueryFilter.AddTableFilter<IDeleted>(it => it.IsDeleted == false);
|
||||
|
|
|
|||
|
|
@ -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<string>(key);
|
||||
var geodata = await _redisService.GetAsync<PositionInfo>(key);
|
||||
if (geodata == null)
|
||||
{
|
||||
geodata = await _db.CopyNew().Queryable<PositionInfo>()
|
||||
.Where(s => s.Id == positionId)
|
||||
.Select(s => s.Region)
|
||||
.FirstAsync();
|
||||
await _redisService.SetAsync<string>(key, geodata);
|
||||
await _redisService.SetAsync<PositionInfo>(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;
|
||||
|
|
|
|||
|
|
@ -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
|
|||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="sqlSugarClient"></param>
|
||||
/// <param name="redisService"></param>
|
||||
public WhitListService(SqlSugarClient sqlSugarClient, RedisService redisService)
|
||||
{
|
||||
_db = sqlSugarClient;
|
||||
|
|
|
|||
Loading…
Reference in New Issue