This commit is contained in:
Mikhail Kuznetsov
2025-12-26 12:37:57 +10:00
45 changed files with 9240 additions and 94 deletions

View File

@@ -531,6 +531,20 @@
public const string GetAll = Base + "/kii-units/"; public const string GetAll = Base + "/kii-units/";
} }
#region Расписание - исключения
public static class ScheduleExcludeType
{
public const string GetAll = Base + "/schedule-exclude-types/";
}
public static class ScheduleExcludeTypeCalendar
{
public const string GetAll = Base + "/schedule-exclude-type-calendars/";
}
#endregion
} }
} }

View File

@@ -23,6 +23,10 @@
public DateTimeOffset ReferenceDate { get; set; } public DateTimeOffset ReferenceDate { get; set; }
public Guid ScheduleExcludeTypeId { get; set; }
public Guid? ScheduleExcludeTypeCalendarId { get; set; }
//public bool IsAutoDistributionEnabled { get; set; } //public bool IsAutoDistributionEnabled { get; set; }
//public bool IsAgent { get; set; } //public bool IsAgent { get; set; }

View File

@@ -57,6 +57,8 @@
public string? ValueMask { get; set; } public string? ValueMask { get; set; }
public bool IsInverse { get; set; } = false;
} }

View File

@@ -42,6 +42,16 @@
public int JobsCount { get; set; } public int JobsCount { get; set; }
public JobGroupScheduleResponse? Schedule { get; set; } public JobGroupScheduleResponse? Schedule { get; set; }
/// <summary>
/// Расписание
/// </summary>
public ScheduleExcludeTypeResponse? ScheduleExcludeType { get; set; }
/// <summary>
/// Тип исключения - календарь
/// </summary>
public ScheduleExcludeTypeCalendarResponse? ScheduleExcludeTypeCalendar { get; set; }
} }
public class JobGroupScheduleResponse public class JobGroupScheduleResponse

View File

@@ -22,7 +22,6 @@
public class JobResponse : JobBaseResponse public class JobResponse : JobBaseResponse
{ {
public TnkResponse? Tnk { get; set; } public TnkResponse? Tnk { get; set; }
public JobGroupBaseResponse? Group { get; set; } public JobGroupBaseResponse? Group { get; set; }
@@ -33,7 +32,7 @@
public JobAutoControlResponse? AutoControl { get; set; } public JobAutoControlResponse? AutoControl { get; set; }
#region Статистика #region Статистика Old
//public TemplateStats? TemplateStatistics { get; set; } //public TemplateStats? TemplateStatistics { get; set; }
@@ -64,6 +63,8 @@
public string? ValueMask { get; set; } public string? ValueMask { get; set; }
public bool IsInverse { get; set; }
} }

View File

@@ -0,0 +1,15 @@
namespace PARR.API.Contracts.V1.Responses
{
public class ScheduleExcludeTypeCalendarResponse
{
public Guid Id { get; set; }
public required string Title { get; set; }
public required string EsppName { get; set; }
public required string EsppValue { get; set; }
public required string Code { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
namespace PARR.API.Contracts.V1.Responses
{
public class ScheduleExcludeTypeResponse
{
public Guid Id { get; set; }
public required string Title { get; set; }
public required string EsppName { get; set; }
public required string EsppValue { get; set; }
public required string Code { get; set; }
}
}

View File

@@ -50,6 +50,16 @@
/// </summary> /// </summary>
public EsppScheduleResponse? Schedule { get; set; } public EsppScheduleResponse? Schedule { get; set; }
/// <summary>
/// Тип исклчения
/// </summary>
public ScheduleExcludeTypeResponse? ScheduleExcludeType { get; set; }
/// <summary>
/// Тип исключения - календарь
/// </summary>
public ScheduleExcludeTypeCalendarResponse? ScheduleExcludeTypeCalendar { get; set; }
public int OrderCount { get; set; } public int OrderCount { get; set; }
public TemplateStatusTypeResponse? StatusType { get; set; } public TemplateStatusTypeResponse? StatusType { get; set; }

View File

@@ -24,6 +24,7 @@ using PARR.DAL.Models.Job;
using PARR.DAL.Services.Interfaces; using PARR.DAL.Services.Interfaces;
using PARR.DAL.Services.Interfaces.Job; using PARR.DAL.Services.Interfaces.Job;
using PARR.DAL.Services.Interfaces.Unit; using PARR.DAL.Services.Interfaces.Unit;
using System.Net;
using System.Text.Json; using System.Text.Json;
namespace PARR.API.Controllers.V1 namespace PARR.API.Controllers.V1
@@ -121,7 +122,8 @@ namespace PARR.API.Controllers.V1
foreach (var jobResponse in response) foreach (var jobResponse in response)
{ {
jobResponse.TemplatesCount = await templateService.Get().CountAsync(t => t.JobId == jobResponse.Id); //jobResponse.TemplatesCount = await templateService.Get().CountAsync(t => t.JobId == jobResponse.Id);
jobResponse.TemplatesCount = await GetCountTemplatesAsync(jobResponse.Id);
} }
var paginationResponse = new PagedResponse<JobResponse>(response, true).GetPaginatedProps(paginationFilter, query); var paginationResponse = new PagedResponse<JobResponse>(response, true).GetPaginatedProps(paginationFilter, query);
@@ -156,10 +158,10 @@ namespace PARR.API.Controllers.V1
var response = mapper.Map<JobResponse>(job); var response = mapper.Map<JobResponse>(job);
response.TemplatesCount = await templateService.Get().CountAsync(t => t.JobId == id); response.TemplatesCount = await GetCountTemplatesAsync(id); //await templateService.Get().CountAsync(t => t.JobId == id);
var statistics = await GetStatisticsAsync(response.Id); //var statistics = await GetStatisticsAsync(response.Id);
BindStatistics(response, statistics); //BindStatistics(response, statistics);
return Ok(new Response<JobResponse>(response, true)); return Ok(new Response<JobResponse>(response, true));
} }
@@ -351,10 +353,11 @@ namespace PARR.API.Controllers.V1
.FirstAsync(t => t.Id == orig.Id); .FirstAsync(t => t.Id == orig.Id);
var response = mapper.Map<JobResponse>(updatedJob); var response = mapper.Map<JobResponse>(updatedJob);
response.TemplatesCount = await templateService.Get().CountAsync(t => t.JobId == id); response.TemplatesCount = await GetCountTemplatesAsync(id); //await templateService.Get().CountAsync(t => t.JobId == id);
var statistics = await GetStatisticsAsync(response.Id); //не используется
BindStatistics(response, statistics); //var statistics = await GetStatisticsAsync(response.Id);
//BindStatistics(response, statistics);
return Ok(new Response<JobResponse>(response, true)); return Ok(new Response<JobResponse>(response, true));
} }
@@ -392,7 +395,9 @@ namespace PARR.API.Controllers.V1
orig.UnitFilters.Add(newUnitFilter); orig.UnitFilters.Add(newUnitFilter);
} }
/* Писал полноценный апдейт, но Миша сказал что нахрен это - просто все удаляем, а потом создаём заново
#region old
/* Писал полноценный апдейт, но Миша сказал что нахрен это - просто все удаляем, а потом создаём заново... Ох уж этот Миша...
//Сразу удаляем UnitFilter которых нет //Сразу удаляем UnitFilter которых нет
var toDelete = orig.UnitFilters.Where(t => !mappedRequest.UnitFilters.Any(e => e.Id == t.Id)); var toDelete = orig.UnitFilters.Where(t => !mappedRequest.UnitFilters.Any(e => e.Id == t.Id));
foreach (var item in toDelete) foreach (var item in toDelete)
@@ -506,6 +511,8 @@ namespace PARR.API.Controllers.V1
#endregion #endregion
} }
}*/ }*/
#endregion
} }
private static JobRelationshipFilter CreateRelationshipFilter(Guid fieldId, bool isParent, bool isFullMatch, bool isInverse, string valueMask) private static JobRelationshipFilter CreateRelationshipFilter(Guid fieldId, bool isParent, bool isFullMatch, bool isInverse, string valueMask)
@@ -636,6 +643,18 @@ namespace PARR.API.Controllers.V1
return true; return true;
} }
/// <summary>
/// Получить кол-во шаблонов в Job
/// </summary>
/// <param name="jobId"></param>
/// <returns></returns>
private async Task<int> GetCountTemplatesAsync(Guid jobId)
{
// Получаем только шаблоны в статусе used
return await templateService.Get().CountAsync(t => t.JobId == jobId && t.StatusTypeId == TemplateStatusTypeEnum.Used);
}
} }
@@ -647,5 +666,4 @@ namespace PARR.API.Controllers.V1
} }
} }

View File

@@ -72,7 +72,9 @@ namespace PARR.API.Controllers.V1
IQueryable<JobGroup> query = groupService.Get() IQueryable<JobGroup> query = groupService.Get()
.Include(t => t.GroupType) .Include(t => t.GroupType)
.Include(t => t.GroupingUnitField); .Include(t => t.GroupingUnitField)
.Include(t => t.ScheduleExcludeType)
.Include(t => t.ScheduleExcludeTypeCalendar);
query = query.OrderBy(t => t.GroupName); query = query.OrderBy(t => t.GroupName);
@@ -111,6 +113,8 @@ namespace PARR.API.Controllers.V1
.Include(t => t.Jobs).ThenInclude(t => t.Tnk) .Include(t => t.Jobs).ThenInclude(t => t.Tnk)
.Include(t => t.GroupType) .Include(t => t.GroupType)
.Include(t => t.GroupingUnitField) .Include(t => t.GroupingUnitField)
.Include(t => t.ScheduleExcludeType)
.Include(t => t.ScheduleExcludeTypeCalendar)
.FirstOrDefaultAsync(t => t.Id == id); .FirstOrDefaultAsync(t => t.Id == id);
if (jobGroup == null) if (jobGroup == null)
@@ -148,6 +152,8 @@ namespace PARR.API.Controllers.V1
Solution = request.Solution.Trim(), Solution = request.Solution.Trim(),
TemplateDuration = request.TemplateDuration.Trim(), TemplateDuration = request.TemplateDuration.Trim(),
ReferenceDate = request.ReferenceDate, ReferenceDate = request.ReferenceDate,
ScheduleExcludeTypeId = request.ScheduleExcludeTypeId,
ScheduleExcludeTypeCalendarId = request.ScheduleExcludeTypeCalendarId
//IsAutoDistributionEnabled = request.IsAutoDistributionEnabled, //IsAutoDistributionEnabled = request.IsAutoDistributionEnabled,
//IsAgent = request.IsAgent, //IsAgent = request.IsAgent,
//AgentName = request.AgentName, //AgentName = request.AgentName,
@@ -175,6 +181,8 @@ namespace PARR.API.Controllers.V1
var createdJobGroup = await groupService.Get().Include(t => t.Jobs).ThenInclude(t => t.Tnk) var createdJobGroup = await groupService.Get().Include(t => t.Jobs).ThenInclude(t => t.Tnk)
.Include(t => t.GroupType) .Include(t => t.GroupType)
.Include(t => t.GroupingUnitField) .Include(t => t.GroupingUnitField)
.Include(t => t.ScheduleExcludeType)
.Include(t => t.ScheduleExcludeTypeCalendar)
.FirstAsync(t => t.Id == jobGroup.Id); .FirstAsync(t => t.Id == jobGroup.Id);
var locationUri = uriService.GetUri(ApiRoutes.JobGroup.Get, ApiRoutes.JobGroup.getParam, createdJobGroup.Id); var locationUri = uriService.GetUri(ApiRoutes.JobGroup.Get, ApiRoutes.JobGroup.getParam, createdJobGroup.Id);
@@ -220,6 +228,8 @@ namespace PARR.API.Controllers.V1
orig.Solution = request.Solution.Trim(); orig.Solution = request.Solution.Trim();
orig.TemplateDuration = request.TemplateDuration.Trim(); orig.TemplateDuration = request.TemplateDuration.Trim();
orig.ReferenceDate = request.ReferenceDate; orig.ReferenceDate = request.ReferenceDate;
orig.ScheduleExcludeTypeId = request.ScheduleExcludeTypeId;
orig.ScheduleExcludeTypeCalendarId = request.ScheduleExcludeTypeCalendarId;
//orig.IsAutoDistributionEnabled = request.IsAutoDistributionEnabled; //orig.IsAutoDistributionEnabled = request.IsAutoDistributionEnabled;
//orig.IsAgent = request.IsAgent; //orig.IsAgent = request.IsAgent;
//orig.AgentName = request.AgentName; //orig.AgentName = request.AgentName;
@@ -273,6 +283,8 @@ namespace PARR.API.Controllers.V1
.ThenInclude(t => t.Tnk) .ThenInclude(t => t.Tnk)
.Include(t => t.GroupType) .Include(t => t.GroupType)
.Include(t => t.GroupingUnitField) .Include(t => t.GroupingUnitField)
.Include(t => t.ScheduleExcludeType)
.Include(t => t.ScheduleExcludeTypeCalendar)
.FirstAsync(t => t.Id == orig.Id); .FirstAsync(t => t.Id == orig.Id);
var response = mapper.Map<JobGroupResponse>(updatedJobGroup); var response = mapper.Map<JobGroupResponse>(updatedJobGroup);

View File

@@ -119,6 +119,14 @@ namespace PARR.API.Controllers.V1
.ThenInclude(t => t!.EsppSchValues) .ThenInclude(t => t!.EsppSchValues)
.ThenInclude(t => t!.EsppSchTypeConfig) .ThenInclude(t => t!.EsppSchTypeConfig)
.ThenInclude(t => t!.EsppSchTypeSchedule) .ThenInclude(t => t!.EsppSchTypeSchedule)
.Include(t => t.Template)
.ThenInclude(t => t!.Job)
.ThenInclude(t => t!.Group)
.ThenInclude(t => t!.ScheduleExcludeType)
.Include(t => t.Template)
.ThenInclude(t => t!.Job)
.ThenInclude(t => t!.Group)
.ThenInclude(t => t.ScheduleExcludeTypeCalendar)
.Include(t => t.Template) .Include(t => t.Template)
.ThenInclude(t => t.UnitsInTemplate); .ThenInclude(t => t.UnitsInTemplate);

View File

@@ -0,0 +1,52 @@
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using PARR.API.Contracts.V1;
using PARR.API.Contracts.V1.Responses;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.Constants;
using PARR.DAL.Services.Interfaces.Schedule;
namespace PARR.API.Controllers.V1
{
/// <summary>
/// Расписание регламентной работы, исключение - Календарь
/// </summary>
[Authorize(Roles = ParrRoles.Administrator.Role)]
public class ScheduleExcludeTypeCalendarController : BaseApiController
{
private readonly IMapper mapper;
private readonly IScheduleExcludeTypeCalendarService scheduleExcludeTypeCalendarService;
public ScheduleExcludeTypeCalendarController(
IMapper mapper,
IScheduleExcludeTypeCalendarService scheduleExcludeTypeCalendarService
)
{
this.mapper = mapper;
this.scheduleExcludeTypeCalendarService = scheduleExcludeTypeCalendarService;
}
/// <summary>
/// Получить список календарей исключений для расписания РР
/// </summary>
/// <returns></returns>
[HttpGet(ApiRoutes.ScheduleExcludeTypeCalendar.GetAll)]
public async Task<IActionResult> GetAll()
{
var query = scheduleExcludeTypeCalendarService.Get().OrderBy(t => t.Title);
var calendars = await query.ToListAsync();
if (!calendars.Any())
return NoContent();
var response = mapper.Map<List<ScheduleExcludeTypeCalendarResponse>>(calendars);
return Ok(new Response<List<ScheduleExcludeTypeCalendarResponse>>(response, true));
}
}
}

View File

@@ -0,0 +1,53 @@
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using PARR.API.Contracts.V1;
using PARR.API.Contracts.V1.Responses;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.Constants;
using PARR.DAL.Services.Interfaces.Schedule;
namespace PARR.API.Controllers.V1
{
/// <summary>
/// Расписание регламентной работы - Тип исключения
/// </summary>
[Authorize(Roles = ParrRoles.Administrator.Role)]
public class ScheduleExcludeTypeController : BaseApiController
{
private readonly IMapper mapper;
private readonly IScheduleExcludeTypeService scheduleExcludeTypeService;
public ScheduleExcludeTypeController(
IMapper mapper,
IScheduleExcludeTypeService scheduleExcludeTypeService
)
{
this.mapper = mapper;
this.scheduleExcludeTypeService = scheduleExcludeTypeService;
}
/// <summary>
/// Получить список типов исключений для расписания РР
/// </summary>
/// <returns></returns>
[HttpGet(ApiRoutes.ScheduleExcludeType.GetAll)]
public async Task<IActionResult> GetAll()
{
var query = scheduleExcludeTypeService.Get().OrderBy(t => t.Title);
var types = await query.ToListAsync();
if (!types.Any())
return NoContent();
var response = mapper.Map<List<ScheduleExcludeTypeResponse>>(types);
return Ok(new Response<List<ScheduleExcludeTypeResponse>>(response, true));
}
}
}

View File

@@ -66,6 +66,8 @@ namespace PARR.API.Controllers.V1
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus) .Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
.Include(t => t.Orders) .Include(t => t.Orders)
.Include(t => t.StatusType) .Include(t => t.StatusType)
.Include(t => t.Job).ThenInclude(t => t.Group).ThenInclude(t => t.ScheduleExcludeType)
.Include(t => t.Job).ThenInclude(t => t.Group).ThenInclude(t => t.ScheduleExcludeTypeCalendar)
.OrderBy(t => t.Name) .OrderBy(t => t.Name)
.AsSplitQuery(); .AsSplitQuery();
@@ -125,6 +127,8 @@ namespace PARR.API.Controllers.V1
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus) .Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
.Include(t => t.Orders) .Include(t => t.Orders)
.Include(t => t.StatusType) .Include(t => t.StatusType)
.Include(t => t.Job).ThenInclude(t => t.Group).ThenInclude(t => t.ScheduleExcludeType)
.Include(t => t.Job).ThenInclude(t => t.Group).ThenInclude(t => t.ScheduleExcludeTypeCalendar)
.AsSplitQuery() .AsSplitQuery()
.FirstOrDefaultAsync(t => t.Id == id); .FirstOrDefaultAsync(t => t.Id == id);
@@ -156,6 +160,8 @@ namespace PARR.API.Controllers.V1
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus) .Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
.Include(t => t.Orders) .Include(t => t.Orders)
.Include(t => t.StatusType) .Include(t => t.StatusType)
.Include(t => t.Job).ThenInclude(t => t.Group).ThenInclude(t => t.ScheduleExcludeType)
.Include(t => t.Job).ThenInclude(t => t.Group).ThenInclude(t => t.ScheduleExcludeTypeCalendar)
.AsSplitQuery() .AsSplitQuery()
.FirstOrDefaultAsync(t => t.Id == id); .FirstOrDefaultAsync(t => t.Id == id);
@@ -189,6 +195,8 @@ namespace PARR.API.Controllers.V1
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus) .Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
.Include(t => t.Orders) .Include(t => t.Orders)
.Include(t => t.StatusType) .Include(t => t.StatusType)
.Include(t => t.Job).ThenInclude(t => t.Group).ThenInclude(t => t.ScheduleExcludeType)
.Include(t => t.Job).ThenInclude(t => t.Group).ThenInclude(t => t.ScheduleExcludeTypeCalendar)
.AsSplitQuery() .AsSplitQuery()
.FirstOrDefaultAsync(t => t.Id == id); .FirstOrDefaultAsync(t => t.Id == id);

View File

@@ -6,6 +6,7 @@ using PARR.Common.Domain;
using PARR.DAL.DomainModels; using PARR.DAL.DomainModels;
using PARR.DAL.Models; using PARR.DAL.Models;
using PARR.DAL.Models.Job; using PARR.DAL.Models.Job;
using PARR.DAL.Models.Schedule;
using PARR.DAL.Models.Unit; using PARR.DAL.Models.Unit;
namespace PARR.API.MappingProfiles namespace PARR.API.MappingProfiles
@@ -39,7 +40,10 @@ namespace PARR.API.MappingProfiles
.ForMember(d => d.LastRun, o => o.MapFrom(s => s.LastRun)) .ForMember(d => d.LastRun, o => o.MapFrom(s => s.LastRun))
.ForMember(d => d.OrderCount, o => o.MapFrom(s => s.Orders.Count())) .ForMember(d => d.OrderCount, o => o.MapFrom(s => s.Orders.Count()))
.ForMember(d => d.IsAutoDistributionEnabled, o => o.MapFrom(s => s.Job!.Group!.IsAutoDistributionEnabled)) .ForMember(d => d.IsAutoDistributionEnabled, o => o.MapFrom(s => s.Job!.Group!.IsAutoDistributionEnabled))
.ForMember(d => d.StatusType, o => o.MapFrom(s => s.StatusType)); .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))
;
// === Template === // === Template ===
@@ -227,8 +231,10 @@ namespace PARR.API.MappingProfiles
.ForMember(d => d.TemplateName, o => o.MapFrom(s => s.Template!.Name)) .ForMember(d => d.TemplateName, o => o.MapFrom(s => s.Template!.Name))
.ForMember(d => d.TemplateId, o => o.MapFrom(s => s.Template!.Id)) .ForMember(d => d.TemplateId, o => o.MapFrom(s => s.Template!.Id))
.ForMember(d => d.WorkGroup, o => o.MapFrom(s => s.Template!.Job!.WorkGroupMask)) .ForMember(d => d.WorkGroup, o => o.MapFrom(s => s.Template!.Job!.WorkGroupMask))
.ForMember(d => d.Exclude, o => o.MapFrom<RobotTaskScheduleExcludeResolver>()) //.ForMember(d => d.Exclude, o => o.MapFrom<RobotTaskScheduleExcludeResolver>())
.ForMember(d => d.ExcludeCalendar, o => o.MapFrom<RobotTaskScheduleExcludeCalendarResolver>()) .ForMember(d => d.Exclude, o => o.MapFrom(s => s.Template!.Job!.Group!.ScheduleExcludeType!.EsppName))
//.ForMember(d => d.ExcludeCalendar, o => o.MapFrom<RobotTaskScheduleExcludeCalendarResolver>())
.ForMember(d => d.ExcludeCalendar, o => o.MapFrom(s => s.Template!.Job!.Group!.ScheduleExcludeTypeCalendar != null ? s.Template!.Job!.Group!.ScheduleExcludeTypeCalendar.EsppName : null))
.ForMember(d => d.Timezone, o => o.MapFrom<RobotTaskScheduleTimezoneResolver>()) .ForMember(d => d.Timezone, o => o.MapFrom<RobotTaskScheduleTimezoneResolver>())
.ForMember(d => d.RepeatRange, o => o.MapFrom<RobotTaskScheduleRepeatRangeResolver>()) .ForMember(d => d.RepeatRange, o => o.MapFrom<RobotTaskScheduleRepeatRangeResolver>())
//todo: GenerationTime //todo: GenerationTime
@@ -351,6 +357,7 @@ namespace PARR.API.MappingProfiles
#endregion #endregion
#region JobGroup #region JobGroup
CreateMap<JobGroup, JobGroupBaseResponse>() CreateMap<JobGroup, JobGroupBaseResponse>()
.Include<JobGroup, JobGroupResponse>() .Include<JobGroup, JobGroupResponse>()
.ForMember(d => d.GroupType, o => o.MapFrom(s => s.GroupType)) .ForMember(d => d.GroupType, o => o.MapFrom(s => s.GroupType))
@@ -359,9 +366,23 @@ namespace PARR.API.MappingProfiles
CreateMap<JobGroup, JobGroupBaseResponse>() CreateMap<JobGroup, JobGroupBaseResponse>()
.ForMember(d => d.Name, o => o.MapFrom(s => s.GroupName)); .ForMember(d => d.Name, o => o.MapFrom(s => s.GroupName));
CreateMap<JobGroup, JobGroupResponse>(); CreateMap<JobGroup, JobGroupResponse>()
.ForMember(d => d.ScheduleExcludeType, o => o.MapFrom(s => s.ScheduleExcludeType))
.ForMember(d => d.ScheduleExcludeTypeCalendar, o => o.MapFrom(s => s.ScheduleExcludeTypeCalendar));
#endregion
#region ScheduleExcludeTypeCalendarResponse
CreateMap<ScheduleExcludeTypeCalendar, ScheduleExcludeTypeCalendarResponse>();
#endregion
#region ScheduleExcludeTypeResponse
CreateMap<ScheduleExcludeType, ScheduleExcludeTypeResponse>();
#endregion #endregion
#region JobGroupType #region JobGroupType

View File

@@ -5,18 +5,18 @@ using PARR.DAL.Models;
namespace PARR.API.MappingProfiles.Resolvers namespace PARR.API.MappingProfiles.Resolvers
{ {
public class RobotTaskScheduleExcludeCalendarResolver : IValueResolver<RobotConfiguration, RobotTaskScheduleResponse, string?> //public class RobotTaskScheduleExcludeCalendarResolver : IValueResolver<RobotConfiguration, RobotTaskScheduleResponse, string?>
{ //{
private readonly SettingsFromDb settingsFromDb; // private readonly SettingsFromDb settingsFromDb;
public RobotTaskScheduleExcludeCalendarResolver(SettingsFromDb settingsFromDb) // public RobotTaskScheduleExcludeCalendarResolver(SettingsFromDb settingsFromDb)
{ // {
this.settingsFromDb = settingsFromDb; // this.settingsFromDb = settingsFromDb;
} // }
public string? Resolve(RobotConfiguration source, RobotTaskScheduleResponse destination, string? destMember, ResolutionContext context) // public string? Resolve(RobotConfiguration source, RobotTaskScheduleResponse destination, string? destMember, ResolutionContext context)
{ // {
return settingsFromDb.ScheduleExcludeCalendar; // return settingsFromDb.ScheduleExcludeCalendar;
} // }
} //}
} }

View File

@@ -5,18 +5,18 @@ using PARR.DAL.Models;
namespace PARR.API.MappingProfiles.Resolvers namespace PARR.API.MappingProfiles.Resolvers
{ {
public class RobotTaskScheduleExcludeResolver : IValueResolver<RobotConfiguration, RobotTaskScheduleResponse, string> //public class RobotTaskScheduleExcludeResolver : IValueResolver<RobotConfiguration, RobotTaskScheduleResponse, string>
{ //{
private readonly SettingsFromDb settingsFromDb; // private readonly SettingsFromDb settingsFromDb;
public RobotTaskScheduleExcludeResolver(SettingsFromDb settingsFromDb) // public RobotTaskScheduleExcludeResolver(SettingsFromDb settingsFromDb)
{ // {
this.settingsFromDb = settingsFromDb; // this.settingsFromDb = settingsFromDb;
} // }
public string Resolve(RobotConfiguration source, RobotTaskScheduleResponse destination, string destMember, ResolutionContext context) // public string Resolve(RobotConfiguration source, RobotTaskScheduleResponse destination, string destMember, ResolutionContext context)
{ // {
return settingsFromDb.ScheduleExcludeType; // return settingsFromDb.ScheduleExcludeType;
} // }
} //}
} }

View File

@@ -1,9 +1,9 @@
using FluentValidation; using FluentValidation;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json.Linq;
using PARR.API.Contracts.V1.Requests; using PARR.API.Contracts.V1.Requests;
using PARR.DAL.Contracts; using PARR.DAL.Contracts;
using PARR.DAL.Services.Interfaces.Job; using PARR.DAL.Services.Interfaces.Job;
using PARR.DAL.Services.Interfaces.Schedule;
using PARR.DAL.Services.Interfaces.Unit; using PARR.DAL.Services.Interfaces.Unit;
namespace PARR.API.Validators namespace PARR.API.Validators
@@ -12,7 +12,9 @@ namespace PARR.API.Validators
{ {
public JobGroupValidator( public JobGroupValidator(
IJobGroupTypeService jobGroupTypeService, IJobGroupTypeService jobGroupTypeService,
IUnitFieldService unitFieldService IUnitFieldService unitFieldService,
IScheduleExcludeTypeService scheduleExcludeTypeService,
IScheduleExcludeTypeCalendarService scheduleExcludeTypeCalendarService
) )
{ {
RuleFor(t => t.Name) RuleFor(t => t.Name)
@@ -60,6 +62,36 @@ namespace PARR.API.Validators
return true; return true;
}) })
.WithMessage("Не указано поле для группировки"); .WithMessage("Не указано поле для группировки");
RuleFor(t => t.ScheduleExcludeTypeId)
.NotNull()
.NotEmpty()
.MustAsync(async (entity, value, c) => await scheduleExcludeTypeService.GetAsync(value) != null)
.WithMessage("Некорректное значение");
RuleFor(t => t.ScheduleExcludeTypeCalendarId)
.MustAsync(async (entity, value, c) =>
{
// Если выбрано "Нет исключений", то это поле должно быть пустое, иначе, должно быть валидное значение
var type = await scheduleExcludeTypeService.GetAsync(entity.ScheduleExcludeTypeId);
if (type == null)
return false;
if (type.Code == ScheduleExcludeTypeEnum.None.ToString())
{
// ScheduleExcludeTypeCalendarId должно быть null
return value == null;
}
// Тип любой кроме "Нет исключений", значение обязательно
if (!value.HasValue)
return false;
return await scheduleExcludeTypeCalendarService.GetAsync(value.Value) != null;
})
.WithMessage("Некорректное значение");
} }
} }
} }

View File

@@ -5,6 +5,7 @@ using PARR.DAL.Contracts;
using PARR.DAL.Extensions; using PARR.DAL.Extensions;
using PARR.DAL.Models; using PARR.DAL.Models;
using PARR.DAL.Models.Job; using PARR.DAL.Models.Job;
using PARR.DAL.Models.Schedule;
using PARR.DAL.Models.Unit; using PARR.DAL.Models.Unit;
namespace PARR.DAL.Context namespace PARR.DAL.Context
@@ -42,12 +43,19 @@ namespace PARR.DAL.Context
public DbSet<RobotConfiguration> RobotConfigurations { get; set; } public DbSet<RobotConfiguration> RobotConfigurations { get; set; }
public DbSet<RobotHistory> RobotHistories { get; set; } public DbSet<RobotHistory> RobotHistories { get; set; }
#region Schedule
public DbSet<EsppSchType> EsppSchTypes { get; set; } public DbSet<EsppSchType> EsppSchTypes { get; set; }
public DbSet<EsppSchTypeValue> EsppSchTypeValues { get; set; } public DbSet<EsppSchTypeValue> EsppSchTypeValues { get; set; }
public DbSet<EsppSchTypeConfig> EsppSchTypeConfigs { get; set; } public DbSet<EsppSchTypeConfig> EsppSchTypeConfigs { get; set; }
public DbSet<EsppSchTypeSchedule> EsppSchTypeSchedules { get; set; } public DbSet<EsppSchTypeSchedule> EsppSchTypeSchedules { get; set; }
public DbSet<EsppSchValue> EsppSchValues { get; set; } public DbSet<EsppSchValue> EsppSchValues { get; set; }
public DbSet<ScheduleExcludeTypeCalendar> ScheduleExcludeTypeCalendars { get; set; }
public DbSet<ScheduleExcludeType> ScheduleExcludeTypes { get; set; }
#endregion
public DbSet<AgentHistory> AgentHistories { get; set; } public DbSet<AgentHistory> AgentHistories { get; set; }
public DbSet<AgentHistoryLevel> AgentHistoryLevels { get; set; } public DbSet<AgentHistoryLevel> AgentHistoryLevels { get; set; }
@@ -179,8 +187,8 @@ namespace PARR.DAL.Context
new { Name = nameof(SettingsFromDb.RobotAttemptsNumber), Description = "Количество попыток выполнения задания роботом", Value = "3" }, new { Name = nameof(SettingsFromDb.RobotAttemptsNumber), Description = "Количество попыток выполнения задания роботом", Value = "3" },
new { Name = nameof(SettingsFromDb.RobotWaitTime), Description = "Время ожидания выполнения роботом задания", Value = "00:15:00" }, new { Name = nameof(SettingsFromDb.RobotWaitTime), Description = "Время ожидания выполнения роботом задания", Value = "00:15:00" },
new { Name = nameof(SettingsFromDb.ScheduleTimezone), Description = "Расписание регламентной работы - В каком часовом поясе", Value = "MSK" }, new { Name = nameof(SettingsFromDb.ScheduleTimezone), Description = "Расписание регламентной работы - В каком часовом поясе", Value = "MSK" },
new { Name = nameof(SettingsFromDb.ScheduleExcludeType), Description = "Расписание регламентной работы - Тип исключения", Value = "Выполнить ТОЛЬКО В указанном календаре" }, //new { Name = nameof(SettingsFromDb.ScheduleExcludeType), Description = "Расписание регламентной работы - Тип исключения", Value = "Выполнить ТОЛЬКО В указанном календаре" },
new { Name = nameof(SettingsFromDb.ScheduleExcludeCalendar), Description = "Расписание регламентной работы - Календарь", Value = "8x5 (8.00-17.00)" }, //new { Name = nameof(SettingsFromDb.ScheduleExcludeCalendar), Description = "Расписание регламентной работы - Календарь", Value = "8x5 (8.00-17.00)" },
new { Name = nameof(SettingsFromDb.ScheduleRepeatRange), Description = "Расписание регламентной работы - Диапазн повторов", Value = "Отсутствует дата завершения" }, new { Name = nameof(SettingsFromDb.ScheduleRepeatRange), Description = "Расписание регламентной работы - Диапазн повторов", Value = "Отсутствует дата завершения" },
new { Name = nameof(SettingsFromDb.OrderSearchDeltaDate), Description = "Промежуток времени для поиска нарядов в ЕСПП", Value = new TimeSpan(1, 30, 0).ToString() }, new { Name = nameof(SettingsFromDb.OrderSearchDeltaDate), Description = "Промежуток времени для поиска нарядов в ЕСПП", Value = new TimeSpan(1, 30, 0).ToString() },
new { Name = nameof(SettingsFromDb.EsppRobotAccountTimeZoneHour), Description = "Таймзона УЗ роботов в ЕСПП, в часах (может быть положительная и отрицательная)", Value = "3" }, new { Name = nameof(SettingsFromDb.EsppRobotAccountTimeZoneHour), Description = "Таймзона УЗ роботов в ЕСПП, в часах (может быть положительная и отрицательная)", Value = "3" },
@@ -195,7 +203,7 @@ namespace PARR.DAL.Context
new TemplateNameConstantPart { Name = "П-2", Value = "ПАРР" } new TemplateNameConstantPart { Name = "П-2", Value = "ПАРР" }
}.ToJson() }.ToJson()
}, },
new { Name = nameof(SettingsFromDb.EsppUnitTag), Description = "Префикс тега в поле ЭК \"Дополнительная информация\"", Value = "ПАРР-" } new { Name = nameof(SettingsFromDb.EsppUnitTag), Description = "Префикс тега в поле ЭК \"Дополнительная информация\"", Value = "ПАРР_" }
); );
}); });
#endregion #endregion
@@ -514,6 +522,31 @@ namespace PARR.DAL.Context
#endregion #endregion
#region ScheduleExcludeType
modelBuilder.Entity<ScheduleExcludeType>(f =>
{
f.HasData(
new() { Id = new Guid("0595B8E0-F322-4661-B5E3-064AF8FBE7CD"), DateCreated = dateCreated, Title = "Нет исключений", EsppName = "Нет исключений", EsppValue = "NONE", Code = ScheduleExcludeTypeEnum.None.ToString() },
new() { Id = new Guid("2B7A4356-9AAF-4E00-B444-42F0B5010E25"), DateCreated = dateCreated, Title = "Выполнить ТОЛЬКО В указанном календаре", EsppName = "Выполнить ТОЛЬКО В указанном календаре", EsppValue = "ONLY", Code = ScheduleExcludeTypeEnum.Only.ToString() },
new() { Id = new Guid("38CD9E64-27C1-4672-A805-2211952A48BD"), DateCreated = dateCreated, Title = "Выполнить везде, КРОМЕ указанного календаря", EsppName = "Выполнить везде, КРОМЕ указанного календаря", EsppValue = "EXCEPT", Code = ScheduleExcludeTypeEnum.Except.ToString() }
);
});
#endregion
#region ScheduleExcludeTypeCalendar
modelBuilder.Entity<ScheduleExcludeTypeCalendar>(f =>
{
f.HasData(
new() { Id = new Guid("A26EDB88-0267-4FBF-B7EC-D172B0A86C9C"), DateCreated = dateCreated, Title = "24x5", EsppName = "24x5", EsppValue = "24x5", Code = "24x5" },
new() { Id = new Guid("6834F1D5-AC51-43D5-974E-4C759D7BBF9F"), DateCreated = dateCreated, Title = "24x7", EsppName = "24x7", EsppValue = "24x7", Code = "24x7" }
);
});
#endregion
} }
//protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) //protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

View File

@@ -13,5 +13,10 @@
/// </summary> /// </summary>
public const string Job = "job"; public const string Job = "job";
/// <summary>
/// Расписание регламентных работ
/// </summary>
public const string Schedule = "schedule";
} }
} }

View File

@@ -0,0 +1,23 @@
namespace PARR.DAL.Contracts
{
/// <summary>
/// Расписание регламентной работы - Тип исключения
/// </summary>
public enum ScheduleExcludeTypeEnum
{
/// <summary>
/// Нет исключений
/// </summary>
None = 0,
/// <summary>
/// Выполнить ТОЛЬКО В указанном календаре
/// </summary>
Only = 1,
/// <summary>
/// Выполнить везде, КРОМЕ указанного календаря
/// </summary>
Except = 2
}
}

View File

@@ -82,15 +82,15 @@ namespace PARR.DAL.Contracts
/// </summary> /// </summary>
public string ScheduleTimezone { get; set; } = string.Empty; public string ScheduleTimezone { get; set; } = string.Empty;
/// <summary> ///// <summary>
/// Расписание регламентной работы - Тип исключения ///// Расписание регламентной работы - Тип исключения
/// </summary> ///// </summary>
public string ScheduleExcludeType { get; set; } = string.Empty; //public string ScheduleExcludeType { get; set; } = string.Empty;
/// <summary> ///// <summary>
/// Расписание регламентной работы - Календарь ///// Расписание регламентной работы - Календарь
/// </summary> ///// </summary>
public string ScheduleExcludeCalendar { get; set; } = string.Empty; //public string ScheduleExcludeCalendar { get; set; } = string.Empty;
/// <summary> /// <summary>
/// Расписание регламентной работы - Диапазн повторов /// Расписание регламентной работы - Диапазн повторов

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,211 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblScheduleExludes : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "Settings",
keyColumn: "Name",
keyValue: "ScheduleExcludeCalendar");
migrationBuilder.DeleteData(
table: "Settings",
keyColumn: "Name",
keyValue: "ScheduleExcludeType");
migrationBuilder.EnsureSchema(
name: "schedule");
migrationBuilder.AddColumn<Guid>(
name: "ScheduleExcludeTypeCalendarId",
schema: "job",
table: "Groups",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "ScheduleExcludeTypeId",
schema: "job",
table: "Groups",
type: "uuid",
nullable: false,
defaultValue: new Guid("0595B8E0-F322-4661-B5E3-064AF8FBE7CD"));
migrationBuilder.AddColumn<bool>(
name: "IsInverse",
schema: "job",
table: "FieldFilters",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.CreateTable(
name: "ExcludeTypeCalendars",
schema: "schedule",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Title = table.Column<string>(type: "text", nullable: false),
EsppName = table.Column<string>(type: "text", nullable: false),
EsppValue = table.Column<string>(type: "text", nullable: false),
Code = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ExcludeTypeCalendars", x => x.Id);
},
comment: "Расписание регламентной работы, исключение - Календарь");
migrationBuilder.CreateTable(
name: "ExcludeTypes",
schema: "schedule",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Title = table.Column<string>(type: "text", nullable: false),
EsppName = table.Column<string>(type: "text", nullable: false),
EsppValue = table.Column<string>(type: "text", nullable: false),
Code = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ExcludeTypes", x => x.Id);
},
comment: "Расписание регламентной работы - Тип исключения");
migrationBuilder.InsertData(
schema: "schedule",
table: "ExcludeTypeCalendars",
columns: new[] { "Id", "Code", "DateCreated", "EsppName", "EsppValue", "Title" },
values: new object[,]
{
{ new Guid("6834f1d5-ac51-43d5-974e-4c759d7bbf9f"), "24x7", new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "24x7", "24x7", "24x7" },
{ new Guid("a26edb88-0267-4fbf-b7ec-d172b0a86c9c"), "24x5", new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "24x5", "24x5", "24x5" }
});
migrationBuilder.InsertData(
schema: "schedule",
table: "ExcludeTypes",
columns: new[] { "Id", "Code", "DateCreated", "EsppName", "EsppValue", "Title" },
values: new object[,]
{
{ new Guid("0595b8e0-f322-4661-b5e3-064af8fbe7cd"), "None", new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Нет исключений", "NONE", "Нет исключений" },
{ new Guid("2b7a4356-9aaf-4e00-b444-42f0b5010e25"), "Only", new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Выполнить ТОЛЬКО В указанном календаре", "ONLY", "Выполнить ТОЛЬКО В указанном календаре" },
{ new Guid("38cd9e64-27c1-4672-a805-2211952a48bd"), "Except", new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Выполнить везде, КРОМЕ указанного календаря", "EXCEPT", "Выполнить везде, КРОМЕ указанного календаря" }
});
migrationBuilder.UpdateData(
table: "Settings",
keyColumn: "Name",
keyValue: "EsppUnitTag",
column: "Value",
value: АРР_");
migrationBuilder.CreateIndex(
name: "IX_Groups_ScheduleExcludeTypeCalendarId",
schema: "job",
table: "Groups",
column: "ScheduleExcludeTypeCalendarId");
migrationBuilder.CreateIndex(
name: "IX_Groups_ScheduleExcludeTypeId",
schema: "job",
table: "Groups",
column: "ScheduleExcludeTypeId");
migrationBuilder.AddForeignKey(
name: "FK_Groups_ExcludeTypeCalendars_ScheduleExcludeTypeCalendarId",
schema: "job",
table: "Groups",
column: "ScheduleExcludeTypeCalendarId",
principalSchema: "schedule",
principalTable: "ExcludeTypeCalendars",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Groups_ExcludeTypes_ScheduleExcludeTypeId",
schema: "job",
table: "Groups",
column: "ScheduleExcludeTypeId",
principalSchema: "schedule",
principalTable: "ExcludeTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Groups_ExcludeTypeCalendars_ScheduleExcludeTypeCalendarId",
schema: "job",
table: "Groups");
migrationBuilder.DropForeignKey(
name: "FK_Groups_ExcludeTypes_ScheduleExcludeTypeId",
schema: "job",
table: "Groups");
migrationBuilder.DropTable(
name: "ExcludeTypeCalendars",
schema: "schedule");
migrationBuilder.DropTable(
name: "ExcludeTypes",
schema: "schedule");
migrationBuilder.DropIndex(
name: "IX_Groups_ScheduleExcludeTypeCalendarId",
schema: "job",
table: "Groups");
migrationBuilder.DropIndex(
name: "IX_Groups_ScheduleExcludeTypeId",
schema: "job",
table: "Groups");
migrationBuilder.DropColumn(
name: "ScheduleExcludeTypeCalendarId",
schema: "job",
table: "Groups");
migrationBuilder.DropColumn(
name: "ScheduleExcludeTypeId",
schema: "job",
table: "Groups");
migrationBuilder.DropColumn(
name: "IsInverse",
schema: "job",
table: "FieldFilters");
migrationBuilder.UpdateData(
table: "Settings",
keyColumn: "Name",
keyValue: "EsppUnitTag",
column: "Value",
value: "ПАРР-");
migrationBuilder.InsertData(
table: "Settings",
columns: new[] { "Name", "Description", "Value" },
values: new object[,]
{
{ "ScheduleExcludeCalendar", "Расписание регламентной работы - Календарь", "8x5 (8.00-17.00)" },
{ "ScheduleExcludeType", "Расписание регламентной работы - Тип исключения", "Выполнить ТОЛЬКО В указанном календаре" }
});
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,68 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblsEsppSchchangeScheme : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameTable(
name: "EsppSchValues",
newName: "EsppSchValues",
newSchema: "schedule");
migrationBuilder.RenameTable(
name: "EsppSchTypeValues",
newName: "EsppSchTypeValues",
newSchema: "schedule");
migrationBuilder.RenameTable(
name: "EsppSchTypeSchedules",
newName: "EsppSchTypeSchedules",
newSchema: "schedule");
migrationBuilder.RenameTable(
name: "EsppSchTypes",
newName: "EsppSchTypes",
newSchema: "schedule");
migrationBuilder.RenameTable(
name: "EsppSchTypeConfigs",
newName: "EsppSchTypeConfigs",
newSchema: "schedule");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameTable(
name: "EsppSchValues",
schema: "schedule",
newName: "EsppSchValues");
migrationBuilder.RenameTable(
name: "EsppSchTypeValues",
schema: "schedule",
newName: "EsppSchTypeValues");
migrationBuilder.RenameTable(
name: "EsppSchTypeSchedules",
schema: "schedule",
newName: "EsppSchTypeSchedules");
migrationBuilder.RenameTable(
name: "EsppSchTypes",
schema: "schedule",
newName: "EsppSchTypes");
migrationBuilder.RenameTable(
name: "EsppSchTypeConfigs",
schema: "schedule",
newName: "EsppSchTypeConfigs");
}
}
}

View File

@@ -446,7 +446,7 @@ namespace PARR.DAL.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("EsppSchTypes"); b.ToTable("EsppSchTypes", "schedule");
b.HasData( b.HasData(
new new
@@ -515,7 +515,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("TypeScheduleId", "TypeId") b.HasIndex("TypeScheduleId", "TypeId")
.IsUnique(); .IsUnique();
b.ToTable("EsppSchTypeConfigs"); b.ToTable("EsppSchTypeConfigs", "schedule");
b.HasData( b.HasData(
new new
@@ -618,7 +618,7 @@ namespace PARR.DAL.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("EsppSchTypeSchedules"); b.ToTable("EsppSchTypeSchedules", "schedule");
b.HasData( b.HasData(
new new
@@ -691,7 +691,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("TypeId"); b.HasIndex("TypeId");
b.ToTable("EsppSchTypeValues"); b.ToTable("EsppSchTypeValues", "schedule");
b.HasData( b.HasData(
new new
@@ -1492,7 +1492,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("TypeValueId"); b.HasIndex("TypeValueId");
b.ToTable("EsppSchValues"); b.ToTable("EsppSchValues", "schedule");
}); });
modelBuilder.Entity("PARR.DAL.Models.Host", b => modelBuilder.Entity("PARR.DAL.Models.Host", b =>
@@ -1634,6 +1634,9 @@ namespace PARR.DAL.Migrations
b.Property<Guid>("FieldId") b.Property<Guid>("FieldId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<bool>("IsInverse")
.HasColumnType("boolean");
b.Property<Guid>("UnitFilterId") b.Property<Guid>("UnitFilterId")
.HasColumnType("uuid"); .HasColumnType("uuid");
@@ -1697,6 +1700,12 @@ namespace PARR.DAL.Migrations
b.Property<DateTimeOffset>("ReferenceDate") b.Property<DateTimeOffset>("ReferenceDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp with time zone");
b.Property<Guid?>("ScheduleExcludeTypeCalendarId")
.HasColumnType("uuid");
b.Property<Guid>("ScheduleExcludeTypeId")
.HasColumnType("uuid");
b.Property<string>("ShortDescription") b.Property<string>("ShortDescription")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
@@ -1715,6 +1724,10 @@ namespace PARR.DAL.Migrations
b.HasIndex("GroupingUnitFieldId"); b.HasIndex("GroupingUnitFieldId");
b.HasIndex("ScheduleExcludeTypeCalendarId");
b.HasIndex("ScheduleExcludeTypeId");
b.ToTable("Groups", "job", t => b.ToTable("Groups", "job", t =>
{ {
t.HasComment("Таблица описания групп работ, для реализации зонтиков"); t.HasComment("Таблица описания групп работ, для реализации зонтиков");
@@ -2436,6 +2449,121 @@ namespace PARR.DAL.Migrations
}); });
}); });
modelBuilder.Entity("PARR.DAL.Models.Schedule.ScheduleExcludeType", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Code")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<string>("EsppName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EsppValue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ExcludeTypes", "schedule", t =>
{
t.HasComment("Расписание регламентной работы - Тип исключения");
});
b.HasData(
new
{
Id = new Guid("0595b8e0-f322-4661-b5e3-064af8fbe7cd"),
Code = "None",
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
EsppName = "Нет исключений",
EsppValue = "NONE",
Title = "Нет исключений"
},
new
{
Id = new Guid("2b7a4356-9aaf-4e00-b444-42f0b5010e25"),
Code = "Only",
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
EsppName = "Выполнить ТОЛЬКО В указанном календаре",
EsppValue = "ONLY",
Title = "Выполнить ТОЛЬКО В указанном календаре"
},
new
{
Id = new Guid("38cd9e64-27c1-4672-a805-2211952a48bd"),
Code = "Except",
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
EsppName = "Выполнить везде, КРОМЕ указанного календаря",
EsppValue = "EXCEPT",
Title = "Выполнить везде, КРОМЕ указанного календаря"
});
});
modelBuilder.Entity("PARR.DAL.Models.Schedule.ScheduleExcludeTypeCalendar", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Code")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<string>("EsppName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EsppValue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ExcludeTypeCalendars", "schedule", t =>
{
t.HasComment("Расписание регламентной работы, исключение - Календарь");
});
b.HasData(
new
{
Id = new Guid("a26edb88-0267-4fbf-b7ec-d172b0a86c9c"),
Code = "24x5",
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
EsppName = "24x5",
EsppValue = "24x5",
Title = "24x5"
},
new
{
Id = new Guid("6834f1d5-ac51-43d5-974e-4c759d7bbf9f"),
Code = "24x7",
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
EsppName = "24x7",
EsppValue = "24x7",
Title = "24x7"
});
});
modelBuilder.Entity("PARR.DAL.Models.Setting", b => modelBuilder.Entity("PARR.DAL.Models.Setting", b =>
{ {
b.Property<string>("Name") b.Property<string>("Name")
@@ -2497,18 +2625,6 @@ namespace PARR.DAL.Migrations
Value = "MSK" Value = "MSK"
}, },
new new
{
Name = "ScheduleExcludeType",
Description = "Расписание регламентной работы - Тип исключения",
Value = "Выполнить ТОЛЬКО В указанном календаре"
},
new
{
Name = "ScheduleExcludeCalendar",
Description = "Расписание регламентной работы - Календарь",
Value = "8x5 (8.00-17.00)"
},
new
{ {
Name = "ScheduleRepeatRange", Name = "ScheduleRepeatRange",
Description = "Расписание регламентной работы - Диапазн повторов", Description = "Расписание регламентной работы - Диапазн повторов",
@@ -2542,7 +2658,7 @@ namespace PARR.DAL.Migrations
{ {
Name = "EsppUnitTag", Name = "EsppUnitTag",
Description = "Префикс тега в поле ЭК \"Дополнительная информация\"", Description = "Префикс тега в поле ЭК \"Дополнительная информация\"",
Value = "ПАРР-" Value = "ПАРР_"
}); });
}); });
@@ -3371,9 +3487,23 @@ namespace PARR.DAL.Migrations
.HasForeignKey("GroupingUnitFieldId") .HasForeignKey("GroupingUnitFieldId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("PARR.DAL.Models.Schedule.ScheduleExcludeTypeCalendar", "ScheduleExcludeTypeCalendar")
.WithMany("JobGroups")
.HasForeignKey("ScheduleExcludeTypeCalendarId");
b.HasOne("PARR.DAL.Models.Schedule.ScheduleExcludeType", "ScheduleExcludeType")
.WithMany("JobGroups")
.HasForeignKey("ScheduleExcludeTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("GroupType"); b.Navigation("GroupType");
b.Navigation("GroupingUnitField"); b.Navigation("GroupingUnitField");
b.Navigation("ScheduleExcludeType");
b.Navigation("ScheduleExcludeTypeCalendar");
}); });
modelBuilder.Entity("PARR.DAL.Models.Job.JobRelationshipFilter", b => modelBuilder.Entity("PARR.DAL.Models.Job.JobRelationshipFilter", b =>
@@ -3847,6 +3977,16 @@ namespace PARR.DAL.Migrations
b.Navigation("Users"); b.Navigation("Users");
}); });
modelBuilder.Entity("PARR.DAL.Models.Schedule.ScheduleExcludeType", b =>
{
b.Navigation("JobGroups");
});
modelBuilder.Entity("PARR.DAL.Models.Schedule.ScheduleExcludeTypeCalendar", b =>
{
b.Navigation("JobGroups");
});
modelBuilder.Entity("PARR.DAL.Models.Subprocess", b => modelBuilder.Entity("PARR.DAL.Models.Subprocess", b =>
{ {
b.Navigation("Tnks"); b.Navigation("Tnks");

View File

@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations; using PARR.DAL.Context;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models namespace PARR.DAL.Models
@@ -6,7 +7,7 @@ namespace PARR.DAL.Models
/// <summary> /// <summary>
/// Расписание ЕСПП: типы повторений /// Расписание ЕСПП: типы повторений
/// </summary> /// </summary>
[Table("EsppSchTypes")] [Table("EsppSchTypes", Schema = DataContextSettings.Schedule)]
public class EsppSchType public class EsppSchType
{ {
[Key] [Key]

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Base; using PARR.DAL.Models.Base;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
@@ -8,7 +9,7 @@ namespace PARR.DAL.Models
/// <summary> /// <summary>
/// Расписание ЕСПП: Конфигурация типов /// Расписание ЕСПП: Конфигурация типов
/// </summary> /// </summary>
[Table("EsppSchTypeConfigs")] [Table("EsppSchTypeConfigs", Schema = DataContextSettings.Schedule)]
[Index(nameof(TypeScheduleId), nameof(TypeId), IsUnique = true)] [Index(nameof(TypeScheduleId), nameof(TypeId), IsUnique = true)]
public class EsppSchTypeConfig : IBase public class EsppSchTypeConfig : IBase
{ {

View File

@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations; using PARR.DAL.Context;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models namespace PARR.DAL.Models
@@ -6,7 +7,7 @@ namespace PARR.DAL.Models
/// <summary> /// <summary>
/// Расписание ЕСПП: Повторять задачу /// Расписание ЕСПП: Повторять задачу
/// </summary> /// </summary>
[Table("EsppSchTypeSchedules")] [Table("EsppSchTypeSchedules", Schema = DataContextSettings.Schedule)]
public class EsppSchTypeSchedule public class EsppSchTypeSchedule
{ {
[Key] [Key]

View File

@@ -1,4 +1,5 @@
using PARR.DAL.Models.Base; using PARR.DAL.Context;
using PARR.DAL.Models.Base;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
@@ -7,7 +8,7 @@ namespace PARR.DAL.Models
/// <summary> /// <summary>
/// Расписание ЕСПП: значения типов повторений /// Расписание ЕСПП: значения типов повторений
/// </summary> /// </summary>
[Table("EsppSchTypeValues")] [Table("EsppSchTypeValues", Schema = DataContextSettings.Schedule)]
public class EsppSchTypeValue : IBase public class EsppSchTypeValue : IBase
{ {
[Key] [Key]

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Job; using PARR.DAL.Models.Job;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
@@ -7,7 +8,7 @@ namespace PARR.DAL.Models
/// <summary> /// <summary>
/// Расписание ЕСПП: значения заданий для ApplicationsInWorks /// Расписание ЕСПП: значения заданий для ApplicationsInWorks
/// </summary> /// </summary>
[Table("EsppSchValues")] [Table("EsppSchValues", Schema = DataContextSettings.Schedule)]
//[Index(nameof(ApplicationsInWorkId), nameof(TypeValueId), nameof(TypeConfigId), IsUnique = true)] //[Index(nameof(ApplicationsInWorkId), nameof(TypeValueId), nameof(TypeConfigId), IsUnique = true)]
//[PrimaryKey(nameof(ApplicationsInWorkId), nameof(TypeValueId), nameof(TypeConfigId))] //[PrimaryKey(nameof(ApplicationsInWorkId), nameof(TypeValueId), nameof(TypeConfigId))]
[PrimaryKey(nameof(JobGroupId), nameof(TypeValueId), nameof(TypeConfigId))] [PrimaryKey(nameof(JobGroupId), nameof(TypeValueId), nameof(TypeConfigId))]
@@ -21,6 +22,7 @@ namespace PARR.DAL.Models
public Guid JobGroupId { get; set; } public Guid JobGroupId { get; set; }
//[ForeignKey(nameof(ApplicationsInWorkId))] //[ForeignKey(nameof(ApplicationsInWorkId))]
//public ApplicationsInWork? ApplicationsInWork { get; set; } //public ApplicationsInWork? ApplicationsInWork { get; set; }

View File

@@ -24,6 +24,11 @@ namespace PARR.DAL.Models.Job
public required string ValueMask { get; set; } public required string ValueMask { get; set; }
/// <summary>
/// Отсутствует
/// </summary>
public bool IsInverse { get; set; } = false;
[ForeignKey(nameof(FieldId))] [ForeignKey(nameof(FieldId))]
public UnitField? UnitField { get; set; } public UnitField? UnitField { get; set; }

View File

@@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context; using PARR.DAL.Context;
using PARR.DAL.Models.Base; using PARR.DAL.Models.Base;
using PARR.DAL.Models.Schedule;
using PARR.DAL.Models.Unit; using PARR.DAL.Models.Unit;
using PARR.DAL.Settings; using PARR.DAL.Settings;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
@@ -128,6 +129,19 @@ namespace PARR.DAL.Models.Job
/// </summary> /// </summary>
public Guid? GroupingUnitFieldId { get; set; } public Guid? GroupingUnitFieldId { get; set; }
/// <summary>
/// Расписание регламентной работы - Тип исключения
/// </summary>
public Guid ScheduleExcludeTypeId { get; set; }
/// <summary>
/// Расписание регламентной работы, исключение - Календарь
/// </summary>
public Guid? ScheduleExcludeTypeCalendarId { get; set; }
/// <summary> /// <summary>
/// Поле по которому группируется (!!!отключено каскадное удаление!!!) /// Поле по которому группируется (!!!отключено каскадное удаление!!!)
/// </summary> /// </summary>
@@ -140,5 +154,11 @@ namespace PARR.DAL.Models.Job
public ICollection<Job> Jobs { get; set; } = new HashSet<Job>(); public ICollection<Job> Jobs { get; set; } = new HashSet<Job>();
public ICollection<EsppSchValue> EsppSchValues { get; set; } = new HashSet<EsppSchValue>(); public ICollection<EsppSchValue> EsppSchValues { get; set; } = new HashSet<EsppSchValue>();
[ForeignKey(nameof(ScheduleExcludeTypeId))]
public ScheduleExcludeType? ScheduleExcludeType { get; set; }
[ForeignKey(nameof(ScheduleExcludeTypeCalendarId))]
public ScheduleExcludeTypeCalendar? ScheduleExcludeTypeCalendar { get; set; }
} }
} }

View File

@@ -16,6 +16,7 @@ namespace PARR.DAL.Models.Job
public DateTimeOffset DateCreated { get; set; } public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; } public DateTimeOffset? DateModified { get; set; }
public required string UnitFilter { get; set; } public required string UnitFilter { get; set; }
public Guid JobId { get; set; } public Guid JobId { get; set; }

View File

@@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Base;
using PARR.DAL.Models.Job;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Schedule
{
/// <summary>
/// Расписание регламентной работы - Тип исключения
/// </summary>
[Table("ExcludeTypes", Schema = DataContextSettings.Schedule)]
[Comment("Расписание регламентной работы - Тип исключения")]
public class ScheduleExcludeType : IBase
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
/// <summary>
/// Название в ПАРР
/// </summary>
public required string Title { get; set; }
public required string EsppName { get; set; }
public required string EsppValue { get; set; }
public required string Code { get; set; }
public ICollection<JobGroup> JobGroups { get; set; } = new HashSet<JobGroup>();
}
}

View File

@@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Base;
using PARR.DAL.Models.Job;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Schedule
{
/// <summary>
/// Расписание регламентной работы, исключение - Календарь
/// </summary>
[Table("ExcludeTypeCalendars", Schema = DataContextSettings.Schedule)]
[Comment("Расписание регламентной работы, исключение - Календарь")]
public class ScheduleExcludeTypeCalendar : IBase
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
/// <summary>
/// Название в ПАРР
/// </summary>
public required string Title { get; set; }
public required string EsppName { get; set; }
public required string EsppValue { get; set; }
public required string Code { get; set; }
public ICollection<JobGroup> JobGroups { get; set; } = new HashSet<JobGroup>();
}
}

View File

@@ -12,9 +12,11 @@ using PARR.DAL.InfluxDbServices;
using PARR.DAL.Services.Implementation; using PARR.DAL.Services.Implementation;
using PARR.DAL.Services.Implementations; using PARR.DAL.Services.Implementations;
using PARR.DAL.Services.Implementations.Job; using PARR.DAL.Services.Implementations.Job;
using PARR.DAL.Services.Implementations.Schedule;
using PARR.DAL.Services.Implementations.Unit; using PARR.DAL.Services.Implementations.Unit;
using PARR.DAL.Services.Interfaces; using PARR.DAL.Services.Interfaces;
using PARR.DAL.Services.Interfaces.Job; using PARR.DAL.Services.Interfaces.Job;
using PARR.DAL.Services.Interfaces.Schedule;
using PARR.DAL.Services.Interfaces.Unit; using PARR.DAL.Services.Interfaces.Unit;
using PARR.DAL.Settings; using PARR.DAL.Settings;
using PARR.DAL.TransformServices; using PARR.DAL.TransformServices;
@@ -99,6 +101,13 @@ namespace PARR.DAL
services.AddTransient<IParrComponentService, ParrComponentService>(); services.AddTransient<IParrComponentService, ParrComponentService>();
services.AddTransient<ITemplateStatusTypeService, TemplateStatusTypeService>(); services.AddTransient<ITemplateStatusTypeService, TemplateStatusTypeService>();
#region Schedule
services.AddTransient<IScheduleExcludeTypeService, ScheduleExcludeTypeService>();
services.AddTransient<IScheduleExcludeTypeCalendarService, ScheduleExcludeTypeCalendarService>();
#endregion
#region Unit #region Unit
services.AddTransient<IUnitService, UnitService>(); services.AddTransient<IUnitService, UnitService>();

View File

@@ -60,7 +60,8 @@ namespace PARR.DAL.Services.Implementations
Order = t.Order, Order = t.Order,
Type = t.Type, Type = t.Type,
Value = t.Value Value = t.Value
}).ToList() }
).ToList()
}; };
return dto; return dto;

View File

@@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.Schedule;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.Schedule;
namespace PARR.DAL.Services.Implementations.Schedule
{
internal class ScheduleExcludeTypeCalendarService : BaseService<ScheduleExcludeTypeCalendar>, IScheduleExcludeTypeCalendarService
{
private readonly DataContext dataContext;
protected override DbSet<ScheduleExcludeTypeCalendar> EntitySet => dataContext.ScheduleExcludeTypeCalendars;
protected override DataContext EntitiContext => dataContext;
public ScheduleExcludeTypeCalendarService(DataContext dataContext, ILogger<ScheduleExcludeTypeCalendarService> logger) : base(logger)
{
this.dataContext = dataContext;
}
}
}

View File

@@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.Schedule;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.Schedule;
namespace PARR.DAL.Services.Implementations.Schedule
{
internal class ScheduleExcludeTypeService : BaseService<ScheduleExcludeType>, IScheduleExcludeTypeService
{
private readonly DataContext dataContext;
protected override DbSet<ScheduleExcludeType> EntitySet => dataContext.ScheduleExcludeTypes;
protected override DataContext EntitiContext => dataContext;
public ScheduleExcludeTypeService(DataContext dataContext, ILogger<ScheduleExcludeTypeService> logger) : base(logger)
{
this.dataContext = dataContext;
}
}
}

View File

@@ -0,0 +1,9 @@
using PARR.DAL.Models.Schedule;
using PARR.DAL.Services.Interfaces.Base;
namespace PARR.DAL.Services.Interfaces.Schedule
{
public interface IScheduleExcludeTypeCalendarService: IBaseService<ScheduleExcludeTypeCalendar>
{
}
}

View File

@@ -0,0 +1,9 @@
using PARR.DAL.Models.Schedule;
using PARR.DAL.Services.Interfaces.Base;
namespace PARR.DAL.Services.Interfaces.Schedule
{
public interface IScheduleExcludeTypeService : IBaseService<ScheduleExcludeType>
{
}
}

View File

@@ -104,8 +104,8 @@ namespace PARR.EsppScheduleSync
//WorkGroup = template.Host!.WorkGroup!.Name,//TODO Migration to job //WorkGroup = template.Host!.WorkGroup!.Name,//TODO Migration to job
//Мы решили, что для всех расписаний "Нет исключений", если что-то поменяется, тут нужно переделать //Мы решили, что для всех расписаний "Нет исключений", если что-то поменяется, тут нужно переделать
//TypeV60calendar = settingsFromDb.ScheduleExcludeType == "Нет исключений" ? "NONE" : "", //TypeV60calendar = settingsFromDb.ScheduleExcludeType == "Нет исключений" ? "NONE" : "",
TypeV60calendar = GetTypeV60calendar(), TypeV60calendar = GetTypeV60calendar(template),
V60calendar = settingsFromDb.ScheduleExcludeCalendar, V60calendar = GetV60calendar(template),
//Scheduled = EsppScheduleHelpers.GetNextRun(template.NextRun), //Scheduled = EsppScheduleHelpers.GetNextRun(template.NextRun),
//Scheduled = EsppScheduleHelpers.GetNextRun(nextRunModifierService.GetNextRunByAccountRobotTimeZone(template.NextRun)), //Scheduled = EsppScheduleHelpers.GetNextRun(nextRunModifierService.GetNextRunByAccountRobotTimeZone(template.NextRun)),
//BasisTime = EsppScheduleHelpers.GetGenerationTime(nextRunModifierService.GetNextRunByAccountRobotTimeZone(template.NextRun)), //BasisTime = EsppScheduleHelpers.GetGenerationTime(nextRunModifierService.GetNextRunByAccountRobotTimeZone(template.NextRun)),
@@ -122,22 +122,61 @@ namespace PARR.EsppScheduleSync
} }
/// <summary>
/// Получить исключение - Календарь
/// </summary>
/// <param name="template"></param>
/// <returns></returns>
private string GetV60calendar(Template template)
{
// мы знаем, что у нас точно в шаблоне есть инклуды до ScheduleExcludeType и ScheduleExcludeTypeCalendar
if (template.Job?.Group?.ScheduleExcludeTypeCalendar == null)
{
logger.LogDebug("Для шаблона шаблона {templte}, {templateId} нет исключений календаря", template.Name, template.Id);
//TODO:!!!!!!!!!!! Вот тут null или string.Empty??? Спросить у Андрея что он нам вернет!
return string.Empty;
}
logger.LogDebug("Для шаблона шаблона {templte}, {templateId} установлено исключений календаря \"{name}\", EsppValue: {esppValue}", template.Name, template.Id, template.Job.Group.ScheduleExcludeTypeCalendar.Title, template.Job.Group.ScheduleExcludeTypeCalendar.EsppValue);
return template.Job.Group.ScheduleExcludeTypeCalendar.EsppValue;
}
/// <summary> /// <summary>
/// Получить тип календаря /// Получить тип календаря
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
private string GetTypeV60calendar() private string GetTypeV60calendar(Template template)
{ {
// Это костыль, нужно придумать как это хранить в БД. // мы знаем, что у нас точно в шаблоне есть инклуды до ScheduleExcludeType и ScheduleExcludeTypeCalendar
switch (settingsFromDb.ScheduleExcludeType.ToLower())
// на всякий конечно же проверим
if (template.Job?.Group?.ScheduleExcludeType == null)
{ {
case ("нет исключений"): logger.LogError("Для шаблона {templte}, {templateId} не смог получить тип исключения, установил значение по умолчанию \"Без исключения\"", template.Name, template.Id);
return "NONE"; return "NONE";
case ("выполнить только в указанном календаре"):
return "ONLY";
default:
return "";
} }
logger.LogDebug("Для шаблона шаблона {templte}, {templateId} тип исключения \"{name}\", EsppValue: {esppValue}", template.Name, template.Id, template.Job.Group.ScheduleExcludeType.Title, template.Job.Group.ScheduleExcludeType.EsppValue);
return template.Job.Group.ScheduleExcludeType.EsppValue;
#region old logic
//// Это костыль, нужно придумать как это хранить в БД.
//switch (settingsFromDb.ScheduleExcludeType.ToLower())
//{
// case ("нет исключений"):
// return "NONE";
// case ("выполнить только в указанном календаре"):
// return "ONLY";
// default:
// return "";
//}
#endregion
} }

View File

@@ -63,6 +63,12 @@ namespace PARR.EsppSync
.Include(t => t.Job) .Include(t => t.Job)
.ThenInclude(j => j.Group) .ThenInclude(j => j.Group)
.ThenInclude(g => g.GroupType) .ThenInclude(g => g.GroupType)
.Include(t => t.Job)
.ThenInclude(t => t.Group)
.ThenInclude(t => t.ScheduleExcludeType)
.Include(t => t.Job)
.ThenInclude(t => t.Group)
.ThenInclude(t => t.ScheduleExcludeTypeCalendar)
.Include(t => t.Job) .Include(t => t.Job)
.ThenInclude(j => j.Tnk) .ThenInclude(j => j.Tnk)
.Include(t => t.UnitsInTemplate); .Include(t => t.UnitsInTemplate);