天气阻飞
parent
674ce9f564
commit
2e2badf277
|
|
@ -1,10 +1,12 @@
|
||||||
using DocumentFormat.OpenXml.EMMA;
|
using DocumentFormat.OpenXml.EMMA;
|
||||||
using DocumentFormat.OpenXml.Math;
|
using DocumentFormat.OpenXml.Math;
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
|
using Infrastructure.Cache;
|
||||||
using Infrastructure.CloudSdk.minio;
|
using Infrastructure.CloudSdk.minio;
|
||||||
using Infrastructure.Extensions;
|
using Infrastructure.Extensions;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NPOI.SS.Formula.Functions;
|
using NPOI.SS.Formula.Functions;
|
||||||
using OpenAuth.App.BaseApp.Base;
|
using OpenAuth.App.BaseApp.Base;
|
||||||
|
|
@ -26,14 +28,16 @@ namespace OpenAuth.App.ServiceApp
|
||||||
private readonly IConfiguration _configuration;
|
private readonly IConfiguration _configuration;
|
||||||
private readonly ISqlSugarClient _client;
|
private readonly ISqlSugarClient _client;
|
||||||
private readonly MinioService _minioService;
|
private readonly MinioService _minioService;
|
||||||
|
private readonly RedisCacheContext _redisCacheContext;
|
||||||
|
|
||||||
public AirportMaintenanceApp(MinioService minioService, ISqlSugarClient client,
|
public AirportMaintenanceApp(MinioService minioService, ISqlSugarClient client, RedisCacheContext redisCacheContext,
|
||||||
ISugarUnitOfWork<SugarDbContext> unitWork, IConfiguration configuration,
|
ISugarUnitOfWork<SugarDbContext> unitWork, IConfiguration configuration,
|
||||||
ISimpleClient<LasaDronePort> repository, IAuth auth) : base(unitWork, repository, auth)
|
ISimpleClient<LasaDronePort> repository, IAuth auth) : base(unitWork, repository, auth)
|
||||||
{
|
{
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_client = client;
|
_client = client;
|
||||||
_minioService = minioService;
|
_minioService = minioService;
|
||||||
|
_redisCacheContext = redisCacheContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取设备绑定码
|
//获取设备绑定码
|
||||||
|
|
@ -553,43 +557,58 @@ namespace OpenAuth.App.ServiceApp
|
||||||
|
|
||||||
#region 天气阻飞
|
#region 天气阻飞
|
||||||
//天气预报和是否有人在操作
|
//天气预报和是否有人在操作
|
||||||
//public async Task<Response<bool>> IsCanFly(string sn, string dock, string address = "兰山")
|
public async Task<Response<bool>> IsCanFly(string sn, string dock, string address = "兰山")
|
||||||
//{
|
{
|
||||||
// var rainThreshforecast = 3; // 天气预报雨量
|
var rainThreshforecast = 3; // 天气预报雨量
|
||||||
// var windSpeedThresh = 12;// 机场设定雨量
|
var windSpeedThresh = 12;// 机场设定雨量
|
||||||
// double weatherWindSpeedforecast = 0; // 天气预报风速
|
double weatherWindSpeedforecast = 0; // 天气预报风速
|
||||||
// double weatherWindSpeedThre = 12;// 机场设定风速
|
double weatherWindSpeedThre = 12;// 机场设定风速
|
||||||
// switch (dock)
|
switch (dock)
|
||||||
// {
|
{
|
||||||
// case "Dock":
|
case "Dock":
|
||||||
// weatherWindSpeedThre = 12;
|
weatherWindSpeedThre = 12;
|
||||||
// break;
|
break;
|
||||||
// case "Dock 2":
|
case "Dock 2":
|
||||||
// weatherWindSpeedThre = 8;
|
weatherWindSpeedThre = 8;
|
||||||
// break;
|
break;
|
||||||
// case "Dock 3":
|
case "Dock 3":
|
||||||
// weatherWindSpeedThre = 8;
|
weatherWindSpeedThre = 8;
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// using (var httpClient = new HttpClient())
|
using (var httpClient = new HttpClient())
|
||||||
// {
|
{
|
||||||
// var response = await httpClient.GetAsync(
|
var response = await httpClient.GetAsync($"http://v1.yiketianqi.com/api?unescape=1&version=v61&appid=84261622&appsecret=k0WPY4Cx&city={address}");
|
||||||
// $"http://v1.yiketianqi.com/api?unescape=1&version=v61&appid=84261622&appsecret=k0WPY4Cx&city={address}");
|
if (response.IsSuccessStatusCode)
|
||||||
// if (response.IsSuccessStatusCode)
|
{
|
||||||
// {
|
var content = await response.Content.ReadAsStringAsync();
|
||||||
// var content = await response.Content.ReadAsStringAsync();
|
var weather = Newtonsoft.Json.JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(content);
|
||||||
// var weather = Newtonsoft.Json.JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(content);
|
var winMeterStr =
|
||||||
// var winMeterStr =
|
weather.GetValue("win_meter")?.Value<string>(); //风速
|
||||||
// weather.GetValue("win_meter")?.Value<string>(); //风速
|
if (!string.IsNullOrEmpty(winMeterStr))
|
||||||
// if (!string.IsNullOrEmpty(winMeterStr))
|
{
|
||||||
// {
|
weatherWindSpeedforecast = int.Parse(winMeterStr.Replace("km/h", "")) / 3.6;
|
||||||
// weatherWindSpeedforecast = int.Parse(winMeterStr.Replace("km/h", "")) / 3.6;
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
//解析osd的雨量和风速数据
|
||||||
|
var info = _redisCacheContext.Get<string>(sn + "_osd");
|
||||||
|
if (!string.IsNullOrEmpty(info))
|
||||||
|
{
|
||||||
|
var dataObject = JsonConvert.DeserializeObject<JObject>(info);
|
||||||
|
var windSpeed = dataObject["data"]?["wind_speed"]?.Value<float>(); // m/s
|
||||||
|
var rainfall = dataObject["data"]?["rainfall"]?.Value<int>();
|
||||||
|
if (windSpeedThresh <= windSpeed || rainThreshforecast <= rainfall || weatherWindSpeedThre <= weatherWindSpeedforecast)
|
||||||
|
{
|
||||||
|
return new Response<bool> { Result = false,Message= "当前天气条件不允许起飞" };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new Response<bool> { Result = true, Message = "当前天气条件允许起飞" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Response<bool> { Result = true, Message = "当前天气条件允许起飞" };
|
||||||
|
|
||||||
|
}
|
||||||
//}
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -736,11 +736,29 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
//只有天气阻飞
|
/// <summary>
|
||||||
//public async Task<Response<bool>> IsCanFly(string address,string sn,string dock)
|
/// 天气阻飞
|
||||||
//{
|
/// </summary>
|
||||||
|
/// <param name="address">机场所在的地址,比如兰山</param>
|
||||||
//}
|
/// <param name="sn">机场sn</param>
|
||||||
|
/// <param name="dock">机场类型,Dock 1,Dock 2,Dock 3</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
[AllowAnonymous]
|
||||||
|
public async Task<Response<bool>> IsCanFly(string address, string sn, string dock)
|
||||||
|
{
|
||||||
|
var result = new Response<bool>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = await _app.IsCanFly(sn, dock, address);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.Code = 500;
|
||||||
|
result.Message = ex.Message;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 获取告警信息
|
#region 获取告警信息
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,12 @@ namespace OpenAuth.WebApi.Model.mqtt
|
||||||
TaskId = root["TaskId"]?.ToString() ?? "",
|
TaskId = root["TaskId"]?.ToString() ?? "",
|
||||||
CreateTime = DateTime.Now,
|
CreateTime = DateTime.Now,
|
||||||
CreateId = long.Parse((root["CreateId"]?.ToString() ?? "0")),
|
CreateId = long.Parse((root["CreateId"]?.ToString() ?? "0")),
|
||||||
Data = root["Data"]?.ToString() ?? "",
|
Data = Newtonsoft.Json.JsonConvert.SerializeObject(root["Data"]),
|
||||||
});
|
});
|
||||||
|
//var info = Newtonsoft.Json.JsonConvert.DeserializeObject<LasaControlOperation>(payload);
|
||||||
|
//info.Id = Guid.NewGuid().ToString();
|
||||||
|
//info.CreateTime = DateTime.Now;
|
||||||
|
//await _app.AddOperationLog(info);
|
||||||
// 自定义处理逻辑
|
// 自定义处理逻辑
|
||||||
//return Task.CompletedTask;
|
//return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ namespace OpenAuth.WebApi
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
services.AddHostedService<DelayedExecutionService>();
|
services.AddHostedService<DelayedExecutionService>();
|
||||||
|
|
||||||
#region rabbitmq
|
#region rabbitmq
|
||||||
//services.AddSingleton<RabbitMqListenerService>();
|
//services.AddSingleton<RabbitMqListenerService>();
|
||||||
//services.AddHostedService(sp => sp.GetRequiredService<RabbitMqListenerService>());
|
//services.AddHostedService(sp => sp.GetRequiredService<RabbitMqListenerService>());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue