89 lines
2.7 KiB
C#
89 lines
2.7 KiB
C#
using Coravel.Invocable;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using VideoAnalysisCore.Common;
|
|
using VideoAnalysisCore.Model;
|
|
using VideoAnalysisCore.Model.Dto;
|
|
using VideoAnalysisCore.Model.蓝鲸智库;
|
|
|
|
namespace VideoAnalysisCore.Job
|
|
{
|
|
/// <summary>
|
|
/// [蓝鲸智库] 查找未处理的视频
|
|
/// </summary>
|
|
public class NodeSubscriptionJob : IInvocable
|
|
{
|
|
private readonly Repository<NodeSubscription> nodesubscriptionDB;
|
|
private readonly Repository<Attachments> attachmentsDB;
|
|
private readonly Repository<VideoTask> videotaskDB;
|
|
public NodeSubscriptionJob(Repository<Attachments> videoTaskDB, Repository<NodeSubscription> nodesubscriptionDB, Repository<VideoTask> videotaskDB)
|
|
{
|
|
this.attachmentsDB = videoTaskDB;
|
|
this.nodesubscriptionDB = nodesubscriptionDB;
|
|
this.videotaskDB = videotaskDB;
|
|
}
|
|
public async Task Invoke()
|
|
{
|
|
Console.WriteLine($"{DateTime.Now} Invoke=>{this.GetType().FullName}");
|
|
|
|
var tasks = await nodesubscriptionDB.GetListAsync(s => s.Enable);
|
|
foreach (var item in tasks)
|
|
{
|
|
var fileNodeId = item.NodeId;
|
|
var data = attachmentsDB.Context.Ado
|
|
.SqlQuery<Attachments>($"""
|
|
SELECT
|
|
*
|
|
FROM
|
|
Attachments
|
|
WHERE
|
|
Id IN (
|
|
SELECT
|
|
AttachmentsId
|
|
FROM
|
|
Material
|
|
WHERE
|
|
id IN (
|
|
SELECT
|
|
MaterialId
|
|
FROM
|
|
FileContentMaterial
|
|
WHERE
|
|
FileContentId IN ( SELECT id FROM FileContent WHERE BagId IN ( SELECT Id FROM FileDirectory WHERE Id={fileNodeId} AND types = 1 AND DeleteState = 0 ) )
|
|
AND DeleteState = 0
|
|
AND ( MaterialName NOT LIKE '%PPT%' OR MaterialName NOT LIKE '%ppt%' )
|
|
)
|
|
)
|
|
AND Type = '录播视频'
|
|
AND (
|
|
NAME NOT LIKE '%PPT%'
|
|
OR NAME NOT LIKE '%ppt%'
|
|
)
|
|
""");
|
|
|
|
var videos = data.Select(s => new VideoTask()
|
|
{
|
|
ComeFrom = "127.0.0.1",
|
|
ApiToken = "",
|
|
Type = item.TaskType,
|
|
Subject = item.Subject,
|
|
Tag = string.Empty,
|
|
TagId = s.VideoCode,
|
|
MediaUrl = s.Url,
|
|
MediaName = s.Name
|
|
}).ToArray();
|
|
|
|
//入库
|
|
await videotaskDB.InsertRangeAsync(videos);
|
|
var ids = videos.Select(s => s.Id).ToArray();
|
|
RedisExpand.JoinQueue(ids);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|