feat(core, api): Workload - Controller для формирования отчетов
This commit is contained in:
@@ -110,7 +110,7 @@ namespace PARR.Core.Services.Workload.Implementations
|
||||
|
||||
var cacheItem = new TemplateCache
|
||||
{
|
||||
Data = new TemplateCacheDto { TemplateId = template.Id, ResponseArea = responseArea, WorkGroup = workGroup },
|
||||
Data = new TemplateCacheDto { TemplateId = template.Id, ResponseArea = responseArea, WorkGroup = workGroup, JobGroupId = template.Job!.GroupId, JobId = template.JobId },
|
||||
Source = nameof(WorkloadCacheService),
|
||||
Timestamp = DateTimeOffset.UtcNow
|
||||
};
|
||||
@@ -193,11 +193,15 @@ namespace PARR.Core.Services.Workload.Implementations
|
||||
var dtStart = new DateTimeOffset(dateStart.Year, dateStart.Month, dateStart.Day, 0, 0, 0, offset);
|
||||
var dtEnd = dtStart.AddDays(durationDays);
|
||||
|
||||
// Конвертируем в UTC для совместимости с PostgreSQL timestamptz
|
||||
var dtStartUtc = dtStart.ToUniversalTime();
|
||||
var dtEndUtc = dtEnd.ToUniversalTime();
|
||||
|
||||
logger.LogDebug("Фильтруем шаблоны в БД по интервалу: Start={DtStart:yyyy-MM-dd HH:mm:ss zzz}, End={DtEnd:yyyy-MM-dd HH:mm:ss zzz}", dtStart, dtEnd);
|
||||
|
||||
var templates = await templateRepository.Get()
|
||||
.AsNoTracking()
|
||||
.Where(t => dtStart <= t.NextRun && t.NextRun < dtEnd)
|
||||
.Where(t => dtStartUtc <= t.NextRun && t.NextRun < dtEndUtc)
|
||||
.Select(t => new { Id = t.Id, IsActiveTemplate = t.IsActiveTemplate, IsActiveSchedule = t.IsActiveSchedule, Name = t.Name, NextRun = t.NextRun })
|
||||
.ToListAsync();
|
||||
|
||||
@@ -231,7 +235,7 @@ namespace PARR.Core.Services.Workload.Implementations
|
||||
template.NextRun,
|
||||
template.IsActiveTemplate,
|
||||
template.IsActiveSchedule,
|
||||
DateTimeOffset.UtcNow);
|
||||
cacheDate);
|
||||
reportData.Add(data);
|
||||
}
|
||||
|
||||
@@ -266,7 +270,7 @@ namespace PARR.Core.Services.Workload.Implementations
|
||||
// Запишем результат в кэш
|
||||
var cacheItem = new TemplateCache
|
||||
{
|
||||
Data = new TemplateCacheDto { TemplateId = template.Id, ResponseArea = responseArea, WorkGroup = workGroup },
|
||||
Data = new TemplateCacheDto { TemplateId = template.Id, ResponseArea = responseArea, WorkGroup = workGroup, JobId = template.JobId, JobGroupId = template.Job!.GroupId },
|
||||
Source = nameof(WorkloadCacheService),
|
||||
Timestamp = DateTimeOffset.UtcNow
|
||||
};
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace PARR.Core.Services.Workload.Implementations
|
||||
break;
|
||||
case WorkloadReportType.ResponseAreaItem:
|
||||
displayName = "По зоне ответственности";
|
||||
//todo: тут нужно вернуть другой отчет, либо группы работ, либо список работ
|
||||
var filteredRA = templates.Where(t => t.ResponseArea.Equals(filterParam, StringComparison.OrdinalIgnoreCase)).ToList();
|
||||
statistics.Add(BuildStatisticItem(filterParam!, filteredRA, reportDays, offset));
|
||||
break;
|
||||
@@ -82,6 +83,7 @@ namespace PARR.Core.Services.Workload.Implementations
|
||||
break;
|
||||
case WorkloadReportType.WorkGroupItem:
|
||||
displayName = "По рабочей группе";
|
||||
//todo: тут нужно вернуть другой отчет, либо группы работ, либо список работ
|
||||
var filteredWG = templates.Where(t => t.WorkGroup.Equals(filterParam, StringComparison.OrdinalIgnoreCase)).ToList();
|
||||
statistics.Add(BuildStatisticItem(filterParam!, filteredWG, reportDays, offset));
|
||||
break;
|
||||
@@ -95,7 +97,7 @@ namespace PARR.Core.Services.Workload.Implementations
|
||||
ReportCacheCreatedAt = DateTimeOffset.UtcNow,
|
||||
TemplateCacheCreatedAt = templates.FirstOrDefault()?.CacheDate ?? DateTimeOffset.MinValue,
|
||||
Days = reportDays,
|
||||
Statistics = statistics
|
||||
Statistics = statistics.OrderBy(t => t.Title).ToList()
|
||||
};
|
||||
|
||||
// Сохраним в кэш
|
||||
|
||||
@@ -1,9 +1,22 @@
|
||||
namespace PARR.Core.Services.Workload.Interfaces
|
||||
using PARR.Domain.DTOs.Workload;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.Core.Services.Workload.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Сервис формирования отчетности о загруженности
|
||||
/// </summary>
|
||||
public interface IWorkloadService
|
||||
{
|
||||
/// <summary>
|
||||
/// Получить отчет о загруженности
|
||||
/// </summary>
|
||||
/// <param name="reportType"></param>
|
||||
/// <param name="dateStart"></param>
|
||||
/// <param name="durationDays"></param>
|
||||
/// <param name="offset"></param>
|
||||
/// <param name="filterParam"></param>
|
||||
/// <returns></returns>
|
||||
Task<WorkloadReport?> GetWorkloadReport(WorkloadReportType reportType, DateOnly dateStart, int durationDays, TimeSpan offset, string? filterParam);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user