diff --git a/VideoAnalysis/AntDeploy.json b/VideoAnalysis/AntDeploy.json index c4da2cd..4b4d6b7 100644 --- a/VideoAnalysis/AntDeploy.json +++ b/VideoAnalysis/AntDeploy.json @@ -120,7 +120,7 @@ "LastEnvName": "10楼刀片机", "RemoveDaysFromPublished": "10", "WorkDir": "/home/heyang/", - "Volume": "/home/hy/VideoAnalysis/AICore:/app/AICore/_Static;/home/hy/VideoAnalysis/TaskCachedFile:/app/TaskCachedFile", + "Volume": "/home/hy/VideoAnalysis/AICore:/app/AICore/_Static;/mnt/2tb/VideoAnalysis/TaskCachedFile:/app/TaskCachedFile", "Other": "-e va_args=\"\"", "EnvPairList": [ { @@ -129,7 +129,7 @@ "LinuxEnvParam": null, "DockerPort": "9040", "DockerEnvName": "", - "DockerVolume": "/home/hy/VideoAnalysis/AICore:/app/AICore/_Static;/home/hy/VideoAnalysis/TaskCachedFile:/app/TaskCachedFile", + "DockerVolume": "/home/hy/VideoAnalysis/AICore:/app/AICore/_Static;/mnt/2tb/VideoAnalysis/TaskCachedFile:/app/TaskCachedFile", "DockerOther": "-e va_args=\"\"" }, { diff --git a/VideoAnalysisCore/AICore/SherpaOnnx/SenseVoice.cs b/VideoAnalysisCore/AICore/SherpaOnnx/SenseVoice.cs index b18f3de..08038ea 100644 --- a/VideoAnalysisCore/AICore/SherpaOnnx/SenseVoice.cs +++ b/VideoAnalysisCore/AICore/SherpaOnnx/SenseVoice.cs @@ -180,7 +180,7 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx .ExecuteCommandAsync(); await RedisExpand.Redis.HMSetAsync(RedisExpandKey.Task(task), "Captions", res); //分析完成视频字幕后继续接收任务 - RedisExpand.NewTaskAsync(); + RedisExpand.NewTask(); } return res; } diff --git a/VideoAnalysisCore/Common/Expand/SqlSugarExpand.cs b/VideoAnalysisCore/Common/Expand/SqlSugarExpand.cs index ea2d7cc..d1ac4fc 100644 --- a/VideoAnalysisCore/Common/Expand/SqlSugarExpand.cs +++ b/VideoAnalysisCore/Common/Expand/SqlSugarExpand.cs @@ -44,7 +44,7 @@ namespace VideoAnalysisCore.Common.Expand DbType = s.SqlType, IsAutoCloseConnection = true })); - services.AddTransient(typeof(Repository<>)); + services.AddScoped(typeof(Repository<>)); //注入SqlSugar 主库 services.AddSqlSugar(dbList); diff --git a/VideoAnalysisCore/Common/RedisExpand.cs b/VideoAnalysisCore/Common/RedisExpand.cs index acd79f8..7d8942e 100644 --- a/VideoAnalysisCore/Common/RedisExpand.cs +++ b/VideoAnalysisCore/Common/RedisExpand.cs @@ -297,20 +297,23 @@ namespace VideoAnalysisCore.Common /// /// 开始接收新任务 /// - public static void RestartTaskAsync() + public static void RestartTask() { StopTask = false; - NewTaskAsync(); + NewTask(); } /// /// 重新执行新任务 /// /// - public static async void NewTaskAsync() + public static void NewTask() { // 取消 消费机的任务订阅 if (StopTask) + { + Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + "-------------> 接收任务已经暂停 "); return; + } ReceivingTaskAsync(); } @@ -374,7 +377,7 @@ namespace VideoAnalysisCore.Common Console.WriteLine(ex.StackTrace); Console.WriteLine("=============================================="); //清除失败任务 重新接收任务 - NewTaskAsync(); + NewTask(); } return await SetTaskError(taskID, error); } diff --git a/VideoAnalysisCore/Common/Repository.cs b/VideoAnalysisCore/Common/Repository.cs index 37f0cc6..2281a9b 100644 --- a/VideoAnalysisCore/Common/Repository.cs +++ b/VideoAnalysisCore/Common/Repository.cs @@ -24,16 +24,16 @@ namespace VideoAnalysisCore.Common if (CID.ContainsKey(t)) { base.Context = CID[t]!=null - ? DbScoped.Sugar.GetConnectionScope(CID[t]) - : DbScoped.Sugar; + ? DbScoped.SugarScope.GetConnectionScope(CID[t]) + : DbScoped.SugarScope; return; } var c = t.GetCustomAttribute(); if (!CID.ContainsKey(t)) CID.Add(t, c?.configId); base.Context = c != null - ? DbScoped.Sugar.GetConnectionScope(c.configId) - : DbScoped.Sugar; + ? DbScoped.SugarScope.GetConnectionScope(c.configId) + : DbScoped.SugarScope; } } } diff --git a/VideoAnalysisCore/Controllers/ApiController.cs b/VideoAnalysisCore/Controllers/ApiController.cs index 625f7eb..10ce01f 100644 --- a/VideoAnalysisCore/Controllers/ApiController.cs +++ b/VideoAnalysisCore/Controllers/ApiController.cs @@ -76,13 +76,16 @@ namespace VideoAnalysisCore.Controllers /// /// ʼ /// - /// ļ + /// Ƿִ /// - [HttpGet(Name = "tets1")] - public IActionResult tets1(string task) + [HttpGet(Name = "StartTask")] + public IActionResult StartTask(bool task) { - var courseArr = courseInfoDB.AsQueryable().ToArray(); - return Ok(courseArr); + if(task) + RedisExpand.RestartTask(); + else + RedisExpand.StopTaskAsync(); + return Ok(); } /// /// ʶ