添加设备加入是否移动属性,过滤掉白名单,加入无人机跟设备的距离限制
This commit is contained in:
parent
4bbd55f677
commit
85bf5da2bc
|
|
@ -43,7 +43,11 @@ namespace LY.App.Model
|
|||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public double distance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否白名单
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_whitelist", ColumnDescription = "是否白名单")]
|
||||
public bool IsWhitelist { get; set; }
|
||||
/// <summary>
|
||||
/// ,#东向速度
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -69,6 +69,12 @@ namespace LY.App.Model
|
|||
/// 图片icon
|
||||
/// </summary>
|
||||
public string icon { get; set; }
|
||||
/// <summary>
|
||||
/// 是否是移动设备
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_move", ColumnDescription = "是否移动设备", IsNullable = true)]
|
||||
|
||||
public bool isMove { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -89,6 +95,7 @@ namespace LY.App.Model
|
|||
public string GraphQlEndpoint { get; set; }
|
||||
public string BrokerAddress { get; set; } // MQTT Broker 地址
|
||||
public string Topic { get; set; } // MQTT 主题
|
||||
public bool isMove { get; set; }
|
||||
/// <summary>
|
||||
/// 机型
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ app.UseCors("CorsPolicy");
|
|||
//异常中间件
|
||||
app.UseMiddleware<CustomErrorMiddleware>();
|
||||
//token验证中间件
|
||||
app.UseMiddleware<TokenValidationMiddleware>();
|
||||
app.UseMiddleware<TokenValidationMiddleware>();
|
||||
//执行匹配的端点
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ 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;
|
||||
|
|
@ -51,6 +52,7 @@ namespace LY.App.Service
|
|||
await _redisService.SetAsync(key, deviceinfo, TimeSpan.FromDays(1));
|
||||
}
|
||||
var entity = input.data.Adapt<List<Alarm>>();
|
||||
entity = entity.Where(s => checkDistance(s.drone_lat, s.drone_lon, deviceinfo.Lat, deviceinfo.Lon) == true).ToList();
|
||||
if (entity.Any())
|
||||
{
|
||||
foreach (var item in entity)
|
||||
|
|
@ -63,6 +65,7 @@ namespace LY.App.Service
|
|||
item.Time = input.time;
|
||||
item.distance = GisHelper.HaversineDistance(item.drone_lat, item.drone_lon, item.app_lat, item.app_lon);
|
||||
item.alarmLevel = await GetAlarmLevel(deviceinfo.PositionId, item.drone_lon, item.drone_lat);
|
||||
item.IsWhitelist = Iswhitlist(item.serial_number);
|
||||
}
|
||||
await _db.CopyNew().Insertable(entity).SplitTable().ExecuteReturnSnowflakeIdListAsync();
|
||||
//推送报警信息
|
||||
|
|
@ -71,6 +74,30 @@ namespace LY.App.Service
|
|||
|
||||
return new ApiResult();
|
||||
}
|
||||
/// <summary>
|
||||
/// 判断 距离是否在范围内
|
||||
/// </summary>
|
||||
/// <param name="lat"></param>
|
||||
/// <param name="lon"></param>
|
||||
/// <param name="d_lat"></param>
|
||||
/// <param name="d_lon"></param>
|
||||
/// <returns></returns>
|
||||
private bool checkDistance(double lat, double lon, double d_lat, double d_lon)
|
||||
{
|
||||
var maxDistance = Convert.ToDouble(_config["MaxDistance"]);
|
||||
var distance = GisHelper.HaversineDistance(lat, lon, d_lat, d_lon);
|
||||
return distance < maxDistance;
|
||||
}
|
||||
|
||||
private bool Iswhitlist(string serial_number)
|
||||
{
|
||||
var whitelist = _config["Whitelist"].Split(',');
|
||||
if (whitelist.Any())
|
||||
{
|
||||
return whitelist.Contains(serial_number);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算入侵级别
|
||||
|
|
@ -125,7 +152,7 @@ namespace LY.App.Service
|
|||
//更新 设备缓存
|
||||
var key = RedisKeyList.DeviceInfo(input.product_ad_id);
|
||||
var deviceinfo = await _redisService.GetAsync<DeviceEntity>(key);
|
||||
if (deviceinfo != null)
|
||||
if (deviceinfo != null && deviceinfo.isMove)
|
||||
{
|
||||
deviceinfo.Lat = input.product_lat;
|
||||
deviceinfo.Lon = input.product_lon;
|
||||
|
|
@ -186,7 +213,7 @@ namespace LY.App.Service
|
|||
DateTime endDate = currentDate.Date.AddDays(1).AddTicks(-1);
|
||||
//计算当天
|
||||
var todaywaring = await _db.Queryable<Alarm>().SplitTable()
|
||||
.Where(s => s.alarmLevel > 0)
|
||||
.Where(s => s.alarmLevel > 0 && s.IsWhitelist == false)
|
||||
.Where(s => s.CreateTime >= startDate && s.CreateTime <= endDate)
|
||||
.GroupBy(s => s.BatchId)
|
||||
.Select(s => s.BatchId).CountAsync();
|
||||
|
|
@ -196,7 +223,7 @@ namespace LY.App.Service
|
|||
// .Where(s => s.CreateTime >= startDate && s.CreateTime <= endDate);
|
||||
//计算总数
|
||||
var totalcount = _db.Queryable<Alarm>().SplitTable()
|
||||
.Where(s => s.alarmLevel > 0)
|
||||
.Where(s => s.alarmLevel > 0 && s.IsWhitelist == false)
|
||||
.GroupBy(s => s.BatchId)
|
||||
.Select(s => s.BatchId);
|
||||
//计算处理总数
|
||||
|
|
|
|||
|
|
@ -29,5 +29,8 @@
|
|||
"Weather": "https://weather.cma.cn/api/now/54511", //天气预报地址,中国气象
|
||||
"Vertify": 5, //登录失败次数
|
||||
"BatchId": 60, //无人机批次连续时间,如果超过这个时间,则变成下一个批次
|
||||
"Whitelist": "sn123,sn234", //白名单sn,用逗号分隔
|
||||
"MaxDistance": 3000, //最大距离,如果超过这个距离,探测到的无人机数据会被丢弃 单位:米
|
||||
|
||||
"SnowFlakeWordId": 1 //雪花算法的wordId,多台服务器时,需要配置不同的wordId,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue