接收日志
parent
779fe62e2a
commit
ba0ce4671a
|
|
@ -1,22 +1,23 @@
|
|||
using OpenAuth.App.BaseApp.Base;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using DocumentFormat.OpenXml.EMMA;
|
||||
using DocumentFormat.OpenXml.Math;
|
||||
using Infrastructure;
|
||||
using Infrastructure.CloudSdk.minio;
|
||||
using Infrastructure.Extensions;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using OpenAuth.App.BaseApp.Base;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.ServiceApp.Response;
|
||||
using OpenAuth.Repository;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenAuth.App.Interface;
|
||||
using SqlSugar;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.ServiceApp.Response;
|
||||
using DocumentFormat.OpenXml.EMMA;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Infrastructure.Extensions;
|
||||
using DocumentFormat.OpenXml.Math;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Infrastructure.CloudSdk.minio;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace OpenAuth.App.ServiceApp
|
||||
{
|
||||
|
|
@ -445,7 +446,7 @@ namespace OpenAuth.App.ServiceApp
|
|||
}
|
||||
#endregion
|
||||
|
||||
public async Task<Response<PageInfo<List<LasaMediaFile>>>> GetMediaFile(string flightId,string taskId, string airId, string device,
|
||||
public async Task<Response<PageInfo<List<LasaMediaFile>>>> GetMediaFile(string flightId, string taskId, string airId, string device,
|
||||
int? type, string picname, DateTime? startTime, DateTime? endTime, int page, int limit, string parentKey, int? objectKeyExist)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
|
|
@ -548,5 +549,47 @@ namespace OpenAuth.App.ServiceApp
|
|||
await _client.Ado.ExecuteCommandAsync(sql);
|
||||
return new Response<string> { Result = "修改成功!" };
|
||||
}
|
||||
|
||||
|
||||
#region 天气阻飞
|
||||
//天气预报和是否有人在操作
|
||||
//public async Task<Response<bool>> IsCanFly(string sn, string dock, string address = "兰山")
|
||||
//{
|
||||
// var rainThreshforecast = 3; // 天气预报雨量
|
||||
// var windSpeedThresh = 12;// 机场设定雨量
|
||||
// double weatherWindSpeedforecast = 0; // 天气预报风速
|
||||
// double weatherWindSpeedThre = 12;// 机场设定风速
|
||||
// switch (dock)
|
||||
// {
|
||||
// case "Dock":
|
||||
// weatherWindSpeedThre = 12;
|
||||
// break;
|
||||
// case "Dock 2":
|
||||
// weatherWindSpeedThre = 8;
|
||||
// break;
|
||||
// case "Dock 3":
|
||||
// weatherWindSpeedThre = 8;
|
||||
// break;
|
||||
// }
|
||||
// using (var httpClient = new HttpClient())
|
||||
// {
|
||||
// var response = await httpClient.GetAsync(
|
||||
// $"http://v1.yiketianqi.com/api?unescape=1&version=v61&appid=84261622&appsecret=k0WPY4Cx&city={address}");
|
||||
// if (response.IsSuccessStatusCode)
|
||||
// {
|
||||
// var content = await response.Content.ReadAsStringAsync();
|
||||
// var weather = Newtonsoft.Json.JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(content);
|
||||
// var winMeterStr =
|
||||
// weather.GetValue("win_meter")?.Value<string>(); //风速
|
||||
// if (!string.IsNullOrEmpty(winMeterStr))
|
||||
// {
|
||||
// weatherWindSpeedforecast = int.Parse(winMeterStr.Replace("km/h", "")) / 3.6;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
//}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -25,6 +25,10 @@ namespace OpenAuth.App.ServiceApp.Response
|
|||
/// </summary>
|
||||
public DateTime ConnectTime { get; set; }
|
||||
/// <summary>
|
||||
/// 设备sn
|
||||
/// </summary>
|
||||
public string DeviceSn { get; set; }
|
||||
/// <summary>
|
||||
/// 是否控制
|
||||
/// </summary>
|
||||
public bool IsLock { get; set; }
|
||||
|
|
|
|||
|
|
@ -632,6 +632,115 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加修改mqtt客户端信息 设备为主
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
public async Task<Response<bool>> AddOrUpdateRedisDevice(MqttClientResp info)
|
||||
{
|
||||
var result = new Response<bool>();
|
||||
try
|
||||
{
|
||||
var clientKey = $"client:{info.DeviceSn}";
|
||||
string lockSetKey = "locked_devices";
|
||||
|
||||
// 查询所有锁定用户
|
||||
var existingLocked = await _cache.SetMembersAsync(lockSetKey);
|
||||
|
||||
// 如果设备锁定,并且锁定的用户不是当前用户,则拒绝
|
||||
if (existingLocked.Length > 0 && info.IsLock == true)
|
||||
{
|
||||
bool isCurrentUserLocked = existingLocked.Any(u => u == info.DeviceSn);
|
||||
if (isCurrentUserLocked)
|
||||
{
|
||||
result.Code = 400;
|
||||
result.Message = "已有其他用户处于锁定状态,不能添加新的锁定用户。";
|
||||
result.Result = false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// 存客户端信息
|
||||
_cache.HashSetAsync(clientKey, new HashEntry[]
|
||||
{
|
||||
new("ClientId", info.ClientId),
|
||||
new("UserId", info.UserId),
|
||||
new("UserName", info.UserName),
|
||||
new("ConnectTime", info.ConnectTime.ToString("O")),
|
||||
new("IsLock", info.IsLock ? "true" : "false")
|
||||
});
|
||||
|
||||
if (info.IsLock)
|
||||
{
|
||||
await _cache.SetAddAsync(lockSetKey, info.DeviceSn);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _cache.SetRemoveAsync(lockSetKey, info.DeviceSn);
|
||||
}
|
||||
|
||||
result.Result = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.Message;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取当前用户mqtt客户端信息
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task<Response<MqttClientResp>> GetRedisDevice(string id)
|
||||
{
|
||||
var result = new Response<MqttClientResp>();
|
||||
try
|
||||
{
|
||||
result.Result = ParseClient(await _cache.HashGetAllAsync($"client:{id}"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.Message;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取所有锁定的用户客户端信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task<List<MqttClientResp>> GetLockedDeviceClients()
|
||||
{
|
||||
var userIds = await _cache.SetMembersAsync("locked_devices");
|
||||
|
||||
var result = new List<MqttClientResp>();
|
||||
|
||||
foreach (var userId in userIds)
|
||||
{
|
||||
var entries = await _cache.HashGetAllAsync($"client:{userId}");
|
||||
if (entries.Length > 0)
|
||||
result.Add(ParseClient(entries));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
//只有天气阻飞
|
||||
//public async Task<Response<bool>> IsCanFly(string address,string sn,string dock)
|
||||
//{
|
||||
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 获取告警信息
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ namespace OpenAuth.WebApi
|
|||
#endregion
|
||||
|
||||
#region Quartz
|
||||
services.AddHostedService<QuartzService>();
|
||||
//services.AddHostedService<QuartzService>();
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue