Merge remote-tracking branch 'origin/main'
commit
b6f659ae47
|
|
@ -89,9 +89,84 @@ namespace OpenAuth.App.ServiceApp
|
|||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//使用网关
|
||||
public async Task<Response<LasaGateway>> GetGateway()
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
using (var db = UnitWork.CreateContext())
|
||||
{
|
||||
var info = await db.LasaGateway.AsQueryable().Where(r => r.BindStatus == 0).FirstAsync();
|
||||
|
||||
if (info != null)
|
||||
{
|
||||
return new Response<LasaGateway>
|
||||
{
|
||||
Code = 200,
|
||||
Message = "获取设备绑定码成功",
|
||||
Result = info
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
//如果网关不存在,则创建一个新的
|
||||
var newGateway = new LasaGateway
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
CreateTime = DateTime.Now,
|
||||
GatewayAccount="sdhc",
|
||||
GatewaySn = Guid.NewGuid().ToString("N").Substring(0, 8).ToUpper(), // 生成一个新的
|
||||
MqttGateway= "175.27.168.120:6011",
|
||||
MqttPassword = "",
|
||||
OrgId = "371300", // 默认组织ID
|
||||
BindStatus = 0 // 未绑定状态
|
||||
};
|
||||
await db.LasaGateway.InsertAsync(newGateway);
|
||||
if (db.Commit())
|
||||
{
|
||||
return new Response<LasaGateway>
|
||||
{
|
||||
Code = 200,
|
||||
Message = "获取设备绑定码成功",
|
||||
Result = newGateway
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Response<LasaGateway>
|
||||
{
|
||||
Code = 500,
|
||||
Message = "获取设备绑定码失败",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public async Task<bool> UpdateGateway(string gateway,string did)
|
||||
{
|
||||
using (var db = UnitWork.CreateContext())
|
||||
{
|
||||
var flag = await db.LasaGateway.UpdateAsync(it => new LasaGateway()
|
||||
{
|
||||
BindStatus = 1,
|
||||
Did = did,
|
||||
UpdateTime = DateTime.Now,
|
||||
}, it => it.GatewaySn == gateway);
|
||||
if (db.Commit())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
#region 健康报警
|
||||
//添加健康报警
|
||||
/// <summary>
|
||||
/// 添加健康报警
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddManageDeviceHms(List<LasaManageDeviceHms> info)
|
||||
{
|
||||
using (var db = UnitWork.CreateContext())
|
||||
|
|
@ -104,5 +179,24 @@ namespace OpenAuth.App.ServiceApp
|
|||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 日志
|
||||
/// <summary>
|
||||
/// 添加日志
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddLog(LasaLog info)
|
||||
{
|
||||
using (var db = UnitWork.CreateContext())
|
||||
{
|
||||
var flag = db.LasaLog.Insert(info);
|
||||
if (db.Commit())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,6 +96,18 @@ namespace OpenAuth.App.ServiceApp
|
|||
}
|
||||
}
|
||||
|
||||
//添加机场信息
|
||||
public bool AddDronePort(LasaDronePort info)
|
||||
{
|
||||
using (var db = UnitWork.CreateContext())
|
||||
{
|
||||
var flag = db.LasaDronePort.Insert(info);
|
||||
if (db.Commit())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -155,6 +167,18 @@ namespace OpenAuth.App.ServiceApp
|
|||
return new Response<bool> { Result = false, Message = "删除失败" };
|
||||
}
|
||||
}
|
||||
//添加无人机
|
||||
public bool AddLasaUav(LasaUav info)
|
||||
{
|
||||
using (var db = UnitWork.CreateContext())
|
||||
{
|
||||
var flag = db.LasaUav.Insert(info);
|
||||
if (db.Commit())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取任务列表
|
||||
|
|
|
|||
|
|
@ -12,8 +12,9 @@ namespace OpenAuth.Repository.Domain
|
|||
public string SerialNumber { get; set; }
|
||||
public string FirmwareVersion { get; set; }
|
||||
public int BindStatus { get; set; }
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
public long OrgId { get; set; }
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
public DateTime? CreateTime { get; set; }
|
||||
public string OrgId { get; set; }
|
||||
public string Sn { get; set; }
|
||||
public string DevicePicUrl { get; set; }
|
||||
public string Did { get; set; }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OpenAuth.Repository.Domain
|
||||
{
|
||||
[SugarTable("lasa_gateway")]
|
||||
public class LasaGateway
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public string Id { get; set; }
|
||||
/// <summary>
|
||||
/// 绑定状态
|
||||
/// </summary>
|
||||
public int BindStatus { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// Did
|
||||
/// </summary>
|
||||
public string Did { get; set; }
|
||||
/// <summary>
|
||||
/// 网关编号
|
||||
/// </summary>
|
||||
public string GatewayAccount { get; set; }
|
||||
/// <summary>
|
||||
/// 网关sn
|
||||
/// </summary>
|
||||
public string GatewaySn { get; set; }
|
||||
/// <summary>
|
||||
/// 网关地址
|
||||
/// </summary>
|
||||
public string MqttGateway { get; set; }
|
||||
/// <summary>
|
||||
/// 网关密码
|
||||
/// </summary>
|
||||
public string MqttPassword { get; set; }
|
||||
/// <summary>
|
||||
/// 网关账号
|
||||
/// </summary>
|
||||
public string MqttUserName { get; set; }
|
||||
/// <summary>
|
||||
/// 组织id
|
||||
/// </summary>
|
||||
public string OrgId { get; set; }
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OpenAuth.Repository.Domain
|
||||
{
|
||||
[SugarTable("lasa_log")]
|
||||
public class LasaLog
|
||||
{
|
||||
/// <summary>
|
||||
/// Desc:标识
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public string Id { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:专题
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string Topic { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:方法
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string Method { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:数据
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
[SugarColumn(IsJson = true)]
|
||||
public JsonObject Data { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -71,7 +71,9 @@ namespace OpenAuth.Repository
|
|||
public SugarRepositiry<LasaSpaceLockFly> LasaSpaceLockFly { get; set; }
|
||||
|
||||
public SugarRepositiry<LasaDeviceBindingCode> LasaDeviceBindingCode { get; set; }
|
||||
public SugarRepositiry<LasaGateway> LasaGateway { get; set; }
|
||||
public SugarRepositiry<LasaManageDeviceHms> LasaManageDeviceHms { get; set; }
|
||||
public SugarRepositiry<LasaLog> LasaLog { get; set; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using DocumentFormat.OpenXml.Math;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MQTTnet;
|
||||
using OpenAuth.App.ServiceApp;
|
||||
|
|
@ -29,6 +30,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Obsolete]
|
||||
public async Task<Response<LasaDeviceBindingCode>> GetDeviceBindingCode()
|
||||
{
|
||||
var result = new Response<LasaDeviceBindingCode>();
|
||||
|
|
@ -72,6 +74,27 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 机场注册 注册码生成
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
public async Task<Response<LasaGateway>> GetGateway()
|
||||
{
|
||||
var result = new Response<LasaGateway>();
|
||||
try
|
||||
{
|
||||
result = await _app.GetGateway();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.Message;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换相机
|
||||
|
|
@ -83,31 +106,31 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
Response<int> response = new Response<int>();
|
||||
try
|
||||
{
|
||||
var videoids = zhiboReq.videoId.Split("/");
|
||||
var topicRequest = $"thing/product/" + videoids[0] +"/services";
|
||||
var requestData = new
|
||||
var videoids = zhiboReq.videoId.Split("/");
|
||||
var topicRequest = $"thing/product/" + videoids[0] + "/services";
|
||||
var requestData = new
|
||||
{
|
||||
bid = Guid.NewGuid().ToString(),
|
||||
method = "live_camera_change",
|
||||
tid = Guid.NewGuid().ToString(),
|
||||
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||
data = new
|
||||
{
|
||||
bid = Guid.NewGuid().ToString(),
|
||||
method = "live_camera_change",
|
||||
tid = Guid.NewGuid().ToString(),
|
||||
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||
data = new
|
||||
{
|
||||
camera_position = zhiboReq.position,
|
||||
video_id = zhiboReq.videoId
|
||||
}
|
||||
};
|
||||
string payload = JsonSerializer.Serialize(requestData);
|
||||
await _mqttClientManager.PublishAsync(topicRequest, payload);
|
||||
camera_position = zhiboReq.position,
|
||||
video_id = zhiboReq.videoId
|
||||
}
|
||||
};
|
||||
string payload = JsonSerializer.Serialize(requestData);
|
||||
await _mqttClientManager.PublishAsync(topicRequest, payload);
|
||||
|
||||
var topicRequest1 = $"thing/product/" + videoids[0] +"/services_reply";
|
||||
var topicRequest1 = $"thing/product/" + videoids[0] + "/services_reply";
|
||||
|
||||
await _mqttClientManager.SubscribeAsync(topicRequest1, async (args) =>
|
||||
{
|
||||
var payload = args.ApplicationMessage.Payload;
|
||||
var message = Encoding.UTF8.GetString(payload);
|
||||
Console.WriteLine($"收到主题 [{args.ApplicationMessage.Topic}] 的消息: {message}");
|
||||
await Task.CompletedTask;
|
||||
await Task.CompletedTask;
|
||||
});
|
||||
response.Result = 0;
|
||||
|
||||
|
|
@ -118,7 +141,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
response.Message = ex.Message;
|
||||
}
|
||||
return response; ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -169,7 +192,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
response.Code = 500;
|
||||
response.Message = ex.Message;
|
||||
}
|
||||
return response;
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +242,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
response.Code = 500;
|
||||
response.Message = ex.Message;
|
||||
}
|
||||
return response;
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -229,7 +252,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Response<int>> EndLive( Zhibo zhiboReq)
|
||||
public async Task<Response<int>> EndLive(Zhibo zhiboReq)
|
||||
{
|
||||
Response<int> response = new Response<int>();
|
||||
try
|
||||
|
|
@ -237,19 +260,19 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
var videoids = zhiboReq.videoId.Split("/");
|
||||
var topicRequest = $"thing/product/" + videoids[0] + "/services";
|
||||
var requestData = new
|
||||
{
|
||||
bid = Guid.NewGuid().ToString(),
|
||||
method = "live_stop_push",
|
||||
tid = Guid.NewGuid().ToString(),
|
||||
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||
data = new
|
||||
{
|
||||
bid = Guid.NewGuid().ToString(),
|
||||
method = "live_stop_push",
|
||||
tid = Guid.NewGuid().ToString(),
|
||||
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||
data = new
|
||||
{
|
||||
|
||||
video_id = zhiboReq.videoId
|
||||
}
|
||||
};
|
||||
string payload = JsonSerializer.Serialize(requestData);
|
||||
await _mqttClientManager.PublishAsync(topicRequest, payload);
|
||||
|
||||
video_id = zhiboReq.videoId
|
||||
}
|
||||
};
|
||||
string payload = JsonSerializer.Serialize(requestData);
|
||||
await _mqttClientManager.PublishAsync(topicRequest, payload);
|
||||
|
||||
var topicRequest1 = $"thing/product/" + videoids[0] + "/services_reply";
|
||||
|
||||
|
|
@ -262,8 +285,8 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
});
|
||||
|
||||
response.Result = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -26,9 +26,13 @@ namespace OpenAuth.WebApi.Model.mqtt
|
|||
);
|
||||
|
||||
await mqttCenter.ConnectAndSubscribeAsync(
|
||||
//"thing/product/8UUXN5400A079H/osd",
|
||||
//"thing/product/8UUXN5400A079H/services",
|
||||
"thing/product/8UUXN5400A079H/events1"
|
||||
// "thing/product/8UUXN5400A079H/osd",
|
||||
// "thing/product/1581F8HGX254V00A0BUY/osd"
|
||||
// "thing/product/8UUXN5400A079H/services",
|
||||
//"thing/product/8UUXN5400A079H/services_reply"
|
||||
"thing/product/8UUXN5400A079H/requests",
|
||||
"thing/product/8UUXN5400A079H/services_reply"
|
||||
//"thing/product/8UUXN5400A079H/events"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,21 @@
|
|||
using Infrastructure.CloudSdk.mqttmessagecenter;
|
||||
using Infrastructure.Cache;
|
||||
using Infrastructure.CloudSdk.mqttmessagecenter;
|
||||
using OpenAuth.App.ServiceApp;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace OpenAuth.WebApi.Model.mqtt
|
||||
{
|
||||
public class ThingOsdHandler : IMqttMessageHandler
|
||||
{
|
||||
private readonly ILogger<ThingRequestHandler> _logger;
|
||||
|
||||
public ThingOsdHandler(ILogger<ThingRequestHandler> logger)
|
||||
AirportMaintenanceApp _app;
|
||||
private readonly ICacheContext _cache;
|
||||
public ThingOsdHandler(ILogger<ThingRequestHandler> logger, AirportMaintenanceApp app, ICacheContext cache)
|
||||
{
|
||||
_logger = logger;
|
||||
_app = app;
|
||||
_cache = cache;
|
||||
}
|
||||
|
||||
public bool CanHandle(string topic)
|
||||
|
|
@ -20,10 +27,26 @@ namespace OpenAuth.WebApi.Model.mqtt
|
|||
{
|
||||
_logger.LogError($"[osd] Topic={topic}, Payload={payload}");
|
||||
Console.WriteLine($"[osd] Topic={topic}, Payload={payload}");
|
||||
if (payload.Contains(""))
|
||||
var root = JsonNode.Parse(payload)?.AsObject();
|
||||
_app.AddLog(new LasaLog
|
||||
{
|
||||
|
||||
}
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
Topic = topic,
|
||||
Method = root["method"]?.ToString() ?? "",
|
||||
CreateTime = DateTime.Now,
|
||||
Data = root
|
||||
});
|
||||
var sub_device = root["data"]?["sub_device"]?.ToString() ?? "";
|
||||
if (!string.IsNullOrEmpty(sub_device))
|
||||
{
|
||||
var data = new
|
||||
{
|
||||
device_sn = root["data"]?["sub_device"]?["device_sn"]?.ToString() ?? "",
|
||||
device_online_status = root["data"]?["sub_device"]?["device_online_status"]?.ToString() ?? "",
|
||||
mode_code = root["data"]?["mode_code"]?.ToString() ?? "",
|
||||
};
|
||||
var a = _cache.Set("DeviceState", data, DateTime.Now.AddMinutes(1));
|
||||
}
|
||||
// 自定义处理逻辑
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using Infrastructure.CloudSdk.mqttmessagecenter;
|
||||
using OpenAuth.App.ServiceApp;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
|
|
@ -10,12 +11,14 @@ namespace OpenAuth.WebApi.Model.mqtt
|
|||
private readonly ILogger<ThingRequestHandler> _logger;
|
||||
private readonly MqttClientManager _mqttClientManager;
|
||||
AirportMaintenanceApp _app;
|
||||
ManageApp _manageApp;
|
||||
|
||||
public ThingRequestHandler(ILogger<ThingRequestHandler> logger, MqttClientManager mqttClientManager, AirportMaintenanceApp app)
|
||||
public ThingRequestHandler(ILogger<ThingRequestHandler> logger, MqttClientManager mqttClientManager, AirportMaintenanceApp app, ManageApp manageApp)
|
||||
{
|
||||
_logger = logger;
|
||||
_mqttClientManager = mqttClientManager;
|
||||
_app = app;
|
||||
_manageApp = manageApp;
|
||||
}
|
||||
|
||||
public bool CanHandle(string topic)
|
||||
|
|
@ -23,7 +26,7 @@ namespace OpenAuth.WebApi.Model.mqtt
|
|||
return topic.Contains("/requests");
|
||||
}
|
||||
string bid, tid, previousgateway;
|
||||
int timestamp;
|
||||
long timestamp;
|
||||
public async Task HandleAsync(string topic, string payload)
|
||||
{
|
||||
_logger.LogError($"[Request] Topic={topic}, Payload={payload}");
|
||||
|
|
@ -41,13 +44,13 @@ namespace OpenAuth.WebApi.Model.mqtt
|
|||
}
|
||||
bid = root["bid"]?.ToString() ?? "";
|
||||
tid = root["tid"]?.ToString() ?? "";
|
||||
timestamp = int.Parse(root["timestamp"]?.ToString() ?? "0");
|
||||
timestamp = long.Parse(root["timestamp"]?.ToString() ?? "0");
|
||||
var requestData = new
|
||||
{
|
||||
bid = bid,
|
||||
method = "config",
|
||||
tid = tid,
|
||||
timestamp = timestamp,
|
||||
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||
gateway = gateway,
|
||||
data = new
|
||||
{
|
||||
|
|
@ -61,11 +64,33 @@ namespace OpenAuth.WebApi.Model.mqtt
|
|||
};
|
||||
string payloadreq = JsonSerializer.Serialize(requestData);
|
||||
await _mqttClientManager.PublishAsync($"thing/product/{gateway}/requests_reply", payloadreq);
|
||||
await _app.UpdateCodeStatus(gateway);
|
||||
await _app.UpdateGateway(gateway, tid);
|
||||
}
|
||||
if (payload.Contains("airport_bind_status"))
|
||||
{
|
||||
//解析返回的设备sn 先不解析,先测试绑定
|
||||
var root = JsonNode.Parse(payload)?.AsObject();
|
||||
if (root == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// 从 data.devices 中提取 sn 列表
|
||||
var snList = root?["data"]?["devices"]?.AsArray()
|
||||
.Select(d => d?["sn"]?.ToString())
|
||||
.Where(sn => !string.IsNullOrEmpty(sn))
|
||||
.ToList();
|
||||
|
||||
// 生成 bind_status 对象列表
|
||||
var bindStatusList = snList?.Select(sn => new
|
||||
{
|
||||
device_callsign = "山东慧创",
|
||||
is_device_bind_organization = true,
|
||||
organization_id = "379",
|
||||
organization_name = "山东慧创",
|
||||
sn = sn
|
||||
}).ToArray();
|
||||
|
||||
// 构造最终请求对象
|
||||
var requestData = new
|
||||
{
|
||||
bid = Guid.NewGuid().ToString(),
|
||||
|
|
@ -73,25 +98,7 @@ namespace OpenAuth.WebApi.Model.mqtt
|
|||
{
|
||||
output = new
|
||||
{
|
||||
bind_status = new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
device_callsign = "山东慧创",
|
||||
is_device_bind_organization = true,
|
||||
organization_id = "379",
|
||||
organization_name = "山东慧创",
|
||||
sn = "8UUXN5400A079H"
|
||||
},
|
||||
new
|
||||
{
|
||||
device_callsign = "山东慧创",
|
||||
is_device_bind_organization = true,
|
||||
organization_id = "379",
|
||||
organization_name = "山东慧创",
|
||||
sn = "1581F8HGX254V00A0BUY"
|
||||
}
|
||||
}
|
||||
bind_status = bindStatusList
|
||||
},
|
||||
result = 0
|
||||
},
|
||||
|
|
@ -104,8 +111,10 @@ namespace OpenAuth.WebApi.Model.mqtt
|
|||
await _mqttClientManager.PublishAsync($"thing/product/{getway}/requests_reply", payloadreq);
|
||||
|
||||
}
|
||||
if (payload.Contains("airport_organization_get"))
|
||||
{
|
||||
if (payload.Contains("airport_organization_get"))//
|
||||
{
|
||||
var root = JsonNode.Parse(payload)?.AsObject();
|
||||
|
||||
var requestData = new
|
||||
{
|
||||
bid = Guid.NewGuid().ToString(),
|
||||
|
|
@ -128,6 +137,46 @@ namespace OpenAuth.WebApi.Model.mqtt
|
|||
}
|
||||
if (payload.Contains("airport_organization_bind"))
|
||||
{
|
||||
|
||||
// 解析 JSON
|
||||
var root = JsonNode.Parse(payload)?.AsObject();
|
||||
// 获取 bind_devices 数组
|
||||
var bindDevices = root?["data"]?["bind_devices"]?.AsArray();
|
||||
string dronesn = "", uavsn = "";
|
||||
LasaDronePort lasaDronePort = new LasaDronePort();
|
||||
LasaUav lasaUav = new LasaUav();
|
||||
if (bindDevices != null)
|
||||
{
|
||||
foreach (var device in bindDevices)
|
||||
{
|
||||
var obj = device?.AsObject();
|
||||
if (obj["device_model_key"].ToString().Contains("3-"))
|
||||
{
|
||||
lasaDronePort.Id = Guid.NewGuid().ToString();
|
||||
lasaDronePort.OrgId = obj["organization_id"]?.ToString();
|
||||
lasaDronePort.CreateTime = DateTime.Now;
|
||||
lasaDronePort.IsDelete = false;
|
||||
lasaDronePort.TypeId = "Dock 3";
|
||||
lasaDronePort.Sn = obj["sn"].ToString();
|
||||
lasaDronePort.BindStatus = 1;
|
||||
lasaDronePort.Name = "机场";
|
||||
dronesn = obj["sn"].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
lasaUav.Id = Guid.NewGuid().ToString();
|
||||
lasaUav.IsDelete = false;
|
||||
//lasaUav.TypeId = obj["device_model_key"].ToString();
|
||||
lasaUav.TypeId = "M4TD";
|
||||
lasaUav.Sn = obj["sn"].ToString();
|
||||
lasaUav.PId = lasaDronePort.Id;
|
||||
lasaUav.Name = "飞行器";
|
||||
uavsn = obj["sn"].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
_manageApp.AddDronePort(lasaDronePort);
|
||||
_manageApp.AddLasaUav(lasaUav);
|
||||
var requestData = new
|
||||
{
|
||||
bid = Guid.NewGuid().ToString(),
|
||||
|
|
@ -140,12 +189,12 @@ namespace OpenAuth.WebApi.Model.mqtt
|
|||
new
|
||||
{
|
||||
err_code = 210231,
|
||||
sn = "8UUXN5400A079H"
|
||||
sn = dronesn
|
||||
},
|
||||
new
|
||||
{
|
||||
err_code = 210231,
|
||||
sn = "1581F8HGX254V00A0BUY"
|
||||
sn = uavsn
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
using Infrastructure.CloudSdk.mqttmessagecenter;
|
||||
using OpenAuth.WebApi.Model.mqtt.ModelResponse;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace OpenAuth.WebApi.Model.mqtt
|
||||
{
|
||||
|
|
@ -13,13 +16,17 @@ namespace OpenAuth.WebApi.Model.mqtt
|
|||
|
||||
public bool CanHandle(string topic)
|
||||
{
|
||||
return topic.Contains("/services");
|
||||
return topic.Contains("/services_reply");
|
||||
}
|
||||
|
||||
public Task HandleAsync(string topic, string payload)
|
||||
{
|
||||
_logger.LogError($"[Service] Topic={topic}, Payload={payload}");
|
||||
Console.WriteLine($"[Service] Topic={topic}, Payload={payload}");
|
||||
if (payload.Contains("live_start_push"))//直播
|
||||
{
|
||||
var root = JsonNode.Parse(payload)?.AsObject();
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ namespace OpenAuth.WebApi
|
|||
|
||||
//services.AddSingleton<IMqttMessageHandler, ThingRequestHandler>();
|
||||
//services.AddSingleton<IMqttMessageHandler, ThingServiceHandler>();
|
||||
//services.AddSingleton<IMqttMessageHandler, ThingOsdHandler>();
|
||||
services.AddSingleton<IMqttMessageHandler, ThingOsdHandler>();
|
||||
//services.AddSingleton<IMqttMessageHandler, ThingEventHandler>();
|
||||
services.AddHostedService<MqttHostedService>();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue