feat(api): JobGroupResponse, TemplateResponse - отображение настроек автораспределения

This commit is contained in:
Mikhail Trubnikov
2026-01-22 14:05:48 +10:00
parent 1845154b26
commit 9e84ef8029
7 changed files with 60 additions and 5 deletions

View File

@@ -0,0 +1,13 @@
namespace PARR.API.Contracts.V1.Responses
{
public class DistributionPeriodResponse
{
public Guid Id { get; set; }
public required string Name { get; set; }
public required string Duration { get; set; }
public required string Type { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
namespace PARR.API.Contracts.V1.Responses
{
public class JobGroupDistributionConfigResponse
{
public bool IsExcludeWeekends { get; set; }
public bool IsGroupingByWorkGroup { get; set; }
public DistributionPeriodResponse? Period { get; set; }
}
}

View File

@@ -25,7 +25,10 @@
/// </summary>
public FieldResponse? GroupingUnitField { get; set; }
// public bool IsAutoDistributionEnabled { get; set; }
/// <summary>
/// Включено автораспределение
/// </summary>
public bool IsAutoDistributionEnabled { get; set; }
// public bool IsAgent { get; set; }
@@ -55,6 +58,11 @@
/// </summary>
public ScheduleExcludeTypeCalendarResponse? ScheduleExcludeTypeCalendar { get; set; }
/// <summary>
/// Настройки автораспределения
/// </summary>
public JobGroupDistributionConfigResponse? DistributionConfig { get; set; }
}
public class JobGroupScheduleResponse
@@ -65,4 +73,6 @@
public List<EsppScheduleValResponse>? Values { get; set; }
}
}

View File

@@ -75,5 +75,7 @@
public int OrderCount { get; set; }
public TemplateStatusTypeResponse? StatusType { get; set; }
public JobGroupDistributionConfigResponse? DistributionConfig { get; set; }
}
}

View File

@@ -86,7 +86,9 @@ namespace PARR.API.Controllers.V1
query = query.Where(t => t.GroupName.ToLower().Contains(filter.Name.ToLower()));
if (filter.IsFull)
query = query.Include(t => t.Jobs).ThenInclude(t => t.Tnk);
query = query
.Include(t => t.Jobs).ThenInclude(t => t.Tnk)
.Include(t => t.DistributionConfig).ThenInclude(t => t.DistributionPeriod);
var jobGroups = await groupService.GetPage(query, paginationFilter).ToListAsync();
@@ -119,6 +121,7 @@ namespace PARR.API.Controllers.V1
.Include(t => t.GroupingUnitField)
.Include(t => t.ScheduleExcludeType)
.Include(t => t.ScheduleExcludeTypeCalendar)
.Include(t => t.DistributionConfig).ThenInclude(t => t.DistributionPeriod)
.FirstOrDefaultAsync(t => t.Id == id);
if (jobGroup == null)
@@ -187,6 +190,7 @@ namespace PARR.API.Controllers.V1
.Include(t => t.GroupingUnitField)
.Include(t => t.ScheduleExcludeType)
.Include(t => t.ScheduleExcludeTypeCalendar)
.Include(t => t.DistributionConfig).ThenInclude(t => t.DistributionPeriod)
.FirstAsync(t => t.Id == jobGroup.Id);
var locationUri = uriService.GetUri(ApiRoutes.JobGroup.Get, ApiRoutes.JobGroup.getParam, createdJobGroup.Id);
@@ -290,6 +294,7 @@ namespace PARR.API.Controllers.V1
.Include(t => t.GroupingUnitField)
.Include(t => t.ScheduleExcludeType)
.Include(t => t.ScheduleExcludeTypeCalendar)
.Include(t => t.DistributionConfig).ThenInclude(t => t.DistributionPeriod)
.FirstAsync(t => t.Id == orig.Id);
var response = mapper.Map<JobGroupResponse>(updatedJobGroup);

View File

@@ -43,6 +43,7 @@ namespace PARR.API.MappingProfiles
.ForMember(d => d.StatusType, o => o.MapFrom(s => s.StatusType))
.ForMember(d => d.ScheduleExcludeType, o => o.MapFrom(s => s.Job!.Group!.ScheduleExcludeType))
.ForMember(d => d.ScheduleExcludeTypeCalendar, o => o.MapFrom(s => s.Job!.Group!.ScheduleExcludeTypeCalendar))
.ForMember(d => d.DistributionConfig, o => o.MapFrom(s => s.Job.Group.DistributionConfig))
;
// === Template ===
@@ -330,7 +331,6 @@ namespace PARR.API.MappingProfiles
#endregion
#region Job
CreateMap<Job, JobBaseResponse>()
@@ -368,9 +368,19 @@ namespace PARR.API.MappingProfiles
CreateMap<JobGroup, JobGroupResponse>()
.ForMember(d => d.ScheduleExcludeType, o => o.MapFrom(s => s.ScheduleExcludeType))
.ForMember(d => d.ScheduleExcludeTypeCalendar, o => o.MapFrom(s => s.ScheduleExcludeTypeCalendar));
.ForMember(d => d.ScheduleExcludeTypeCalendar, o => o.MapFrom(s => s.ScheduleExcludeTypeCalendar))
.ForMember(d => d.DistributionConfig, o => o.MapFrom(s => s.DistributionConfig));
#endregion
#region JobGroupDistributionConfig
CreateMap<JobGroupDistributionConfig, JobGroupDistributionConfigResponse>()
.ForMember(d => d.Period, o => o.MapFrom(s => s.DistributionPeriod));
CreateMap<DistributionPeriod, DistributionPeriodResponse>();
#endregion
#region ScheduleExcludeTypeCalendarResponse

View File

@@ -48,7 +48,11 @@ namespace PARR.DAL.Services.Implementations
.ThenInclude(p => p!.Process)
.Include(t => t.Job)
.ThenInclude(t => t!.Group)
.ThenInclude(t => t!.GroupType);
.ThenInclude(t => t!.GroupType)
.Include(t => t.Job)
.ThenInclude(t => t!.Group)
.ThenInclude(t => t.DistributionConfig)
.ThenInclude(t => t.DistributionPeriod);
}
public override Task<bool> CreateAsync(Template obj)