From 7ef238e4e2d57c0f80d9579085ac8f2e83c0357b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=82=A5=E7=BE=8A?= <1048382248@qq.com> Date: Tue, 8 Apr 2025 18:16:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=86=E5=88=86=E9=A1=B9=E7=9B=AE=20?= =?UTF-8?q?=E4=B8=BA=20API+=E6=B6=88=E8=B4=B9=E7=AB=AF=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=20=E9=85=8D=E7=BD=AE=20=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=20dockerFIle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Learn.VideoAnalysis.API/AntDeploy.json | 172 ++++++++++ .../Controllers/ApiController.cs | 299 ++++++++++++++++++ .../Controllers/Dto/ApiDto.cs | 246 ++++++++++++++ .../Controllers/LJZK_Controller.cs | 196 ++++++++++++ Learn.VideoAnalysis.API/Dockerfile | 15 + .../Expand/CoravelExpand.cs | 36 +++ .../Learn.VideoAnalysis.API.csproj | 41 +++ .../Learn.VideoAnalysis.API.http | 6 + Learn.VideoAnalysis.API/Program.cs | 71 +++++ .../Properties/launchSettings.json | 15 + .../appsettings.Production.json | 32 ++ Learn.VideoAnalysis.API/appsettings.json | 76 +++++ Learn.VideoAnalysis.sln | 6 + VideoAnalysis/AntDeploy.json | 10 +- .../Components/Layouts/BasicLayout.razor | 1 + .../Pages/EvaluationProject.razor.cs | 1 + .../Pages/NodeSubscriptionPage.razor.cs | 1 + .../Components/Pages/VideoTaskPage.razor.cs | 1 + .../Components/Pages/VideoTaskShow.razor.cs | 28 +- VideoAnalysis/Controllers/Dto/ApiDto.cs | 2 +- VideoAnalysis/Dockerfile | 8 +- VideoAnalysis/Expand/CoravelExpand.cs | 12 +- VideoAnalysis/Expand/SearchExpand.cs | 48 +++ VideoAnalysis/Learn.VideoAnalysis.csproj | 3 +- VideoAnalysis/Program.cs | 11 +- VideoAnalysis/appsettings.Production.json | 4 +- VideoAnalysis/appsettings.json | 2 +- .../AICore/GPT/ChatGPT/ChatGPTClient.cs | 2 - .../AICore/GPT/DeepSeek/DeepSeekClient.cs | 2 - .../AICore/GPT/DeepSeek/DeepSeek_GPT.cs | 12 - VideoAnalysisCore/AICore/GPT/KIMI/KIMI_GPT.cs | 1 - .../AICore/GPT/KIMI/MoonshotClient.cs | 2 - VideoAnalysisCore/Common/AppCommon.cs | 41 +-- VideoAnalysisCore/Common/AppConfig.cs | 7 +- VideoAnalysisCore/Common/DownloadFile.cs | 3 +- VideoAnalysisCore/Common/ExceptionFilter.cs | 31 +- .../Common}/Expand/AppConfigExpand.cs | 11 +- .../Common}/Expand/CorsExpand.cs | 8 +- .../Common}/Expand/SqlSugarExpand.cs | 9 +- .../Common/Expand/StartUpExpand.cs | 15 + VideoAnalysisCore/Common/RedisExpand.cs | 8 +- VideoAnalysisCore/Job/NodePackageJob.cs | 15 +- VideoAnalysisCore/Job/NodeSubscriptionJob.cs | 3 +- VideoAnalysisCore/Job/TaskFileClearJob.cs | 2 +- .../Model/Dto/SpeakerCaptionsDto.cs | 3 +- .../Model/Enum/AttachmentsInfoType.cs | 16 +- VideoAnalysisCore/Model/NodePackageInfo.cs | 3 +- VideoAnalysisCore/Model/NodeSubscription.cs | 3 +- VideoAnalysisCore/VideoAnalysisCore.csproj | 3 +- 49 files changed, 1384 insertions(+), 159 deletions(-) create mode 100644 Learn.VideoAnalysis.API/AntDeploy.json create mode 100644 Learn.VideoAnalysis.API/Controllers/ApiController.cs create mode 100644 Learn.VideoAnalysis.API/Controllers/Dto/ApiDto.cs create mode 100644 Learn.VideoAnalysis.API/Controllers/LJZK_Controller.cs create mode 100644 Learn.VideoAnalysis.API/Dockerfile create mode 100644 Learn.VideoAnalysis.API/Expand/CoravelExpand.cs create mode 100644 Learn.VideoAnalysis.API/Learn.VideoAnalysis.API.csproj create mode 100644 Learn.VideoAnalysis.API/Learn.VideoAnalysis.API.http create mode 100644 Learn.VideoAnalysis.API/Program.cs create mode 100644 Learn.VideoAnalysis.API/Properties/launchSettings.json create mode 100644 Learn.VideoAnalysis.API/appsettings.Production.json create mode 100644 Learn.VideoAnalysis.API/appsettings.json create mode 100644 VideoAnalysis/Expand/SearchExpand.cs rename {VideoAnalysis => VideoAnalysisCore/Common}/Expand/AppConfigExpand.cs (70%) rename {VideoAnalysis => VideoAnalysisCore/Common}/Expand/CorsExpand.cs (84%) rename {VideoAnalysis => VideoAnalysisCore/Common}/Expand/SqlSugarExpand.cs (96%) create mode 100644 VideoAnalysisCore/Common/Expand/StartUpExpand.cs diff --git a/Learn.VideoAnalysis.API/AntDeploy.json b/Learn.VideoAnalysis.API/AntDeploy.json new file mode 100644 index 0000000..4dd9b44 --- /dev/null +++ b/Learn.VideoAnalysis.API/AntDeploy.json @@ -0,0 +1,172 @@ +{ + "Env": [ + { + "Name": "10楼刀片机", + "ServerList": [], + "LinuxServerList": [ + { + "UserName": "heyang", + "Pwd": "9718CB3C9A0760CA326767D677ADEC1C", + "Host": "10.127.127.107", + "NickName": "10楼刀片机", + "IIsFireUrl": null, + "DockerFireUrl": "", + "WindowsServiceFireUrl": null, + "LinuxServiceFireUrl": null + } + ], + "IgnoreList": [ + "ffmpeg.exe" + ], + "WindowsBackUpIgnoreList": [] + }, + { + "Name": "阿里云_代理", + "ServerList": [], + "LinuxServerList": [ + { + "UserName": "heyang", + "Pwd": "AAC53130AF118B652BCED77C39B959F9", + "Host": "10.127.127.77:10022", + "NickName": "", + "IIsFireUrl": null, + "DockerFireUrl": "", + "WindowsServiceFireUrl": null, + "LinuxServiceFireUrl": null + } + ], + "IgnoreList": [], + "WindowsBackUpIgnoreList": [] + } + ], + "IIsConfig": { + "SdkType": null, + "WebSiteName": "", + "LastEnvName": null, + "EnvPairList": [ + { + "EnvName": "10楼刀片机", + "ConfigName": "", + "LinuxEnvParam": null, + "DockerPort": null, + "DockerEnvName": null, + "DockerVolume": null, + "DockerOther": null + }, + { + "EnvName": "阿里云_代理", + "ConfigName": "", + "LinuxEnvParam": null, + "DockerPort": null, + "DockerEnvName": null, + "DockerVolume": null, + "DockerOther": null + } + ] + }, + "WindowsServiveConfig": { + "ServiceName": "", + "SdkType": null, + "LastEnvName": null, + "EnvPairList": [ + { + "EnvName": "10楼刀片机", + "ConfigName": "", + "LinuxEnvParam": null, + "DockerPort": null, + "DockerEnvName": null, + "DockerVolume": null, + "DockerOther": null + }, + { + "EnvName": "阿里云_代理", + "ConfigName": "", + "LinuxEnvParam": null, + "DockerPort": null, + "DockerEnvName": null, + "DockerVolume": null, + "DockerOther": null + } + ] + }, + "LinuxServiveConfig": { + "ServiceName": "", + "EnvParam": "", + "LastEnvName": null, + "EnvPairList": [ + { + "EnvName": "10楼刀片机", + "ConfigName": "", + "LinuxEnvParam": null, + "DockerPort": null, + "DockerEnvName": null, + "DockerVolume": null, + "DockerOther": null + }, + { + "EnvName": "阿里云_代理", + "ConfigName": "", + "LinuxEnvParam": null, + "DockerPort": null, + "DockerEnvName": null, + "DockerVolume": null, + "DockerOther": null + } + ] + }, + "DockerConfig": { + "Prot": "9040", + "AspNetCoreEnv": "", + "LastEnvName": "阿里云_代理", + "RemoveDaysFromPublished": "10", + "WorkDir": "/home/heyang/", + "Volume": "/home/hy/VideoAnalysis/AICore:/app/AICore/_Static;/home/hy/VideoAnalysis/TaskCachedFile:/app/TaskCachedFile", + "Other": "-e va_args=\"\" --name videoanalysis", + "EnvPairList": [ + { + "EnvName": "10楼刀片机", + "ConfigName": null, + "LinuxEnvParam": null, + "DockerPort": "9040", + "DockerEnvName": "", + "DockerVolume": "/home/hy/VideoAnalysis/AICore:/app/AICore/_Static;/home/hy/VideoAnalysis/TaskCachedFile:/app/TaskCachedFile", + "DockerOther": "-e va_args=\"\"" + }, + { + "EnvName": "阿里云_代理", + "ConfigName": null, + "LinuxEnvParam": null, + "DockerPort": "9040", + "DockerEnvName": "", + "DockerVolume": "/home/hy/VideoAnalysis/AICore:/app/AICore/_Static;/home/hy/VideoAnalysis/TaskCachedFile:/app/TaskCachedFile", + "DockerOther": "-e va_args=\"\" --name videoanalysis" + } + ] + }, + "DockerImageConfig": { + "BaseHttpProxy": "", + "BaseImage": "", + "BaseImageCredential": { + "UserName": "", + "Password": "" + }, + "TargetImage": "", + "TargetHttpProxy": "", + "TargetTags": [ + "" + ], + "TargetImageCredential": { + "UserName": "", + "Password": "" + }, + "ImageFormat": "Docker", + "Entrypoint": [ + "" + ], + "Cmd": [ + "" + ], + "IgnoreList": [], + "SkipExistingImages": false + } +} \ No newline at end of file diff --git a/Learn.VideoAnalysis.API/Controllers/ApiController.cs b/Learn.VideoAnalysis.API/Controllers/ApiController.cs new file mode 100644 index 0000000..cc903bc --- /dev/null +++ b/Learn.VideoAnalysis.API/Controllers/ApiController.cs @@ -0,0 +1,299 @@ + +using VideoAnalysisCore.Common; +using Microsoft.AspNetCore.Mvc; +using System.Reflection; +using MapsterMapper; +using Mapster; +using VideoAnalysisCore.AICore.SherpaOnnx; +using UserCenter.Model.Enum; +using VideoAnalysisCore.AICore.GPT.ChatGPT; +using VideoAnalysisCore.AICore.GPT; +using System.Text.Json; +using VideoAnalysisCore.Model.Enum; +using Yitter.IdGenerator; +using VideoAnalysisCore.Model; +using VideoAnalysisCore.Model.Dto; +using Learn.VideoAnalysis.API.Controllers.Dto; + +namespace Learn.VideoAnalysis.API.Controllers +{ + [ApiController] + [Route("[controller]/[action]")] + public class ApiController : ControllerBase + { + private readonly ILogger _logger; + private readonly IMapper mp; + private readonly Repository videoTaskDB; + private readonly Repository videoKonwDB; + private readonly IBserGPT chatGPT; + public ApiController(ILogger logger, Repository videoTaskDB, + IMapper mp, IBserGPT chatGPT, Repository videoKonwDB) + { + _logger = logger; + this.videoTaskDB = videoTaskDB; + this.mp = mp; + this.chatGPT = chatGPT; + this.videoKonwDB = videoKonwDB; + } + + private string GetClientIpAddress() + { + // X-Forwarded-For ͷ + if (HttpContext.Request.Headers.ContainsKey("X-Forwarded-For") + && !string.IsNullOrEmpty(HttpContext.Request.Headers["X-Forwarded-For"])) + return HttpContext.Request.Headers["X-Forwarded-For"].ToString(); + if (HttpContext.Connection.RemoteIpAddress != null) + return HttpContext.Connection.RemoteIpAddress.ToString(); + throw new Exception("δܻȡͻipַ"); + } + + /// + /// ʶ + /// + /// ļ + /// + [HttpGet(Name = "AudioRecognitionUrl")] + public async Task AudioRecognitionUrl(string url) + { + try + { + using HttpClient client = new HttpClient(); + // GETȡļ + using var networkStream = await client.GetStreamAsync(url); + var res = await SenseVoice.RunTask(networkStream); + return Ok(res); + } + catch (Exception ex) + { + return BadRequest(ex.Message); + } + } + /// + /// ʶ + /// + /// ļ + /// + [HttpPost(Name = "AudioRecognition")] + public async Task AudioRecognition(IFormFile file) + { + using var s = file.OpenReadStream(); + var res = await SenseVoice.RunTask(s); + return Ok(res); + } + + + /// + /// ȡFTS_Data str + /// + /// · + /// + [HttpGet(Name = "fts_data")] + public async Task FTS_Data(string path = "itn_subject_sx.fst") + { + var hotwords = JsonSerializer + .Deserialize(System.IO.File.ReadAllText(Path.Combine(AppCommon.AIModelFile, "Hotwords.json"))); + var res = new List(100); + foreach (var element in hotwords.OrderByDescending(s => s.key.Count())) + foreach (var e in element.v) + res.Add($"""("{e}", "{element.key}")"""); + var pyFile = System.IO.File.ReadAllText(Path.Combine(AppCommon.AIModelFile, "sherpa-onnx-fst.py")); + var resStr = pyFile + .Replace("(fts_data)", "[" + string.Join(',', res) + "]") + .Replace("(path)", path); + return Ok(resStr); + } + + + /// + /// ¿ʼִGPTtaskId/tagIdѡһ + /// + /// + /// Զid + /// лѧ null + /// + [HttpGet(Name = "ReStart")] + public async Task ReStart(long taskId, string? tagId, SubjectEnum? subject) + { + var task = await videoTaskDB.AsQueryable() + .WhereIF(taskId != 0, s => s.Id == taskId) + .WhereIF(!string.IsNullOrEmpty(tagId), s => s.TagId == tagId) + .FirstAsync(); + if (task is null) + return BadRequest("δҵӦ"); + if (subject is not null) + { + task.Subject = subject; + await videoTaskDB.UpdateAsync(task); + } + //¿ʼִGPT + RedisExpand.InsertChannel(RedisChannelEnum.ChatModelAnalysis + , task.Id); + return Ok(); + } + + + /// + /// + /// + /// + /// + /// + [HttpPost(Name = "TestInsertChannel")] + public IActionResult TestInsertChannel(int @enum = 1, string msg = "1") + { + RedisExpand.InsertChannel(@enum.ToEnum().Value + , msg); + return Ok(); + } + + /// + /// Ƶ + /// + /// + /// + [HttpPost(Name = "VideoAnalysis")] + public async Task VideoAnalysis(VideoAnalysisReq req) + { + if (!ModelState.IsValid) return BadRequest(ModelState); + + if (await videoTaskDB.IsAnyAsync(s => s.TagId == req.TagId)) + return BadRequest("ظ"); + // ԶӳԵϣ + var task = new VideoTask() + { + Id = YitIdHelper.NextId(), + ComeFrom = GetClientIpAddress(), + MediaUrl = req.MediaUrl, + ApiToken = req.ApiToken, + Type = req.Type, + Subject = req.Subject, + Tag = req.Tag, + TagId = req.TagId, + MediaName = req.Name + }; + // + var hashEntries = task.GetType() + .GetProperties(BindingFlags.Public | BindingFlags.Instance) + .ToDictionary(s => s.Name, s => s.GetValue(task)); + await videoTaskDB.InsertAsync(task); + RedisExpand.Redis.HMSet(RedisExpandKey.Task(task.Id), hashEntries); + RedisExpand.Redis.LPush(RedisExpandKey.ChannelKey, task.Id); + return Ok(task.Id); + } + + + + + + + ///// + ///// ȡƵ֪ʶƬtaskId/tagIdѡһ + ///// + ///// + ///// Զid + ///// + //[HttpGet(Name = "TaskKnowInfo")] + //public async Task TaskKnowInfo(long taskId, string? tagId) + //{ + // if (taskId == 0 && string.IsNullOrEmpty(tagId)) + // return BadRequest(); + // var task = await videoTaskDB.AsQueryable() + // .WhereIF(taskId != 0, s => s.Id == taskId) + // .WhereIF(!string.IsNullOrEmpty(tagId), s => s.TagId == tagId) + // .FirstAsync(); + // if (task is null) + // return BadRequest("Ч"); + + // var konwArr = await videoKonwDB.AsQueryable() + // .Where(s => s.VideoTaskId == task.Id) + // .ToArrayAsync(); + // if (konwArr is null || konwArr.Length == 0) + // return BadRequest("Ч"); + // return Ok(new TaskKnowRes() + // { + // TagId = task.TagId, + // Status = task.LastEnum, + // VideoTaskId = task.Id, + // KnowBlockArr = konwArr + // .GroupBy(s => s.StartTime) + // .Select(s => new TaskKnowBlock() + // { + // Id = s.First().Id, + // Content = s.First().Content, + // StartTime = s.First().StartTime, + // EndTime = s.First().EndTime, + // Theme = s.First().Theme, + // Know = s.Select(x => new TaskKnowInfo() + // { + // Id = x.Id, + // KnowPoint = x.KnowPoint, + // KnowPointId = x.KnowPointId + // }).ToArray() + // }).ToArray() + // }); + //} + ///// + ///// ȡƵϢtaskId/tagIdѡһ + ///// + ///// + ///// Զid + ///// + //[HttpGet(Name = "TaskInfo")] + //public async Task TaskInfo(long taskId, string? tagId) + //{ + // if (taskId == 0 && string.IsNullOrEmpty(tagId)) + // return BadRequest(); + // var task = await videoTaskDB.AsQueryable() + // .WhereIF(taskId != 0, s => s.Id == taskId) + // .WhereIF(!string.IsNullOrEmpty(tagId), s => s.TagId == tagId) + // .FirstAsync(); + // if (task is null) + // return BadRequest(); + // var taskData = task.ChatAnalysis.Adapt(); + // if (taskData is null) + // return BadRequest(); + // taskData.Status = task.LastEnum; + // if (task.LastEnum != RedisChannelEnum.EndTask) + // return BadRequest(taskData); + // if (taskData != null && taskData.TimeBase != null) + // taskData.TimeBase = MergeTimeBases(taskData.TimeBase); + // return Ok(taskData); + //} + + + //[NonAction] + //private static List MergeTimeBases(IEnumerable timeBases) + //{ + // if (timeBases == null || timeBases.Count() == 0) + // { + // return new List(); + // } + // var mergedList = new List(); + // // ʼϲ + // var current = timeBases.First(); + // current.Content = string.Empty; + // foreach (var next in timeBases) + // { + // // ͬչʱ + // if (current.TimeBaseType == next.TimeBaseType) + // current.End = Math.Max(current.End, next.End); + // else + // { + // // Ͳͬǰʱμбʼʱ + // mergedList.Add(current); + // current = next; + // current.Content = string.Empty; + // } + // } + // // ʱ + // mergedList.Add(current); + // return mergedList; + //} + + + + + + + } +} diff --git a/Learn.VideoAnalysis.API/Controllers/Dto/ApiDto.cs b/Learn.VideoAnalysis.API/Controllers/Dto/ApiDto.cs new file mode 100644 index 0000000..650f11a --- /dev/null +++ b/Learn.VideoAnalysis.API/Controllers/Dto/ApiDto.cs @@ -0,0 +1,246 @@ +using SqlSugar; +using System.ComponentModel.DataAnnotations; +using UserCenter.Model.Enum; +using VideoAnalysisCore.AICore.GPT.Dto; +using VideoAnalysisCore.Model.Enum; + +namespace Learn.VideoAnalysis.API.Controllers.Dto +{ + /// + /// 视频列表项 + /// + public class StructurePageContentAnalyzeItem + { + /// + /// 录播内容编号 + /// + public long StructurePageContentId { get; set; } + + /// + /// 素材ID + /// + public long MaterialId { get; set; } + + /// + /// 视频编码 + /// + public string VideoCode { get; set; } + + /// + /// 视频文件名称 + /// + public string VideoName { get; set; } + /// + /// 内容类型 + /// + public AttachmentsInfoType AttachmentsInfoType { get; set; } + } + public class NodePackageReq + { + + /// + /// 录播结构目录节点编号 + /// + [Required(ErrorMessage = "目录节点编号是必填项")] + public long NodeId { get; set; } + + /// + /// 科目类型 + /// + [Required(ErrorMessage = "科目类型是必填项")] + public SubjectEnum SubjectType { get; set; } + + /// + /// 任务类型 + /// + [Required(ErrorMessage = "任务类型是必填项")] + public TaskTypeEnum TaskType { get; set; } + + /// + /// 视频列表 + /// + [Required(ErrorMessage = "文件数量是必填项")] + public List AnalyzeItems { get; set; } + + } + /// + /// 视频处理 请求 + /// + public class NodeMonitoringReq + { + /// + /// 媒体路径 + /// + [Required(ErrorMessage = "文件节点ID是必填项")] + public long NodeId { get; set; } + /// + /// 任务类型 + /// + public TaskTypeEnum? Type { get; set; } + /// + /// 学科类型 + /// + public SubjectEnum? Subject { get; set; } + + } + /// + /// 视频处理 请求 + /// + public class VideoAnalysisReq + { + /// + /// 媒体路径 + /// + [Required(ErrorMessage = "资源URL是必填项")] + public string MediaUrl { get; set; } = string.Empty; + /// + /// 资源名称 + /// + [Required(ErrorMessage = "资源名称是必要的")] + public string Name { get; set; } = string.Empty; + /// + /// ApiKey + /// + [Required(ErrorMessage = "接口Token是必填项")] + public string ApiToken { get; set; } = string.Empty; + /// + /// 内容所属学科 + /// + public SubjectEnum? Subject { get; set; } + /// + /// 任务类型 + /// + public TaskTypeEnum? Type { get; set; } + /// + /// 自定义值 任务完成后附带通知 + /// + public string Tag { get; set; } = string.Empty; + /// + /// 自定义Id可用于任务完成之后的查询 + /// + public string? TagId { get; set; } + /// + ///回调Api地址 + /// + //[Required(ErrorMessage = "回调Api地址是必填项")] + //[Url(ErrorMessage = "请输入有效的 URL")] + //public string CallBackUrl { get; set; } = string.Empty; + + } + public class TextValue + { + public TextValue(float v) + { + var s = TimeSpan.FromSeconds((double)v); + var td = new[] { s.Hours, s.Minutes, s.Seconds }; + Text = string.Join(':', td.Where(s => s > 0)); + Value = v; + } + public TextValue(string t, object v) + { + Text = t; + Value = v; + } + public TextValue() + { + + } + public string Text { get; set; } + public object Value { get; set; } + } + public class TaskKnowInfo + { + /// + ///视频片段知识点 id + /// + public long Id { get; set; } + /// + /// 知识点 + /// + public string KnowPoint { get; set; } + /// + /// 知识点ID + /// + public string KnowPointId { get; set; } + + } + public class TaskKnowBlock + { + public long Id { get; set; } + + /// + /// 开始时间 + /// + public float? StartTime { get; set; } + /// + /// 结束时间 + /// + public float? EndTime { get; set; } + /// + /// 持续时间 + /// + [SugarColumn(IsIgnore = true)] + public float? KeepTime => (EndTime ?? 0) - StartTime ?? 0; + /// + /// 主题 + /// + public string? Theme { get; set; } + /// + /// 内容总结 + /// + public string? Content { get; set; } + /// + /// 知识点列表 + /// + public TaskKnowInfo[] Know { get; set; } + } + /// + /// 视频片段知识点结果 + /// + public class TaskKnowRes + { + /// + /// 自定义Id [任务视频自定义id] + /// + /// + public string? TagId { get; set; } + /// + /// 任务当前执行状态 + /// + public RedisChannelEnum Status { get; set; } + /// + /// 视频任务id + /// + public long VideoTaskId { get; set; } + /// + /// 视频知识快 + /// + public TaskKnowBlock[] KnowBlockArr { get; set; } + + } + public class TaskInfoRes : TaskRes + { + public TaskInfoRes() + { + + } + /// + /// 任务当前执行状态 + /// + public RedisChannelEnum Status { get; set; } + ///// + ///// 时间轴状态枚举 + ///// + //public Dictionary TimeTypeEnum => + // Enum.GetValues(typeof(TimeBaseTypeEnum)) + // .Cast() + // .ToDictionary(x => (int)x, x => x.ToString()); + + ///// + ///// 时间轴合计 + ///// + //public Dictionary? TimeBaseTotal => + // TimeBase?.GroupBy(s => s.TimeBaseType??TimeBaseTypeEnum.教师讲授)? + // .ToDictionary(s => s.Key, s => new TextValue(s.Sum(x => x.End - x.Start))); + } +} diff --git a/Learn.VideoAnalysis.API/Controllers/LJZK_Controller.cs b/Learn.VideoAnalysis.API/Controllers/LJZK_Controller.cs new file mode 100644 index 0000000..35c42f7 --- /dev/null +++ b/Learn.VideoAnalysis.API/Controllers/LJZK_Controller.cs @@ -0,0 +1,196 @@ + +using VideoAnalysisCore.Common; +using Microsoft.AspNetCore.Mvc; +using System.Reflection; +using MapsterMapper; +using Mapster; +using VideoAnalysisCore.AICore.SherpaOnnx; +using UserCenter.Model.Enum; +using VideoAnalysisCore.AICore.GPT.ChatGPT; +using VideoAnalysisCore.AICore.GPT; +using System.Text.Json; +using Microsoft.AspNetCore.Authorization; +using VideoAnalysisCore.Model.Enum; +using FFmpeg.NET.Services; +using Yitter.IdGenerator; +using VideoAnalysisCore.AICore.GPT.Dto; +using VideoAnalysisCore.Model; +using Learn.VideoAnalysis.API.Controllers.Dto; + +namespace Learn.VideoAnalysis.API.Controllers +{ + /// + /// ֿӿ + /// + [ApiController] + [Route("LJZK/[action]")] + public class LJZK_Controller : ControllerBase + { + private readonly ILogger _logger; + private readonly IMapper mp; + private readonly Repository nodesubscriptionDB; + private readonly Repository videoTaskDB; + private readonly Repository videoKonwPointDB; + private readonly Repository nodePackageInfoDB; + public LJZK_Controller(ILogger logger, + IMapper mp, Repository nodesubscriptionDB, + Repository videoTaskDB = null, Repository videoKonwPointDB = null + , Repository nodePackageInfoDB = null) + { + _logger = logger; + this.mp = mp; + this.nodesubscriptionDB = nodesubscriptionDB; + this.videoTaskDB = videoTaskDB; + this.videoKonwPointDB = videoKonwPointDB; + this.nodePackageInfoDB = nodePackageInfoDB; + } + + + /// + /// ǿ_ļڵ + /// + /// + /// + [HttpPost(Name = "NodeSubscription")] + public async Task NodeSubscription(NodeMonitoringReq req) + { + if (req is null || req.NodeId == 0) + return BadRequest("Чύ"); + if (nodesubscriptionDB.IsAny(s => s.NodeId == req.NodeId)) + return BadRequest("ظ˽ڵ" + req.NodeId); + var res = await nodesubscriptionDB.InsertReturnEntityAsync(new NodeSubscription() + { + NodeId = req.NodeId, + TaskType = req.Type ?? default, + Subject = req.Subject ?? default, + + }); + return Ok(res); + } + + /// + /// ǿ_ļ + /// + /// + /// + [HttpPost(Name = "NodePackage")] + public async Task NodePackage(NodePackageReq req) + { + Console.WriteLine($"{DateTime.Now} ļ req=" + JsonSerializer.Serialize(req)); + if (req.AnalyzeItems is null || req.AnalyzeItems.Count() == 0) + return BadRequest("ЧƵб"); + var videos = new List(req.AnalyzeItems.Count); + var nodePackages = new List(req.AnalyzeItems.Count); + var videoIdArr = videoTaskDB.AsQueryable().Select(v => v.TagId).Distinct().ToArray(); + foreach (var s in req.AnalyzeItems) + { + var np = new NodePackageInfo() + { + VideoCode = s.VideoCode, + AttachmentsInfoType = s.AttachmentsInfoType, + MaterialId = s.MaterialId, + StructurePageContentId = s.StructurePageContentId, + VideoName = s.VideoName, + NodeId = req.NodeId, + TaskType = req.TaskType, + SubjectType = req.SubjectType, + }; + nodePackages.Add(np); + if (videoIdArr.Contains(s.VideoCode)) + continue; + videos.Add(new VideoTask() + { + Id = YitIdHelper.NextId(), + ComeFrom = "127.0.0.1", + ApiToken = "", + Type = req.TaskType, + Subject = req.SubjectType, + TagId = s.VideoCode, + MediaUrl = string.Empty, + 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(); + } + + /// + /// ȡ + /// + /// + [HttpGet(Name = "TaskTypList")] + public IActionResult TaskType() + { + Type type = typeof(TaskTypeEnum); + return Ok(Enum.GetValues(type).Cast() + .Select(s => new { Text = s.ToString(), Value = (int)s })); + } + /// + /// ȡѧ + /// + /// + [HttpGet(Name = "SubjectList")] + public IActionResult Subject() + { + Type type = typeof(SubjectEnum); + return Ok(Enum.GetValues(type).Cast() + .Select(s => new { Text = s.ToString(), Value = (int)s })); + } + + /// + /// ȡƵ֪ʶƬtaskId/tagIdѡһ + /// + /// + /// Զid + /// + [HttpGet(Name = "TaskKnowInfo")] + public async Task TaskKnowInfo(long taskId, string? tagId) + { + if (taskId == 0 && string.IsNullOrEmpty(tagId)) + return BadRequest(); + var task = await videoTaskDB.AsQueryable() + .WhereIF(taskId != 0, s => s.Id == taskId) + .WhereIF(!string.IsNullOrEmpty(tagId), s => s.TagId == tagId) + .FirstAsync(); + if (task is null) + return BadRequest("Ч"); + + var konwArr = await videoKonwPointDB.AsQueryable() + .Where(s => s.VideoTaskId == task.Id) + .ToArrayAsync(); + if (konwArr is null || konwArr.Length == 0) + return BadRequest("Ч"); + return Ok(new TaskKnowRes() + { + TagId = task.TagId, + Status = task.LastEnum, + VideoTaskId = task.Id, + KnowBlockArr = konwArr + .GroupBy(s => s.StartTime) + .Select(s => new TaskKnowBlock() + { + Id = s.First().Id, + Content = s.First().Content, + StartTime = s.First().StartTime, + EndTime = s.First().EndTime, + Theme = s.First().Theme, + Know = s.Select(x => new TaskKnowInfo() + { + Id = x.Id, + KnowPoint = x.KnowPoint, + KnowPointId = x.KnowPointId + }).ToArray() + }).ToArray() + }); + } + + + + + } +} diff --git a/Learn.VideoAnalysis.API/Dockerfile b/Learn.VideoAnalysis.API/Dockerfile new file mode 100644 index 0000000..dc117ef --- /dev/null +++ b/Learn.VideoAnalysis.API/Dockerfile @@ -0,0 +1,15 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base + +WORKDIR /app +EXPOSE 9040 +COPY . . +#设置时间为中国上海 环境为开发环境 +ENV TZ=Asia/Shanghai + + # 给我们要传的参数一个初始值 +ENV va_args= + + +ENV ASPNETCORE_URLS=http://+:9040 + +ENTRYPOINT dotnet Learn.VideoAnalysis.API.dll $va_args diff --git a/Learn.VideoAnalysis.API/Expand/CoravelExpand.cs b/Learn.VideoAnalysis.API/Expand/CoravelExpand.cs new file mode 100644 index 0000000..9586794 --- /dev/null +++ b/Learn.VideoAnalysis.API/Expand/CoravelExpand.cs @@ -0,0 +1,36 @@ +using Coravel; +using Coravel.Scheduling.Schedule; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VideoAnalysisCore.Job; + +namespace Learn.VideoAnalysis.API.Expand +{ + public static class CoravelExpand + { + public static void AddCoravel(this IServiceCollection service) + { + + Console.WriteLine($"{DateTime.Now}=>初始化 Coravel"); + service.AddScheduler(); + service.AddTransient(); + service.AddTransient(); + service.AddTransient(); + } + public static void UseCoravelExpand(this IApplicationBuilder provider) + { + provider.ApplicationServices.UseScheduler(scheduler => + { + //每5分钟执行一次 未处理视频扫描 + scheduler.Schedule().EveryFiveMinutes(); + //文件包分析 + scheduler.Schedule().EveryThirtyMinutes(); //每30分钟执行一次 + }); + } + } +} diff --git a/Learn.VideoAnalysis.API/Learn.VideoAnalysis.API.csproj b/Learn.VideoAnalysis.API/Learn.VideoAnalysis.API.csproj new file mode 100644 index 0000000..7a1ec0a --- /dev/null +++ b/Learn.VideoAnalysis.API/Learn.VideoAnalysis.API.csproj @@ -0,0 +1,41 @@ + + + + net8.0 + enable + enable + True + + + + + + + + + Always + + + + + + + + + + + + + + + Always + + + Always + + + Always + + + + diff --git a/Learn.VideoAnalysis.API/Learn.VideoAnalysis.API.http b/Learn.VideoAnalysis.API/Learn.VideoAnalysis.API.http new file mode 100644 index 0000000..94de2da --- /dev/null +++ b/Learn.VideoAnalysis.API/Learn.VideoAnalysis.API.http @@ -0,0 +1,6 @@ +@Learn.VideoAnalysis.API_HostAddress = http://localhost:5245 + +GET {{Learn.VideoAnalysis.API_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/Learn.VideoAnalysis.API/Program.cs b/Learn.VideoAnalysis.API/Program.cs new file mode 100644 index 0000000..240fdb1 --- /dev/null +++ b/Learn.VideoAnalysis.API/Program.cs @@ -0,0 +1,71 @@ + +using Learn.VideoAnalysis.API.Expand; +using Mapster; +using Microsoft.OpenApi.Models; +using VideoAnalysisCore.AICore.GPT.DeepSeek; +using VideoAnalysisCore.Common; +using VideoAnalysisCore.Common.Expand; + +namespace Learn.VideoAnalysis.API +{ + public class Program + { + public static void Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + + // Add services to the container. + + builder.Services.AddControllers(); + // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle + builder.Services.AddEndpointsApiExplorer(); + builder.Services.AddSwaggerGen(c => + { + var file = Path.Combine(AppContext.BaseDirectory, "Learn.VideoAnalysis.API.xml"); // xmlĵ· + c.IncludeXmlComments(file, true); // true : ʾע + c.OrderActionsBy(o => o.RelativePath); // actionƽжͿԿЧˡ + }); + + + builder.Services.AddMapster(); + + //ʼ + builder.Configuration.AddAppConfig(args); + + builder.Services.AddSqlSugarExpand(); + builder.Services.AddRedisExpand(); + builder.Services.AddCoravel(); + builder.Services.AddCorsExpand(); + builder.Services.AddHttpContextAccessor(); + builder.Services.AddControllersWithViews(options => + { + options.Filters.Add(typeof(ExceptionFilter)); + }); + + + var app = builder.Build(); + AppCommon.Services = app.Services; + // Configure the HTTP request pipeline. + if (app.Environment.IsDevelopment()) + { + app.UseSwagger(); + app.UseSwaggerUI(); + } + + app.UseHttpsRedirection(); + + app.UseAuthorization(); + + + app.MapControllers(); + + //Զ Ӧ + app.UseCorsExpand(); + app.UseSqlSugarExpand(); + app.UseCoravelExpand(); + + + app.Run(); + } + } +} diff --git a/Learn.VideoAnalysis.API/Properties/launchSettings.json b/Learn.VideoAnalysis.API/Properties/launchSettings.json new file mode 100644 index 0000000..6381c65 --- /dev/null +++ b/Learn.VideoAnalysis.API/Properties/launchSettings.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "profiles": { + "http:5238": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5238", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Learn.VideoAnalysis.API/appsettings.Production.json b/Learn.VideoAnalysis.API/appsettings.Production.json new file mode 100644 index 0000000..3e96819 --- /dev/null +++ b/Learn.VideoAnalysis.API/appsettings.Production.json @@ -0,0 +1,32 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Error", + "Microsoft.AspNetCore": "Error" + } + }, + "AppConfig": { + "TaskSetting": { + "DownloadSpeed": 8, + "IS_Server": true //接收任务? + }, + "Subsystem": { + "蓝鲸智库": { + "APIUrl": "https://zyapi.23544.com", + "Token": "" + } + }, + "Redis": { + "ConnectionString": "redis-external.23544.com:16379,password=poiuyt)(*&^%,defaultDatabase=3" + }, + "FFmpeg": { + " TimeSlice": 600 + }, + "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", + "SqlType": "MySql", + "UpdateTable": false + } + } +} diff --git a/Learn.VideoAnalysis.API/appsettings.json b/Learn.VideoAnalysis.API/appsettings.json new file mode 100644 index 0000000..0b0817c --- /dev/null +++ b/Learn.VideoAnalysis.API/appsettings.json @@ -0,0 +1,76 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "AppConfig": { + "ID": 1, //程序唯一值 + "TaskSetting": { + "DownloadSpeed": 2, + "IS_Server": true //接收任务 + }, + "Admin": { + "Account": "admin", + "Password": "q1w2e3!@#" + }, + "Subsystem": { + "蓝鲸智库": { + "APIUrl": "http://192.168.2.117:6400", + "Token": "" + } + }, + "Redis": { + "ConnectionString": "127.0.0.1:6379,password=Woshiren123,defaultDatabase=10" + }, + "Whisper": { + "ModelName": "ggml-small.bin" + }, + "FFmpeg": { + " TimeSlice": 600 + }, + "ChatGpt": { + "KIMI": { + "Host": "https://api.moonshot.cn", + "ApiKey": "sk-8BvvhESZIkgUbiaaJhglPxFa4o2X9H3xEv9lXELrWWwGxHWY" + }, + "ChatGpt": { + "Host": "https://api.g4f.icu/", + //"Host": "https://api.oaibest.com/", + "ApiKey": "sk-D15tBln31N7dI9Fi7lds7OySFv5tOEK7DMNsG5rY2E6DCr4s" + }, + "DeepSeek": { + "Host": "https://api.deepseek.com/chat/completions", + "ApiKey": "sk-88d3d2bc3dae4d50854b2569b281cf76" + }, + "aliyun": { + "Host": "https://dashscope.aliyuncs.com/compatible-mode/", + "ApiKey": "sk-1742c2bf7b9846ae835de598dc6c427b" + } + }, + "DB": { + "ConnectionString": "AllowLoadLocalInfile=true;Server=192.168.2.9;User ID=root;Password=qwe123!@#;Port=3306;Database=learn.videoanalysis;CharSet=utf8mb4;pooling=true;SslMode=None", + "SqlType": "MySql", + "UpdateTable": false + }, + "AlibabaCloudVod": { + "AccessKeyId": "LTAI5tDC6p9h747B7FHbgwkH", + "AccessKeySecret": "vRKgmbp1LB05LaGOjh3ZrZxbHSLYLF", + "EndPoint": "vod.cn-shanghai.aliyuncs.com" //上传节点 + }, + "OtherDBArr": [ + { + "ConfigId": 1001, //ResourceBank + "ConnectionString": "Server=47.109.35.116;Database=ResourceBank;UID=live;Password=Woshiren^&*();MultipleActiveResultSets=true;Encrypt=True;TrustServerCertificate=True;", + "SqlType": "SqlServer" + }, + { + "ConfigId": 1002, //App.public.live + "ConnectionString": "Server=47.109.35.116;Database=App.public.live;UID=live;Password=Woshiren^&*();MultipleActiveResultSets=true;Encrypt=True;TrustServerCertificate=True;", + "SqlType": "SqlServer" + } + ] + } +} diff --git a/Learn.VideoAnalysis.sln b/Learn.VideoAnalysis.sln index 713ed78..450a0c5 100644 --- a/Learn.VideoAnalysis.sln +++ b/Learn.VideoAnalysis.sln @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Learn.VideoAnalysis", "Vide EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VideoAnalysisCore", "VideoAnalysisCore\VideoAnalysisCore.csproj", "{69F4243A-B22E-431B-8F0B-ECD8729B8665}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Learn.VideoAnalysis.API", "Learn.VideoAnalysis.API\Learn.VideoAnalysis.API.csproj", "{D31BA4AB-73FC-47B1-A10A-34FD5E921F4A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {69F4243A-B22E-431B-8F0B-ECD8729B8665}.Debug|Any CPU.Build.0 = Debug|Any CPU {69F4243A-B22E-431B-8F0B-ECD8729B8665}.Release|Any CPU.ActiveCfg = Release|Any CPU {69F4243A-B22E-431B-8F0B-ECD8729B8665}.Release|Any CPU.Build.0 = Release|Any CPU + {D31BA4AB-73FC-47B1-A10A-34FD5E921F4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D31BA4AB-73FC-47B1-A10A-34FD5E921F4A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D31BA4AB-73FC-47B1-A10A-34FD5E921F4A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D31BA4AB-73FC-47B1-A10A-34FD5E921F4A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/VideoAnalysis/AntDeploy.json b/VideoAnalysis/AntDeploy.json index 86fde1e..c4da2cd 100644 --- a/VideoAnalysis/AntDeploy.json +++ b/VideoAnalysis/AntDeploy.json @@ -5,7 +5,7 @@ "ServerList": [], "LinuxServerList": [ { - "UserName": "hy", + "UserName": "heyang", "Pwd": "9718CB3C9A0760CA326767D677ADEC1C", "Host": "10.127.127.107", "NickName": "10楼刀片机", @@ -117,11 +117,11 @@ "DockerConfig": { "Prot": "9040", "AspNetCoreEnv": "", - "LastEnvName": "阿里云_代理", + "LastEnvName": "10楼刀片机", "RemoveDaysFromPublished": "10", "WorkDir": "/home/heyang/", "Volume": "/home/hy/VideoAnalysis/AICore:/app/AICore/_Static;/home/hy/VideoAnalysis/TaskCachedFile:/app/TaskCachedFile", - "Other": "-e va_args=\"NoTask\" --name videoanalysis", + "Other": "-e va_args=\"\"", "EnvPairList": [ { "EnvName": "10楼刀片机", @@ -130,7 +130,7 @@ "DockerPort": "9040", "DockerEnvName": "", "DockerVolume": "/home/hy/VideoAnalysis/AICore:/app/AICore/_Static;/home/hy/VideoAnalysis/TaskCachedFile:/app/TaskCachedFile", - "DockerOther": "-e va_args=\"NoTask1\"" + "DockerOther": "-e va_args=\"\"" }, { "EnvName": "阿里云_代理", @@ -139,7 +139,7 @@ "DockerPort": "9040", "DockerEnvName": "", "DockerVolume": "/home/hy/VideoAnalysis/AICore:/app/AICore/_Static;/home/hy/VideoAnalysis/TaskCachedFile:/app/TaskCachedFile", - "DockerOther": "-e va_args=\"NoTask\" --name videoanalysis" + "DockerOther": "-e va_args=\"IS_Server\" --name videoanalysis" } ] }, diff --git a/VideoAnalysis/Components/Layouts/BasicLayout.razor b/VideoAnalysis/Components/Layouts/BasicLayout.razor index 19d247a..b8d5774 100644 --- a/VideoAnalysis/Components/Layouts/BasicLayout.razor +++ b/VideoAnalysis/Components/Layouts/BasicLayout.razor @@ -1,4 +1,5 @@ @namespace VideoAnalysisRazor.Layouts +@using static AntDesign.IconType @inherits LayoutComponentBase taskDB { get; set; } = default!; + [Inject] private Repository videoKonwPointDB { get; set; } = default!; [Inject] private IJSRuntime JSRuntime { get; set; } = default!; private VideoTask nowTask { get; set; } = default!; @@ -57,7 +59,7 @@ namespace Learn.VideoAnalysis.Components.Pages } public string getF(VideoKnowRes segment) { - var sf = ((int)((segment.StartTime ?? 0) / 60)).ToString().PadLeft(2,'0'); + var sf = ((int)((segment.StartTime ?? 0) / 60)).ToString().PadLeft(2, '0'); var sm = ((int)((segment.StartTime ?? 0) % 60)).ToString().PadLeft(2, '0'); return $"{sf}:{sm}"; //var ef = ((int)((segment.EndTime ?? 0) / 60)).ToString().PadLeft(2, '0'); @@ -73,13 +75,27 @@ namespace Learn.VideoAnalysis.Components.Pages return; long taskId = this.taskId.Value; nowTask = await taskDB.GetFirstAsync(s => s.Id == taskId); - if(nowTask is null) + if (nowTask is null) return; - captionsArr = RedisExpand.Redis.HMGet(RedisExpandKey.Task(taskId), "Captions").FirstOrDefault(); - videoKnows = RedisExpand.Redis.HMGet(RedisExpandKey.Task(taskId), "VideoKnows").FirstOrDefault(); - videoPath = AppCommon.GetVideoPath(nowTask.Id.ToString()); + captionsArr = JsonSerializer.Deserialize(nowTask.Captions); + RedisExpand.Redis.HMGet(RedisExpandKey.Task(taskId), "Captions").FirstOrDefault(); - await JSRuntime.InvokeVoidAsync("setDB", captionsArr,videoKnows, videoPath); + var konwArr = await videoKonwPointDB.AsQueryable() + .Where(s => s.VideoTaskId == nowTask.Id) + .ToArrayAsync(); + + videoKnows = konwArr + .GroupBy(s => s.StartTime) + .Select(s => new VideoKnowRes() + { + Content = s.First().Content, + StartTime = s.First().StartTime, + EndTime = s.First().EndTime, + Theme = s.First().Theme, + KnowPoint = string.Join(',', s.Select(x => x.KnowPoint)) + }).ToArray(); + videoPath = AppCommon.GetVideoPath(nowTask.Id.ToString()); + await JSRuntime.InvokeVoidAsync("setDB", captionsArr, videoKnows, videoPath); StateHasChanged(); } diff --git a/VideoAnalysis/Controllers/Dto/ApiDto.cs b/VideoAnalysis/Controllers/Dto/ApiDto.cs index b37ffe3..e57524b 100644 --- a/VideoAnalysis/Controllers/Dto/ApiDto.cs +++ b/VideoAnalysis/Controllers/Dto/ApiDto.cs @@ -51,7 +51,7 @@ namespace Learn.VideoAnalysis.Controllers.Dto [Required(ErrorMessage = "科目类型是必填项")] public SubjectEnum SubjectType { get; set; } - /// + /// /// 任务类型 /// [Required(ErrorMessage = "任务类型是必填项")] diff --git a/VideoAnalysis/Dockerfile b/VideoAnalysis/Dockerfile index c28f887..c76862c 100644 --- a/VideoAnalysis/Dockerfile +++ b/VideoAnalysis/Dockerfile @@ -1,6 +1,6 @@ #See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. -FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +FROM harbor.w.23544.com:8843/marking/learnvideo-net8.0:v0.1 AS base WORKDIR /app @@ -9,13 +9,9 @@ COPY . . #设置时间为中国上海 环境为开发环境 ENV TZ=Asia/Shanghai -# 更新 apt 源 -COPY sources.list /etc/apt/sources.list -RUN apt-get update -RUN apt-get install -y ffmpeg - # 给我们要传的参数一个初始值 ENV va_args= + ENV ASPNETCORE_URLS=http://+:9040 diff --git a/VideoAnalysis/Expand/CoravelExpand.cs b/VideoAnalysis/Expand/CoravelExpand.cs index 1c7c59d..669edb6 100644 --- a/VideoAnalysis/Expand/CoravelExpand.cs +++ b/VideoAnalysis/Expand/CoravelExpand.cs @@ -1,5 +1,6 @@ using Coravel; using Coravel.Scheduling.Schedule; +using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; @@ -12,7 +13,6 @@ namespace Learn.VideoAnalysis.Expand { public static class CoravelExpand { - public static int MyProperty { get; set; } public static void AddCoravel(this IServiceCollection service) { @@ -22,15 +22,11 @@ namespace Learn.VideoAnalysis.Expand service.AddTransient(); service.AddTransient(); } - public static void UseCoravelExpand(this IServiceProvider provider) + public static void UseCoravelExpand(this IApplicationBuilder provider) { - provider.UseScheduler(scheduler => + provider.ApplicationServices.UseScheduler(scheduler => { - //每5分钟执行一次 未处理视频扫描 - scheduler.Schedule().EveryFiveMinutes(); - //文件包分析 - scheduler.Schedule().EveryThirtyMinutes(); //每30分钟执行一次 - //任务缓存清理 + //任务缓存清理 // scheduler.Schedule().HourlyAt(10); }); } diff --git a/VideoAnalysis/Expand/SearchExpand.cs b/VideoAnalysis/Expand/SearchExpand.cs new file mode 100644 index 0000000..c3ecacf --- /dev/null +++ b/VideoAnalysis/Expand/SearchExpand.cs @@ -0,0 +1,48 @@ +using SqlSugar; +using AntDesign; +using AntDesign.TableModels; + +namespace Learn.VideoAnalysis.API.Expand +{ + public static class SearchExpand + { + + /// + /// 转换 ant 查询枚举 到 sqlsuger枚举 + /// + /// ant 查询枚举 + /// + /// + public static ConditionalType ConvertToConditionalType(TableFilterCompareOperator filterOperator) + { + return filterOperator switch + { + TableFilterCompareOperator.Equals => ConditionalType.Equal, + TableFilterCompareOperator.Contains => ConditionalType.Like, + TableFilterCompareOperator.StartsWith => ConditionalType.LikeLeft, + TableFilterCompareOperator.EndsWith => ConditionalType.LikeRight, + TableFilterCompareOperator.GreaterThan => ConditionalType.GreaterThan, + TableFilterCompareOperator.LessThan => ConditionalType.LessThan, + TableFilterCompareOperator.GreaterThanOrEquals => ConditionalType.GreaterThanOrEqual, + TableFilterCompareOperator.LessThanOrEquals => ConditionalType.LessThanOrEqual, + TableFilterCompareOperator.Condition => ConditionalType.In, + TableFilterCompareOperator.NotEquals => ConditionalType.NoEqual, + TableFilterCompareOperator.IsNull => ConditionalType.IsNullOrEmpty, + TableFilterCompareOperator.IsNotNull => ConditionalType.IsNot, + TableFilterCompareOperator.NotContains => ConditionalType.NoLike, + TableFilterCompareOperator.TheSameDateWith => ConditionalType.EqualNull, + TableFilterCompareOperator.Between => ConditionalType.Range, + _ => throw new ArgumentOutOfRangeException(nameof(filterOperator), filterOperator, "未知的枚举类型!") + }; + } + public static List ToSqlSugerWhere(this QueryModel qm) + { + return qm.FilterModel.SelectMany(s => s.Filters.Select(x => new ConditionalModel() + { + FieldName = s.FieldName, + ConditionalType = ConvertToConditionalType(x.FilterCompareOperator), + FieldValue = x.Value.GetType().IsEnum ? ((int)x.Value).ToString() : x.Value.ToString(), + } as IConditionalModel)).ToList(); + } + } +} diff --git a/VideoAnalysis/Learn.VideoAnalysis.csproj b/VideoAnalysis/Learn.VideoAnalysis.csproj index 1b9556b..39f817c 100644 --- a/VideoAnalysis/Learn.VideoAnalysis.csproj +++ b/VideoAnalysis/Learn.VideoAnalysis.csproj @@ -32,10 +32,11 @@ + - + diff --git a/VideoAnalysis/Program.cs b/VideoAnalysis/Program.cs index 6720994..acf33d7 100644 --- a/VideoAnalysis/Program.cs +++ b/VideoAnalysis/Program.cs @@ -1,7 +1,6 @@ using VideoAnalysisCore.Common; using Learn.VideoAnalysis.Components; using Microsoft.OpenApi.Models; -using AntDesign.ProLayout; using VideoAnalysisCore.AICore.SherpaOnnx; using Mapster; using VideoAnalysisCore.AICore.GPT; @@ -10,6 +9,7 @@ using VideoAnalysisCore.AICore.GPT.ChatGPT; using Microsoft.Extensions.FileProviders; using VideoAnalysisCore.AICore.GPT.DeepSeek; using Microsoft.Extensions.DependencyInjection; +using VideoAnalysisCore.Common.Expand; using Learn.VideoAnalysis.Expand; @@ -88,9 +88,6 @@ namespace Learn.VideoAnalysis builder.Services.AddMapster(); builder.Services.AddCorsExpand(); - - builder.Services.Configure(builder.Configuration.GetSection("ProSettings")); - builder.Services.AddHttpClient(); builder.Services.AddHttpContextAccessor(); builder.Services.AddSingleton(); @@ -128,11 +125,11 @@ namespace Learn.VideoAnalysis app.MapControllers(); - app.UseCorsExpand(); //Զ Ӧ - SqlSugarExpand.InitDB(); - app.Services.UseCoravelExpand(); + app.UseCorsExpand(); + app.UseSqlSugarExpand(); + app.UseCoravelExpand(); app.Run(); diff --git a/VideoAnalysis/appsettings.Production.json b/VideoAnalysis/appsettings.Production.json index 24562c6..e7a4068 100644 --- a/VideoAnalysis/appsettings.Production.json +++ b/VideoAnalysis/appsettings.Production.json @@ -8,7 +8,7 @@ "AppConfig": { "TaskSetting": { "DownloadSpeed": 8, - "ProcessingTasks": true //接收任务? + "IS_Server": false //接收任务? }, "Subsystem": { "蓝鲸智库": { @@ -17,7 +17,7 @@ } }, "Redis": { - "ConnectionString": "172.28.0.1,password=qwe123!@#,defaultDatabase=3" + "ConnectionString": "redis-external.23544.com:16379,password=poiuyt)(*&^%,defaultDatabase=3" }, "FFmpeg": { " TimeSlice": 600 diff --git a/VideoAnalysis/appsettings.json b/VideoAnalysis/appsettings.json index 9f7bc1e..2e2bc56 100644 --- a/VideoAnalysis/appsettings.json +++ b/VideoAnalysis/appsettings.json @@ -10,7 +10,7 @@ "ID": 1, //程序唯一值 "TaskSetting": { "DownloadSpeed": 2, - "ProcessingTasks": true,//接收任务? + "IS_Server": false //接收任务 }, "Admin": { "Account": "admin", diff --git a/VideoAnalysisCore/AICore/GPT/ChatGPT/ChatGPTClient.cs b/VideoAnalysisCore/AICore/GPT/ChatGPT/ChatGPTClient.cs index 28690de..67aff13 100644 --- a/VideoAnalysisCore/AICore/GPT/ChatGPT/ChatGPTClient.cs +++ b/VideoAnalysisCore/AICore/GPT/ChatGPT/ChatGPTClient.cs @@ -6,8 +6,6 @@ using Newtonsoft.Json.Linq; using System.Net.Http; using Newtonsoft.Json; using System.Net.Http.Json; -using AntDesign; -using OneOf.Types; using System.Net; diff --git a/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeekClient.cs b/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeekClient.cs index 72b40cb..8bc087e 100644 --- a/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeekClient.cs +++ b/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeekClient.cs @@ -6,8 +6,6 @@ using Newtonsoft.Json.Linq; using System.Net.Http; using Newtonsoft.Json; using System.Net.Http.Json; -using AntDesign; -using OneOf.Types; using System.Net; using VideoAnalysisCore.AICore.GPT.KIMI; using System.Threading; diff --git a/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeek_GPT.cs b/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeek_GPT.cs index ae470db..b99dd82 100644 --- a/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeek_GPT.cs +++ b/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeek_GPT.cs @@ -112,18 +112,6 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek VideoKnowRes[] questionRes; while (true) { - // var postMessages = - //$"你的任务是分析视频字幕内容并提取出中国高考考试试题方法点,然后分析出<知识块>,来帮助学生快速了解视频字幕的内容" + - //$"通过阅读并理解字幕内容.然后识别出{subject}学科中属于{fileNameInfoRes.授课章节}章节相关的方法点以及对应的时间段。" + - //$"关联合并知识内容相似的知识点来合并为<知识块>。" + - //$"分配空余未使用的时间段到内容相近的<知识块>时间区间来获取更加详细的上下文,但是请避免<知识块>之间时间重合。" + - //$"从提取出的<知识块>内容称来匹配我提供的知识点,来作为片段的知识点(请确保匹配的知识点是用户提供的,否则片段知识点值为空字符串)。" + - //$"提供的方法点名称({knows})。 格式 (方法点Id|方法点名称) 如果一个<知识块>出现多个知识点那么知识点Id与知识点名称都用逗号','分割。" + - //$"这是输入的视频字幕并且是包含时间戳的视频字幕的固定格式文本。" + - ////$"字幕格式(说话人:开始秒:结束秒:内容|下一段字幕).以下是包含时间的视频字幕文本。字幕列表 {captions.Captions}。" + - //$"字幕格式(开始秒:结束秒:内容|下一段字幕).以下是包含时间的视频字幕文本。字幕列表 {captions.Captions}。" + - //$"最后请检查某些<知识块>之间的过渡是否自然,如果<知识块>时长超过500秒则考虑拆封为两个更加贴切的<知识块>.或者<知识块>时长小于30秒则考虑合并<知识块>到相邻的<知识块>)。" + - //$"输出内容只返回json格式({resFormat})"; var resFormat = """[{"StartTime":开始秒(number),"Theme":主题(string),"Content":内容总结(string)}]"""; var postMessages = diff --git a/VideoAnalysisCore/AICore/GPT/KIMI/KIMI_GPT.cs b/VideoAnalysisCore/AICore/GPT/KIMI/KIMI_GPT.cs index 5576b54..6b9ad23 100644 --- a/VideoAnalysisCore/AICore/GPT/KIMI/KIMI_GPT.cs +++ b/VideoAnalysisCore/AICore/GPT/KIMI/KIMI_GPT.cs @@ -11,7 +11,6 @@ using System.ComponentModel.DataAnnotations; using System.Reflection; using FreeRedis; using VideoAnalysisCore.Model.Dto; -using AntDesign; using SqlSugar.IOC; using VideoAnalysisCore.AICore.GPT.Dto; using VideoAnalysisCore.AICore.GPT; diff --git a/VideoAnalysisCore/AICore/GPT/KIMI/MoonshotClient.cs b/VideoAnalysisCore/AICore/GPT/KIMI/MoonshotClient.cs index 9f2bef8..20f255b 100644 --- a/VideoAnalysisCore/AICore/GPT/KIMI/MoonshotClient.cs +++ b/VideoAnalysisCore/AICore/GPT/KIMI/MoonshotClient.cs @@ -6,8 +6,6 @@ using Newtonsoft.Json.Linq; using System.Net.Http; using Newtonsoft.Json; using System.Net.Http.Json; -using AntDesign; -using OneOf.Types; using System.Net; using Azure; using System.Reflection.PortableExecutable; diff --git a/VideoAnalysisCore/Common/AppCommon.cs b/VideoAnalysisCore/Common/AppCommon.cs index 29a8885..b4e0e11 100644 --- a/VideoAnalysisCore/Common/AppCommon.cs +++ b/VideoAnalysisCore/Common/AppCommon.cs @@ -1,6 +1,4 @@ -using AntDesign; -using AntDesign.TableModels; -using FreeRedis; +using FreeRedis; using Microsoft.Extensions.DependencyModel; using SqlSugar; using SqlSugar.IOC; @@ -155,43 +153,6 @@ namespace VideoAnalysisCore.Common ); } /// - /// 转换 ant 查询枚举 到 sqlsuger枚举 - /// - /// ant 查询枚举 - /// - /// - public static ConditionalType ConvertToConditionalType(TableFilterCompareOperator filterOperator) - { - return filterOperator switch - { - TableFilterCompareOperator.Equals => ConditionalType.Equal, - TableFilterCompareOperator.Contains => ConditionalType.Like, - TableFilterCompareOperator.StartsWith => ConditionalType.LikeLeft, - TableFilterCompareOperator.EndsWith => ConditionalType.LikeRight, - TableFilterCompareOperator.GreaterThan => ConditionalType.GreaterThan, - TableFilterCompareOperator.LessThan => ConditionalType.LessThan, - TableFilterCompareOperator.GreaterThanOrEquals => ConditionalType.GreaterThanOrEqual, - TableFilterCompareOperator.LessThanOrEquals => ConditionalType.LessThanOrEqual, - TableFilterCompareOperator.Condition => ConditionalType.In, - TableFilterCompareOperator.NotEquals => ConditionalType.NoEqual, - TableFilterCompareOperator.IsNull => ConditionalType.IsNullOrEmpty, - TableFilterCompareOperator.IsNotNull => ConditionalType.IsNot, - TableFilterCompareOperator.NotContains => ConditionalType.NoLike, - TableFilterCompareOperator.TheSameDateWith => ConditionalType.EqualNull, - TableFilterCompareOperator.Between => ConditionalType.Range, - _ => throw new ArgumentOutOfRangeException(nameof(filterOperator), filterOperator, "未知的枚举类型!") - }; - } - public static List ToSqlSugerWhere(this QueryModel qm ) - { - return qm.FilterModel.SelectMany(s => s.Filters.Select(x => new ConditionalModel() - { - FieldName = s.FieldName, - ConditionalType = ConvertToConditionalType( x.FilterCompareOperator), - FieldValue = x.Value.GetType().IsEnum?((int)x.Value).ToString() : x.Value.ToString(), - } as IConditionalModel)).ToList(); - } - /// /// 获取应用有效程序集 /// /// IEnumerable diff --git a/VideoAnalysisCore/Common/AppConfig.cs b/VideoAnalysisCore/Common/AppConfig.cs index 42a16ac..b5ce884 100644 --- a/VideoAnalysisCore/Common/AppConfig.cs +++ b/VideoAnalysisCore/Common/AppConfig.cs @@ -66,11 +66,12 @@ namespace VideoAnalysisCore.Common /// /// 下载速度MB/S /// - public int DownloadSpeed { get; set; } + public int DownloadSpeed { get; set; } /// - /// 是否接收任务 + /// 是服务端 + /// 不执行任务,不回调接口 /// - public bool ProcessingTasks { get; set; } + public bool IS_Server { get; set; } } /// diff --git a/VideoAnalysisCore/Common/DownloadFile.cs b/VideoAnalysisCore/Common/DownloadFile.cs index 0843d7f..7a58859 100644 --- a/VideoAnalysisCore/Common/DownloadFile.cs +++ b/VideoAnalysisCore/Common/DownloadFile.cs @@ -1,5 +1,4 @@ -using AntDesign; -using Downloader; +using Downloader; using Microsoft.Extensions.DependencyInjection; using SqlSugar; using SqlSugar.IOC; diff --git a/VideoAnalysisCore/Common/ExceptionFilter.cs b/VideoAnalysisCore/Common/ExceptionFilter.cs index 7850e42..2c1622f 100644 --- a/VideoAnalysisCore/Common/ExceptionFilter.cs +++ b/VideoAnalysisCore/Common/ExceptionFilter.cs @@ -1,5 +1,4 @@ -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Filters; using System; using System.Collections.Generic; @@ -20,23 +19,21 @@ namespace VideoAnalysisCore.Common public async Task OnExceptionAsync(ExceptionContext context) { + // 创建一个包含错误信息的对象 + var errorObject = new { - // 创建一个包含错误信息的对象 - var errorObject = new - { - ErrorMessage = context.Exception.Message, - StackTrace = context.Exception.StackTrace, - }; - // 将错误对象序列化为JSON格式 - var json = JsonSerializer.Serialize(errorObject); + ErrorMessage = context.Exception.Message, + StackTrace = context.Exception.StackTrace, + }; + // 将错误对象序列化为JSON格式 + var json = JsonSerializer.Serialize(errorObject); - // 设置响应内容类型为JSON - context.HttpContext.Response.ContentType = "application/json"; - // 设置状态码 - context.HttpContext.Response.StatusCode = 500; - // 将JSON数据写入响应体 - await context.HttpContext.Response.WriteAsync(json); - } + // 设置响应内容类型为JSON + context.HttpContext.Response.ContentType = "application/json"; + // 设置状态码 + context.HttpContext.Response.StatusCode = 500; + // 将JSON数据写入响应体 + await context.HttpContext.Response.WriteAsync(json); } } } diff --git a/VideoAnalysis/Expand/AppConfigExpand.cs b/VideoAnalysisCore/Common/Expand/AppConfigExpand.cs similarity index 70% rename from VideoAnalysis/Expand/AppConfigExpand.cs rename to VideoAnalysisCore/Common/Expand/AppConfigExpand.cs index ec5a232..37236b5 100644 --- a/VideoAnalysis/Expand/AppConfigExpand.cs +++ b/VideoAnalysisCore/Common/Expand/AppConfigExpand.cs @@ -1,17 +1,18 @@ using Coravel; +using Microsoft.Extensions.Configuration; using System.Collections.Generic; using VideoAnalysisCore.Common; using VideoAnalysisCore.Job; -namespace Learn.VideoAnalysis.Expand +namespace VideoAnalysisCore.Common.Expand { public static class AppConfigExpand { - public static void AddAppConfig(this ConfigurationManager cm, string[] args) + public static void AddAppConfig(this IConfigurationManager cm, string[] args) { Console.WriteLine($"{DateTime.Now}=>初始化 AppConfig"); cm.GetSection("AppConfig").Bind(AppCommon.Config); - var argList= args.ToList(); + var argList = args.ToList(); var eArgs = Environment.GetEnvironmentVariable("va_args"); if (!string.IsNullOrEmpty(eArgs)) argList.AddRange(eArgs.Split(",")); @@ -21,8 +22,8 @@ namespace Learn.VideoAnalysis.Expand Console.WriteLine(string.Join(',', args)); Console.WriteLine("==========================================="); - if (args.Contains("NoTask")) - AppCommon.Config.TaskSetting.ProcessingTasks = false; + if (args.Contains("IS_Server")) + AppCommon.Config.TaskSetting.IS_Server = true; } } } diff --git a/VideoAnalysis/Expand/CorsExpand.cs b/VideoAnalysisCore/Common/Expand/CorsExpand.cs similarity index 84% rename from VideoAnalysis/Expand/CorsExpand.cs rename to VideoAnalysisCore/Common/Expand/CorsExpand.cs index c521851..1001d42 100644 --- a/VideoAnalysis/Expand/CorsExpand.cs +++ b/VideoAnalysisCore/Common/Expand/CorsExpand.cs @@ -1,10 +1,10 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; -namespace Learn.VideoAnalysis.Expand +namespace VideoAnalysisCore.Common.Expand { /// - /// + /// 跨域 /// public static class CorsExpand { @@ -14,7 +14,7 @@ namespace Learn.VideoAnalysis.Expand /// public static void AddCorsExpand(this IServiceCollection services) { - services.AddCors(c => + CorsServiceCollectionExtensions.AddCors(services,c => { c.AddPolicy("All", policy => { @@ -26,7 +26,7 @@ namespace Learn.VideoAnalysis.Expand /// 使用跨域 /// /// - public static void UseCorsExpand(this WebApplication app) + public static void UseCorsExpand(this IApplicationBuilder app) { app.UseCors("All"); // 获取配置文件中的允许跨域的地址 diff --git a/VideoAnalysis/Expand/SqlSugarExpand.cs b/VideoAnalysisCore/Common/Expand/SqlSugarExpand.cs similarity index 96% rename from VideoAnalysis/Expand/SqlSugarExpand.cs rename to VideoAnalysisCore/Common/Expand/SqlSugarExpand.cs index 3761d20..0cc7c23 100644 --- a/VideoAnalysis/Expand/SqlSugarExpand.cs +++ b/VideoAnalysisCore/Common/Expand/SqlSugarExpand.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.DependencyInjection; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using MySqlConnector; using SqlSugar; @@ -13,7 +14,7 @@ using System.Xml.Linq; using VideoAnalysisCore.Common; using Yitter.IdGenerator; -namespace Learn.VideoAnalysis.Expand +namespace VideoAnalysisCore.Common.Expand { public static class SqlSugarExpand { @@ -21,7 +22,7 @@ namespace Learn.VideoAnalysis.Expand public static void AddSqlSugarExpand(this IServiceCollection services) { - services.AddHttpContextAccessor(); + HttpServiceCollectionExtensions.AddHttpContextAccessor(services); Console.WriteLine($"{DateTime.Now}=>初始化 YitId雪花ID"); var options = new IdGeneratorOptions(ushort.Parse(AppCommon.Config.ID)); YitIdHelper.SetIdGenerator(options); @@ -102,7 +103,7 @@ namespace Learn.VideoAnalysis.Expand #endregion } - public static void InitDB() + public static void UseSqlSugarExpand(this IApplicationBuilder app) { ShowSQL = false; var builder = new MySqlConnectionStringBuilder(AppCommon.Config.DB.ConnectionString); diff --git a/VideoAnalysisCore/Common/Expand/StartUpExpand.cs b/VideoAnalysisCore/Common/Expand/StartUpExpand.cs new file mode 100644 index 0000000..abe20b4 --- /dev/null +++ b/VideoAnalysisCore/Common/Expand/StartUpExpand.cs @@ -0,0 +1,15 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VideoAnalysisCore.Common.Expand +{ + public static class StartUpExpand + { + } +} diff --git a/VideoAnalysisCore/Common/RedisExpand.cs b/VideoAnalysisCore/Common/RedisExpand.cs index e630075..62144e6 100644 --- a/VideoAnalysisCore/Common/RedisExpand.cs +++ b/VideoAnalysisCore/Common/RedisExpand.cs @@ -1,5 +1,4 @@ -using AntDesign; -using FreeRedis; +using FreeRedis; using FreeRedis.Internal; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json.Schema; @@ -276,8 +275,11 @@ namespace VideoAnalysisCore.Common /// public static async Task ReceivingTaskAsync() { - if (!AppCommon.Config.TaskSetting.ProcessingTasks)//是否接收任务 + if (AppCommon.Config.TaskSetting.IS_Server) + { + Console.WriteLine($"{DateTime.Now} =>服务端不接收任务"); return; + } var oldTask = await Redis.GetAsync(RedisExpandKey.IDTask); if (!string.IsNullOrEmpty(oldTask)) { diff --git a/VideoAnalysisCore/Job/NodePackageJob.cs b/VideoAnalysisCore/Job/NodePackageJob.cs index 55e9423..111e836 100644 --- a/VideoAnalysisCore/Job/NodePackageJob.cs +++ b/VideoAnalysisCore/Job/NodePackageJob.cs @@ -40,11 +40,10 @@ namespace VideoAnalysisCore.Job } public async Task Invoke() { - Console.WriteLine($"{DateTime.Now} Invoke=>文件包任务"); - + Console.WriteLine($"{DateTime.Now} 执行=>文件包任务"); var taskArr = await nodePackageInfoDB.AsQueryable() - .Where(s => s.SuccessTime == null) - .ToArrayAsync(); + .Where(s => s.SuccessTime == null) + .ToArrayAsync(); var videoIdArr = await videoTaskDB.AsQueryable() .Where(s => s.EndTime != null) .Select(s => s.TagId) @@ -58,7 +57,7 @@ namespace VideoAnalysisCore.Job item.SuccessTime = DateTime.Now; } } - Console.WriteLine($"{DateTime.Now} Invoke=>文件包任务 已完成任务回调 数量{postData.Count}"); + Console.WriteLine($"{DateTime.Now} 执行=>文件包任务 已完成任务回调 数量{postData.Count}"); if (postData.Count() == 0) return; var responseMessage = await new HttpClient() @@ -66,16 +65,16 @@ namespace VideoAnalysisCore.Job if (responseMessage.IsSuccessStatusCode) { var res = await responseMessage.Content.ReadAsStringAsync(); - Console.WriteLine($"{DateTime.Now} Invoke=>文件包任务 回调结果 {res}"); + Console.WriteLine($"{DateTime.Now} 执行=>文件包任务 回调结果 {res}"); await nodePackageInfoDB.AsUpdateable(postData) .UpdateColumns(it => new { it.SuccessTime }) .ExecuteCommandAsync(); } - else + else { var res = await responseMessage.Content.ReadAsStringAsync(); - Console.WriteLine($"{DateTime.Now} Invoke=>文件包任务 回调失败!!! {responseMessage.StatusCode} {res}"); + Console.WriteLine($"{DateTime.Now} 执行=>文件包任务 回调失败!!! {responseMessage.StatusCode} {res}"); } } } diff --git a/VideoAnalysisCore/Job/NodeSubscriptionJob.cs b/VideoAnalysisCore/Job/NodeSubscriptionJob.cs index c6841d4..db03543 100644 --- a/VideoAnalysisCore/Job/NodeSubscriptionJob.cs +++ b/VideoAnalysisCore/Job/NodeSubscriptionJob.cs @@ -35,7 +35,8 @@ namespace VideoAnalysisCore.Job } public async Task Invoke() { - Console.WriteLine($"{DateTime.Now} Invoke=>{this.GetType().FullName}"); + Console.WriteLine($"{DateTime.Now} 执行=>文件节点订阅"); + var videoIdArr = videotaskDB.AsQueryable().Select(v => v.TagId).Distinct().ToArray(); var tasks = await nodesubscriptionDB.GetListAsync(s => s.Enable && s.Subject ==SubjectEnum.数学); diff --git a/VideoAnalysisCore/Job/TaskFileClearJob.cs b/VideoAnalysisCore/Job/TaskFileClearJob.cs index f3e4aef..6cfeada 100644 --- a/VideoAnalysisCore/Job/TaskFileClearJob.cs +++ b/VideoAnalysisCore/Job/TaskFileClearJob.cs @@ -71,7 +71,7 @@ namespace VideoAnalysisCore.Job } public async Task Invoke() { - Console.WriteLine($"{DateTime.Now} Invoke=>{this.GetType().FullName}"); + Console.WriteLine($"{DateTime.Now} 执行=>{this.GetType().FullName}"); DeleteOldCompletedTaskCaches(); } diff --git a/VideoAnalysisCore/Model/Dto/SpeakerCaptionsDto.cs b/VideoAnalysisCore/Model/Dto/SpeakerCaptionsDto.cs index fca152e..3c31000 100644 --- a/VideoAnalysisCore/Model/Dto/SpeakerCaptionsDto.cs +++ b/VideoAnalysisCore/Model/Dto/SpeakerCaptionsDto.cs @@ -1,5 +1,4 @@ -using AntDesign; -using VideoAnalysisCore.AICore.GPT.Dto; +using VideoAnalysisCore.AICore.GPT.Dto; using VideoAnalysisCore.Model.Enum; namespace VideoAnalysisCore.Model.Dto diff --git a/VideoAnalysisCore/Model/Enum/AttachmentsInfoType.cs b/VideoAnalysisCore/Model/Enum/AttachmentsInfoType.cs index 4abdd97..4a50a1e 100644 --- a/VideoAnalysisCore/Model/Enum/AttachmentsInfoType.cs +++ b/VideoAnalysisCore/Model/Enum/AttachmentsInfoType.cs @@ -9,19 +9,19 @@ namespace VideoAnalysisCore.Model.Enum { public enum AttachmentsInfoType { - [Description("默认")] - None = 0, [Description("常规课程")] - RegularClasses = 1, + None = 0, [Description("教研")] - TeachingResearch = 2, + TeachingResearch = 1, [Description("PPT")] - PPT = 3, + PPT = 2, [Description("复习")] - Review = 4, + Review = 3, [Description("活动")] - Activities = 5, + Activities = 4, [Description("班会")] - Meeting = 6, + Meeting = 5, + [Description("行为分析")] + Behavior = 6, } } diff --git a/VideoAnalysisCore/Model/NodePackageInfo.cs b/VideoAnalysisCore/Model/NodePackageInfo.cs index f6d6c6b..bfc7609 100644 --- a/VideoAnalysisCore/Model/NodePackageInfo.cs +++ b/VideoAnalysisCore/Model/NodePackageInfo.cs @@ -1,5 +1,4 @@ -using AntDesign; -using SqlSugar; +using SqlSugar; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/VideoAnalysisCore/Model/NodeSubscription.cs b/VideoAnalysisCore/Model/NodeSubscription.cs index 2a5fa19..ca584a1 100644 --- a/VideoAnalysisCore/Model/NodeSubscription.cs +++ b/VideoAnalysisCore/Model/NodeSubscription.cs @@ -1,5 +1,4 @@ -using AntDesign; -using SqlSugar; +using SqlSugar; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/VideoAnalysisCore/VideoAnalysisCore.csproj b/VideoAnalysisCore/VideoAnalysisCore.csproj index 2beed3a..241dbd3 100644 --- a/VideoAnalysisCore/VideoAnalysisCore.csproj +++ b/VideoAnalysisCore/VideoAnalysisCore.csproj @@ -62,6 +62,8 @@ + + @@ -73,7 +75,6 @@ -