From 6b9fc167ee7c42d317b3a260918957a9a854eeab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=82=A5=E7=BE=8A?= <1048382248@qq.com> Date: Mon, 24 Mar 2025 18:12:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=8C=85=E5=9B=9E=E8=B0=83=E6=89=A7=E8=A1=8C=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Pages/VideoTaskPage.razor | 2 +- .../Components/Pages/VideoTaskPage.razor.cs | 27 ++++++++----------- VideoAnalysis/Controllers/LJZK_Controller.cs | 9 +++---- VideoAnalysis/Expand/CoravelExpand.cs | 4 +-- VideoAnalysis/Program.cs | 1 - .../AICore/SherpaOnnx/SenseVoice.cs | 2 +- VideoAnalysisCore/Common/RedisExpand.cs | 2 ++ VideoAnalysisCore/Job/NodePackageJob.cs | 5 ++++ VideoAnalysisCore/Model/Dto/VideoTaskDto.cs | 7 ++++- 9 files changed, 32 insertions(+), 27 deletions(-) diff --git a/VideoAnalysis/Components/Pages/VideoTaskPage.razor b/VideoAnalysis/Components/Pages/VideoTaskPage.razor index b96f992..9917d06 100644 --- a/VideoAnalysis/Components/Pages/VideoTaskPage.razor +++ b/VideoAnalysis/Components/Pages/VideoTaskPage.razor @@ -52,7 +52,7 @@ - + diff --git a/VideoAnalysis/Components/Pages/VideoTaskPage.razor.cs b/VideoAnalysis/Components/Pages/VideoTaskPage.razor.cs index c9610b3..ec5999b 100644 --- a/VideoAnalysis/Components/Pages/VideoTaskPage.razor.cs +++ b/VideoAnalysis/Components/Pages/VideoTaskPage.razor.cs @@ -131,6 +131,15 @@ namespace Learn.VideoAnalysis.Components.Pages item.StartTimeDic = System.Text.Json.JsonSerializer.Deserialize>(data[2]) ?? null; item.ErrorMessage = data[3]; rowRestartLoading = false; + var statusStr = "wait"; + var dic = rowData.Data.StartTimeDic; + if (dic is null) + statusStr= "wait"; + else if (!string.IsNullOrEmpty(rowData.Data.ErrorMessage)) + statusStr= "error"; + else if (dic.ContainsKey(RedisChannelEnum.EndTask)) + statusStr= "finish"; + item.TaskStatus = statusStr; StateHasChanged(); } /// @@ -144,24 +153,10 @@ namespace Learn.VideoAnalysis.Components.Pages return "--"; return dic[e].ToString(); } - private string RowSTStatus(RowData rowData) - { - var dic = rowData.Data.StartTimeDic; - if (dic is null) - return "wait"; - if (!string.IsNullOrEmpty(rowData.Data.ErrorMessage)) - return "error"; - if (dic.ContainsKey(RedisChannelEnum.EndTask)) - return "finish"; - return "wait"; - } - private int RowSTIndex(RowData rowData) - { - return (int)rowData.Data.LastEnum; - } private void OnExpand(RowData rowData) { - RowRload(rowData); + if(rowData.Expanded) + RowRload(rowData); } /// /// 在渲染页面之后 diff --git a/VideoAnalysis/Controllers/LJZK_Controller.cs b/VideoAnalysis/Controllers/LJZK_Controller.cs index ebe1515..c09cb6e 100644 --- a/VideoAnalysis/Controllers/LJZK_Controller.cs +++ b/VideoAnalysis/Controllers/LJZK_Controller.cs @@ -15,6 +15,7 @@ using FFmpeg.NET.Services; using static FFmpeg.NET.MetaData; using static System.Runtime.InteropServices.JavaScript.JSType; using Yitter.IdGenerator; +using VideoAnalysisCore.AICore.GPT.Dto; namespace Learn.VideoAnalysis.Controllers { @@ -77,6 +78,7 @@ namespace Learn.VideoAnalysis.Controllers [HttpPost(Name = "NodePackage")] public async Task NodePackage(NodePackageReq req) { + Console.WriteLine($"{DateTime.Now} ļ req=" + JsonSerializer.Serialize(req)); if (req is null || req.NodeId == 0) return BadRequest("Чύ"); if (req.AnalyzeItems is null || req.AnalyzeItems.Count() == 0) @@ -94,12 +96,8 @@ namespace Learn.VideoAnalysis.Controllers StructurePageContentId = s.StructurePageContentId, }; nodePackages.Add(np); - if (videoIdArr.Contains(s.VideoCode)) - { - Console.WriteLine($"ظ"); continue; - } videos.Add(new VideoTask() { Id = YitIdHelper.NextId(), @@ -113,9 +111,10 @@ namespace Learn.VideoAnalysis.Controllers MediaName = s.VideoName }); } - await nodePackageInfoDB.InsertRangeAsync(nodePackages); await videoTaskDB.InsertRangeAsync(videos); + if (videos is null || videos.Count == 0) + return Ok(); var ids = videos.Select(s => s.Id).ToArray(); RedisExpand.JoinQueue(ids); return Ok(); diff --git a/VideoAnalysis/Expand/CoravelExpand.cs b/VideoAnalysis/Expand/CoravelExpand.cs index 5d5e663..1c7c59d 100644 --- a/VideoAnalysis/Expand/CoravelExpand.cs +++ b/VideoAnalysis/Expand/CoravelExpand.cs @@ -29,9 +29,9 @@ namespace Learn.VideoAnalysis.Expand //每5分钟执行一次 未处理视频扫描 scheduler.Schedule().EveryFiveMinutes(); //文件包分析 - scheduler.Schedule().HourlyAt(10); + scheduler.Schedule().EveryThirtyMinutes(); //每30分钟执行一次 //任务缓存清理 - // scheduler.Schedule().HourlyAt(10); + // scheduler.Schedule().HourlyAt(10); }); } } diff --git a/VideoAnalysis/Program.cs b/VideoAnalysis/Program.cs index b8b558f..7c40910 100644 --- a/VideoAnalysis/Program.cs +++ b/VideoAnalysis/Program.cs @@ -20,7 +20,6 @@ namespace Learn.VideoAnalysis { public static void Main(string[] args) { - var builder = WebApplication.CreateBuilder(args); // Add services to the container. diff --git a/VideoAnalysisCore/AICore/SherpaOnnx/SenseVoice.cs b/VideoAnalysisCore/AICore/SherpaOnnx/SenseVoice.cs index e76db03..6d8f3c9 100644 --- a/VideoAnalysisCore/AICore/SherpaOnnx/SenseVoice.cs +++ b/VideoAnalysisCore/AICore/SherpaOnnx/SenseVoice.cs @@ -208,7 +208,7 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx if (!string.IsNullOrEmpty(stream.Result.Text)) { var text = stream.Result.Text.Trim(); - if (text.Length == 1 && text.First() >= '\uFF00' && text.First() <= '\uFFEF') // 检查字符是否在全角半角字符集的标点符号范围内 + if (text.Length == 1 && text == "。")// 检查字符是否只有一个句号 { VAD.Pop(); return; diff --git a/VideoAnalysisCore/Common/RedisExpand.cs b/VideoAnalysisCore/Common/RedisExpand.cs index 91f997a..fba0da3 100644 --- a/VideoAnalysisCore/Common/RedisExpand.cs +++ b/VideoAnalysisCore/Common/RedisExpand.cs @@ -121,6 +121,8 @@ namespace VideoAnalysisCore.Common /// public static void JoinQueue(params long[] taskIds) { //事务 + if (taskIds is null || taskIds.Length == 0) + return; using (var tran = Redis.Multi()) { foreach (var item in taskIds) diff --git a/VideoAnalysisCore/Job/NodePackageJob.cs b/VideoAnalysisCore/Job/NodePackageJob.cs index 852dc1e..55e9423 100644 --- a/VideoAnalysisCore/Job/NodePackageJob.cs +++ b/VideoAnalysisCore/Job/NodePackageJob.cs @@ -72,6 +72,11 @@ namespace VideoAnalysisCore.Job .UpdateColumns(it => new { it.SuccessTime }) .ExecuteCommandAsync(); } + else + { + var res = await responseMessage.Content.ReadAsStringAsync(); + Console.WriteLine($"{DateTime.Now} Invoke=>文件包任务 回调失败!!! {responseMessage.StatusCode} {res}"); + } } } } diff --git a/VideoAnalysisCore/Model/Dto/VideoTaskDto.cs b/VideoAnalysisCore/Model/Dto/VideoTaskDto.cs index a80893d..0c9b0df 100644 --- a/VideoAnalysisCore/Model/Dto/VideoTaskDto.cs +++ b/VideoAnalysisCore/Model/Dto/VideoTaskDto.cs @@ -80,6 +80,11 @@ namespace VideoAnalysisCore.Model.Dto /// 开始时间轴 /// 逻辑字段 /// - public Dictionary? StartTimeDic {get; set;} + public Dictionary? StartTimeDic {get; set; } + /// + /// 任务处理状态 + /// 逻辑字段 + /// + public string? TaskStatus { get; set; } } }