feat(templateUpdater): Добавлена предварительная запись в базу данных обновляемой информации шаблона для корректного расчета даты и времени следующего запуска в группированных работах

This commit is contained in:
Mikhail Kuznetsov
2026-03-27 11:58:03 +10:00
parent 62fecb1ff5
commit 3800cac97a
3 changed files with 28 additions and 23 deletions

View File

@@ -88,28 +88,6 @@ namespace PARR.TemplateUpdater.Services
scheduleIsChanged = true;
}
var nextRun = await nextRunService.GetNextRunForTemplateAsync(template.Id, query.IsNew);
if (!nextRun.HasValue)
{
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;
}
if (template.UnitId != query.UnitId)
{
template.UnitId = query.UnitId;
@@ -151,6 +129,28 @@ namespace PARR.TemplateUpdater.Services
// Поскольку коллекция изменилась — шаблон считается изменённым
templateIsChanged = true;
}
//Для правильного расчета shortcod'ов в БД должны быть сохранены данные UnitInTemplates, JobId, UnitId и т.д.
if (templateIsChanged && !await templateService.CommitAsync(query.Initiator))
{
logger.LogError("Не удалось сохранить изменения в БД. {QueryType}: {Query}", nameof(TemplateUpdaterMq), query.ToJson());
return;
}
var nextRun = await nextRunService.GetNextRunForTemplateAsync(template.Id, query.IsNew);
if (!nextRun.HasValue)
{
logger.LogError("Ошибка при расчете нового nextRun (вернулся null) для шаблона {templateId}, {templateName}", template.Id, template.Name);
return;
}
if (template.NextRun != nextRun.Value)
{
template.LastRun = template.NextRun;
template.NextRun = nextRun.Value;
scheduleIsChanged = true;
}
// === конец обработки UnitsInTemplate ===
if (templateIsChanged)