Compare commits
2 Commits
3b431b978a
...
3df0615dc4
| Author | SHA1 | Date |
|---|---|---|
|
|
3df0615dc4 | |
|
|
7dd5054060 |
|
|
@ -61,13 +61,13 @@
|
|||
"UpdateTable": false
|
||||
},
|
||||
"AlibabaCloudVod": {
|
||||
"AccessKeyId": "LTAI5tDC6p9h747B7FHbgwkH",
|
||||
"AccessKeySecret": "vRKgmbp1LB05LaGOjh3ZrZxbHSLYLF",
|
||||
"AccessKeyId": "LTAI5tFLXyC3ixVdxhxLih8K",
|
||||
"AccessKeySecret": "dlGu3WMoW0XQaoAYxiCPpnxry6qLhB",
|
||||
"EndPoint": "vod.cn-shanghai.aliyuncs.com" //上传节点
|
||||
},
|
||||
"AliyunOSS": {
|
||||
"AccessKeyId": "LTAI5tDC6p9h747B7FHbgwkH",
|
||||
"AccessKeySecret": "vRKgmbp1LB05LaGOjh3ZrZxbHSLYLF",
|
||||
"AccessKeyId": "LTAI5tFLXyC3ixVdxhxLih8K",
|
||||
"AccessKeySecret": "dlGu3WMoW0XQaoAYxiCPpnxry6qLhB",
|
||||
"BucketDomain": "https://learn-videoanalysis.oss-cn-chengdu.aliyuncs.com",
|
||||
"Region": "cn-chengdu",
|
||||
"BucketName": "learn-videoanalysis",
|
||||
|
|
|
|||
|
|
@ -22,14 +22,6 @@
|
|||
"FFmpeg": {
|
||||
" TimeSlice": 600
|
||||
},
|
||||
"AliyunOSS": {
|
||||
"AccessKeyId": "LTAI5tDC6p9h747B7FHbgwkH",
|
||||
"AccessKeySecret": "vRKgmbp1LB05LaGOjh3ZrZxbHSLYLF",
|
||||
"BucketDomain": "https://learn-videoanalysis.oss-cn-chengdu.aliyuncs.com",
|
||||
"Region": "cn-chengdu",
|
||||
"BucketName": "learn-videoanalysis",
|
||||
"EndPoint": "oss-cn-chengdu.aliyuncs.com" //上传节点
|
||||
},
|
||||
"DB": {
|
||||
//"ConnectionString": "AllowLoadLocalInfile=true;Server=10.255.255.3;Port=3306;Database=learn.videoanalysis;User ID=marking;Password=qwe123!@#;CharSet=utf8mb4;pooling=true;SslMode=None",
|
||||
"ConnectionString": "AllowLoadLocalInfile=true;Server=rm-2vc20nd3d11g0oh6g2o.rwlb.cn-chengdu.rds.aliyuncs.com;User ID=marking;Password=poiuytPOIUYT098765)(*&^%;Port=3306;Database=learn.videoanalysis;CharSet=utf8mb4;pooling=true;SslMode=None",
|
||||
|
|
|
|||
|
|
@ -76,16 +76,16 @@
|
|||
//"ConnectionString": "AllowLoadLocalInfile=true;Server=rm-2vc20nd3d11g0oh6g2o.rwlb.cn-chengdu.rds.aliyuncs.com;User ID=marking;Password=poiuytPOIUYT098765)(*&^%;Port=3306;Database=learn.videoanalysis;CharSet=utf8mb4;pooling=true;SslMode=None",
|
||||
|
||||
"SqlType": "MySql",
|
||||
"UpdateTable": true
|
||||
"UpdateTable": false
|
||||
},
|
||||
"AlibabaCloudVod": {
|
||||
"AccessKeyId": "LTAI5tDC6p9h747B7FHbgwkH",
|
||||
"AccessKeySecret": "vRKgmbp1LB05LaGOjh3ZrZxbHSLYLF",
|
||||
"AccessKeyId": "LTAI5tFLXyC3ixVdxhxLih8K",
|
||||
"AccessKeySecret": "dlGu3WMoW0XQaoAYxiCPpnxry6qLhB",
|
||||
"EndPoint": "vod.cn-shanghai.aliyuncs.com" //上传节点
|
||||
},
|
||||
"AliyunOSS": {
|
||||
"AccessKeyId": "LTAI5tDC6p9h747B7FHbgwkH",
|
||||
"AccessKeySecret": "vRKgmbp1LB05LaGOjh3ZrZxbHSLYLF",
|
||||
"AccessKeyId": "LTAI5tFLXyC3ixVdxhxLih8K",
|
||||
"AccessKeySecret": "dlGu3WMoW0XQaoAYxiCPpnxry6qLhB",
|
||||
"BucketDomain": "https://learn-videoanalysis.oss-cn-chengdu.aliyuncs.com",
|
||||
"Region": "cn-chengdu",
|
||||
"BucketName": "learn-videoanalysis",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ using VideoAnalysisCore.AICore.GPT.Gemini;
|
|||
namespace VideoAnalysisCore.AICore.GPT
|
||||
{
|
||||
|
||||
public interface IBserGPTWorkflow
|
||||
public interface IBaseGPTWorkflow
|
||||
{
|
||||
/// <summary>
|
||||
/// 访问GPT
|
||||
|
|
@ -185,10 +185,13 @@ namespace VideoAnalysisCore.AICore.GPT
|
|||
public static void AddGPTService(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<DeepSeekGPTClient>();
|
||||
services.AddSingleton<BSET_DeepSeekGPTClient>();
|
||||
services.AddSingleton<BSET_DeepSeekGPTClient
|
||||
|
||||
|
||||
>();
|
||||
services.AddSingleton<BestAIClient>();
|
||||
services.AddSingleton<GeminiGPTClient>();
|
||||
services.AddSingleton<IBserGPTWorkflow, GTP_Analysis_1>();
|
||||
services.AddSingleton<IBaseGPTWorkflow, GTP_Analysis_1>();
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
using VideoAnalysisCore.Common;
|
||||
using VideoAnalysisCore.Common;
|
||||
using System.Text.Json;
|
||||
using VideoAnalysisCore.Model;
|
||||
using System.Text;
|
||||
|
|
@ -33,7 +33,7 @@ namespace VideoAnalysisCore.AICore.GPT
|
|||
/// <summary>
|
||||
/// 视频分析工作流1
|
||||
/// </summary>
|
||||
public class GTP_Analysis_1 : IBserGPTWorkflow
|
||||
public class GTP_Analysis_1 : IBaseGPTWorkflow
|
||||
{
|
||||
private readonly GeminiGPTClient geminiClient;
|
||||
private readonly DeepSeekGPTClient deepSeekClient;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using SherpaOnnx;
|
||||
using SqlSugar;
|
||||
|
|
|
|||
|
|
@ -148,21 +148,34 @@ namespace VideoAnalysisCore.Common
|
|||
public async Task RunTask(string task, string workflowName = "VideoSliceWorkflow")
|
||||
{
|
||||
var taskId = long.Parse(task);
|
||||
//获取资源文件 地址
|
||||
var taskInfo = await GetTaskInfoAsync(taskId);
|
||||
var fileUrl = await GetMediaUrlAsync(taskInfo);
|
||||
|
||||
// 准备本地目录
|
||||
var localPath = task.LocalPath();
|
||||
await PrepareDirectoryAndDbAsync(taskId, localPath);
|
||||
|
||||
// 处理 PPT 视频
|
||||
await ProcessPPTVideoAsync(taskInfo, localPath, taskId, workflowName, task);
|
||||
|
||||
// 下载主视频
|
||||
await DownloadWithCacheCheckAsync(taskId, fileUrl, localPath, taskVideoName, workflowName, task, "主视频");
|
||||
}
|
||||
|
||||
private async Task<VideoTask> GetTaskInfoAsync(long taskId)
|
||||
{
|
||||
var taskInfo = await videoTaskDB.CopyNew().AsQueryable()
|
||||
.Where(s => s.Id == taskId).FirstAsync();
|
||||
|
||||
if (taskInfo is null)
|
||||
throw new Exception($"任务为null/是教研视频/没有视频课程名称");
|
||||
var fileUrl = taskInfo.MediaUrl;
|
||||
switch (taskInfo?.VideoType)
|
||||
{
|
||||
case AttachmentsInfoType.无:
|
||||
case AttachmentsInfoType.新课:
|
||||
case AttachmentsInfoType.复习:
|
||||
break;
|
||||
default:
|
||||
throw new Exception("无效的课程类型");
|
||||
|
||||
return taskInfo;
|
||||
}
|
||||
|
||||
private async Task<string> GetMediaUrlAsync(VideoTask taskInfo)
|
||||
{
|
||||
var fileUrl = taskInfo.MediaUrl;
|
||||
if (string.IsNullOrEmpty(fileUrl))
|
||||
{
|
||||
var videoInfo = await vodClient.GetPlayInfoAsync(new GetPlayInfoRequest()
|
||||
|
|
@ -176,57 +189,70 @@ namespace VideoAnalysisCore.Common
|
|||
throw new Exception($"{DateTime.Now} 视频订阅=>获取阿里云视频信息失败 VideoCode {taskInfo.TagId} StatusCode {videoInfo?.StatusCode}");
|
||||
fileUrl = videoInfo.Body.PlayInfoList.PlayInfo.First().PlayURL;
|
||||
}
|
||||
if (string.IsNullOrEmpty(fileUrl))
|
||||
throw new Exception($"任务id[{task}] 资源地址无效 {fileUrl}");
|
||||
|
||||
// 尝试从 URL 中获取文件后缀
|
||||
if (string.IsNullOrEmpty(fileUrl))
|
||||
throw new Exception($"任务id[{taskInfo.Id}] 资源地址无效 {fileUrl}");
|
||||
|
||||
// 尝试从 URL 中获取文件后缀 (保留原有校验逻辑)
|
||||
string fileExtension = Path.GetExtension(new Uri(fileUrl).AbsolutePath);
|
||||
//否则 获取 从Content-Type 获取文件后缀
|
||||
if (string.IsNullOrEmpty(fileExtension))
|
||||
throw new Exception($"未能从资源路径中获取文件后缀");
|
||||
|
||||
//创建下载文件缓存路径
|
||||
if (!Directory.Exists(AppCommon.TaskCachedFile)) Directory.CreateDirectory(AppCommon.TaskCachedFile);
|
||||
return fileUrl;
|
||||
}
|
||||
|
||||
var localPath = task.LocalPath();
|
||||
var outputPath = Path.Combine(localPath, taskVideoName);
|
||||
private async Task PrepareDirectoryAndDbAsync(long taskId, string localPath)
|
||||
{
|
||||
if (!Directory.Exists(AppCommon.TaskCachedFile)) Directory.CreateDirectory(AppCommon.TaskCachedFile);
|
||||
if (!Directory.Exists(localPath)) Directory.CreateDirectory(localPath);
|
||||
|
||||
var outputPath = Path.Combine(localPath, taskVideoName);
|
||||
await videoTaskDB.CopyNew()
|
||||
.AsUpdateable()
|
||||
.SetColumns(it => it.LocalMediaPath == outputPath)
|
||||
.Where(it => it.Id == long.Parse(task))
|
||||
.Where(it => it.Id == taskId)
|
||||
.ExecuteCommandAsync();
|
||||
//下载PPT视频
|
||||
if (string.IsNullOrEmpty(taskInfo.PPTVideoUrl)&&
|
||||
!string.IsNullOrEmpty(taskInfo.PPTVideoCode))
|
||||
}
|
||||
|
||||
private async Task ProcessPPTVideoAsync(VideoTask taskInfo, string localPath, long taskId, string workflowName, string taskStr)
|
||||
{
|
||||
// 更新 PPT 视频 URL
|
||||
if (string.IsNullOrEmpty(taskInfo.PPTVideoUrl) && !string.IsNullOrEmpty(taskInfo.PPTVideoCode))
|
||||
{
|
||||
taskInfo.PPTVideoUrl = await packageInfoTaskDB.AsQueryable()
|
||||
.Where(s => s.VideoCode == taskInfo.PPTVideoCode)
|
||||
.Select(s => s.VideoUrl)
|
||||
.FirstAsync();
|
||||
|
||||
if (!string.IsNullOrEmpty(taskInfo.PPTVideoUrl))
|
||||
{
|
||||
await videoTaskDB.CopyNew().AsUpdateable(taskInfo)
|
||||
.UpdateColumns(it => new { it.PPTVideoUrl })
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 下载 PPT 视频
|
||||
if (!string.IsNullOrEmpty(taskInfo.PPTVideoUrl))
|
||||
{
|
||||
await Download(taskInfo.PPTVideoUrl, localPath, taskPPTVideoName,
|
||||
(s, e) => GetWorkflowManager(workflowName).SetTaskProgress(task, "PPT->" + Math.Round(e.ProgressPercentage, 1))
|
||||
);
|
||||
await DownloadWithCacheCheckAsync(taskId, taskInfo.PPTVideoUrl, localPath, taskPPTVideoName, workflowName, taskStr, "PPT视频", true);
|
||||
}
|
||||
try
|
||||
{
|
||||
//下载原视频
|
||||
await Download(fileUrl, localPath, taskVideoName,
|
||||
(s, e) => GetWorkflowManager(workflowName).SetTaskProgress(task, Math.Round(e.ProgressPercentage, 1))
|
||||
);
|
||||
}
|
||||
catch
|
||||
|
||||
private async Task DownloadWithCacheCheckAsync(long taskId, string url, string localPath, string fileName, string workflowName, string taskStr, string logPrefix, bool isPPT = false)
|
||||
{
|
||||
throw;
|
||||
var filePath = Path.Combine(localPath, fileName);
|
||||
if (File.Exists(filePath) && new FileInfo(filePath).Length > 10 * 1024 * 1024)
|
||||
{
|
||||
await GetWorkflowManager(workflowName).AddTaskLog(taskId, $"{logPrefix}命中本地缓存");
|
||||
}
|
||||
else
|
||||
{
|
||||
await Download(url, localPath, fileName, (s, e) =>
|
||||
{
|
||||
var progressPrefix = isPPT ? "PPT->" : "";
|
||||
GetWorkflowManager(workflowName).SetTaskProgress(taskStr, $"{progressPrefix}" + Math.Round(e.ProgressPercentage, 1));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -265,7 +291,7 @@ namespace VideoAnalysisCore.Common
|
|||
try
|
||||
{
|
||||
using var scope = serviceProvider.CreateScope();
|
||||
var clearJob = scope.ServiceProvider.GetRequiredService<TaskFileClearJob>();
|
||||
var clearJob = scope.ServiceProvider.GetRequiredService<ClearAllCacheJob>();
|
||||
await clearJob.Invoke();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using FreeRedis;
|
||||
using FreeRedis;
|
||||
using FreeRedis.Internal;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
|
@ -140,25 +140,13 @@ namespace VideoAnalysisCore.Common
|
|||
public class RedisManager
|
||||
{
|
||||
public static bool StopTask { get; set; } = false;
|
||||
public static Dictionary<RedisChannelEnum, Func<string, Task>> SubscribeList = new Dictionary<RedisChannelEnum, Func<string, Task>>();
|
||||
|
||||
/// <summary>
|
||||
/// 正在后台运行的任务集合
|
||||
/// </summary>
|
||||
public static ConcurrentDictionary<string, Task> RunningTasks = new ConcurrentDictionary<string, Task>();
|
||||
|
||||
private static CancellationTokenSource? _cts;
|
||||
private static Task? _workerTask;
|
||||
|
||||
public RedisClient Redis { get; set; }
|
||||
public Repository<VideoTask> videoTaskDB { get; set; }
|
||||
public Repository<TaskLog> taskLogDB { get; set; }
|
||||
|
||||
public RedisManager(RedisClient redis, Repository<VideoTask> videoTaskDB, Repository<TaskLog> taskLogDB)
|
||||
public RedisManager(RedisClient redis)
|
||||
{
|
||||
Redis = redis;
|
||||
this.videoTaskDB = videoTaskDB;
|
||||
this.taskLogDB = taskLogDB;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -170,37 +158,5 @@ namespace VideoAnalysisCore.Common
|
|||
{
|
||||
Redis.Set(RedisExpandKey.TaskGPT(taskId) + ":" + time, data, timeoutSeconds: 3600 * 24);
|
||||
}
|
||||
/// <summary>
|
||||
/// 加入到消费队列
|
||||
/// </summary>
|
||||
/// <param name="taskIds"></param>
|
||||
public void JoinQueue(params long[] taskIds)
|
||||
{ //事务
|
||||
if (taskIds is null || taskIds.Length == 0)
|
||||
return;
|
||||
using (var tran = Redis.Multi())
|
||||
{
|
||||
foreach (var item in taskIds)
|
||||
tran.LPush(RedisExpandKey.ChannelKey, item);
|
||||
tran.Exec();
|
||||
}
|
||||
}
|
||||
|
||||
// AddTaskLog 已迁移至 WorkflowBase
|
||||
|
||||
/// <summary>
|
||||
/// 获取任务进度
|
||||
/// </summary>
|
||||
/// <param name="taskId"></param>
|
||||
/// <param name="workflowName">工作流名称(可选)</param>
|
||||
public string GetTaskProgress(object taskId, string workflowName = "VideoSliceWorkflow")
|
||||
{
|
||||
var fieldName = workflowName == "VideoSliceWorkflow" ? "Progress" : $"Progress:{workflowName}";
|
||||
return Redis.HMGet<string>(RedisExpandKey.Task(taskId), fieldName)[0] ?? "";
|
||||
}
|
||||
|
||||
// 注意:SetTaskProgress, TaskEnd, SetTaskErrorMessage, ClearTaskError, SetTaskError
|
||||
// 已迁移至 WorkflowBase,此处移除或标记为已废弃
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,13 +39,15 @@ namespace VideoAnalysisCore.Common
|
|||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly FFMPGEHandle _ffmpeg;
|
||||
private readonly SenseVoice _senseVoice;
|
||||
private readonly TidySlideWorkflowManager _tidySlideWorkflowManager;
|
||||
|
||||
public VideoSliceWorkflowInit(VideoSliceWorkflowManager manager, IServiceProvider serviceProvider, FFMPGEHandle ffmpeg, SenseVoice senseVoice)
|
||||
public VideoSliceWorkflowInit(VideoSliceWorkflowManager manager, IServiceProvider serviceProvider, FFMPGEHandle ffmpeg, SenseVoice senseVoice, TidySlideWorkflowManager tidySlideWorkflowManager)
|
||||
{
|
||||
_manager = manager;
|
||||
_serviceProvider = serviceProvider;
|
||||
_ffmpeg = ffmpeg;
|
||||
_senseVoice = senseVoice;
|
||||
_tidySlideWorkflowManager = tidySlideWorkflowManager;
|
||||
Init();
|
||||
_manager.InitChannel();
|
||||
}
|
||||
|
|
@ -62,26 +64,36 @@ namespace VideoAnalysisCore.Common
|
|||
await downloadService.RunTask(task, "VideoSliceWorkflow");
|
||||
});
|
||||
SubscribeList.Add(RedisChannelEnum.分离音频, _ffmpeg.RunAsync);
|
||||
SubscribeList.Add(RedisChannelEnum.解析字幕, _senseVoice.RunTask);
|
||||
SubscribeList.Add(RedisChannelEnum.解析字幕, async (task) =>
|
||||
{
|
||||
await _senseVoice.RunTask(task);
|
||||
// 触发 TidySlide 工作流
|
||||
if (AppCommon.Config.Workflow.TidySlide.Enabled)
|
||||
{
|
||||
await _tidySlideWorkflowManager.AddTaskLog(long.Parse(task), "由解析字幕完成触发 TidySlide 工作流");
|
||||
//不阻塞
|
||||
_=_tidySlideWorkflowManager.InsertChannel(RedisTidySlideChannelEnum.下载文件, task);
|
||||
}
|
||||
});
|
||||
|
||||
SubscribeList.Add(RedisChannelEnum.AI课程类型, async (task) =>
|
||||
{
|
||||
using var scope = _serviceProvider.CreateScope();
|
||||
var service = scope.ServiceProvider.GetService<IBserGPTWorkflow>();
|
||||
var service = scope.ServiceProvider.GetService<IBaseGPTWorkflow>();
|
||||
if (service is null) throw new Exception("IBserGPT 未注入");
|
||||
await service.GetVideoType(task);
|
||||
});
|
||||
SubscribeList.Add(RedisChannelEnum.AI模型分析, async (task) =>
|
||||
{
|
||||
using var scope = _serviceProvider.CreateScope();
|
||||
var service = scope.ServiceProvider.GetService<IBserGPTWorkflow>();
|
||||
var service = scope.ServiceProvider.GetService<IBaseGPTWorkflow>();
|
||||
if (service is null) throw new Exception("IBserGPT 未注入");
|
||||
await service.GetKnow(task);
|
||||
});
|
||||
SubscribeList.Add(RedisChannelEnum.AI分析试题, async (task) =>
|
||||
{
|
||||
using var scope = _serviceProvider.CreateScope();
|
||||
var service = scope.ServiceProvider.GetService<IBserGPTWorkflow>();
|
||||
var service = scope.ServiceProvider.GetService<IBaseGPTWorkflow>();
|
||||
if (service is null) throw new Exception("IBserGPT 未注入");
|
||||
await service.GetVideoQuestion(task);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -461,5 +461,19 @@ namespace VideoAnalysisCore.Common
|
|||
RunningTasks.TryAdd(tId, bgTask);
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加入到消费队列
|
||||
/// </summary>
|
||||
/// <param name="taskIds"></param>
|
||||
public void JoinQueue(params long[] taskIds)
|
||||
{
|
||||
if (taskIds is null || taskIds.Length == 0)
|
||||
return;
|
||||
// 直接批量推入,避免循环和事务开销
|
||||
var d = taskIds.Select(s => (object)s).ToArray();
|
||||
Redis.LPush(ChannelKey, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,10 +40,11 @@ namespace VideoAnalysisCore.Controllers
|
|||
private readonly Repository<VideoQuestion> videoQuestionDB;
|
||||
private readonly Repository<VideoQuestionKonw> videoQuestionKonwDB;
|
||||
private readonly RedisManager redisManager;
|
||||
readonly VideoSliceWorkflowManager videoSliceWorkflowManager;
|
||||
|
||||
public LJZK_Controller(IMapper mp, Repository<NodeSubscription> nodesubscriptionDB,
|
||||
Repository<VideoTask> videoTaskDB = null, Repository<VideoKonwPoint> videoKonwPointDB = null
|
||||
, Repository<NodePackageInfo> nodePackageInfoDB = null, Repository<VideoQuestion> videoQuestionDB = null, Repository<VideoQuestionKonw> videoQuestionKonwDB = null, Repository<CourseInfo> courseInfoDB = null, RedisManager redisManager = null, Repository<VideoTaskStage> videoTaskStageDB = null)
|
||||
, Repository<NodePackageInfo> nodePackageInfoDB = null, Repository<VideoQuestion> videoQuestionDB = null, Repository<VideoQuestionKonw> videoQuestionKonwDB = null, Repository<CourseInfo> courseInfoDB = null, RedisManager redisManager = null, Repository<VideoTaskStage> videoTaskStageDB = null, VideoSliceWorkflowManager videoSliceWorkflowManager = null)
|
||||
{
|
||||
this.mp = mp;
|
||||
this.nodesubscriptionDB = nodesubscriptionDB;
|
||||
|
|
@ -55,6 +56,7 @@ namespace VideoAnalysisCore.Controllers
|
|||
this.courseInfoDB = courseInfoDB;
|
||||
this.redisManager = redisManager;
|
||||
this.videoTaskStageDB = videoTaskStageDB;
|
||||
this.videoSliceWorkflowManager = videoSliceWorkflowManager;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -158,7 +160,7 @@ namespace VideoAnalysisCore.Controllers
|
|||
if (videos is null || videos.Count == 0)
|
||||
return Ok();
|
||||
var ids = videos.Select(s => s.Id).ToArray();
|
||||
redisManager.JoinQueue(ids);
|
||||
videoSliceWorkflowManager.JoinQueue(ids);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -110,16 +110,30 @@ namespace VideoAnalysisCore.Controllers
|
|||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 插入批量任务id
|
||||
/// 添加任务到 TidySlide队列
|
||||
/// </summary>
|
||||
/// <param name="ids">是否执行任务</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost(Name = "JoinQueue")]
|
||||
[HttpPost(Name = "JoinQueueVideoSlice")]
|
||||
public IActionResult JoinQueue( long[] ids)
|
||||
{
|
||||
if (ids == null || ids.Count() == 0)
|
||||
if (ids == null || ids.Length == 0)
|
||||
return BadRequest("录入数据无效");
|
||||
redisManager.JoinQueue(ids);
|
||||
videoSliceWorkflowManager.JoinQueue(ids);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加任务到 TidySlide队列
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost(Name = "JoinQueueTidySlide")]
|
||||
public IActionResult JoinTidySlideQueue( long[] ids)
|
||||
{
|
||||
if (ids == null || ids.Length == 0)
|
||||
return BadRequest("录入数据无效");
|
||||
tidySlideWorkflowManager.JoinQueue(ids);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
|
@ -464,7 +478,15 @@ namespace VideoAnalysisCore.Controllers
|
|||
{
|
||||
// 扫描 Heartbeat Key
|
||||
var pattern = RedisExpandKey.DeviceHeartbeat("*");
|
||||
var keys = redisManager.Redis.Scan(pattern, 1000).ToList();
|
||||
var keys = new List<string>();
|
||||
long cursor = 0;
|
||||
do
|
||||
{
|
||||
var scanResult = redisManager.Redis.Scan(cursor, pattern, 1000, null);
|
||||
keys.AddRange(scanResult.items);
|
||||
cursor = scanResult.cursor;
|
||||
} while (cursor != 0);
|
||||
|
||||
var prefix = RedisExpandKey.DeviceHeartbeat("");
|
||||
var devices = keys.Select(k => k.Replace(prefix, "")).ToList();
|
||||
return Ok(devices);
|
||||
|
|
@ -490,7 +512,15 @@ namespace VideoAnalysisCore.Controllers
|
|||
oldTaskArr = new List<long>();
|
||||
// 直接扫描 Heartbeat Key 获取在线设备
|
||||
var pattern = RedisExpandKey.DeviceHeartbeat("*");
|
||||
var keys = redisManager.Redis.Scan(pattern, 1000).ToList();
|
||||
var keys = new List<string>();
|
||||
long cursor = 0;
|
||||
do
|
||||
{
|
||||
var scanResult = redisManager.Redis.Scan(cursor, pattern, 1000, null);
|
||||
keys.AddRange(scanResult.items);
|
||||
cursor = scanResult.cursor;
|
||||
} while (cursor != 0);
|
||||
|
||||
var prefix = RedisExpandKey.DeviceHeartbeat("");
|
||||
var onlineDevices = keys.Select(k => k.Replace(prefix, "")).ToList();
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
<PackageReference Include="AlibabaCloud.SDK.Vod20170321" Version="3.6.1" />
|
||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
|
||||
<PackageReference Include="Coravel" Version="6.0.2" />
|
||||
<PackageReference Include="FreeRedis" Version="1.3.2" />
|
||||
<PackageReference Include="FreeRedis" Version="1.5.5" />
|
||||
<PackageReference Include="Downloader" Version="3.2.1" />
|
||||
<PackageReference Include="Mapster" Version="7.4.1-pre01" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.3.0" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue