优化 TaskInfo接口
This commit is contained in:
parent
a8dba48589
commit
f627891634
|
|
@ -11,6 +11,8 @@ using VideoAnalysisCore.AICore.ChatGPT.Dto;
|
||||||
using AntDesign;
|
using AntDesign;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using FFmpeg.NET.Services;
|
using FFmpeg.NET.Services;
|
||||||
|
using MapsterMapper;
|
||||||
|
using Mapster;
|
||||||
|
|
||||||
namespace Learn.VideoAnalysis.Controllers
|
namespace Learn.VideoAnalysis.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -19,11 +21,13 @@ namespace Learn.VideoAnalysis.Controllers
|
||||||
public class ApiController : ControllerBase
|
public class ApiController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly ILogger<ApiController> _logger;
|
private readonly ILogger<ApiController> _logger;
|
||||||
|
private readonly IMapper mp;
|
||||||
private readonly Repository<VideoTask> videoTaskDB;
|
private readonly Repository<VideoTask> videoTaskDB;
|
||||||
public ApiController(ILogger<ApiController> logger, Repository<VideoTask> videoTaskDB)
|
public ApiController(ILogger<ApiController> logger, Repository<VideoTask> videoTaskDB, IMapper mp)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
this.videoTaskDB = videoTaskDB;
|
this.videoTaskDB = videoTaskDB;
|
||||||
|
this.mp = mp;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetClientIpAddress()
|
private string GetClientIpAddress()
|
||||||
|
|
@ -53,25 +57,23 @@ namespace Learn.VideoAnalysis.Controllers
|
||||||
.FirstAsync();
|
.FirstAsync();
|
||||||
if (task is null)
|
if (task is null)
|
||||||
return BadRequest();
|
return BadRequest();
|
||||||
var taskData = task.ChatAnalysis;
|
var taskData = task.ChatAnalysis.Adapt<TaskInfoRes>();
|
||||||
|
if (taskData is null)
|
||||||
|
return BadRequest();
|
||||||
|
taskData.Status = task.LastEnum;
|
||||||
if (task.LastEnum != RedisChannelEnum.EndTask)
|
if (task.LastEnum != RedisChannelEnum.EndTask)
|
||||||
return BadRequest(new
|
return BadRequest(taskData);
|
||||||
{
|
|
||||||
Enum = task.LastEnum ,
|
|
||||||
Task = taskData
|
|
||||||
});
|
|
||||||
if (!needSubtitle && taskData != null && taskData.TimeBase != null)
|
if (!needSubtitle && taskData != null && taskData.TimeBase != null)
|
||||||
{
|
{
|
||||||
foreach (var item in taskData.TimeBase)
|
taskData.TimeBase = taskData.TimeBase
|
||||||
{
|
.Select(s =>
|
||||||
item.Content = null;
|
{
|
||||||
}
|
s.Content = null;
|
||||||
|
return s;
|
||||||
|
})
|
||||||
|
.ToArray();
|
||||||
}
|
}
|
||||||
return Ok(new
|
return Ok(taskData);
|
||||||
{
|
|
||||||
Enum = task.LastEnum,
|
|
||||||
Task = taskData
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
using System.ComponentModel.DataAnnotations;
|
using AntDesign;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using VideoAnalysisCore.AICore.ChatGPT.Dto;
|
||||||
|
using VideoAnalysisCore.Enum;
|
||||||
|
|
||||||
namespace Learn.VideoAnalysis.Controllers.Dto
|
namespace Learn.VideoAnalysis.Controllers.Dto
|
||||||
{
|
{
|
||||||
|
|
@ -35,4 +38,47 @@ namespace Learn.VideoAnalysis.Controllers.Dto
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public class TextValue
|
||||||
|
{
|
||||||
|
public TextValue(float v)
|
||||||
|
{
|
||||||
|
var s = TimeSpan.FromSeconds((double)v);
|
||||||
|
Text = s.ToString(@"mm\:ss");
|
||||||
|
Value = v;
|
||||||
|
}
|
||||||
|
public TextValue(string t,object v)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public TextValue()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public string Text { get; set; }
|
||||||
|
public object Value { get; set; }
|
||||||
|
}
|
||||||
|
public class TaskInfoRes: TaskRes
|
||||||
|
{
|
||||||
|
public TaskInfoRes()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 任务当前执行状态
|
||||||
|
/// </summary>
|
||||||
|
public RedisChannelEnum Status { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 时间轴状态枚举
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<int, string> TimeTypeEnum =>
|
||||||
|
Enum.GetValues(typeof(TimeBaseTypeEnum))
|
||||||
|
.Cast<TimeBaseTypeEnum>()
|
||||||
|
.ToDictionary(x => (int)x, x => x.ToString());
|
||||||
|
/// <summary>
|
||||||
|
/// 时间轴合计
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<TimeBaseTypeEnum, TextValue>? TimeBaseTotal =>
|
||||||
|
TimeBase?.GroupBy(s => s.TimeBaseType??TimeBaseTypeEnum.教师讲授)?
|
||||||
|
.ToDictionary(s => s.Key, s => new TextValue(s.Sum(x => x.End - x.Start)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,11 @@ namespace VideoAnalysisCore.AICore.ChatGPT.Dto
|
||||||
/// 差的评价
|
/// 差的评价
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CourseCriteria[]? Bad { get; set; }
|
public CourseCriteria[]? Bad { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 改进意见
|
||||||
|
/// </summary>
|
||||||
|
public string[]? BadImprovedMethods =>
|
||||||
|
Bad?.Select(s => s.ImprovedMethods??string.Empty)?.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue