Compare commits

...

5 Commits

7 changed files with 82 additions and 30 deletions

View File

@ -48,12 +48,11 @@ namespace Learn.VideoAnalysis.API
var app = builder.Build(); var app = builder.Build();
AppCommon.Services = app.Services; AppCommon.Services = app.Services;
app.UseMiddleware<BasicAuthMiddleware>("Swagger");
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{ app.UseSwagger();
app.UseSwagger(); app.UseSwaggerUI();
app.UseSwaggerUI();
}
app.UseHttpsRedirection(); app.UseHttpsRedirection();

View File

@ -22,6 +22,11 @@
"Token": "" "Token": ""
} }
}, },
"SimpLetex": {
"Host": "https://server.simpletex.cn/api/",
"AppSecret": "05ZbPfCFZgTmfd4uIqHHc9pHgYR2V8bk",
"AppId": "GH2OXwuxSZEH5W28H61bdSzD"
},
"Redis": { "Redis": {
"ConnectionString": "127.0.0.1:6379,password=Woshiren123,defaultDatabase=10" "ConnectionString": "127.0.0.1:6379,password=Woshiren123,defaultDatabase=10"
}, },
@ -60,6 +65,14 @@
"AccessKeySecret": "vRKgmbp1LB05LaGOjh3ZrZxbHSLYLF", "AccessKeySecret": "vRKgmbp1LB05LaGOjh3ZrZxbHSLYLF",
"EndPoint": "vod.cn-shanghai.aliyuncs.com" // "EndPoint": "vod.cn-shanghai.aliyuncs.com" //
}, },
"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" //
},
"OtherDBArr": [ "OtherDBArr": [
{ {
"ConfigId": 1001, //ResourceBank "ConfigId": 1001, //ResourceBank

View File

@ -118,12 +118,11 @@ namespace Learn.VideoAnalysis
app.UseMiddleware<BasicAuthMiddleware>("Swagger"); app.UseMiddleware<BasicAuthMiddleware>("Swagger");
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{ app.UseSwagger();
app.UseSwagger(); app.UseSwaggerUI();
app.UseSwaggerUI(); app.UseExceptionHandler("/Error");
app.UseExceptionHandler("/Error");
}
//Ìí¼Ówwwroot ¾²Ì¬Ä¿Â¼ //Ìí¼Ówwwroot ¾²Ì¬Ä¿Â¼
app.UseStaticFiles(); app.UseStaticFiles();
//Ìí¼Ó ×Ô¶¨Òå ¾²Ì¬Ä¿Â¼ //Ìí¼Ó ×Ô¶¨Òå ¾²Ì¬Ä¿Â¼

View File

@ -197,7 +197,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
var totalCount = captionsArr.Length / spanCount + 1; var totalCount = captionsArr.Length / spanCount + 1;
await Parallel.ForAsync(0, totalCount, await Parallel.ForAsync(0, totalCount,
new ParallelOptions() { MaxDegreeOfParallelism = 10 }, new ParallelOptions() { MaxDegreeOfParallelism = 20 },
async (s, c) => async (s, c) =>
{ {
while (true) while (true)
@ -285,6 +285,9 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
$"字幕列表 {captions.Captions} 字幕结束!"; $"字幕列表 {captions.Captions} 字幕结束!";
break; break;
case AttachmentsInfoType.: case AttachmentsInfoType.:
postMessages = postMessages =
$"请通过视频字幕内容分析出视频中课堂的授课阶段。" + $"请通过视频字幕内容分析出视频中课堂的授课阶段。" +
$"课堂内容与{taskInfo.Subject}学科下的{sections}章节相关。" + $"课堂内容与{taskInfo.Subject}学科下的{sections}章节相关。" +
@ -319,7 +322,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
} }
/// <summary> /// <summary>
/// /// 请求AI
/// </summary> /// </summary>
/// <typeparam name="T">返回JSON类型</typeparam> /// <typeparam name="T">返回JSON类型</typeparam>
/// <param name="task">任务id</param> /// <param name="task">任务id</param>

View File

@ -184,7 +184,7 @@ namespace VideoAnalysisCore.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
await SetTaskErrorMessage((long)taskId, ex); await SetTaskErrorMessage(long.Parse(tId), ex);
} }
} }

View File

@ -2,6 +2,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using UserCenter.Model.Enum; using UserCenter.Model.Enum;
using VideoAnalysisCore.AICore.GPT.Dto; using VideoAnalysisCore.AICore.GPT.Dto;
using VideoAnalysisCore.Model.Dto;
using VideoAnalysisCore.Model.Enum; using VideoAnalysisCore.Model.Enum;
namespace VideoAnalysisCore.Controllers.Dto namespace VideoAnalysisCore.Controllers.Dto
@ -228,6 +229,10 @@ namespace VideoAnalysisCore.Controllers.Dto
public class TaskKnowBlock public class TaskKnowBlock
{ {
public long Id { get; set; } public long Id { get; set; }
/// <summary>
/// 阶段id
/// </summary>
public long StageId { get; set; }
/// <summary> /// <summary>
/// 开始时间 /// 开始时间
@ -254,6 +259,11 @@ namespace VideoAnalysisCore.Controllers.Dto
/// 知识点列表 /// 知识点列表
/// </summary> /// </summary>
public TaskKnowInfo[] Know { get; set; } public TaskKnowInfo[] Know { get; set; }
/// <summary>
/// 片段内的试题
/// </summary>
public virtual VideoQuestionShowDto[]? QuestionArr { get; set; }
} }
/// <summary> /// <summary>
/// 视频片段知识点结果 /// 视频片段知识点结果
@ -274,7 +284,7 @@ namespace VideoAnalysisCore.Controllers.Dto
/// </summary> /// </summary>
public long VideoTaskId { get; set; } public long VideoTaskId { get; set; }
/// <summary> /// <summary>
/// 视频知识快 /// 视频片段
/// </summary> /// </summary>
public TaskKnowBlock[] KnowBlockArr { get; set; } public TaskKnowBlock[] KnowBlockArr { get; set; }

View File

@ -18,6 +18,7 @@ using Yitter.IdGenerator;
using VideoAnalysisCore.AICore.GPT.Dto; using VideoAnalysisCore.AICore.GPT.Dto;
using VideoAnalysisCore.Model; using VideoAnalysisCore.Model;
using VideoAnalysisCore.Controllers.Dto; using VideoAnalysisCore.Controllers.Dto;
using VideoAnalysisCore.Model.Dto;
namespace VideoAnalysisCore.Controllers namespace VideoAnalysisCore.Controllers
{ {
@ -33,15 +34,20 @@ namespace VideoAnalysisCore.Controllers
private readonly Repository<VideoTask> videoTaskDB; private readonly Repository<VideoTask> videoTaskDB;
private readonly Repository<VideoKonwPoint> videoKonwPointDB; private readonly Repository<VideoKonwPoint> videoKonwPointDB;
private readonly Repository<NodePackageInfo> nodePackageInfoDB; private readonly Repository<NodePackageInfo> nodePackageInfoDB;
public LJZK_Controller( IMapper mp, Repository<NodeSubscription> nodesubscriptionDB, private readonly Repository<VideoQuestion> videoQuestionDB;
private readonly Repository<VideoQuestionKonw> videoQuestionKonwDB;
public LJZK_Controller(IMapper mp, Repository<NodeSubscription> nodesubscriptionDB,
Repository<VideoTask> videoTaskDB = null, Repository<VideoKonwPoint> videoKonwPointDB = null Repository<VideoTask> videoTaskDB = null, Repository<VideoKonwPoint> videoKonwPointDB = null
, Repository<NodePackageInfo> nodePackageInfoDB = null) , Repository<NodePackageInfo> nodePackageInfoDB = null, Repository<VideoQuestion> videoQuestionDB = null, Repository<VideoQuestionKonw> videoQuestionKonwDB = null)
{ {
this.mp = mp; this.mp = mp;
this.nodesubscriptionDB = nodesubscriptionDB; this.nodesubscriptionDB = nodesubscriptionDB;
this.videoTaskDB = videoTaskDB; this.videoTaskDB = videoTaskDB;
this.videoKonwPointDB = videoKonwPointDB; this.videoKonwPointDB = videoKonwPointDB;
this.nodePackageInfoDB = nodePackageInfoDB; this.nodePackageInfoDB = nodePackageInfoDB;
this.videoQuestionDB = videoQuestionDB;
this.videoQuestionKonwDB = videoQuestionKonwDB;
} }
@ -60,10 +66,12 @@ namespace VideoAnalysisCore.Controllers
var videos = new List<VideoTask>(reqArr.Count()); var videos = new List<VideoTask>(reqArr.Count());
var nodePackages = new List<NodePackageInfo>(reqArr.Count()); var nodePackages = new List<NodePackageInfo>(reqArr.Count());
var videoIdArr = videoTaskDB.AsQueryable().Select(v => v.TagId).Distinct().ToArray(); var videoIdArr = videoTaskDB.AsQueryable().Select(v => v.TagId).Distinct().ToArray();
foreach (var sGroup in reqArr.GroupBy(s=>s.ContentId)) foreach (var sGroup in reqArr.GroupBy(s => s.ContentId))
{ {
var s= sGroup.First(s=>s.VideoType==VideoType.ÉãÏñÍ·); var s = sGroup.FirstOrDefault(s => s.VideoType == VideoType.);
var sPPT= sGroup.FirstOrDefault(s=>s.VideoType==VideoType.PPT¿Î¼þ); if (s is null)
return BadRequest("无有效的老师授课视频");
var sPPT = sGroup.FirstOrDefault(s => s.VideoType == VideoType.PPT课件);
var np = new NodePackageInfo() var np = new NodePackageInfo()
{ {
VideoCode = s.VideoCode, VideoCode = s.VideoCode,
@ -72,16 +80,16 @@ namespace VideoAnalysisCore.Controllers
Stage = s.StageId, Stage = s.StageId,
CourseId = s.CourseId, CourseId = s.CourseId,
SubjectType = s.SubjectId, SubjectType = s.SubjectId,
VideoUrl =s.VideoUrl, VideoUrl = s.VideoUrl,
CourseType = s.CourseType, CourseType = s.CourseType,
CallBackUrl=s.CallBackUrl, CallBackUrl = s.CallBackUrl,
Area = s.Area, Area = s.Area,
HostIP = s.HostIP, HostIP = s.HostIP,
}; };
nodePackages.Add(np); nodePackages.Add(np);
if (videoIdArr.Contains(s.VideoCode)) if (videoIdArr.Contains(s.VideoCode))
continue; continue;
var pptCode = sPPT!=null ? sPPT.VideoCode : string.Empty; var pptCode = sPPT != null ? sPPT.VideoCode : string.Empty;
videos.Add(new VideoTask() videos.Add(new VideoTask()
{ {
Id = YitIdHelper.NextId(), Id = YitIdHelper.NextId(),
@ -91,9 +99,9 @@ namespace VideoAnalysisCore.Controllers
CourseId = s.CourseId, CourseId = s.CourseId,
Subject = s.SubjectId, Subject = s.SubjectId,
TagId = s.VideoCode, TagId = s.VideoCode,
MediaUrl =s.VideoUrl, MediaUrl = s.VideoUrl,
PPTVideoCode = pptCode, PPTVideoCode = pptCode,
VideoType =s.CourseType VideoType = s.CourseType
}); });
} }
await nodePackageInfoDB.InsertRangeAsync(nodePackages); await nodePackageInfoDB.InsertRangeAsync(nodePackages);
@ -126,6 +134,7 @@ namespace VideoAnalysisCore.Controllers
return Ok(Enum.GetValues(type).Cast<object>() return Ok(Enum.GetValues(type).Cast<object>()
.Select(s => new { Text = s.ToString(), Value = (int)s })); .Select(s => new { Text = s.ToString(), Value = (int)s }));
} }
/// <summary> /// <summary>
/// 获取学科类型 /// 获取学科类型
/// </summary> /// </summary>
@ -146,12 +155,12 @@ namespace VideoAnalysisCore.Controllers
[HttpGet(Name = "TaskKnowInfo")] [HttpGet(Name = "TaskKnowInfo")]
public async Task<IActionResult> TaskKnowInfo(string? tagId) public async Task<IActionResult> TaskKnowInfo(string? tagId)
{ {
if ( string.IsNullOrEmpty(tagId)) if (string.IsNullOrEmpty(tagId))
return BadRequest(); return BadRequest();
long taskId = 0; long taskId = 0;
var taskIdOK = long.TryParse(tagId,out taskId); var taskIdOK = long.TryParse(tagId, out taskId);
var task = await videoTaskDB.AsQueryable() var task = await videoTaskDB.AsQueryable()
.Where(s=> s.TagId == tagId || s.PPTVideoCode== tagId || (taskIdOK&& s.Id == taskId)) .Where(s => s.TagId == tagId || s.PPTVideoCode == tagId || (taskIdOK && s.Id == taskId))
.FirstAsync(); .FirstAsync();
if (task is null) if (task is null)
return BadRequest("无效任务"); return BadRequest("无效任务");
@ -161,7 +170,7 @@ namespace VideoAnalysisCore.Controllers
.ToArrayAsync(); .ToArrayAsync();
if (konwArr is null || konwArr.Length == 0) if (konwArr is null || konwArr.Length == 0)
return BadRequest("无效任务"); return BadRequest("无效任务");
return Ok(new TaskKnowRes() var res = new TaskKnowRes()
{ {
TagId = task.TagId, TagId = task.TagId,
Status = task.LastEnum, Status = task.LastEnum,
@ -173,6 +182,7 @@ namespace VideoAnalysisCore.Controllers
Id = s.First().Id, Id = s.First().Id,
Content = s.First().Content, Content = s.First().Content,
StartTime = s.First().StartTime, StartTime = s.First().StartTime,
StageId = s.First().StageId,
EndTime = s.First().EndTime, EndTime = s.First().EndTime,
Theme = s.First().Theme, Theme = s.First().Theme,
Know = s.Select(x => new TaskKnowInfo() Know = s.Select(x => new TaskKnowInfo()
@ -182,7 +192,25 @@ namespace VideoAnalysisCore.Controllers
KnowPointId = x.KnowPointId KnowPointId = x.KnowPointId
}).ToArray() }).ToArray()
}).ToArray() }).ToArray()
}); };
if (task.VideoType == AttachmentsInfoType.)
{
var questionArr = await videoQuestionDB
.AsQueryable().Where(s => s.VideoTaskId == task.Id)
.Select<VideoQuestionShowDto>()
.ToArrayAsync();
var konwDic = (await videoQuestionKonwDB
.AsQueryable().Where(s => s.VideoTaskId == task.Id)
.ToArrayAsync()).GroupBy(s => s.VideoQuestionId)
.ToDictionary(s => s.Key);
foreach (var item in questionArr.Where(s => konwDic.ContainsKey(s.Id)))
item.KonwArr = konwDic[item.Id].ToArray();
foreach (var item in res.KnowBlockArr)
item.QuestionArr = questionArr
.Where(s => s.StageId == item.StageId).ToArray();
}
return Ok(res);
} }