feat(api, domain, core): StatWorkloadTemplate - дополнительная фильтрация по РГ и ЗО.

This commit is contained in:
Mikhail Trubnikov
2026-06-05 10:28:15 +10:00
parent 1baa8f2296
commit 8cb7a2d599
7 changed files with 126 additions and 17 deletions

View File

@@ -0,0 +1,17 @@
using PARR.Domain.Enums.Workload;
namespace PARR.API.Contracts.V1.Requests.Queries
{
public record StatWorkloadTemplateReqportQuery
{
/// <summary>
/// Тип дополнительно фильтра для работы (ЗО, РГ)
/// </summary>
public WorkloadJobSubfliterType? JobSubfilterType { get; init; }
/// <summary>
/// Значение дополнительного фильтра для работы
/// </summary>
public string? JobSubfilterValue { get; init; }
}
}

View File

@@ -72,6 +72,8 @@ namespace PARR.API.Contracts.V1.Responses.Statistics
{
public required string Title { get; init; }
public Guid? ObjId { get; init; }
public required WorkloadSummaryResponse Summary { get; init; }
public required List<WorkloadDailyItemResponse> DailyMetrics { get; init; }

View File

@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using PARR.API.Contracts.V1;
using PARR.API.Contracts.V1.Requests.BaseRequests;
using PARR.API.Contracts.V1.Requests.Queries;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Contracts.V1.Responses.Statistics;
using PARR.API.Controllers.V1.Base;
@@ -45,7 +46,14 @@ namespace PARR.API.Controllers.V1.Statistics
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
[HttpGet(ApiRoutes.StatWorkloadTemplate.GetWorkloadTemplateReport)]
public async Task<IActionResult> GetWorkloadTemplateReport([FromRoute] WorkloadTemplateReportType reportType, [FromRoute] string filter, [FromRoute] WorkloadTemplateReportState state, [FromRoute] DateOnly date, [FromQuery] TimeZoneOffsetClient offset)
public async Task<IActionResult> GetWorkloadTemplateReport(
[FromRoute] WorkloadTemplateReportType reportType,
[FromRoute] string filter,
[FromRoute] WorkloadTemplateReportState state,
[FromRoute] DateOnly date,
[FromQuery] TimeZoneOffsetClient offset,
[FromQuery] StatWorkloadTemplateReqportQuery query
)
{
if (string.IsNullOrWhiteSpace(filter))
{
@@ -53,7 +61,13 @@ namespace PARR.API.Controllers.V1.Statistics
throw new ArgumentException(nameof(filter), "Не передано значение фильтра.");
}
var report = await workloadService.GetTemplateReportAsync(reportType, filter, state, date, offset.TimeZoneOffset);
if (query.JobSubfilterType.HasValue && string.IsNullOrWhiteSpace(query.JobSubfilterValue))
{
logger.LogWarning("Не передано значение дополнительного фильтра для работы");
throw new ArgumentException(nameof(filter), "Не передано значение дополнительного фильтра для работы.");
}
var report = await workloadService.GetTemplateReportAsync(reportType, filter, state, date, offset.TimeZoneOffset, query.JobSubfilterType, query.JobSubfilterValue);
var response = mapper.Map<List<StatWorkloadTemplateReportResponse>>(report);