feat(dal, TemplateDistributorWorker): NextRunServiceV2 - реализован метод распределения шаблонов. Обновлен TemplateDistributorWorker для использования новой логики.
This commit is contained in:
@@ -11,13 +11,15 @@ namespace PARR.TemplateDistributor
|
||||
internal class TemplateDistributor : ITemplateDistributor
|
||||
{
|
||||
private readonly ILogger<TemplateDistributor> logger;
|
||||
private readonly INextRunService nextRunService;
|
||||
//private readonly INextRunService nextRunService;
|
||||
private readonly INextRunServiceV2 nextRunService;
|
||||
private readonly ITemplateService templateService;
|
||||
private readonly IRobotConfigurationService robotConfigurationService;
|
||||
|
||||
public TemplateDistributor(
|
||||
ILogger<TemplateDistributor> logger,
|
||||
INextRunService nextRunService,
|
||||
//INextRunService nextRunService,
|
||||
INextRunServiceV2 nextRunService,
|
||||
ITemplateService templateService,
|
||||
IRobotConfigurationService robotConfigurationService
|
||||
)
|
||||
@@ -32,20 +34,22 @@ namespace PARR.TemplateDistributor
|
||||
public async Task DistributeAsync(TemplateDistributorMq mqResponse)
|
||||
{
|
||||
var jobGroupId = mqResponse.JobGroupId;
|
||||
// распределяем шаблоны только в статусе Used
|
||||
var templateStatusType = TemplateStatusTypeEnum.Used;
|
||||
|
||||
// вызвать метод распределения, и получить новые даты
|
||||
var distributedTemplates = await nextRunService.GetNextRunForJobGroupWithAutoDistributionAsync(jobGroupId);
|
||||
var distributedTemplates = await nextRunService.GetNextRunForJobGroupWithAutoDistributionAsync(jobGroupId, templateStatusType);
|
||||
|
||||
if (distributedTemplates == null)
|
||||
{
|
||||
logger.LogWarning("При распределении шаблонов по jobGroupId {jobGroupId} вернулся null. Это ошибка. Прекращаю распределение.", jobGroupId);
|
||||
logger.LogError("При распределении шаблонов по jobGroupId {jobGroupId} вернулся null. Это ошибка. Прекращаю распределение.", jobGroupId);
|
||||
return;
|
||||
}
|
||||
|
||||
// получить список шаблонов, сравнить их с распределенными, обновить даты, сохранить
|
||||
var groupTemplates = await templateService.Get()
|
||||
.Include(t => t.RobotConfigurations)
|
||||
.Where(t => t.Job.GroupId == jobGroupId)
|
||||
.Where(t => t.Job!.GroupId == jobGroupId && t.StatusTypeId == templateStatusType)
|
||||
.ToListAsync();
|
||||
|
||||
if (!groupTemplates.Any())
|
||||
|
||||
Reference in New Issue
Block a user