diff --git a/OpenAuth.App/ServiceApp/DroneDocking/DroneDockApp.cs b/OpenAuth.App/ServiceApp/DroneDocking/DroneDockApp.cs index e250306..15c73bb 100644 --- a/OpenAuth.App/ServiceApp/DroneDocking/DroneDockApp.cs +++ b/OpenAuth.App/ServiceApp/DroneDocking/DroneDockApp.cs @@ -25,6 +25,7 @@ using System.Linq.Expressions; using System.Text.Json; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; +using System.Net; namespace OpenAuth.App.ServiceApp.DroneDocking { @@ -969,7 +970,7 @@ namespace OpenAuth.App.ServiceApp.DroneDocking public async Task> UploadFile(AirPortUploadDbReq req) { Response Response = new Response(); - //db包校验 + // 首先检查文件是否存在 if (!File.Exists(req.filePath)) { @@ -977,14 +978,10 @@ namespace OpenAuth.App.ServiceApp.DroneDocking Response.Code = 500; return Response; } - - - - + var filePath = req.filePath; var uploadUrl = req.fileUrl; var fileName = req.filename; - byte[] fileBuffer = null; HttpClient client = null; MultipartFormDataContent formData = null; try @@ -996,20 +993,20 @@ namespace OpenAuth.App.ServiceApp.DroneDocking client = new HttpClient(); //client.Timeout = new TimeSpan(0, 0, 0, 5); client.Timeout = TimeSpan.FromMinutes(5); - formData = new MultipartFormDataContent(); - var fileContent = new StreamContent(fileStream); + //formData = new MultipartFormDataContent(); + var fileContent = new StreamContent(fileStream); fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); fileContent.Headers.ContentDisposition.FileName = fileName; //注意:务必 根据 文件扩展名,这里指定 ContentType fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); - formData.Add(fileContent); + //formData.Add(fileContent); var request = new HttpRequestMessage { //注意:这里是 PUT Method = HttpMethod.Put, RequestUri = new Uri(uploadUrl), - Content = formData + Content = fileContent }; var result = client.SendAsync(request).Result.Content.ReadAsStringAsync().Result; if (string.IsNullOrWhiteSpace(result)) @@ -1017,7 +1014,7 @@ namespace OpenAuth.App.ServiceApp.DroneDocking Response.Result = result; } } - + } catch (Exception ex) { @@ -1025,11 +1022,54 @@ namespace OpenAuth.App.ServiceApp.DroneDocking } finally { - fileBuffer = null; formData?.Dispose(); client?.Dispose(); } + #region + //string fileName = Path.GetFileName(filePath); + //HttpWebRequest reqs = null; + //HttpWebResponse resp = null; + //try + //{ + // reqs = WebRequest.Create(uploadUrl) as HttpWebRequest; + // reqs.Method = "PUT"; + // reqs.ContentType = "application/octet-stream"; + // reqs.ContentLength = new FileInfo(filePath).Length; + + // reqs.SendChunked = true; + // reqs.AllowWriteStreamBuffering = false; + + // using (Stream dataStream = reqs.GetRequestStream()) + // { + // var buffer = new byte[8000]; + // using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) + // { + // int bytesRead = 0; + // while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) > 0) + // { + // dataStream.Write(buffer, 0, bytesRead); + // } + // } + // } + // resp = reqs.GetResponse() as HttpWebResponse; + // var isOk = resp.StatusCode == HttpStatusCode.OK; + + // Stream streamReceive = resp.GetResponseStream(); + // var encoding = Encoding.UTF8; + + // StreamReader streamReader = new StreamReader(streamReceive, encoding); + // string strResult = streamReader.ReadToEnd(); + //} + //catch (Exception ex) + //{ + //} + //finally + //{ + // resp?.Dispose(); + //} + #endregion + return Response; } @@ -1379,7 +1419,7 @@ namespace OpenAuth.App.ServiceApp.DroneDocking //上传文件 AirPortUploadDbReq req = new AirPortUploadDbReq(); req.fileUrl = write; - req.filePath = filepath; + req.filePath = tempFilePath; req.filename = filename; //数据写入数据库 @@ -1398,6 +1438,11 @@ namespace OpenAuth.App.ServiceApp.DroneDocking dbfine.key = "hopetry"; dbfine.sign = signData.Sign; dbfine.timestamp= Convert.ToInt32(signData.Timestamp); + var dbinfo = uow.DbfineInfo.GetList(r => r.taskid == taskidsheng); + if(dbinfo.Count > 0) + { + await uow.DbfineInfo.DeleteAsync(r=>r.taskid == taskidsheng); + } var info = await uow.DbfineInfo.InsertAsync(dbfine); if (info == false) { diff --git a/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs b/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs index 02cfed5..fdb8ff8 100644 --- a/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs +++ b/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs @@ -561,9 +561,7 @@ public class ConfigSubscribe : IJob } _logger.LogDebug("航线进度未跳过处理"); code = data.result; // result - - - + var taskAssign1 = _manageApp.GetTaskAssignByFlightId(flightId1); // 处理航线进度 ,也有可能是失败 if (code != 0) @@ -603,39 +601,7 @@ public class ConfigSubscribe : IJob } else { - var step = (int)data.output.progress.current_step; - _logger.LogDebug($"航线进度:{waylineMissionState} {step} {message}"); - if (step.Equals(25)) // todo 关于会接收到不同消息问题,如何处理 - { - var task = await _sqlSugarClient.Queryable() - .FirstAsync(y => y.Id == taskAssign1.TaskId); - if (task != null && !string.IsNullOrEmpty(task.AIInspection) && - task.AIInspection.Equals("true") && string.IsNullOrEmpty(task.PushUrl)) - { - _logger.LogDebug("执行AI 智能巡检。。。。。"); - //var rtmp = "rtmp://box.wisestcity.com:1935/live/7"; - var bid = Guid.NewGuid().ToString(); - var tid = Guid.NewGuid().ToString(); - var param = @$"{{ - ""bid"": ""{bid}"", - ""method"": ""live_start_push"", - ""tid"": ""{tid}"", - ""timestamp"": {DateTimeOffset.Now.ToUnixTimeMilliseconds()}, - ""data"": {{ - ""url_type"": 1, - ""url"": ""{rtmp}"", - ""video_id"": ""1581F8HGX254V00A0BUY/99-0-0/normal-0"", - ""video_quality"": 3 - }} - }}"; - _logger.LogDebug($"直播参数:{param}"); - var topicRequest = $"thing/product/{sn}/services"; - // 开启直播 - await _mqttClientManager.PublishAsync(topicRequest, param); - liveInfo[$"{tid}{bid}"] = taskAssign1.TaskId; - } - } - + // 航线成功 if (waylineMissionState.Equals(9)) // 航结结束,更新任务状态 { @@ -669,6 +635,39 @@ public class ConfigSubscribe : IJob }; await _sqlSugarClient.Updateable(record).IgnoreNullColumns().ExecuteCommandAsync(); } + var step = (int)data.output.progress.current_step; + _logger.LogDebug($"航线进度:{waylineMissionState} {step} {message}"); + if (step.Equals(25)) // todo 关于会接收到不同消息问题,如何处理 + { + var task = await _sqlSugarClient.Queryable() + .FirstAsync(y => y.Id == taskAssign1.TaskId); + if (task != null && !string.IsNullOrEmpty(task.AIInspection) && + task.AIInspection.Equals("true") && string.IsNullOrEmpty(task.PushUrl)) + { + _logger.LogDebug("执行AI 智能巡检。。。。。"); + //var rtmp = "rtmp://box.wisestcity.com:1935/live/7"; + var bid = Guid.NewGuid().ToString(); + var tid = Guid.NewGuid().ToString(); + var param = @$"{{ + ""bid"": ""{bid}"", + ""method"": ""live_start_push"", + ""tid"": ""{tid}"", + ""timestamp"": {DateTimeOffset.Now.ToUnixTimeMilliseconds()}, + ""data"": {{ + ""url_type"": 1, + ""url"": ""{rtmp}"", + ""video_id"": ""1581F8HGX254V00A0BUY/99-0-0/normal-0"", + ""video_quality"": 3 + }} + }}"; + _logger.LogDebug($"直播参数:{param}"); + var topicRequest = $"thing/product/{sn}/services"; + // 开启直播 + await _mqttClientManager.PublishAsync(topicRequest, param); + liveInfo[$"{tid}{bid}"] = taskAssign1.TaskId; + } + } + } /*if (result.need_reply.Equals(1)) diff --git a/OpenAuth.WebApi/temp/WRJ00000076.db b/OpenAuth.WebApi/temp/WRJ00000076.db index fbec1ba..43e463e 100644 Binary files a/OpenAuth.WebApi/temp/WRJ00000076.db and b/OpenAuth.WebApi/temp/WRJ00000076.db differ diff --git a/OpenAuth.WebApi/temp/WRJ00000076.sign b/OpenAuth.WebApi/temp/WRJ00000076.sign index 936edc6..814c35a 100644 --- a/OpenAuth.WebApi/temp/WRJ00000076.sign +++ b/OpenAuth.WebApi/temp/WRJ00000076.sign @@ -3,10 +3,10 @@ "code": "AirportData", "count": "0", "extension": "db", - "hash": "25FBDC0C75E0EEFC531474430C4F4FF12AA08C2BF8DA9C53DCB2FBDE23AB2C4E", + "hash": "2E9A0386FF02A387B7771080CA759C0328CD6ED517ED8F150F2525365A8498A5", "regioncode": "370000", - "sign": "6DC82902D95BF1BC7CE40E931D3A6D06BF015B5C082841476718AE038BC23C48842DE7757BD05A625BF526256110273FCE57A156CB96B5CA478A1C4C097D49DB", + "sign": "EC22B9BB9779C39977314A94B50207ED31C3B418DFAFC9F50354A3E405537F6C6E0E1CEFD91EB47D2DF61E5242EC82624D940674D879931B1BC0036488B8B5C1", "size": "26650624", - "timestamp": "1757124448", + "timestamp": "1757466021", "version": "1" }