diff --git a/PARR.API/Contracts/V1/ApiRoutes.cs b/PARR.API/Contracts/V1/ApiRoutes.cs
index 03ebe157..656c52f5 100644
--- a/PARR.API/Contracts/V1/ApiRoutes.cs
+++ b/PARR.API/Contracts/V1/ApiRoutes.cs
@@ -394,9 +394,9 @@
///
public static class TemplateActivator
{
- public const string SendRequest = Base + "/jobs/" + appInWorkId + "/template-activator";
+ public const string SendRequest = Base + "/jobs/" + jobId + "/template-activator";
- public const string appInWorkId = "{applicationInWorkId}";
+ public const string jobId = "{jobId}";
}
#endregion
diff --git a/PARR.API/Contracts/V1/Requests/Queries/TemplateQuery.cs b/PARR.API/Contracts/V1/Requests/Queries/TemplateQuery.cs
index 44a9af00..4d62c365 100644
--- a/PARR.API/Contracts/V1/Requests/Queries/TemplateQuery.cs
+++ b/PARR.API/Contracts/V1/Requests/Queries/TemplateQuery.cs
@@ -8,14 +8,14 @@
//public int? StatusCode { get; set; }
///
- /// Поиск по маске. Например: "*-ДВС"
+ /// Поиск по маске. Например: "ДВС-*"
///
public string? Mask { get; set; }
///
- /// Поиск по ИД Задания (ApplicationInWorkId)
+ /// Поиск по ИД Задания (JobGroupId)
///
- public Guid? AppInWorkId { get; set; }
+ public Guid? JobGroupId { get; set; }
}
}
diff --git a/PARR.API/Contracts/V1/Responses/TemplateResponse.cs b/PARR.API/Contracts/V1/Responses/TemplateResponse.cs
index cf9f8bc6..d8910576 100644
--- a/PARR.API/Contracts/V1/Responses/TemplateResponse.cs
+++ b/PARR.API/Contracts/V1/Responses/TemplateResponse.cs
@@ -3,36 +3,43 @@
public class TemplateResponse
{
public Guid Id { get; set; }
+
public required string Name { get; set; }
+
public bool IsActiveTemplate { get; set; }
+
public bool IsActiveSchedule { get; set; }
- public Guid ApplicationInWorkId { get; set; }
-
public required string Category { get; set; }
+
public required string Initiator { get; set; }
+
public required string ClosingCode { get; set; }
public required string ShortDescription { get; set; }
+
public required string FullDescription { get; set; }
+
public required string Solution { get; set; }
+
public required string TemplateDuration { get; set; }
public TemplateAgentResponse? Agent { get; set; }
public DateTimeOffset? LastRun { get; set; }
+
public DateTimeOffset NextRun { get; set; }
public bool IsAutoDistributionEnabled { get; set; }
- //public HostTemplateResponse? Host { get; set; }
public UnitBaseResponse? Unit { get; set; }
public JobBaseResponse? Job { get; set; }
- //public WorkResponse? Work { get; set; }
public ProcessResponse? Process { get; set; }
+
public SubprocessResponse? Subprocess { get; set; }
+
public TnkResponse? Tnk { get; set; }
public List? SyncStatus { get; set; }
diff --git a/PARR.API/Controllers/V1/RobotTaskController.cs b/PARR.API/Controllers/V1/RobotTaskController.cs
index 7cfee3dc..b7081525 100644
--- a/PARR.API/Controllers/V1/RobotTaskController.cs
+++ b/PARR.API/Controllers/V1/RobotTaskController.cs
@@ -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);
diff --git a/PARR.API/Controllers/V1/TemplateActivatorController.cs b/PARR.API/Controllers/V1/TemplateActivatorController.cs
index 4e385f60..6e3f6407 100644
--- a/PARR.API/Controllers/V1/TemplateActivatorController.cs
+++ b/PARR.API/Controllers/V1/TemplateActivatorController.cs
@@ -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
///
/// Отправить запрос на активацию/деактивацию шаблонов/расписаний
///
- ///
+ ///
///
[HttpPost(ApiRoutes.TemplateActivator.SendRequest)]
- public async Task SendRequest([FromRoute] Guid applicationInWorkId, [FromBody] TemplateActivatorRequest request)
+ public async Task 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 { new ErrorModel { FieldName = nameof(applicationInWorkId), Message = "Некорректное значение" } }));
+ if (job == null)
+ return BadRequest(new Response(false, new List { 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 }
};
diff --git a/PARR.API/Controllers/V1/TemplateController.cs b/PARR.API/Controllers/V1/TemplateController.cs
index 018a9245..85a8e443 100644
--- a/PARR.API/Controllers/V1/TemplateController.cs
+++ b/PARR.API/Controllers/V1/TemplateController.cs
@@ -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(paginationQuery);
- IQueryable query = templateService.GetWithIncludes()
+ IQueryable 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 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 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 { 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)
diff --git a/PARR.API/MappingProfiles/DomainToResponseProfile.cs b/PARR.API/MappingProfiles/DomainToResponseProfile.cs
index 60c5a990..9453c87b 100644
--- a/PARR.API/MappingProfiles/DomainToResponseProfile.cs
+++ b/PARR.API/MappingProfiles/DomainToResponseProfile.cs
@@ -48,7 +48,7 @@ namespace PARR.API.MappingProfiles
#endregion
- CreateMap()
+ CreateMap()
.ForMember(d => d.IsAgent, o => o.MapFrom(s => s.IsAgent))
.ForMember(d => d.Name, o => o.MapFrom(s => s.AgentName))
.ForMember(d => d.Script, o => o.MapFrom(s => s.AgentScript))
@@ -167,7 +167,7 @@ namespace PARR.API.MappingProfiles
.ForMember(d => d.Initiator, o => o.MapFrom())
.ForMember(d => d.Category, o => o.MapFrom())
.ForMember(d => d.WorkGroup, o => o.MapFrom(s => s.Template!.Unit.BaseFields.WorkGroup))
- .ForMember(d => d.Ek, o => o.MapFrom(s => s.Template!.Unit.Name))
+ .ForMember(d => d.Ek, o => o.MapFrom(s => s.Template!.Unit!.Name))
.ForMember(d => d.Name, o => o.MapFrom(s => s.Template!.Name))
.ForMember(d => d.ProcessName, o => o.MapFrom(s => s.Template!.Job!.Tnk!.Subprocess!.Process!.Name))
.ForMember(d => d.ProcessEsppId, o => o.MapFrom(s => s.Template!.Job!.Tnk!.Subprocess!.Process!.EsppId))
diff --git a/PARR.API/MappingProfiles/Resolvers/RobotTaskScheduleSchResolver.cs b/PARR.API/MappingProfiles/Resolvers/RobotTaskScheduleSchResolver.cs
index 938c558e..18561284 100644
--- a/PARR.API/MappingProfiles/Resolvers/RobotTaskScheduleSchResolver.cs
+++ b/PARR.API/MappingProfiles/Resolvers/RobotTaskScheduleSchResolver.cs
@@ -26,13 +26,13 @@ namespace PARR.API.MappingProfiles.Resolvers
public List? Resolve(RobotConfiguration source, RobotTaskScheduleResponse destination, List? destMember, ResolutionContext context)
{
- var appInWorksId = source.Template!.JobId;
+ var jobGroupId = source.Template!.Job!.GroupId;
- var schedule = esppConfigService.GetEsppScheduleDto(appInWorksId);
+ var schedule = esppConfigService.GetEsppScheduleDto(jobGroupId);
if (schedule == null)
{
- logger.LogError($"RobotTaskScheduleSchResolver: Не смог замапить расписание для робота, так как оно null. appInWorksId: {appInWorksId}");
+ logger.LogError($"RobotTaskScheduleSchResolver: Не смог замапить расписание для робота, так как оно null. jobGroupId: {jobGroupId}");
return null;
}
diff --git a/PARR.BLL/Domain/Mq/TemplateActivatorMq.cs b/PARR.BLL/Domain/Mq/TemplateActivatorMq.cs
index 0cafd462..b9d124a5 100644
--- a/PARR.BLL/Domain/Mq/TemplateActivatorMq.cs
+++ b/PARR.BLL/Domain/Mq/TemplateActivatorMq.cs
@@ -11,7 +11,7 @@ namespace PARR.BLL.Domain.Mq
///
/// Id регламентной работы
///
- public Guid ApplicationInWorkId { get; set; }
+ public Guid JobId { get; set; }
///
/// Действие по активации/деактивации
diff --git a/PARR.DAL/Services/Implementations/EsppSchTypeConfigService.cs b/PARR.DAL/Services/Implementations/EsppSchTypeConfigService.cs
index 0972685f..be50736b 100644
--- a/PARR.DAL/Services/Implementations/EsppSchTypeConfigService.cs
+++ b/PARR.DAL/Services/Implementations/EsppSchTypeConfigService.cs
@@ -35,15 +35,6 @@ namespace PARR.DAL.Services.Implementations
{
//Формирует расписание в нормальном понятном виде из БД
- var test = await dataContext.EsppSchValues
- //.Include(t => t.JobGroup)
- //.Include(t => t.EsppSchTypeConfig)
- // .ThenInclude(t => t!.EsppSchTypeSchedule)
- //.Include(t => t.EsppSchTypeConfig)
- // .ThenInclude(t => t.EsppSchType)
- //.Include(t => t.EsppSchTypeValue)
- .ToListAsync();
-
var schValues = await dataContext.EsppSchValues
.Include(t => t.EsppSchTypeConfig)
.ThenInclude(t => t!.EsppSchTypeSchedule)
diff --git a/PARR.DAL/Services/Implementations/TemplateService.cs b/PARR.DAL/Services/Implementations/TemplateService.cs
index e1eef628..d800f75f 100644
--- a/PARR.DAL/Services/Implementations/TemplateService.cs
+++ b/PARR.DAL/Services/Implementations/TemplateService.cs
@@ -38,7 +38,10 @@ namespace PARR.DAL.Services.Implementations
.Include(a => a.Job)
.ThenInclude(t => t!.Tnk)
.ThenInclude(s => s!.Subprocess)
- .ThenInclude(p => p!.Process);
+ .ThenInclude(p => p!.Process)
+ .Include(t=>t.Job)
+ .ThenInclude(t=>t!.Group);
+
//return Get()
// .Include(h => h.Host)
// .ThenInclude(t => t!.ResponseArea)
diff --git a/PARR.DAL/TransformServices/EsppScheduleTransformService.cs b/PARR.DAL/TransformServices/EsppScheduleTransformService.cs
index 73a63dd8..4792cf83 100644
--- a/PARR.DAL/TransformServices/EsppScheduleTransformService.cs
+++ b/PARR.DAL/TransformServices/EsppScheduleTransformService.cs
@@ -1,6 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
-using PARR.Common;
using PARR.Constants;
using PARR.DAL.Contracts;
using PARR.DAL.DomainModels;
@@ -13,8 +12,6 @@ namespace PARR.DAL.TransformServices
internal class EsppScheduleTransformService : IEsppScheduleTransformService
{
private readonly IEsppSchTypeConfigService esppSchTypeConfigService;
- private readonly IApplicationsInWorkService applicationsInWorkService;
- private readonly IWeekendDayService weekendDayService;
private readonly INextRunModifierService nextRunModifierService;
private readonly IJobGroupService jobGroupService;
private readonly ILogger logger;
@@ -59,15 +56,12 @@ namespace PARR.DAL.TransformServices
public EsppScheduleTransformService(
ILogger logger,
IEsppSchTypeConfigService esppSchTypeConfigService,
- IApplicationsInWorkService applicationsInWorkService,
IWeekendDayService weekendDayService,
INextRunModifierService nextRunModifierService,
IJobGroupService jobGroupService
)
{
this.esppSchTypeConfigService = esppSchTypeConfigService;
- this.applicationsInWorkService = applicationsInWorkService;
- this.weekendDayService = weekendDayService;
this.nextRunModifierService = nextRunModifierService;
this.jobGroupService = jobGroupService;
this.logger = logger;
@@ -167,13 +161,8 @@ namespace PARR.DAL.TransformServices
if (lastRun > DateTimeOffset.UtcNow)
return await nextRunModifierService.GetWorkDayAsync(lastRun);
- //var appInWork = await applicationsInWorkService.Get()
- // .Include(aiw => aiw.EsppSchValues)
- // .ThenInclude(esv => esv.EsppSchTypeValue)
- // .ThenInclude(etv => etv!.DistributionPeriod)
- // .FirstOrDefaultAsync(t => t.Id == applicationInWorkId);
- var jobGroup = await jobGroupService.Get()
- .Include(t=>t.EsppSchValues)
+ var jobGroup = await jobGroupService.Get().AsTracking()
+ .Include(t => t.EsppSchValues)
.ThenInclude(esv => esv.EsppSchTypeValue)
.ThenInclude(etv => etv!.DistributionPeriod)
.FirstOrDefaultAsync(t => t.Id == jobGroupId);