LASAPlatform/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceControlle...

841 lines
29 KiB
C#
Raw Normal View History

2025-06-26 11:28:43 +08:00
using DocumentFormat.OpenXml.EMMA;
using DocumentFormat.OpenXml.Math;
2025-06-19 14:47:46 +08:00
using DocumentFormat.OpenXml.Spreadsheet;
2025-06-12 14:33:37 +08:00
using Infrastructure;
2025-06-26 11:28:43 +08:00
using Infrastructure.Cache;
2025-06-18 15:44:13 +08:00
using Microsoft.AspNetCore.Authorization;
2025-06-12 14:33:37 +08:00
using Microsoft.AspNetCore.Mvc;
using MQTTnet;
using OpenAuth.App.ServiceApp;
2025-06-26 11:28:43 +08:00
using OpenAuth.App.ServiceApp.Response;
2025-06-12 14:33:37 +08:00
using OpenAuth.Repository.Domain;
2025-06-26 11:28:43 +08:00
using StackExchange.Redis;
2025-06-16 15:12:06 +08:00
using System.Text;
2025-06-12 14:33:37 +08:00
using System.Text.Json;
2025-06-26 11:28:43 +08:00
using System.Threading.Tasks;
2025-07-24 14:24:32 +08:00
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.PixelFormats;
using Minio;
using Infrastructure.CloudSdk.minio;
2025-06-12 14:33:37 +08:00
namespace OpenAuth.WebApi.Controllers.ServiceControllers
{
/// <summary>
/// 机场运维
/// </summary>
[Route("api/[controller]/[action]")]
[ApiController]
public class AirportMaintenanceController : ControllerBase
{
private readonly AirportMaintenanceApp _app;
private readonly MqttClientManager _mqttClientManager;
2025-06-19 14:47:46 +08:00
private readonly MqttMessageCenter _mqttCenter;
2025-06-26 11:28:43 +08:00
private readonly RedisCacheContext _cache;
2025-07-24 14:24:32 +08:00
private readonly HttpClient _httpClient;
private readonly MinioService _minioService;
2025-06-12 14:33:37 +08:00
2025-08-15 13:49:54 +08:00
public AirportMaintenanceController(AirportMaintenanceApp app, MqttClientManager mqttClientManager,
MqttMessageCenter mqttCenter, RedisCacheContext cache, HttpClient httpClient, MinioService minioService)
2025-06-12 14:33:37 +08:00
{
_app = app;
_mqttClientManager = mqttClientManager;
2025-06-19 14:47:46 +08:00
_mqttCenter = mqttCenter;
2025-06-26 11:28:43 +08:00
_cache = cache;
2025-07-24 14:24:32 +08:00
_httpClient = httpClient;
_minioService = minioService;
2025-06-12 14:33:37 +08:00
}
2025-08-15 13:49:54 +08:00
2025-06-12 15:58:24 +08:00
/// <summary>
/// 机场注册 注册码生成
/// </summary>
/// <returns></returns>
2025-06-12 14:33:37 +08:00
[HttpPost]
2025-06-18 15:44:13 +08:00
[Obsolete]
2025-06-12 14:33:37 +08:00
public async Task<Response<LasaDeviceBindingCode>> GetDeviceBindingCode()
{
var result = new Response<LasaDeviceBindingCode>();
try
{
result = await _app.GetDeviceBindingCode();
//发送MQTT消息
if (result.Code == 200 && result.Result != null)
{
var topicRequest = $"thing/product/{result.Result.DeviceBindingCode}/requests";
var requestData = new
{
bid = Guid.NewGuid().ToString(),
method = "airport_organization_bind",
tid = Guid.NewGuid().ToString(),
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
data = new
{
bind_devices = new[]
{
new
{
device_binding_code = result.Result.DeviceBindingCode,
organization_id = result.Result.OrgId
}
}
}
};
string payload = JsonSerializer.Serialize(requestData);
await _mqttClientManager.PublishAsync(topicRequest, payload);
//在这个地方在接收一下?
}
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
return result;
}
2025-08-15 13:49:54 +08:00
2025-06-18 15:44:13 +08:00
/// <summary>
/// 机场注册 注册码生成
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<Response<LasaGateway>> GetGateway()
{
var result = new Response<LasaGateway>();
try
{
result = await _app.GetGateway();
2025-06-19 14:47:46 +08:00
//自动更新主题
string sn = result.Result.GatewaySn;
var topics = new List<string>();
topics.AddRange(new[]
{
$"thing/product/{sn}/osd",
$"thing/product/{sn}/events",
$"thing/product/{sn}/requests",
$"thing/product/{sn}/services"
});
await _mqttCenter.SubscribeAsync(topics.ToArray());
2025-06-18 15:44:13 +08:00
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
return result;
}
2025-08-15 13:49:54 +08:00
2025-08-05 11:19:30 +08:00
/// <summary>
/// 获取网关列表
/// </summary>
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
[HttpGet]
public async Task<Response<PageInfo<List<LasaGateway>>>> GetGatewayList(int page, int limit)
{
var result = new Response<PageInfo<List<LasaGateway>>>();
try
{
result = await _app.GetPageList(page, limit);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
return result;
}
2025-06-13 09:09:13 +08:00
2025-06-24 10:47:51 +08:00
#region 固件版本管理
2025-08-15 13:49:54 +08:00
2025-06-24 10:47:51 +08:00
/// <summary>
/// 添加固件版本
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
[HttpPost]
2025-07-15 09:47:03 +08:00
[AllowAnonymous]
2025-06-24 10:47:51 +08:00
public async Task<Response<bool>> AddFirmware(LasaFirmware info)
{
var result = new Response<bool>();
try
{
result = await _app.AddFirmware(info);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
2025-08-15 13:49:54 +08:00
2025-06-24 10:47:51 +08:00
return result;
}
2025-08-15 13:49:54 +08:00
2025-07-15 09:47:03 +08:00
/// <summary>
/// 修改无人机或机场版本
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public async Task<Response<bool>> UpdateFirmware(string id, string version, int type)
{
var result = new Response<bool>();
try
{
result = await _app.UpdateFirmware(id, version, type);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
2025-08-15 13:49:54 +08:00
2025-07-15 09:47:03 +08:00
return result;
}
2025-08-15 13:49:54 +08:00
2025-07-15 09:47:03 +08:00
/// <summary>
/// 上传固件文件
/// </summary>
/// <param name="xmlFile"></param>
/// <returns></returns>
[HttpPost("upload")]
[AllowAnonymous]
public async Task<IActionResult> UploadFirmwareFile(IFormFile xmlFile)
{
if (xmlFile == null || xmlFile.Length == 0)
return BadRequest("文件为空");
var path = await _app.UploadFile(xmlFile);
return Ok(new { message = "上传成功", path });
}
2025-08-15 13:49:54 +08:00
2025-06-24 10:47:51 +08:00
#endregion
2025-06-13 09:09:13 +08:00
/// <summary>
/// 切换相机
/// </summary>
/// <returns></returns>
[HttpPost]
2025-06-16 15:52:11 +08:00
public async Task<Response<int>> ExchangeCamera(Zhibo zhiboReq)
2025-06-13 09:09:13 +08:00
{
Response<int> response = new Response<int>();
try
{
2025-06-18 15:44:13 +08:00
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
2025-06-13 09:09:13 +08:00
{
2025-06-18 15:44:13 +08:00
camera_position = zhiboReq.position,
video_id = zhiboReq.videoId
}
};
string payload = JsonSerializer.Serialize(requestData);
await _mqttClientManager.PublishAsync(topicRequest, payload);
2025-06-13 09:09:13 +08:00
2025-06-18 15:44:13 +08:00
var topicRequest1 = $"thing/product/" + videoids[0] + "/services_reply";
2025-06-13 09:09:13 +08:00
2025-06-16 15:12:06 +08:00
await _mqttClientManager.SubscribeAsync(topicRequest1, async (args) =>
{
var payload = args.ApplicationMessage.Payload;
var message = Encoding.UTF8.GetString(payload);
Console.WriteLine($"收到主题 [{args.ApplicationMessage.Topic}] 的消息: {message}");
2025-06-18 15:44:13 +08:00
await Task.CompletedTask;
2025-06-16 15:12:06 +08:00
});
response.Result = 0;
2025-06-13 09:09:13 +08:00
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.Message;
}
2025-06-18 15:44:13 +08:00
2025-08-15 13:49:54 +08:00
return response;
;
2025-06-13 09:09:13 +08:00
}
/// <summary>
/// 设置直播镜头
/// </summary>
/// <returns></returns>
[HttpPost]
2025-06-16 15:52:11 +08:00
public async Task<Response<int>> SetCamera(Zhibo zhiboReq)
2025-06-13 09:09:13 +08:00
{
Response<int> response = new Response<int>();
try
{
2025-06-16 15:52:11 +08:00
var videoids = zhiboReq.videoId.Split("/");
2025-06-16 15:12:06 +08:00
var topicRequest = $"thing/product/" + videoids[0] + "/services";
2025-06-13 09:09:13 +08:00
var requestData = new
{
bid = Guid.NewGuid().ToString(),
method = "live_lens_change",
tid = Guid.NewGuid().ToString(),
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
data = new
{
2025-06-16 15:52:11 +08:00
video_type = zhiboReq.cameraType,
video_id = zhiboReq.videoId
2025-06-13 09:09:13 +08:00
}
};
string payload = JsonSerializer.Serialize(requestData);
await _mqttClientManager.PublishAsync(topicRequest, payload);
2025-06-16 15:12:06 +08:00
var topicRequest1 = $"thing/product/" + videoids[0] + "/services_reply";
await _mqttClientManager.SubscribeAsync(topicRequest1, async (args) =>
2025-06-13 09:09:13 +08:00
{
2025-06-16 15:12:06 +08:00
var payload = args.ApplicationMessage.Payload;
var message = Encoding.UTF8.GetString(payload);
Console.WriteLine($"收到主题 [{args.ApplicationMessage.Topic}] 的消息: {message}");
await Task.CompletedTask;
});
2025-06-13 09:09:13 +08:00
2025-06-16 15:12:06 +08:00
response.Result = 0;
2025-06-13 09:09:13 +08:00
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.Message;
}
2025-08-15 13:49:54 +08:00
return response;
2025-06-13 09:09:13 +08:00
}
/// <summary>
/// 设置直播清晰度
/// </summary>
/// <returns></returns>
[HttpPost]
2025-06-16 15:52:11 +08:00
public async Task<Response<int>> SetCameraVideo(Zhibo zhiboReq)
2025-06-13 09:09:13 +08:00
{
Response<int> response = new Response<int>();
try
{
2025-06-16 15:52:11 +08:00
var videoids = zhiboReq.videoId.Split("/");
2025-06-16 15:12:06 +08:00
var topicRequest = $"thing/product/" + videoids[0] + "/services";
2025-06-13 09:09:13 +08:00
var requestData = new
{
bid = Guid.NewGuid().ToString(),
method = "live_set_quality",
tid = Guid.NewGuid().ToString(),
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
data = new
{
2025-06-16 15:52:11 +08:00
video_quality = zhiboReq.videoQuality,
video_id = zhiboReq.videoId
2025-06-13 09:09:13 +08:00
}
};
string payload = JsonSerializer.Serialize(requestData);
await _mqttClientManager.PublishAsync(topicRequest, payload);
2025-06-16 15:12:06 +08:00
var topicRequest1 = $"thing/product/" + videoids[0] + "/services_reply";
await _mqttClientManager.SubscribeAsync(topicRequest1, async (args) =>
2025-06-13 09:09:13 +08:00
{
2025-06-16 15:12:06 +08:00
var payload = args.ApplicationMessage.Payload;
var message = Encoding.UTF8.GetString(payload);
Console.WriteLine($"收到主题 [{args.ApplicationMessage.Topic}] 的消息: {message}");
await Task.CompletedTask;
});
2025-06-13 09:09:13 +08:00
2025-06-16 15:12:06 +08:00
response.Result = 0;
2025-06-13 09:09:13 +08:00
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.Message;
}
2025-08-15 13:49:54 +08:00
return response;
2025-06-13 09:09:13 +08:00
}
/// <summary>
/// 停止直播
/// </summary>
/// <returns></returns>
[HttpPost]
2025-06-18 15:44:13 +08:00
public async Task<Response<int>> EndLive(Zhibo zhiboReq)
2025-06-13 09:09:13 +08:00
{
Response<int> response = new Response<int>();
try
{
2025-06-16 15:52:11 +08:00
var videoids = zhiboReq.videoId.Split("/");
2025-06-16 15:12:06 +08:00
var topicRequest = $"thing/product/" + videoids[0] + "/services";
var requestData = new
2025-06-18 15:44:13 +08:00
{
bid = Guid.NewGuid().ToString(),
method = "live_stop_push",
tid = Guid.NewGuid().ToString(),
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
data = new
2025-06-13 09:09:13 +08:00
{
2025-06-18 15:44:13 +08:00
video_id = zhiboReq.videoId
}
};
string payload = JsonSerializer.Serialize(requestData);
await _mqttClientManager.PublishAsync(topicRequest, payload);
2025-06-13 09:09:13 +08:00
2025-06-16 15:12:06 +08:00
var topicRequest1 = $"thing/product/" + videoids[0] + "/services_reply";
await _mqttClientManager.SubscribeAsync(topicRequest1, async (args) =>
2025-06-13 09:09:13 +08:00
{
2025-06-16 15:12:06 +08:00
var payload = args.ApplicationMessage.Payload;
var message = Encoding.UTF8.GetString(payload);
Console.WriteLine($"收到主题 [{args.ApplicationMessage.Topic}] 的消息: {message}");
await Task.CompletedTask;
});
2025-06-13 09:09:13 +08:00
2025-06-16 15:12:06 +08:00
response.Result = 0;
2025-07-02 14:11:05 +08:00
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.Message;
}
2025-08-15 13:49:54 +08:00
return response;
2025-07-02 14:11:05 +08:00
}
/// <summary>
/// 关联minio
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<Response<int>> RefMinio(Zhibo zhiboReq)
{
Response<int> response = new Response<int>();
try
{
var videoids = zhiboReq.videoId.Split("/");
var topicRequest = $"thing/product/" + videoids[0] + "/requests_reply";
var requestData = new
{
bid = Guid.NewGuid().ToString(),
method = "storage_config_get",
tid = Guid.NewGuid().ToString(),
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
data = new
{
2025-07-04 14:53:20 +08:00
output = new
{
bucket = "test",
credentials = new
{
access_key_id = "minioadmin",
access_key_secret = "minioadmin",
expire = 3600,
security_token = "security_token"
},
endpoint = "175.27.168.120:6013",
object_key_prefix = "",
provider = "ali",
region = "hz"
},
result = 0
2025-07-02 14:11:05 +08:00
}
};
2025-07-04 14:53:20 +08:00
2025-07-02 14:11:05 +08:00
response.Result = 0;
2025-06-13 09:09:13 +08:00
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.Message;
}
2025-08-15 13:49:54 +08:00
return response;
2025-06-13 09:09:13 +08:00
}
/// <summary>
/// 开始直播
/// </summary>
/// <returns></returns>
[HttpPost]
2025-06-16 15:52:11 +08:00
public async Task<Response<int>> StartLive(Zhibo zhiboReq)
2025-06-13 09:09:13 +08:00
{
Response<int> response = new Response<int>();
try
{
2025-06-16 15:52:11 +08:00
var videoids = zhiboReq.videoId.Split("/");
2025-06-16 15:12:06 +08:00
var topicRequest = $"thing/product/" + videoids[0] + "/services";
2025-06-13 09:09:13 +08:00
var requestData = new
{
bid = Guid.NewGuid().ToString(),
method = "live_start_push",
tid = Guid.NewGuid().ToString(),
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
data = new
{
2025-06-16 15:52:11 +08:00
url_type = zhiboReq.urlType,
url = zhiboReq.url,
video_quality = zhiboReq.videoQuality,
video_id = zhiboReq.videoId
2025-06-13 09:09:13 +08:00
}
};
string payload = JsonSerializer.Serialize(requestData);
await _mqttClientManager.PublishAsync(topicRequest, payload);
2025-06-16 15:12:06 +08:00
var topicRequest1 = $"thing/product/" + videoids[0] + "/services_reply";
await _mqttClientManager.SubscribeAsync(topicRequest1, async (args) =>
{
var payload1 = args.ApplicationMessage.Payload;
var message = Encoding.UTF8.GetString(payload1);
Console.WriteLine($"收到主题 [{args.ApplicationMessage.Topic}] 的消息: {message}");
await Task.CompletedTask;
});
2025-06-13 09:09:13 +08:00
2025-06-16 15:12:06 +08:00
response.Result = 0;
2025-06-13 09:09:13 +08:00
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.Message;
}
2025-08-15 13:49:54 +08:00
return response;
2025-06-13 09:09:13 +08:00
}
2025-06-26 11:28:43 +08:00
#region redis 多用户控制
2025-08-15 13:49:54 +08:00
2025-06-26 11:28:43 +08:00
/// <summary>
/// 添加修改mqtt客户端信息
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
[HttpPost]
public async Task<Response<bool>> AddOrUpdateRedisUser(MqttClientResp info)
{
var result = new Response<bool>();
try
{
var clientKey = $"client:{info.UserId}";
string lockSetKey = "locked_users";
// 查询所有锁定用户
var existingLocked = await _cache.SetMembersAsync(lockSetKey);
// 如果有锁定用户,并且锁定的用户不是当前用户,则拒绝
if (existingLocked.Length > 0 && info.IsLock == true)
{
bool isCurrentUserLocked = existingLocked.Any(u => u == info.UserId);
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.UserId);
}
else
{
await _cache.SetRemoveAsync(lockSetKey, info.UserId);
}
2025-08-15 13:49:54 +08:00
2025-06-26 11:28:43 +08:00
result.Result = true;
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
2025-08-15 13:49:54 +08:00
2025-06-26 11:28:43 +08:00
return result;
}
2025-08-15 13:49:54 +08:00
2025-06-26 11:28:43 +08:00
/// <summary>
/// 获取当前用户mqtt客户端信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
public async Task<Response<MqttClientResp>> GetRedisUser(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;
}
2025-08-15 13:49:54 +08:00
2025-06-26 11:28:43 +08:00
return result;
}
2025-08-15 13:49:54 +08:00
2025-06-26 11:28:43 +08:00
private MqttClientResp ParseClient(HashEntry[] entries)
{
2025-06-26 11:36:01 +08:00
if (entries == null || entries.Length == 0)
return null;
2025-06-26 11:28:43 +08:00
var dict = entries.ToDictionary(e => e.Name.ToString(), e => e.Value.ToString());
return new MqttClientResp
{
ClientId = dict["ClientId"],
UserId = dict["UserId"],
UserName = dict["UserName"],
ConnectTime = DateTime.Parse(dict["ConnectTime"]),
IsLock = bool.Parse(dict["IsLock"])
};
}
2025-08-15 13:49:54 +08:00
2025-06-26 11:28:43 +08:00
/// <summary>
/// 获取所有锁定的用户客户端信息
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<List<MqttClientResp>> GetLockedClients()
{
var userIds = await _cache.SetMembersAsync("locked_users");
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));
}
2025-08-15 13:49:54 +08:00
2025-06-26 11:28:43 +08:00
return result;
}
2025-08-15 13:49:54 +08:00
2025-06-26 11:28:43 +08:00
#endregion
2025-06-27 15:49:25 +08:00
#region 获取告警信息
2025-08-15 13:49:54 +08:00
2025-06-27 15:49:25 +08:00
/// <summary>
/// 获取告警信息
/// </summary>
/// <param name="level">告警等级0-全部1-注意2-告警</param>
/// <param name="model">设备0-全部1-设备管理2-媒体管理3-HMS告警</param>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
[HttpGet]
2025-08-15 13:49:54 +08:00
public async Task<Response<PageInfo<List<LasaManageDeviceHms>>>> GetManageDeviceHmsList(int level, int model,
DateTime startTime, DateTime endTime, int page, int limit, string message, string getway)
2025-06-27 15:49:25 +08:00
{
var result = new Response<PageInfo<List<LasaManageDeviceHms>>>();
try
{
2025-08-15 13:49:54 +08:00
result = await _app.GetManageDeviceHmsList(level, model, startTime, endTime, page, limit, message,
getway);
2025-06-27 15:49:25 +08:00
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
return result;
}
2025-08-15 13:49:54 +08:00
2025-06-27 15:49:25 +08:00
#endregion
2025-07-04 14:53:20 +08:00
#region 日志信息
2025-08-15 13:49:54 +08:00
2025-07-04 14:53:20 +08:00
/// <summary>
/// 根据设备sn读取实时数据
/// </summary>
/// <param name="sn">设备sn</param>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
[HttpGet]
2025-08-15 13:49:54 +08:00
public async Task<Response<PageInfo<List<LasaLog>>>> GetLogList(string sn, DateTime startTime, DateTime endTime,
int page, int limit)
2025-07-04 14:53:20 +08:00
{
var result = new Response<PageInfo<List<LasaLog>>>();
try
{
result = await _app.GetLogList(sn, startTime, endTime, page, limit);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
2025-08-15 13:49:54 +08:00
2025-07-04 14:53:20 +08:00
return result;
}
2025-08-15 13:49:54 +08:00
2025-07-04 14:53:20 +08:00
#endregion
2025-07-10 14:04:47 +08:00
[HttpGet]
public async Task<Response<PageInfo<List<LasaMediaFile>>>> GetMediaFile(string flightId,string taskId, string airId,
2025-08-15 13:49:54 +08:00
string device, int? type, string picname, DateTime startTime, DateTime endTime, int page, int limit,
string parentKey, int? objectKeyExist)
2025-07-10 14:04:47 +08:00
{
var result = new Response<PageInfo<List<LasaMediaFile>>>();
try
{
result = await _app.GetMediaFile(flightId,taskId, airId, device,type, picname, startTime, endTime, page, limit,
2025-08-15 13:49:54 +08:00
parentKey, objectKeyExist);
2025-07-10 14:04:47 +08:00
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
2025-08-15 13:49:54 +08:00
2025-07-10 14:04:47 +08:00
return result;
}
2025-07-15 09:19:05 +08:00
[HttpGet]
[AllowAnonymous]
2025-08-15 13:49:54 +08:00
public async Task<Response<string>> UpdatePicStatus(string id, int showOnMap, int display, string fileTags,
string graffitiJson)
2025-07-15 09:19:05 +08:00
{
var result = new Response<string>();
try
{
2025-08-15 13:49:54 +08:00
result = await _app.UpdatePicStatus(id, showOnMap, display, fileTags, graffitiJson);
2025-07-15 09:19:05 +08:00
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
2025-08-15 13:49:54 +08:00
2025-07-15 09:19:05 +08:00
return result;
}
[HttpGet]
[AllowAnonymous]
public async Task<Response<string>> deletepic(string ids)
{
var result = new Response<string>();
try
{
result = await _app.deletepic(ids);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
2025-08-15 13:49:54 +08:00
2025-07-15 09:19:05 +08:00
return result;
}
2025-07-16 14:12:22 +08:00
[HttpGet]
[AllowAnonymous]
public async Task<Response<string>> UpdatePicName(string id, string name)
{
var result = new Response<string>();
try
{
result = await _app.UpdatePicName(id, name);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
2025-08-15 13:49:54 +08:00
2025-07-16 14:12:22 +08:00
return result;
}
[HttpGet]
[AllowAnonymous]
public async Task<Response<string>> UpdatePicParentKey(string id, string ParentKey)
{
var result = new Response<string>();
try
{
result = await _app.UpdatePicParentKey(id, ParentKey);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
2025-08-15 13:49:54 +08:00
2025-07-16 14:12:22 +08:00
return result;
}
2025-08-15 13:49:54 +08:00
2025-07-24 14:24:32 +08:00
[HttpGet]
[AllowAnonymous]
public async Task<Response<string>> getMiniPic()
{
var result = new Response<string>();
try
{
2025-08-15 13:49:54 +08:00
// string presignedUrl = "http://175.27.168.120:6014/test/44fc8b4b-9448-4e79-a71d-536d094b8598/ad854032-d4b7-42dc-8ac0-d1faef0ebc1e/DJI_202507231000_002_ad854032-d4b7-42dc-8ac0-d1faef0ebc1e/DJI_20250723100110_0001_V.jpeg";
var imageStream = _minioService.GetObjectAsStream("test",
"44fc8b4b-9448-4e79-a71d-536d094b8598/ad854032-d4b7-42dc-8ac0-d1faef0ebc1e/DJI_202507231000_002_ad854032-d4b7-42dc-8ac0-d1faef0ebc1e/DJI_20250723100110_0001_V.jpeg");
// var imageStream = await _httpClient.GetStreamAsync(presignedUrl);
2025-07-16 14:12:22 +08:00
2025-07-24 14:24:32 +08:00
using (var image = Image.Load(imageStream.Result))
{
var width = image.Width;
var height = image.Height;
var thumbnailSize = 100; // 缩略图大小,可以根据需要调整
var thumbnail = image.Clone(ctx => ctx.Resize(new ResizeOptions
{
Size = new Size(thumbnailSize, thumbnailSize),
Mode = ResizeMode.Crop // 根据需要选择裁剪或填充模式
}));
// 将缩略图保存到内存流中(为了上传)
using (var memoryStream = new MemoryStream())
{
thumbnail.SaveAsJpeg(memoryStream); // 可以根据需要选择不同的格式如Png, Bmp等。
memoryStream.Position = 0; // 重置流的位置到开始处
2025-08-15 13:49:54 +08:00
2025-07-24 14:24:32 +08:00
// 上传缩略图到MinIO
2025-08-15 13:49:54 +08:00
await _minioService.PutObjectAsync("test", "suolue_DJI_20250723100110_0001_V.jpeg",
"abc/suolue_DJI_20250723100110_0001_V.jpeg", memoryStream); // 根据实际格式修改Content-Type
2025-07-24 14:24:32 +08:00
}
}
2025-08-15 13:49:54 +08:00
}
2025-07-24 14:24:32 +08:00
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
2025-08-15 13:49:54 +08:00
2025-07-24 14:24:32 +08:00
return result;
}
2025-06-12 14:33:37 +08:00
}
2025-08-15 13:49:54 +08:00
}