zhangbin 1 month ago
commit fd4e3920f6

@ -391,7 +391,7 @@ namespace OpenAuth.App.ServiceApp
#endregion #endregion
public async Task<Response<PageInfo<List<LasaMediaFile>>>> GetMediaFile(string taskId, string device, public async Task<Response<PageInfo<List<LasaMediaFile>>>> GetMediaFile(string taskId, string device,
string picname, DateTime? startTime, DateTime? endTime, int page, int limit, string parentKey) string picname, DateTime? startTime, DateTime? endTime, int page, int limit, string parentKey,int? objectKeyExist)
{ {
RefAsync<int> totalCount = 0; RefAsync<int> totalCount = 0;
using (var db = UnitWork.CreateContext()) using (var db = UnitWork.CreateContext())
@ -401,6 +401,8 @@ namespace OpenAuth.App.ServiceApp
.LeftJoin<LasaTask>((x, b) => x.FlightId == b.FlightId) .LeftJoin<LasaTask>((x, b) => x.FlightId == b.FlightId)
.WhereIF(!string.IsNullOrEmpty(device), x => x.DroneModelKey == device) .WhereIF(!string.IsNullOrEmpty(device), x => x.DroneModelKey == device)
.WhereIF(!string.IsNullOrEmpty(picname), x => x.Name.Contains(picname)) .WhereIF(!string.IsNullOrEmpty(picname), x => x.Name.Contains(picname))
.WhereIF(objectKeyExist is 0,x=> x.ObjectKey == null)
.WhereIF(objectKeyExist is 1,x=> x.ObjectKey != null)
.WhereIF(!"0001/1/1 0:00:00".Equal(startTime.ToString()), x => x.CreateTime >= startTime) .WhereIF(!"0001/1/1 0:00:00".Equal(startTime.ToString()), x => x.CreateTime >= startTime)
.WhereIF(!"0001/1/1 0:00:00".Equal(endTime.ToString()), x => x.CreateTime <= endTime) .WhereIF(!"0001/1/1 0:00:00".Equal(endTime.ToString()), x => x.CreateTime <= endTime)
.WhereIF(!string.IsNullOrEmpty(parentKey), x => x.ParentKey == parentKey) .WhereIF(!string.IsNullOrEmpty(parentKey), x => x.ParentKey == parentKey)

@ -17,6 +17,8 @@ using DocumentFormat.OpenXml.Math;
using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource; using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource;
using DocumentFormat.OpenXml.Drawing.Charts; using DocumentFormat.OpenXml.Drawing.Charts;
using Org.BouncyCastle.Ocsp; using Org.BouncyCastle.Ocsp;
using System.Net.Http.Headers;
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
namespace OpenAuth.App.ServiceApp.DroneDocking namespace OpenAuth.App.ServiceApp.DroneDocking
@ -828,13 +830,62 @@ namespace OpenAuth.App.ServiceApp.DroneDocking
return Response; return Response;
} }
public Response<string> UploadFile(AirPortUploadDbReq req)
/// <summary> {
/// 无人机状态获取 Response<string> Response = new Response<string>();
/// </summary> var filePath = req.filePath;
/// <param name="req"></param> var uploadUrl = req.fileUrl;
/// <returns></returns> var fileName = Path.GetFileName(filePath);
public async Task<ResData> getResult(string taskid) byte[] fileBuffer = null;
HttpClient client = null;
MultipartFormDataContent formData = null;
try
{
//文件过大,建议使用 大文件上传接口,分段读取,进行上传
fileBuffer = File.ReadAllBytes(filePath);
client = new HttpClient();
client.Timeout = new TimeSpan(0, 0, 0, 5);
formData = new MultipartFormDataContent();
var fileContent = new ByteArrayContent(fileBuffer);
fileContent.Headers.ContentDisposition = new
ContentDispositionHeaderValue("attachment");
fileContent.Headers.ContentDisposition.FileName = fileName;
//注意:务必 根据 文件扩展名,这里指定 ContentType
fileContent.Headers.ContentType = new
MediaTypeHeaderValue(fileName);
formData.Add(fileContent);
var request = new HttpRequestMessage
{
//注意:这里是 PUT
Method = HttpMethod.Put,
RequestUri = new Uri(uploadUrl),
Content = formData
};
var result = client.SendAsync(request).Result.Content.ReadAsStringAsync().Result;
if (string.IsNullOrWhiteSpace(result))
{
Response.Result = result;
}
}
catch (Exception ex)
{
Response.Result = "上传失败";
}
finally
{
fileBuffer = null;
formData?.Dispose();
client?.Dispose();
}
return Response;
}
/// <summary>
/// 无人机状态获取
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public async Task<ResData> getResult(string taskid)
{ {
ResData Response = new ResData(); ResData Response = new ResData();
using (var uow = base.UnitWork.CreateContext()) using (var uow = base.UnitWork.CreateContext())

@ -6,15 +6,28 @@ using System.Threading.Tasks;
namespace OpenAuth.App.ServiceApp.DroneDocking.Request namespace OpenAuth.App.ServiceApp.DroneDocking.Request
{ {
public class AirPortUploadReq public class AirPortStatusApply
{ {
public string code { get; set; } public string deviceid { get; set; }
public string regioncode { get; set; } public string onlinestate { get; set; }
public List<string> filenames { get; set; } public double longitude { get; set; }
public double latitude { get; set; }
public double height { get; set; }
public double elevation { get; set; }
public double gimbal_pitch { get; set; }
public double gimbal_ya { get; set; }
public int battery_capacity_percent { get; set; }
public int gps_state { get; set; }
} }
} }

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenAuth.App.ServiceApp.DroneDocking.Request
{
public class AirPortUploadDbReq
{
public string filePath { get; set; }
public string fileUrl { get; set; }
}
}

@ -6,28 +6,15 @@ using System.Threading.Tasks;
namespace OpenAuth.App.ServiceApp.DroneDocking.Request namespace OpenAuth.App.ServiceApp.DroneDocking.Request
{ {
public class AirPortStatusApply public class AirPortUploadReq
{ {
public string deviceid { get; set; } public string code { get; set; }
public string onlinestate { get; set; } public string regioncode { get; set; }
public double longitude { get; set; } public List<string> filenames { get; set; }
public double latitude { get; set; }
public double height { get; set; }
public double elevation { get; set; }
public double gimbal_pitch { get; set; }
public double gimbal_ya { get; set; }
public int battery_capacity_percent { get; set; }
public int gps_state { get; set; }
} }
} }

@ -58,7 +58,7 @@ public class ConfigSubscribe : IJob
//"thing/product/+/osd", //"thing/product/+/osd",
//"thing/product/+/status" //"thing/product/+/status"
}; };
_logger.LogInformation("开启监听");
await _mqttClientManager await _mqttClientManager
.SubscribeAsync(topicList, .SubscribeAsync(topicList,
async (args) => async (args) =>
@ -242,7 +242,8 @@ public class ConfigSubscribe : IJob
WorkspaceId = executeTask.WorkspaceId, WorkspaceId = executeTask.WorkspaceId,
}; };
parents.Add(parent1);*/ parents.Add(parent1);*/
var timeStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); var date = DateTime.Now;
var timeStr = date.ToString("yyyy-MM-dd HH:mm:ss");
var parent1 = new LasaMediaFile() var parent1 = new LasaMediaFile()
{ {
Id = folderKey[2], Id = folderKey[2],
@ -251,6 +252,7 @@ public class ConfigSubscribe : IJob
ParentKey = "0", ParentKey = "0",
Name = string.IsNullOrEmpty(executeTask.TaskName) ? timeStr : $"{executeTask.TaskName} {timeStr}", Name = string.IsNullOrEmpty(executeTask.TaskName) ? timeStr : $"{executeTask.TaskName} {timeStr}",
WorkspaceId = executeTask.WorkspaceId, WorkspaceId = executeTask.WorkspaceId,
CreateTime = date,
}; };
await _sqlSugarClient.Insertable(parent1).ExecuteCommandAsync(); await _sqlSugarClient.Insertable(parent1).ExecuteCommandAsync();
} }
@ -299,9 +301,9 @@ public class ConfigSubscribe : IJob
FlightId = flightId, // 计划id FlightId = flightId, // 计划id
TaskId = taskAssign.TaskId, // 任务id TaskId = taskAssign.TaskId, // 任务id
DroneModelKey = data.file.ext.drone_model_key, // 无人机型号 DroneModelKey = data.file.ext.drone_model_key, // 无人机型号
PayloadModelKey = data.file.ext.payload_model_key, //这应该可以标明是什么设置
IsOriginal = data.file.ext.is_original, IsOriginal = data.file.ext.is_original,
MediaIndex = data.file.ext.media_index, MediaIndex = data.file.ext.media_index,
PayloadModelKey = data.file.ext.payload_model_key, //这应该可以标明是什么设置
AbsoluteAltitude = data.file.metadata.absolute_altitude, // 拍摄绝对高度 AbsoluteAltitude = data.file.metadata.absolute_altitude, // 拍摄绝对高度
GimbalYawDegree = data.file.metadata.gimbal_yaw_degree, //云台偏航角度 GimbalYawDegree = data.file.metadata.gimbal_yaw_degree, //云台偏航角度
RelativeAltitude = data.file.metadata.relative_altitude, // 拍摄相对高度 RelativeAltitude = data.file.metadata.relative_altitude, // 拍摄相对高度

@ -670,13 +670,12 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
[HttpGet] [HttpGet]
[AllowAnonymous] public async Task<Response<PageInfo<List<LasaMediaFile>>>> GetMediaFile(string taskId,string device,string picname, DateTime startTime, DateTime endTime, int page, int limit,string parentKey,int? objectKeyExist)
public async Task<Response<PageInfo<List<LasaMediaFile>>>> GetMediaFile(string taskId,string device,string picname, DateTime startTime, DateTime endTime, int page, int limit,string parentKey)
{ {
var result = new Response<PageInfo<List<LasaMediaFile>>>(); var result = new Response<PageInfo<List<LasaMediaFile>>>();
try try
{ {
result = await _app.GetMediaFile(taskId,device, picname,startTime, endTime, page, limit,parentKey); result = await _app.GetMediaFile(taskId,device, picname,startTime, endTime, page, limit,parentKey,objectKeyExist);
} }
catch (Exception ex) catch (Exception ex)
{ {

@ -8,6 +8,7 @@ using OpenAuth.App.ServiceApp.DroneDocking.Request;
using OpenAuth.App.ServiceApp.DroneDocking.Response; using OpenAuth.App.ServiceApp.DroneDocking.Response;
using OpenAuth.App.ServiceApp.Response; using OpenAuth.App.ServiceApp.Response;
using OpenAuth.Repository.Domain; using OpenAuth.Repository.Domain;
using Org.BouncyCastle.Ocsp;
using System.Text; using System.Text;
namespace OpenAuth.WebApi.Controllers.ServiceControllers namespace OpenAuth.WebApi.Controllers.ServiceControllers
@ -472,7 +473,6 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
/// 获取临时上传地址 /// 获取临时上传地址
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[Route("/zhcfzx/DataExchange/getUploadFilePath")]
[HttpPost] [HttpPost]
[AllowAnonymous] [AllowAnonymous]
public async Task<Response<string>> getUploadFilePath([FromBody] AirPortUploadReq req) public async Task<Response<string>> getUploadFilePath([FromBody] AirPortUploadReq req)
@ -490,6 +490,22 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
return result; return result;
} }
[HttpPost]
[AllowAnonymous]
public Response<string> UploadFile(AirPortUploadDbReq req) {
var result = new Response<string>();
try
{
result = _app.UploadFile(req);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
return result;
}
[HttpGet] [HttpGet]
[AllowAnonymous] [AllowAnonymous]
[Route("/zhcfzx/droneAirport/getResult")] [Route("/zhcfzx/droneAirport/getResult")]

Loading…
Cancel
Save