feat(api,dal,nextRun): добаботана логика расчета nextRun в API и NetRunWorker. Рассчет ведется относительно refDate

This commit is contained in:
Mikhail Trubnikov
2025-11-25 16:49:28 +10:00
parent ce12f1b5fe
commit 2823823784
4 changed files with 166 additions and 78 deletions

View File

@@ -201,21 +201,28 @@ namespace PARR.API.Controllers.V1
{
var template = task.Template!;
#region old
// передаем LastRun, если его нет, то NextRun
//var nextRun = await esppScheduleTransformService.GetNextDateAsync(task.Template!.ApplicationInWorkId, task.Template.ApplicationsInWork!.LastRun ?? task.Template.ApplicationsInWork.NextRun);
// всегда считаем по nextRun
var nextRun = await esppScheduleTransformService.GetNextDateAsync(template.Job!.GroupId, template.NextRun);
//var nextRun = await esppScheduleTransformService.GetNextDateAsync(template.Job!.GroupId, template.NextRun);
#endregion
//пока у нас выключено автораспределение, считает по refDate
//TODO: когда заработает автораспределение, будем думать!!!!!
var nextRun = await esppScheduleTransformService.GetNextDateAsync(template.Job!.GroupId, template!.Job!.Group!.ReferenceDate);
if (nextRun != template.NextRun)
{
logger.LogDebug($"Для шаблона id {template.Id} обновляю nextRun, новое значение {nextRun}, старое значение {template.NextRun}");
if (template.NextRun < DateTimeOffset.UtcNow)
{
logger.LogDebug($"Для шаблона id {template.Id} обновляю lastRun, новое значение {template.NextRun}, старое значение {template.LastRun}");
template.LastRun = template.NextRun;
}
//if (template.NextRun < DateTimeOffset.UtcNow)
//{
// logger.LogDebug($"Для шаблона id {template.Id} обновляю lastRun, новое значение {template.NextRun}, старое значение {template.LastRun}");
// template.LastRun = template.NextRun;
//}
template.LastRun = template.NextRun;
template.NextRun = nextRun;
await robotConfigurationService.CommitAsync(new HistoryInitiator { InitiatorComment = "При получении задания роботом, обновил NextRun", InitiatorIp = clientService.GetClientIp()?.ToString(), InitiatorParrComponentId = ParrComponentsEnum.Api });