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

@@ -31,76 +31,97 @@ namespace PARR.DAL.Services.Implementations
.ThenInclude(t => t!.EsppSchValues);
}
public async Task<EsppScheduleDto?> GetEsppScheduleDtoAsync(Guid jobGroupId)
{
//Формирует расписание в нормальном понятном виде из БД
var schValues = await dataContext.EsppSchValues
.Include(t => t.EsppSchTypeConfig)
.ThenInclude(t => t!.EsppSchTypeSchedule)
.Include(t => t.EsppSchTypeConfig)
.ThenInclude(t => t.EsppSchType)
.Include(t => t.EsppSchTypeValue)
.Include(t => t.JobGroup)
.Where(t => t.JobGroup!.Id == jobGroupId)//TODO Migration to job
.OrderBy(t => t.EsppSchTypeConfig!.Order)
.ToListAsync();
var items = await dataContext.EsppSchValues.Where(t => t.JobGroupId == jobGroupId)
.Select(t => new
{
t.EsppSchTypeConfig!.Order,
Type = t.EsppSchTypeConfig.EsppSchType!,
Value = t.EsppSchTypeValue!,
TypeSchedule = t.EsppSchTypeConfig.EsppSchTypeSchedule!
})
.OrderBy(t => t.Order)
.ToListAsync();
//var configs = await GetWithSchIncludes()
// .Where(t => t.EsppSchValues.Any(x => x.ApplicationsInWorkId == applicationInWorksId))
// .ToListAsync();
//if (!configs.Any())
// return null;
if (!schValues.Any())
if (items.Count == 0)
return null;
var values = new List<EsppScheduleValDto>();
//foreach (var config in configs)
//{
// var value = new EsppScheduleValDto
// {
// Order = config.Order,
// Type = config.EsppSchType!,
// Value = config.EsppSchValues.First().EsppSchTypeValue!
// };
// values.Add(value);
//}
foreach (var schValue in schValues)
{
var value = new EsppScheduleValDto
{
Order = schValue.EsppSchTypeConfig!.Order,
Type = schValue.EsppSchTypeConfig!.EsppSchType!,
Value = schValue.EsppSchTypeValue!
};
values.Add(value);
}
var typeSchedule = items.First().TypeSchedule;
var dto = new EsppScheduleDto
{
TypeSchedule = schValues.First().EsppSchTypeConfig!.EsppSchTypeSchedule!,
Values = values.OrderBy(t => t.Order).ToList()
TypeSchedule = typeSchedule,
Values = items.Select(t => new EsppScheduleValDto
{
Order = t.Order,
Type = t.Type,
Value = t.Value
}).ToList()
};
return dto;
}
#region original GetEsppScheduleDtoAsync
//public async Task<EsppScheduleDto?> GetEsppScheduleDtoAsync(Guid jobGroupId)
//{
// //Формирует расписание в нормальном понятном виде из БД
// var schValues = await dataContext.EsppSchValues
// .AsNoTracking()
// .Include(t => t.EsppSchTypeConfig)
// .ThenInclude(t => t!.EsppSchTypeSchedule)
// .Include(t => t.EsppSchTypeConfig)
// .ThenInclude(t => t.EsppSchType)
// .Include(t => t.EsppSchTypeValue)
// .Include(t => t.JobGroup)
// .Where(t => t.JobGroup!.Id == jobGroupId)
// .OrderBy(t => t.EsppSchTypeConfig!.Order)
// .ToListAsync();
// if (!schValues.Any())
// return null;
// var values = new List<EsppScheduleValDto>();
// foreach (var schValue in schValues)
// {
// var value = new EsppScheduleValDto
// {
// Order = schValue.EsppSchTypeConfig!.Order,
// Type = schValue.EsppSchTypeConfig!.EsppSchType!,
// Value = schValue.EsppSchTypeValue!
// };
// values.Add(value);
// }
// var dto = new EsppScheduleDto
// {
// TypeSchedule = schValues.First().EsppSchTypeConfig!.EsppSchTypeSchedule!,
// Values = values.OrderBy(t => t.Order).ToList()
// };
// return dto;
//}
#endregion
public EsppScheduleDto? GetEsppScheduleDto(Guid jobGroupId)
{
var result = Task.Run(async () =>
{
return await GetEsppScheduleDtoAsync(jobGroupId);
}).Result;
}).GetAwaiter().GetResult();
return result;
}