Merge branch 'dev' of http://gitlab.dvgd.oao.rzd/devptk/parr/parr_api into dev
This commit is contained in:
@@ -226,6 +226,7 @@ namespace PARR.API.Contracts.V1
|
||||
{
|
||||
public const string Get = BaseStat + "/templates/";
|
||||
public const string GetForPeriod = BaseStat + "/templates/period";
|
||||
public const string GetTemplatesWithoutScheduleAndTaskCount = BaseStat + "/templates/without-schedule";
|
||||
}
|
||||
|
||||
public static class StatStatusTypeTemplates
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace PARR.API.Contracts.V1.Responses.Statistics
|
||||
{
|
||||
public record StatTemplatesWithoutScheduleResponse(int Count);
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@ using PARR.API.Helpers;
|
||||
using PARR.Core.Repositories.Interfaces;
|
||||
using PARR.Core.Services.NextRunServices;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Entities;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Controllers.V1.Statistics
|
||||
@@ -20,16 +21,16 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class StatTemplateController : BaseApiController
|
||||
{
|
||||
private readonly ITemplateRepository templateService;
|
||||
private readonly INextRunService nextRunService;
|
||||
private readonly ITemplateRepository _templateRepository;
|
||||
private readonly INextRunService _nextRunService;
|
||||
|
||||
public StatTemplateController(
|
||||
ITemplateRepository templateService,
|
||||
ITemplateRepository templateRepository,
|
||||
INextRunService nextRunService
|
||||
)
|
||||
{
|
||||
this.templateService = templateService;
|
||||
this.nextRunService = nextRunService;
|
||||
_templateRepository = templateRepository;
|
||||
_nextRunService = nextRunService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -41,12 +42,12 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
{
|
||||
var response = new StatTemplateResponse
|
||||
{
|
||||
ActivateScheduleCount = await templateService.Get().AsNoTracking().CountAsync(t => t.IsActiveSchedule),
|
||||
ActivateTemplateCount = await templateService.Get().AsNoTracking().CountAsync(t => t.IsActiveTemplate),
|
||||
TemplateAgentCount = await templateService.Get().AsNoTracking().CountAsync(t => t.Job!.Group!.IsAgent),
|
||||
TemplateCount = await templateService.Get().AsNoTracking().CountAsync(),
|
||||
SyncEsppScheduleCount = await templateService.Get().AsNoTracking().CountAsync(t => t.RobotConfigurations.Any(c => c.RobotCode == (int)RobotsEnum.ScheduleOrder && c.TaskStatusCode == (int)TaskStatusEnum.Ok)),
|
||||
SyncEsppTemplatesCount = await templateService.Get().AsNoTracking().CountAsync(t => t.RobotConfigurations.Any(c => c.RobotCode == (int)RobotsEnum.TemplateOrder && c.TaskStatusCode == (int)TaskStatusEnum.Ok))
|
||||
ActivateScheduleCount = await _templateRepository.Get().AsNoTracking().CountAsync(t => t.IsActiveSchedule),
|
||||
ActivateTemplateCount = await _templateRepository.Get().AsNoTracking().CountAsync(t => t.IsActiveTemplate),
|
||||
TemplateAgentCount = await _templateRepository.Get().AsNoTracking().CountAsync(t => t.Job!.Group!.IsAgent),
|
||||
TemplateCount = await _templateRepository.Get().AsNoTracking().CountAsync(),
|
||||
SyncEsppScheduleCount = await _templateRepository.Get().AsNoTracking().CountAsync(t => t.RobotConfigurations.Any(c => c.RobotCode == (int)RobotsEnum.ScheduleOrder && c.TaskStatusCode == (int)TaskStatusEnum.Ok)),
|
||||
SyncEsppTemplatesCount = await _templateRepository.Get().AsNoTracking().CountAsync(t => t.RobotConfigurations.Any(c => c.RobotCode == (int)RobotsEnum.TemplateOrder && c.TaskStatusCode == (int)TaskStatusEnum.Ok))
|
||||
};
|
||||
|
||||
return Ok(new Response<StatTemplateResponse>(response, true));
|
||||
@@ -71,7 +72,7 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
userEnd.AddDays(1),
|
||||
timeZoneQuery.TimeZoneOffset);
|
||||
|
||||
var allRecords = await templateService.Get()
|
||||
var allRecords = await _templateRepository.Get()
|
||||
.AsNoTracking()
|
||||
.FilterByDateRangeUtc(t => t.DateCreated, utcStart, utcEnd)
|
||||
.Select(t => new { t.Id, t.DateCreated })
|
||||
@@ -80,7 +81,7 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
var resultDict = allRecords.GroupByUserDate(t => t.DateCreated, timeZoneQuery.TimeZoneOffset);
|
||||
|
||||
|
||||
var daysList = await nextRunService.GetWorkDaysAsync(userStart, userEnd, false);
|
||||
var daysList = await _nextRunService.GetWorkDaysAsync(userStart, userEnd, false);
|
||||
|
||||
var response = daysList.Select(date => new StatTemplatePeriodResponse
|
||||
{
|
||||
@@ -92,5 +93,27 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить кол-во шаблонов у которых ИД расписания null и нет задания на создание расписания
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.StatTemplate.GetTemplatesWithoutScheduleAndTaskCount)]
|
||||
public async Task<IActionResult> GetTemplatesWithoutScheduleAndTaskCount()
|
||||
{
|
||||
var count = await _templateRepository.Get()
|
||||
.CountAsync(t =>
|
||||
t.ScheduleEsppId == null
|
||||
&& !t.RobotConfigurations.Any(x =>
|
||||
x.RobotCode == (int)RobotsEnum.ScheduleOrder
|
||||
&& x.TaskStatusCode == (int)TaskStatusEnum.Creating
|
||||
)
|
||||
);
|
||||
|
||||
var resposne = new StatTemplatesWithoutScheduleResponse(count);
|
||||
|
||||
return Ok(new Response<StatTemplatesWithoutScheduleResponse>(resposne, true));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user