feat(api): Просмотр истории роботов
This commit is contained in:
@@ -75,7 +75,7 @@
|
|||||||
|
|
||||||
public static class RobotHistory
|
public static class RobotHistory
|
||||||
{
|
{
|
||||||
//public const string GetAll = Base + "/robot-histories/";
|
public const string GetAll = Base + "/robot-histories/";
|
||||||
public const string Create = Base + "/robot-histories/";
|
public const string Create = Base + "/robot-histories/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
23
PARR.API/Contracts/V1/Requests/Queries/RobotHistoryQuery.cs
Normal file
23
PARR.API/Contracts/V1/Requests/Queries/RobotHistoryQuery.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using PARR.DAL.Contracts;
|
||||||
|
|
||||||
|
namespace PARR.API.Contracts.V1.Requests.Queries
|
||||||
|
{
|
||||||
|
public class RobotHistoryQuery
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Фильтр по ИД шаблона
|
||||||
|
/// </summary>
|
||||||
|
public Guid? TemplateId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Фильтр по ИД робота
|
||||||
|
/// </summary>
|
||||||
|
public RobotsEnum? RobotCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Фильтр по уровню истории
|
||||||
|
/// </summary>
|
||||||
|
public RobotHistoryLevelEnum? HistoryLevel { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
namespace PARR.API.Contracts.V1.Requests.Queries
|
|
||||||
{
|
|
||||||
public class RobotTemplateHistoryQuery
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Фильтр по ИД шаблона
|
|
||||||
/// </summary>
|
|
||||||
public Guid? TemplateId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Фильтр по ИД серии
|
|
||||||
/// </summary>
|
|
||||||
public Guid? IdSeries { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,11 +10,19 @@
|
|||||||
|
|
||||||
public string? EsppMessage { get; set; }
|
public string? EsppMessage { get; set; }
|
||||||
|
|
||||||
public int TaskStatusCode { get; set; }
|
//public int TaskStatusCode { get; set; }
|
||||||
|
|
||||||
|
public TaskStatusResponse? TaskStatus { get; set; }
|
||||||
|
|
||||||
public Guid TaskId { get; set; }
|
public Guid TaskId { get; set; }
|
||||||
|
|
||||||
public RobotHistoryLevelResponse? Level { get; set; }
|
public RobotHistoryLevelResponse? Level { get; set; }
|
||||||
|
|
||||||
|
public Guid TemplateId { get; set; }
|
||||||
|
|
||||||
|
public string? TemplateName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,13 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PARR.API.Contracts.V1;
|
using PARR.API.Contracts.V1;
|
||||||
using PARR.API.Contracts.V1.Requests;
|
using PARR.API.Contracts.V1.Requests;
|
||||||
|
using PARR.API.Contracts.V1.Requests.Queries;
|
||||||
using PARR.API.Contracts.V1.Responses;
|
using PARR.API.Contracts.V1.Responses;
|
||||||
using PARR.API.Contracts.V1.Responses.Base;
|
using PARR.API.Contracts.V1.Responses.Base;
|
||||||
using PARR.API.Controllers.V1.Base;
|
using PARR.API.Controllers.V1.Base;
|
||||||
|
using PARR.API.Extensions;
|
||||||
using PARR.API.Services.Interfaces;
|
using PARR.API.Services.Interfaces;
|
||||||
|
using PARR.DAL.DomainModels;
|
||||||
using PARR.DAL.Models;
|
using PARR.DAL.Models;
|
||||||
using PARR.DAL.Services.Interfaces;
|
using PARR.DAL.Services.Interfaces;
|
||||||
|
|
||||||
@@ -38,39 +41,43 @@ namespace PARR.API.Controllers.V1
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///// <summary>
|
/// <summary>
|
||||||
///// Получить историю робота шаблонов
|
/// Просмотр истории работы робота
|
||||||
///// </summary>
|
/// </summary>
|
||||||
///// <param name="paginationQuery"></param>
|
/// <param name="paginationQuery"></param>
|
||||||
///// <param name="filter"></param>
|
/// <param name="request"></param>
|
||||||
///// <returns></returns>
|
/// <returns></returns>
|
||||||
//[HttpGet(ApiRoutes.RobotTemplateHistory.GetAll)]
|
[HttpGet(ApiRoutes.RobotHistory.GetAll)]
|
||||||
//public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] RobotTemplateHistoryQuery filter)
|
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] RobotHistoryQuery request)
|
||||||
//{
|
{
|
||||||
// var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||||
|
|
||||||
// IQueryable<RobotTemplateHistory> query = historyService.Get()
|
IQueryable<RobotHistory> query = robotHistoryService.Get()
|
||||||
// .Include(t => t.Template)
|
.Include(t => t.RobotConfiguration)
|
||||||
// .Include(t => t.RobotHistoryLevel)
|
.ThenInclude(t=>t!.Template)
|
||||||
// .OrderByDescending(t => t.DateCreated).ThenBy(t => t.IdSeries);
|
.Include(t => t.RobotHistoryLevel)
|
||||||
|
.Include(t => t.StatusTask)
|
||||||
|
.OrderByDescending(t => t.DateCreated);
|
||||||
|
|
||||||
// if (filter.IdSeries != null)
|
if (request.TemplateId.HasValue)
|
||||||
// query = query.Where(t => t.IdSeries == filter.IdSeries);
|
query = query.Where(t => t.RobotConfiguration!.TemplateId == request.TemplateId.Value);
|
||||||
|
|
||||||
// if (filter.TemplateId != null)
|
if (request.RobotCode.HasValue)
|
||||||
// query = query.Where(t => t.TemplateId == filter.TemplateId);
|
query = query.Where(t => t.RobotConfiguration!.RobotCode == (int)request.RobotCode);
|
||||||
|
|
||||||
|
if (request.HistoryLevel.HasValue)
|
||||||
|
query = query.Where(t => t.HistoryLevel == (int)request.HistoryLevel);
|
||||||
|
|
||||||
// var history = await historyService.GetPage(query, paginationFilter).ToListAsync();
|
var history = await robotHistoryService.GetPage(query, paginationFilter).ToListAsync();
|
||||||
|
|
||||||
// if (!history.Any())
|
if (!history.Any())
|
||||||
// return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
// var response = mapper.Map<List<RobotTemplateHistoryResponse>>(history);
|
var response = mapper.Map<List<RobotHistoryResponse>>(history);
|
||||||
// var paginationResponse = new PagedResponse<RobotTemplateHistoryResponse>(response, true).GetPaginatedProps(paginationFilter, query);
|
var paginationResponse = new PagedResponse<RobotHistoryResponse>(response, true).GetPaginatedProps(paginationFilter, query);
|
||||||
|
|
||||||
// return Ok(paginationResponse);
|
return Ok(paginationResponse);
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -105,7 +112,9 @@ namespace PARR.API.Controllers.V1
|
|||||||
|
|
||||||
var createdObj = await robotHistoryService.Get()
|
var createdObj = await robotHistoryService.Get()
|
||||||
.Include(t => t.RobotConfiguration)
|
.Include(t => t.RobotConfiguration)
|
||||||
|
.ThenInclude(t => t!.Template)
|
||||||
.Include(t => t.RobotHistoryLevel)
|
.Include(t => t.RobotHistoryLevel)
|
||||||
|
.Include(t => t.StatusTask)
|
||||||
.FirstOrDefaultAsync(t => t.Id == history.Id);
|
.FirstOrDefaultAsync(t => t.Id == history.Id);
|
||||||
|
|
||||||
var response = mapper.Map<RobotHistoryResponse>(createdObj);
|
var response = mapper.Map<RobotHistoryResponse>(createdObj);
|
||||||
|
|||||||
@@ -71,7 +71,10 @@ namespace PARR.API.MappingProfiles
|
|||||||
CreateMap<RobotHistory, RobotHistoryResponse>()
|
CreateMap<RobotHistory, RobotHistoryResponse>()
|
||||||
.ForMember(d => d.Level, o => o.MapFrom(s => s.RobotHistoryLevel))
|
.ForMember(d => d.Level, o => o.MapFrom(s => s.RobotHistoryLevel))
|
||||||
.ForMember(d => d.Date, o => o.MapFrom(s => s.DateCreated))
|
.ForMember(d => d.Date, o => o.MapFrom(s => s.DateCreated))
|
||||||
.ForMember(d => d.TaskId, o => o.MapFrom(s => s.RobotConfigurationId));
|
.ForMember(d => d.TaskId, o => o.MapFrom(s => s.RobotConfigurationId))
|
||||||
|
.ForMember(d => d.TaskStatus, o => o.MapFrom(s => s.StatusTask))
|
||||||
|
.ForMember(d => d.TemplateId, o => o.MapFrom(s => s.RobotConfiguration!.TemplateId))
|
||||||
|
.ForMember(d => d.TemplateName, o => o.MapFrom(s => s.RobotConfiguration!.Template!.Name));
|
||||||
|
|
||||||
|
|
||||||
// --- RobotConfiguration ---
|
// --- RobotConfiguration ---
|
||||||
|
|||||||
Reference in New Issue
Block a user