天气阻飞时添加设备锁定人
parent
d6d7339bca
commit
60165516dc
|
|
@ -1,5 +1,6 @@
|
|||
using DocumentFormat.OpenXml.EMMA;
|
||||
using DocumentFormat.OpenXml.Math;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Cache;
|
||||
using Infrastructure.CloudSdk.minio;
|
||||
|
|
@ -15,6 +16,7 @@ using OpenAuth.App.ServiceApp.Response;
|
|||
using OpenAuth.Repository;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using SqlSugar;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
@ -557,6 +559,27 @@ namespace OpenAuth.App.ServiceApp
|
|||
|
||||
|
||||
#region 天气阻飞
|
||||
private MqttClientResp ParseClient(HashEntry[] entries)
|
||||
{
|
||||
if (entries == null || entries.Length == 0)
|
||||
return null;
|
||||
var dict = entries.ToDictionary(e => e.Name.ToString(), e => e.Value.ToString());
|
||||
dict.TryGetValue("ClientId", out var clientId);
|
||||
dict.TryGetValue("UserId", out var userId);
|
||||
dict.TryGetValue("UserName", out var userName);
|
||||
dict.TryGetValue("ConnectTime", out var connectTimeStr);
|
||||
dict.TryGetValue("DeviceSn", out var deviceSn);
|
||||
dict.TryGetValue("IsLock", out var isLockStr);
|
||||
return new MqttClientResp
|
||||
{
|
||||
ClientId = clientId ?? "",
|
||||
UserId = userId ?? "",
|
||||
UserName = userName ?? "",
|
||||
DeviceSn = deviceSn ?? "",
|
||||
ConnectTime = DateTime.TryParse(connectTimeStr, out var ct) ? ct : DateTime.MinValue,
|
||||
IsLock = bool.TryParse(isLockStr, out var lk) && lk
|
||||
};
|
||||
}
|
||||
//天气预报和是否有人在操作
|
||||
public async Task<Response<dynamic>> IsCanFly(string sn, string dock, string address = "兰山")
|
||||
{
|
||||
|
|
@ -567,8 +590,10 @@ namespace OpenAuth.App.ServiceApp
|
|||
bool islock = false;//是否有人在操作
|
||||
var existingLocked = await _redisCacheContext.SetMembersAsync("locked_devices");
|
||||
islock = existingLocked.Any(u => u == sn);
|
||||
//查找被谁锁定
|
||||
var entries = ParseClient(await _redisCacheContext.HashGetAllAsync($"client:{sn}"));
|
||||
if (islock)
|
||||
return new Response<dynamic> { Result = new { status = false, msg = "设备已锁定" } };
|
||||
return new Response<dynamic> { Result = new { status = false, msg = "设备已被" + entries?.UserName + "锁定" } };
|
||||
switch (dock)
|
||||
{
|
||||
case "Dock 1":
|
||||
|
|
|
|||
|
|
@ -48,33 +48,6 @@ namespace OpenAuth.WebApi.Model.mqtt
|
|||
username: username,
|
||||
password: password
|
||||
);
|
||||
////查询网关,订阅主题
|
||||
//var topics = new List<string>();
|
||||
//var gatewayList = await _app.GetGatewaysnList();
|
||||
|
||||
//foreach (var gateway in gatewayList)
|
||||
//{
|
||||
// topics.AddRange(new[]
|
||||
// {
|
||||
// $"thing/product/{gateway}/osd",
|
||||
// $"thing/product/{gateway}/events",
|
||||
// $"thing/product/{gateway}/requests",
|
||||
// $"thing/product/{gateway}/services_reply",
|
||||
// //$"thing/product/{gateway}/drc/up",
|
||||
// //$"thing/product/{gateway}/drc/down",
|
||||
// $"sys/product/{gateway}/status"
|
||||
// });
|
||||
//}
|
||||
//var snList = await _app.GetUavSn();
|
||||
|
||||
//foreach (var sn in snList)
|
||||
//{
|
||||
// topics.AddRange(new[]
|
||||
// {
|
||||
// // $"thing/product/1581F8HGX254V00A0BUY/osd",
|
||||
// $"thing/product/{sn}/osd"
|
||||
// });
|
||||
//}
|
||||
string[] topicList =
|
||||
{
|
||||
"thing/product/+/services_reply",
|
||||
|
|
|
|||
Loading…
Reference in New Issue