feat(dal): template distributor - логика получения NextRun. Рефакторинг

This commit is contained in:
Mikhail Trubnikov
2026-01-20 15:04:36 +10:00
parent 6e8e3c89c2
commit 2038f7b57d
8 changed files with 282 additions and 451 deletions

View File

@@ -1,6 +1,7 @@

using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.NextRunServices.Subservices;
using PARR.DAL.Services.Interfaces;
using PARR.DAL.Services.Interfaces.Job;
using PARR.DAL.TransformServices;
@@ -13,25 +14,29 @@ namespace PARR.DAL.NextRunServices
private readonly ITemplateService templateService;
private readonly IJobGroupService jobGroupService;
private readonly IEsppScheduleTransformService esppScheduleTransformService;
private readonly ITemplateDistributor templateDistributor;
public NextRunService(
ILogger<NextRunService> logger,
ITemplateService templateService,
IJobGroupService jobGroupService,
IEsppScheduleTransformService esppScheduleTransformService
IEsppScheduleTransformService esppScheduleTransformService,
ITemplateDistributor templateDistributor
)
{
this.logger = logger;
this.templateService = templateService;
this.jobGroupService = jobGroupService;
this.esppScheduleTransformService = esppScheduleTransformService;
this.templateDistributor = templateDistributor;
}
public Task<List<(Guid TemplateId, DateTimeOffset NextRun)>> GetNextRunForJobGroupWithAutoDistributionAsync(Guid jobGroupId)
public async Task<List<(Guid TemplateId, DateTimeOffset NextRun)>> GetNextRunForJobGroupWithAutoDistributionAsync(Guid jobGroupId)
{
//TODO:
throw new NotImplementedException();
//var ditributedTemplateList = await templateDistributor.DistributeTemplatesAsync();
}
@@ -50,7 +55,7 @@ namespace PARR.DAL.NextRunServices
}
public async Task<DateTimeOffset> GetNextRunForTemplate(Guid templateId)
public async Task<DateTimeOffset> GetNextRunForTemplate(Guid templateId, bool isNew)
{
var template = await templateService.Get()
.Include(t => t.Job).ThenInclude(t => t.Group)
@@ -67,7 +72,8 @@ namespace PARR.DAL.NextRunServices
{
// включено автораспределение
//TODO: !!!!!!!!!!!!!!!! добавить метод рассчета с учетом распределения
throw new NotImplementedException("добавить метод рассчета с учетом распределения");
throw new NotImplementedException();
//return await templateDistributor.GetValidNextRunForTemplateAsync();
}
else
{