fix(API,DAL): Восстановлена работа контроллеров RobotTask, TemplateActivator, Template
This commit is contained in:
@@ -72,10 +72,17 @@ namespace PARR.API.Controllers.V1
|
||||
// шаблоны
|
||||
query = query.Include(t => t.Template)
|
||||
.ThenInclude(t => t!.Unit)
|
||||
//.ThenInclude(t => t!.Hosts).ThenInclude(t => t.WorkGroup).ThenInclude(t => t!.ResponseArea)
|
||||
.Include(t => t.Template)
|
||||
.ThenInclude(t => t!.UnitValues)
|
||||
.ThenInclude(t => t.Field)
|
||||
.Include(t => t.Template)
|
||||
.ThenInclude(t => t!.Unit)
|
||||
.ThenInclude(t => t!.UnitValues)
|
||||
.ThenInclude(t => t.Value)
|
||||
.Include(t => t.Template)
|
||||
.ThenInclude(a => a!.Job)
|
||||
//.ThenInclude(w => w!.Work)
|
||||
.ThenInclude(t => t!.Group)
|
||||
.Include(t => t.Template)
|
||||
.ThenInclude(w => w!.Job)
|
||||
.ThenInclude(t => t!.Tnk)
|
||||
.ThenInclude(s => s!.Subprocess)
|
||||
.ThenInclude(p => p!.Process);
|
||||
@@ -84,12 +91,16 @@ namespace PARR.API.Controllers.V1
|
||||
//расписание
|
||||
// тут не делаем AsSplitQuery, не может подтянуть все таблицы
|
||||
query = query.Include(t => t.Template)
|
||||
.ThenInclude(t => t!.Unit)//.ThenInclude(t => t!.ResponseArea)
|
||||
//.ThenInclude(t => t!.Hosts).ThenInclude(t => t.WorkGroup)
|
||||
.Include(t => t.Template)
|
||||
.ThenInclude(t => t!.Job)
|
||||
.ThenInclude(t => t!.Group)
|
||||
//.ThenInclude(t => t!.ApplicationsInWork)
|
||||
.ThenInclude(t => t!.Unit)
|
||||
.ThenInclude(t => t!.UnitValues)
|
||||
.ThenInclude(t => t.Field)
|
||||
.Include(t => t.Template)
|
||||
.ThenInclude(t => t!.Unit)
|
||||
.ThenInclude(t => t!.UnitValues)
|
||||
.ThenInclude(t => t.Value)
|
||||
.Include(t => t.Template)
|
||||
.ThenInclude(a => a!.Job)
|
||||
.ThenInclude(t => t!.Group)
|
||||
.ThenInclude(t => t!.EsppSchValues)
|
||||
.ThenInclude(t => t!.EsppSchTypeConfig)
|
||||
.ThenInclude(t => t!.EsppSchTypeSchedule);
|
||||
|
||||
@@ -11,7 +11,7 @@ using PARR.BLL.Domain.Mq;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Common.Domain;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
@@ -26,7 +26,7 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly IMqService mqService;
|
||||
private readonly IUriService uriService;
|
||||
private readonly MqSettings mqSettings;
|
||||
private readonly IApplicationsInWorkService applicationsInWorkService;
|
||||
private readonly IJobService jobService;
|
||||
private readonly IClientService clientService;
|
||||
|
||||
public TemplateActivatorController(
|
||||
@@ -34,7 +34,7 @@ namespace PARR.API.Controllers.V1
|
||||
IMqService mqService,
|
||||
IUriService uriService,
|
||||
MqSettings mqSettings,
|
||||
IApplicationsInWorkService applicationsInWorkService,
|
||||
IJobService jobService,
|
||||
IClientService clientService
|
||||
)
|
||||
{
|
||||
@@ -42,7 +42,7 @@ namespace PARR.API.Controllers.V1
|
||||
this.mqService = mqService;
|
||||
this.uriService = uriService;
|
||||
this.mqSettings = mqSettings;
|
||||
this.applicationsInWorkService = applicationsInWorkService;
|
||||
this.jobService = jobService;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
@@ -50,24 +50,24 @@ namespace PARR.API.Controllers.V1
|
||||
/// <summary>
|
||||
/// Отправить запрос на активацию/деактивацию шаблонов/расписаний
|
||||
/// </summary>
|
||||
/// <param name="applicationInWorkId"></param>
|
||||
/// <param name="jobId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost(ApiRoutes.TemplateActivator.SendRequest)]
|
||||
public async Task<IActionResult> SendRequest([FromRoute] Guid applicationInWorkId, [FromBody] TemplateActivatorRequest request)
|
||||
public async Task<IActionResult> SendRequest([FromRoute] Guid jobId, [FromBody] TemplateActivatorRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var appInWork = await applicationsInWorkService.GetAsync(applicationInWorkId);
|
||||
var job = await jobService.GetAsync(jobId);
|
||||
|
||||
if (appInWork == null)
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { FieldName = nameof(applicationInWorkId), Message = "Некорректное значение" } }));
|
||||
if (job == null)
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { FieldName = nameof(jobId), Message = "Некорректное значение" } }));
|
||||
|
||||
|
||||
var mqRequest = new TemplateActivatorMq
|
||||
{
|
||||
ApplicationInWorkId = applicationInWorkId,
|
||||
JobId = jobId,
|
||||
Action = request.Action,
|
||||
HistoryInitiator = new HistoryInitiator { InitiatorIp = clientService.GetClientIp()?.ToString(), InitiatorParrComponentId = ParrComponentsEnum.Api }
|
||||
};
|
||||
|
||||
@@ -28,21 +28,18 @@ namespace PARR.API.Controllers.V1
|
||||
{
|
||||
private readonly IMapper mapper;
|
||||
private readonly ITemplateService templateService;
|
||||
private readonly SettingsFromDb settingsFromDb;
|
||||
private readonly IRobotConfigurationService robotConfigurationService;
|
||||
private readonly IClientService clientService;
|
||||
|
||||
public TemplateController(
|
||||
IMapper mapper,
|
||||
ITemplateService templateService,
|
||||
SettingsFromDb settingsFromDb,
|
||||
IRobotConfigurationService robotConfigurationService,
|
||||
IClientService clientService
|
||||
)
|
||||
{
|
||||
this.mapper = mapper;
|
||||
this.templateService = templateService;
|
||||
this.settingsFromDb = settingsFromDb;
|
||||
this.robotConfigurationService = robotConfigurationService;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
@@ -58,7 +55,9 @@ namespace PARR.API.Controllers.V1
|
||||
{
|
||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||
|
||||
IQueryable<Template> query = templateService.GetWithIncludes()
|
||||
IQueryable<Template> query = templateService.GetWithIncludes().AsNoTracking()
|
||||
.Include(t => t.Unit).ThenInclude(t => t!.UnitValues).ThenInclude(t => t.Field)
|
||||
.Include(t => t.Unit).ThenInclude(t => t!.UnitValues).ThenInclude(t => t.Value)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.Robot)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.TaskStatus)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
|
||||
@@ -70,8 +69,8 @@ namespace PARR.API.Controllers.V1
|
||||
if (!string.IsNullOrEmpty(filter.Mask))
|
||||
query = query.Where(t => EF.Functions.Like(t.Name.ToLower(), SqlHelpers.RegexToLike(filter.Mask)));
|
||||
|
||||
if (filter.AppInWorkId.HasValue)
|
||||
query = query.Where(t => t.JobId == filter.AppInWorkId.Value);//TODO Migration to job
|
||||
if (filter.JobGroupId.HasValue)
|
||||
query = query.Where(t => t.Job!.GroupId == filter.JobGroupId.Value);
|
||||
|
||||
var templates = await templateService.GetPage(query, paginationFilter).ToListAsync();
|
||||
|
||||
@@ -92,7 +91,9 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpGet(ApiRoutes.Template.Get)]
|
||||
public async Task<IActionResult> GetById([FromRoute] Guid id)
|
||||
{
|
||||
var template = await templateService.GetWithIncludes()
|
||||
var template = await templateService.GetWithIncludes().AsNoTracking()
|
||||
.Include(t => t.Unit).ThenInclude(t => t!.UnitValues).ThenInclude(t => t.Field)
|
||||
.Include(t => t.Unit).ThenInclude(t => t!.UnitValues).ThenInclude(t => t.Value)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.Robot)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.TaskStatus)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
|
||||
@@ -118,6 +119,8 @@ namespace PARR.API.Controllers.V1
|
||||
public async Task<IActionResult> ChangeState([FromRoute] Guid id, [FromBody] TemplateChangeStateRequest request)
|
||||
{
|
||||
var template = await templateService.GetWithIncludes()
|
||||
.Include(t => t.Unit).ThenInclude(t => t!.UnitValues).ThenInclude(t => t.Field)
|
||||
.Include(t => t.Unit).ThenInclude(t => t!.UnitValues).ThenInclude(t => t.Value)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.Robot)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.TaskStatus)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
|
||||
@@ -147,7 +150,9 @@ namespace PARR.API.Controllers.V1
|
||||
if (!await templateService.CommitAsync(new HistoryInitiator { InitiatorComment = "Изменён статус шаблона/расписания", InitiatorIp = clientService.GetClientIp()?.ToString(), InitiatorParrComponentId = ParrComponentsEnum.Api }))
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при изменении шаблона." } }));
|
||||
|
||||
var templateToResponse = await templateService.GetWithIncludes()
|
||||
var templateToResponse = await templateService.GetWithIncludes().AsNoTracking()
|
||||
.Include(t => t.Unit).ThenInclude(t => t.UnitValues).ThenInclude(t => t.Field)
|
||||
.Include(t => t.Unit).ThenInclude(t => t.UnitValues).ThenInclude(t => t.Value)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.Robot)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.TaskStatus)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
|
||||
|
||||
Reference in New Issue
Block a user