feat(bll, dal, templateGenertartor, templateMatcher, templateUpdater): интеграция с INextRunServiceV2
This commit is contained in:
@@ -5,6 +5,7 @@ using PARR.Constants;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Extensions;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.NextRunServices;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
@@ -18,13 +19,15 @@ namespace PARR.TemplateUpdater.Services
|
||||
private readonly IJobService jobService;
|
||||
private readonly IUnitService unitService;
|
||||
private readonly IRobotConfigurationService robotConfigurationService;
|
||||
private readonly INextRunServiceV2 nextRunService;
|
||||
|
||||
public TemplateUpdaterService(
|
||||
ILogger<TemplateUpdaterService> logger,
|
||||
ITemplateService templateService,
|
||||
IJobService jobService,
|
||||
IUnitService unitService,
|
||||
IRobotConfigurationService robotConfigurationService
|
||||
IRobotConfigurationService robotConfigurationService,
|
||||
INextRunServiceV2 nextRunService
|
||||
)
|
||||
{
|
||||
this.logger = logger;
|
||||
@@ -32,6 +35,7 @@ namespace PARR.TemplateUpdater.Services
|
||||
this.jobService = jobService;
|
||||
this.unitService = unitService;
|
||||
this.robotConfigurationService = robotConfigurationService;
|
||||
this.nextRunService = nextRunService;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,9 +88,24 @@ namespace PARR.TemplateUpdater.Services
|
||||
scheduleIsChanged = true;
|
||||
}
|
||||
|
||||
if (template.NextRun != query.NextRun)
|
||||
var nextRun = await nextRunService.GetNextRunForTemplateAsync(template.Id, query.IsNew);
|
||||
if (!nextRun.HasValue)
|
||||
{
|
||||
template.NextRun = query.NextRun;
|
||||
logger.LogError("Ошибка при расчете нового nextRun (вернулся null) для шаблона {templateId}, {templateName}", template.Id, template.Name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//if (template.NextRun != query.NextRun)
|
||||
//{
|
||||
// template.NextRun = query.NextRun;
|
||||
// scheduleIsChanged = true;
|
||||
//}
|
||||
|
||||
if (template.NextRun != nextRun.Value)
|
||||
{
|
||||
template.LastRun = template.NextRun;
|
||||
template.NextRun = nextRun.Value;
|
||||
scheduleIsChanged = true;
|
||||
}
|
||||
|
||||
@@ -99,7 +118,7 @@ namespace PARR.TemplateUpdater.Services
|
||||
}
|
||||
|
||||
//просто обнволяем. не влияет ни на шаблон, ни на расписание
|
||||
template.LastRun = query.LastRun;
|
||||
//template.LastRun = query.LastRun;
|
||||
template.Index = query.Index;
|
||||
template.StatusTypeId = query.StatusTypeId;
|
||||
|
||||
@@ -170,8 +189,8 @@ namespace PARR.TemplateUpdater.Services
|
||||
/// <returns></returns>
|
||||
private async Task<bool> IsValidAsync(TemplateUpdaterMq query)
|
||||
{
|
||||
var template= await templateService.Get().AsNoTracking()
|
||||
.Include(t=>t.RobotConfigurations)
|
||||
var template = await templateService.Get().AsNoTracking()
|
||||
.Include(t => t.RobotConfigurations)
|
||||
.FirstOrDefaultAsync(t => t.Id == query.TemplateId);
|
||||
|
||||
if (template == null)
|
||||
@@ -180,7 +199,7 @@ namespace PARR.TemplateUpdater.Services
|
||||
return false;
|
||||
}
|
||||
|
||||
if(template.ScheduleEsppId == null)
|
||||
if (template.ScheduleEsppId == null)
|
||||
{
|
||||
logger.LogError("Сообщение не валидно. Номер расписания не может быть null, робот не сможет обновить шаблон: {TemplateName}", template.Name);
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user