fix(templateGenerator): Исправлена ошибка преобразования сообщений из RabbitMq
This commit is contained in:
@@ -2,6 +2,6 @@
|
||||
{
|
||||
public interface IValidatorService
|
||||
{
|
||||
Task<bool> IsValidAsync(Guid jobId, Guid unitId, int? index, List<Guid>? unitsInTemplate = null);
|
||||
Task<bool> IsValidAsync(Guid jobId, Guid unitId, int? index, List<(Guid UnitId, Guid UnitFieldValueId)>? unitsInTemplate = null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,6 @@ namespace PARR.TemplateGeneratorWorker
|
||||
private readonly ITemplateRepository templateService;
|
||||
private readonly INextRunService nextRunService;
|
||||
|
||||
//private readonly INextRunService nextRunService;
|
||||
|
||||
//private readonly IEsppScheduleTransformService esppScheduleTransformService;
|
||||
|
||||
public TemplateGenerator(
|
||||
ILogger<TemplateGenerator> logger,
|
||||
@@ -35,8 +32,6 @@ namespace PARR.TemplateGeneratorWorker
|
||||
IShortcodesService shortcodesService,
|
||||
ITemplateRepository templateService,
|
||||
INextRunService nextRunService
|
||||
//INextRunService nextRunService
|
||||
//IEsppScheduleTransformService esppScheduleTransformService
|
||||
)
|
||||
{
|
||||
this.logger = logger;
|
||||
@@ -46,10 +41,9 @@ namespace PARR.TemplateGeneratorWorker
|
||||
this.shortcodesService = shortcodesService;
|
||||
this.templateService = templateService;
|
||||
this.nextRunService = nextRunService;
|
||||
//this.nextRunService = nextRunService;
|
||||
//this.esppScheduleTransformService = esppScheduleTransformService;
|
||||
}
|
||||
|
||||
|
||||
public async Task GenerateTemplateAsync(string msg)
|
||||
{
|
||||
logger.LogInformation($"Получили запрос: {msg}");
|
||||
@@ -63,7 +57,8 @@ namespace PARR.TemplateGeneratorWorker
|
||||
}
|
||||
|
||||
// Проверяем всё
|
||||
if (!await validatorService.IsValidAsync(query.JobId, query.UnitId, query.Index, query.UnitsInTemplate))
|
||||
var unitsInTemplate = query.UnitsInTemplate.Select(s => (s.UnitId, s.UnitFieldValueId)).ToList();
|
||||
if (!await validatorService.IsValidAsync(query.JobId, query.UnitId, query.Index, unitsInTemplate))
|
||||
{
|
||||
logger.LogError($"Параметры запроса не прошли валидацию: JobId={query.JobId}, UnitId={query.UnitId}, Index={query.Index}, UnitsInTemplateCount={query.UnitsInTemplate?.Count ?? 0}");
|
||||
return;
|
||||
@@ -98,15 +93,13 @@ namespace PARR.TemplateGeneratorWorker
|
||||
Index = query.Index,
|
||||
Job = job,
|
||||
Unit = null, // ShortcodesService сам догрузит при необходимости
|
||||
UnitsInTemplate = query.UnitsInTemplate?.Select(unitId => new UnitsInTemplate { UnitId = unitId }).ToList() ?? new List<UnitsInTemplate>()
|
||||
UnitsInTemplate = query.UnitsInTemplate?.Select(uit => new UnitsInTemplate { UnitId = uit.UnitId, UnitFieldValueId = uit.UnitFieldValueId }).ToList() ?? new List<UnitsInTemplate>()
|
||||
};
|
||||
|
||||
var templateName = await shortcodesService.ApplyShortcodesAsync(job.TemplateNameMask!, tempTemplateForShortcodes);
|
||||
|
||||
var responseArea = await shortcodesService.ApplyShortcodesAsync(job.ResponseAreaMask, tempTemplateForShortcodes);
|
||||
var workGroup = await shortcodesService.ApplyShortcodesAsync(job.WorkGroupMask, tempTemplateForShortcodes);
|
||||
//var nextRun = await esppScheduleTransformService.GetNextDateAsync(job.GroupId, job.Group!.ReferenceDate);
|
||||
//var nextRun = await nextRunService.GetNextRunForNewTemplateAsync(job.GroupId, responseArea);
|
||||
var nextRun = await nextRunService.GetNextRunForNewTemplateAsync(job.GroupId, workGroup, responseArea);
|
||||
|
||||
if (!nextRun.HasValue)
|
||||
@@ -128,7 +121,7 @@ namespace PARR.TemplateGeneratorWorker
|
||||
InitiatorComment = query.HistoryInitiator?.InitiatorComment,
|
||||
InitiatorParrComponentId = query.HistoryInitiator?.InitiatorParrComponentId,
|
||||
Index = query.Index,
|
||||
UnitsInTemplate = query.UnitsInTemplate?.Select(unitId => new UnitsInTemplate { UnitId = unitId }).ToList() ?? new List<UnitsInTemplate>()
|
||||
UnitsInTemplate = query.UnitsInTemplate?.Select(uit => new UnitsInTemplate { UnitId = uit.UnitId, UnitFieldValueId = uit.UnitFieldValueId }).ToList() ?? new List<UnitsInTemplate>()
|
||||
};
|
||||
|
||||
if (await templateService.CreateAsync(template) && await templateService.CommitAsync(new HistoryInitiator { InitiatorComment = "Запрос на генерацию с тестового шаблона", InitiatorParrComponentId = ParrComponentsEnum.TemplateTaskGenerator }))
|
||||
|
||||
Reference in New Issue
Block a user