修改 数据结构后调整管理端UI

优化 任务接收辞池[进行中]
This commit is contained in:
小肥羊 2025-06-13 18:23:30 +08:00
parent f943c4fec4
commit f7c787cdf7
9 changed files with 67 additions and 70 deletions

View File

@ -20,7 +20,6 @@
<ColumnDefinitions Context="row"> <ColumnDefinitions Context="row">
<Selection /> <Selection />
<PropertyColumn Property="c=>c.Id" Width="110px" Filterable="true" Sortable="true" /> <PropertyColumn Property="c=>c.Id" Width="110px" Filterable="true" Sortable="true" />
<PropertyColumn Property="c=>c.MediaName" Width="200px" />
<PropertyColumn Property="c=>c.TagId" Width="160px" /> <PropertyColumn Property="c=>c.TagId" Width="160px" />
<PropertyColumn Property="c=>c.LastEnum" Width="150px" /> <PropertyColumn Property="c=>c.LastEnum" Width="150px" />
<PropertyColumn Property="c=>c.Subject" Width="100px" /> <PropertyColumn Property="c=>c.Subject" Width="100px" />

View File

@ -6,8 +6,7 @@
<div id="segmentsContainer" class="sc"> <div id="segmentsContainer" class="sc">
<h2> <h2>
<button class="gudingBtn" onclick="gd(this)">🔒</button> <button class="gudingBtn" onclick="gd(this)">🔒</button></h2>
@nowTask.MediaName</h2>
@for (int i = 0; i < videoKnows.Length; i++) @for (int i = 0; i < videoKnows.Length; i++)
{ {
var item = videoKnows[i]; var item = videoKnows[i];
@ -20,17 +19,20 @@
</div> </div>
<div>概览: @item.Content</div> <div>概览: @item.Content</div>
<br /> <br />
@if (item.QuestionArr != null)
{
@foreach (var q in item.QuestionArr) @foreach (var q in item.QuestionArr)
{ {
<div class="knowQuestion" onclick="spClickTime(@q.StartTime)"> <div class="knowQuestion" onclick="spClickTime(@q.StartTime)">
<h3>问题: <span class="kSpan">@q.StartTime 秒</span></h3> <h3>问题: <span class="kSpan">@q.StartTime 秒</span></h3>
<div class="kSpan">@q.TopicStem</div> <div class="kSpan">@q.TopicStem</div>
<div >@q.Question</div> <div>@q.Question</div>
<img style="text-align:center" src="@q.PPTImageUrl" width="320" height="180" /> <img style="text-align:center" src="@q.PPTImageUrl" width="320" height="180" />
</div> </div>
<br /> <br />
} }
}
<br /> <br />
<br /> <br />

View File

@ -82,9 +82,8 @@ namespace VideoAnalysisCore.AICore.GPT.ChatGPT
.Where(s => s.Course_Id == 27 .Where(s => s.Course_Id == 27
&& s.Depth == 2) && s.Depth == 2)
.Select(s => s.Name).ToArrayAsync(); .Select(s => s.Name).ToArrayAsync();
string title = taskInfo.MediaName;
var fileNameResFormat = "{授课章节: string|null, 授课内容:string}"; var fileNameResFormat = "{授课章节: string|null, 授课内容:string}";
var fileNamePostMessages = title + var fileNamePostMessages =
" 这是一堂课的标题,请你帮我分析一些关于课堂方面的内容." + " 这是一堂课的标题,请你帮我分析一些关于课堂方面的内容." +
$"1.分析出高中{subject}课堂授课的主要章节(例如 章节: 数列),章节范围限定在[{string.Join(',', xkwKnows)}]范围." + $"1.分析出高中{subject}课堂授课的主要章节(例如 章节: 数列),章节范围限定在[{string.Join(',', xkwKnows)}]范围." +
$"2.分析出这堂课的主要授课内容." + $"2.分析出这堂课的主要授课内容." +

View File

@ -386,7 +386,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
foreach (var item in farmeArr) foreach (var item in farmeArr)
{ {
var knowInfoArr = videoKnowArr var knowInfoArr = videoKnowArr
.Where(s => item+30 >= s.StartTime && item <= s.EndTime) .Where(s => item+20 >= s.StartTime && item < s.EndTime)
.ToArray(); .ToArray();
if (knowInfoArr is null || knowInfoArr.Count() ==0) if (knowInfoArr is null || knowInfoArr.Count() ==0)
continue; continue;
@ -414,7 +414,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
$"排除不是试题内容的文字,优化试题排版并且去除题号,尽量保留latex数学公式。" + $"排除不是试题内容的文字,优化试题排版并且去除题号,尽量保留latex数学公式。" +
$"如果存在多道题,则需要拆分成为多个试题对象!" + $"如果存在多道题,则需要拆分成为多个试题对象!" +
$"试题的类型约束在 填空题/判断题/选择题/解答题/填空题 范围内。" + $"试题的类型约束在 填空题/判断题/选择题/解答题/填空题 范围内。" +
$"如果存在题干中存在下划线则试题的题型应该是填空题。" + $"如果是有效试题且题干中存在下划线则试题的题型应该是填空题。" +
$"请检查我提供的字符串内容,如果不能识别知识点则不处理知识点,如不包含问题试题则返回`[]`" + $"请检查我提供的字符串内容,如果不能识别知识点则不处理知识点,如不包含问题试题则返回`[]`" +
$"输出内容只返回json格式为({resFormat})" + $"输出内容只返回json格式为({resFormat})" +
$"以下是试题内容" + $"以下是试题内容" +

View File

@ -179,9 +179,11 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
.Where(it => it.Id == long.Parse(task)) .Where(it => it.Id == long.Parse(task))
.ExecuteCommandAsync(); .ExecuteCommandAsync();
await RedisExpand.Redis.HMSetAsync(RedisExpandKey.Task(task), "Captions", res); await RedisExpand.Redis.HMSetAsync(RedisExpandKey.Task(task), "Captions", res);
//RedisExpand.InsertChannel(Enum.RedisChannelEnum.ParsingSpeaker, task); //RedisExpand.InsertChannel(Enum.RedisChannelEnum.ParsingSpeaker, task);
//分析完成视频字幕后继续接收任务 //分析完成视频字幕后继续接收任务
RedisExpand.NewTask(); await RedisExpand.NewTaskAsync();
RedisExpand.InsertChannel(RedisChannelEnum.ChatModelAnalysis, task); RedisExpand.InsertChannel(RedisChannelEnum.ChatModelAnalysis, task);
} }

View File

@ -176,7 +176,8 @@ namespace VideoAnalysisCore.Common
// .HMGetAsync<TaskRes>(RedisExpandKey.Task(task), "ChatAnalysis")).FirstOrDefault(); // .HMGetAsync<TaskRes>(RedisExpandKey.Task(task), "ChatAnalysis")).FirstOrDefault();
//if (gptRes is null) //if (gptRes is null)
// throw new Exception("未能读取到GPT处理结果"); // throw new Exception("未能读取到GPT处理结果");
//删除任务执行状态
await Redis.HDelAsync(RedisExpandKey.IDTask,task);
var taskData = await DbScoped.Sugar.Queryable<VideoTask>() var taskData = await DbScoped.Sugar.Queryable<VideoTask>()
.FirstAsync(s => s.Id == tId); .FirstAsync(s => s.Id == tId);
if (taskData.Captions == "[]") if (taskData.Captions == "[]")
@ -215,29 +216,23 @@ namespace VideoAnalysisCore.Common
if (Redis is null) throw new Exception("redis未初始化"); if (Redis is null) throw new Exception("redis未初始化");
SubscribeList.Add(RedisChannelEnum.DownloadFile, SubscribeList.Add(RedisChannelEnum.DownloadFile,
(Action<string>)((msg) => { (msg) => TouchChannel(RedisChannelEnum.DownloadFile, msg,
TouchChannel(RedisChannelEnum.DownloadFile, msg, (task) =>
(Func<string, Task>)((task) =>
{ {
using var scope = AppCommon.Services?.CreateScope(); using var scope = AppCommon.Services?.CreateScope();
if (scope is null || ServiceProviderServiceExtensions.GetService<DownloadFile>(scope.ServiceProvider) is null) if (scope is null || scope.ServiceProvider.GetService<DownloadFile>() is null)
throw new Exception("DownloadFile 未注入"); throw new Exception("DownloadFile 未注入");
else else
return (Task)(scope.ServiceProvider.GetService<DownloadFile>()?.RunTask(task) ?? Task.CompletedTask); return scope.ServiceProvider.GetService<DownloadFile>()?.RunTask(task) ?? Task.CompletedTask;
})); }));
}));
SubscribeList.Add(RedisChannelEnum.SeparateAudio, SubscribeList.Add(RedisChannelEnum.SeparateAudio,
(msg) => { TouchChannel(RedisChannelEnum.SeparateAudio, msg, FFMPGEHandle.RunAsync); }); (msg) => TouchChannel(RedisChannelEnum.SeparateAudio, msg, FFMPGEHandle.RunAsync));
SubscribeList.Add(RedisChannelEnum.ParsingCaptions, SubscribeList.Add(RedisChannelEnum.ParsingCaptions,
(msg) => { TouchChannel(RedisChannelEnum.ParsingCaptions, msg, SenseVoice.RunTask); }); (msg) => TouchChannel(RedisChannelEnum.ParsingCaptions, msg, SenseVoice.RunTask));
SubscribeList.Add(RedisChannelEnum.ParsingSpeaker, SubscribeList.Add(RedisChannelEnum.ParsingSpeaker,
(msg) => { TouchChannel(RedisChannelEnum.ParsingSpeaker, msg, Speaker.Run); }); (msg) => TouchChannel(RedisChannelEnum.ParsingSpeaker, msg, Speaker.Run));
SubscribeList.Add(RedisChannelEnum.ChatModelAnalysis, SubscribeList.Add(RedisChannelEnum.ChatModelAnalysis,
(msg) => (msg) => TouchChannel(RedisChannelEnum.ChatModelAnalysis, msg,
{
TouchChannel(RedisChannelEnum.ChatModelAnalysis, msg,
(task) => (task) =>
{ {
using var scope = AppCommon.Services?.CreateScope(); using var scope = AppCommon.Services?.CreateScope();
@ -245,40 +240,45 @@ namespace VideoAnalysisCore.Common
throw new Exception("IBserGPT 未注入"); throw new Exception("IBserGPT 未注入");
else else
return scope.ServiceProvider.GetService<IBserGPT>()?.GetKnow(task) ?? Task.CompletedTask; return scope.ServiceProvider.GetService<IBserGPT>()?.GetKnow(task) ?? Task.CompletedTask;
}); }));
});
SubscribeList.Add(RedisChannelEnum.EndTask, SubscribeList.Add(RedisChannelEnum.EndTask,
(msg) => { TouchChannel(RedisChannelEnum.EndTask, msg, TaskEnd); }); (msg) => TouchChannel(RedisChannelEnum.EndTask, msg, TaskEnd));
await ReceivingTaskAsync(); ReceivingTaskAsync();
} }
/// <summary> /// <summary>
/// 重新执行新任务 /// 重新执行新任务
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static void NewTask() public static async Task NewTaskAsync()
{ {
Task.Run(async () => ReceivingTaskAsync();
{
await Redis.DelAsync(RedisExpandKey.IDTask);
await ReceivingTaskAsync();
});
} }
/// <summary> /// <summary>
/// 重新接收新任务 /// 重新接收新任务
/// </summary> /// </summary>
public static async Task ReceivingTaskAsync() public static void ReceivingTaskAsync()
{ {
if (AppCommon.Config.TaskSetting.IS_Server) if (AppCommon.Config.TaskSetting.IS_Server)
{ {
Console.WriteLine($"{DateTime.Now} =>服务端不接收任务"); Console.WriteLine($"{DateTime.Now} =>服务端不接收任务");
return; return;
} }
Task.Run(async () =>
{
//todo 项目接收任务进程池
//接收任务加入池
//重试任务加入池
//失败任务删除池
//停止任务删除池
//重启项目运行池内所有可用任务
var oldTask = await Redis.GetAsync(RedisExpandKey.IDTask); var oldTask = await Redis.GetAsync(RedisExpandKey.IDTask);
if (!string.IsNullOrEmpty(oldTask)) if (!string.IsNullOrEmpty(oldTask))
{ {
Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + "-------------> 接收重试任务 " + oldTask);
var lastEnum = (await Redis.HMGetAsync<RedisChannelEnum>(RedisExpandKey.Task(oldTask), "LastEnum")).FirstOrDefault(); var lastEnum = (await Redis.HMGetAsync<RedisChannelEnum>(RedisExpandKey.Task(oldTask), "LastEnum")).FirstOrDefault();
await SetTaskErrorMessage(long.Parse(oldTask), null); await SetTaskErrorMessage(long.Parse(oldTask), null);
InsertChannel(lastEnum, oldTask); InsertChannel(lastEnum, oldTask);
@ -289,19 +289,21 @@ namespace VideoAnalysisCore.Common
Subscribe = Redis.SubscribeList(RedisExpandKey.ChannelKey, (taskId) => Subscribe = Redis.SubscribeList(RedisExpandKey.ChannelKey, (taskId) =>
{ {
if (taskId is null) return; if (taskId is null) return;
Subscribe?.Dispose(); Subscribe?.Dispose();//取消接收任务监听
//存储当前机器的任务 //存储当前机器的任务
Redis.Set(RedisExpandKey.IDTask, taskId); Redis.HSet(RedisExpandKey.IDTask, taskId,true);
Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + "-------------> 接收到任务 " + taskId); Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + "-------------> 接收到任务 " + taskId);
InsertChannel(RedisChannelEnum.DownloadFile, taskId); InsertChannel(RedisChannelEnum.DownloadFile, taskId);
}); });
});
} }
/// <summary> /// <summary>
/// 写入任务异常 /// 写入任务异常
/// </summary> /// </summary>
/// <param name="taskID"></param> /// <param name="taskID"></param>
/// <param name="errorMessage"></param> /// <param name="ex"></param>
/// <returns></returns> /// <returns></returns>
public static async Task<bool> SetTaskErrorMessage(long taskID, Exception? ex) public static async Task<bool> SetTaskErrorMessage(long taskID, Exception? ex)
{ {
@ -315,8 +317,7 @@ namespace VideoAnalysisCore.Common
Console.WriteLine(ex.StackTrace); Console.WriteLine(ex.StackTrace);
Console.WriteLine("=============================================="); Console.WriteLine("==============================================");
//清除失败任务 重新接收任务 //清除失败任务 重新接收任务
await Redis.DelAsync(RedisExpandKey.IDTask); await NewTaskAsync();
await ReceivingTaskAsync();
} }
Redis.HMSet(RedisExpandKey.Task(taskID), "ErrorMessage", error); Redis.HMSet(RedisExpandKey.Task(taskID), "ErrorMessage", error);

View File

@ -190,7 +190,6 @@ namespace VideoAnalysisCore.Controllers
Subject = req.Subject, Subject = req.Subject,
Tag = req.Tag, Tag = req.Tag,
TagId = req.TagId, TagId = req.TagId,
MediaName = req.Name,
PPTVideoCode = req.PPTVideoCode, PPTVideoCode = req.PPTVideoCode,
VideoType=req.VideoType VideoType=req.VideoType
}; };

View File

@ -132,11 +132,6 @@ namespace VideoAnalysisCore.Controllers.Dto
[Required(ErrorMessage = "资源URL是必填项")] [Required(ErrorMessage = "资源URL是必填项")]
public string MediaUrl { get; set; } = string.Empty; public string MediaUrl { get; set; } = string.Empty;
/// <summary> /// <summary>
/// 资源名称
/// </summary>
[Required(ErrorMessage = "资源名称是必要的")]
public string Name { get; set; } = string.Empty;
/// <summary>
/// ApiKey /// ApiKey
/// </summary> /// </summary>
[Required(ErrorMessage = "接口Token是必填项")] [Required(ErrorMessage = "接口Token是必填项")]