Merge branch 'next-run-service' into dev

# Conflicts:
#	PARR.DAL/Contracts/SettingsFromDb.cs
This commit is contained in:
Mikhail Trubnikov
2026-02-26 08:42:07 +10:00
37 changed files with 7328 additions and 897 deletions

View File

@@ -1,33 +1,83 @@
using Microsoft.EntityFrameworkCore;
using PARR.Constants;
using PARR.DAL.DomainServices.Shortcodes;
using PARR.DAL.NextRunServices;
using PARR.DAL.NextRunServices.Models;
using PARR.DAL.NextRunServices.Subservices;
using PARR.DAL.Services.Interfaces;
using System.Threading.Tasks;
namespace PARR.Test.NextRun
{
internal class NextRunTest
{
//private readonly ITemplateDistributor templateDistributor;
private readonly INextRunService nextRunService;
//private readonly INextRunService nextRunService;
private readonly ITemplateService templateService;
private readonly IShortcodesService shortcodesService;
//private readonly ITemplateDistributorV2 templateDistributorV2;
private readonly INextRunServiceV2 nextRunServiceV2;
public NextRunTest(/*ITemplateDistributor templateDistributor, */INextRunService nextRunService, ITemplateService templateService, IShortcodesService shortcodesService)
public NextRunTest(
/*ITemplateDistributor templateDistributor, */
//INextRunService nextRunService,
ITemplateService templateService,
IShortcodesService shortcodesService,
//ITemplateDistributorV2 templateDistributorV2,
INextRunServiceV2 nextRunServiceV2
)
{
//this.templateDistributor = templateDistributor;
this.nextRunService = nextRunService;
//this.nextRunService = nextRunService;
this.templateService = templateService;
this.shortcodesService = shortcodesService;
//this.templateDistributorV2 = templateDistributorV2;
this.nextRunServiceV2 = nextRunServiceV2;
}
int periodDays = 10;
DateTimeOffset referenceDate = new DateTimeOffset(2025, 1, 20, 3, 0, 0, TimeSpan.Zero);
public async Task Test()
{
#region тестирование INextRunServiceV2
//рапсределить
//var distributeResult = await nextRunServiceV2.GetNextRunForJobGroupWithAutoDistributionAsync(Guid.Parse("d25d8a9e-898f-417a-9bec-ef3a356e7c94"), TemplateStatusTypeEnum.Used);
// новый шаблон - автодистриб
//var nextRunForNewTemplateDistrib = await nextRunServiceV2.GetNextRunForNewTemplateAsync(Guid.Parse("d25d8a9e-898f-417a-9bec-ef3a356e7c94"), workGroupName: "ЦКИТ-ВСИБ", responseAreaName: "92-ВСИБ");
// новый шаблон - еспп
//var nextRunForNewTemplateEspp = await nextRunServiceV2.GetNextRunForNewTemplateAsync(Guid.Parse("692531d6-4ef4-4a6d-99be-d2ef375d520f"), workGroupName: "ЦКИТ-ЗСИБ", responseAreaName: "83-ЗСИБ");
// существующий шаблон - автодистриб
//var nextRunForExistTemplateDistib = await nextRunServiceV2.GetNextRunForTemplateAsync(Guid.Parse("05769f8d-9630-4683-b07a-070d69e1dc12"), false);
// существующий шаблон - еспп
//var nextRunForExistTemplateEspp = await nextRunServiceV2.GetNextRunForTemplateAsync(Guid.Parse("1329dfca-5e09-4b19-a2e6-560a4896080c"), false);
#endregion
#region Тестирование templateDistributorV2
//var duration = 2;
//var offset = TimeSpan.FromHours(3);
//var startDate = new DateOnly(2026, 2, 10);
//var referenceDate = new DateTimeOffset(2026, 2, 13, 23, 0, 0, TimeSpan.Zero);
//var templates = GetTemplates();
//var templatesEmpty = new List<TemplateNextRunDto>();
//var templatesToHandeler = templatesEmpty; // templatesEmpty // templates
//// распределить шаблоны
//var distributedTemplates = await templateDistributorV2.DistributeTemplatesAsync(startDate, duration, referenceDate, offset, templates, true);
//// получить актуальный nextRun
//var targetTemplate = new TemplateNextRunDto(Guid.Parse("DA151719-2742-4260-BFFE-012B61591053"), new DateTimeOffset(2026, 2, 15, 23, 30, 0, TimeSpan.Zero));
////var validNextRun = await templateDistributorV2.GetNextRunForTemplateAsync(startDate, duration, referenceDate, offset, targetTemplate, templatesToHandeler, true, isNew: false);
#endregion
//var template = await templateService.Get().Include(t => t.Job).ThenInclude(t => t.Group).FirstAsync(t => t.Name == "ЭИТИ-ПАРРКИТВЦ_СХД ТО-1_СХД-AERODISK-432-2-4-U26-EN4SAG022-ГВЦ");
//var responseAreae = await shortcodesService.ApplyShortcodesAsync(template.Job.ResponseAreaMask, template);
//var nextRunWithTimezone = nextRunService.GetNextRunWithTimezoneEsppAndResponseArea(template.NextRun, template.Job?.Group?.IsResponseAreaTimezone, responseAreae);
@@ -117,14 +167,14 @@ namespace PARR.Test.NextRun
}
private DateOnly GetDateStart()
{
var today = DateOnly.FromDateTime(DateTime.UtcNow.Date);
//private DateOnly GetDateStart()
//{
// var today = DateOnly.FromDateTime(DateTime.UtcNow.Date);
var refDate = DateOnly.FromDateTime(referenceDate.Date);
// var refDate = DateOnly.FromDateTime(referenceDate.Date);
return today < refDate ? refDate : today;
}
// return today < refDate ? refDate : today;
//}
//private DateOnly GetDateEnd()
//{
@@ -143,7 +193,7 @@ namespace PARR.Test.NextRun
templates.Add(new TemplateNextRunDto(Id: Guid.Parse("B397F1FE-DF2B-4B50-B8D6-2DABECD3D5A1"), NextRun: new DateTimeOffset(2025, 12, 18, 3, 0, 0, TimeSpan.Zero)));
templates.Add(new TemplateNextRunDto(Id: Guid.Parse("619D9621-2B45-4108-AF54-CF96862A8E9B"), NextRun: new DateTimeOffset(2025, 12, 18, 3, 0, 0, TimeSpan.Zero)));
templates.Add(new TemplateNextRunDto(Id: Guid.Parse("D74D831C-D435-46BF-9B5F-A24884AAA7DC"), NextRun: new DateTimeOffset(2025, 12, 25, 3, 0, 0, TimeSpan.Zero)));
templates.Add(new TemplateNextRunDto(Id: Guid.Parse("DE7241F1-5C62-4164-A3DC-99B946350E10"), NextRun: new DateTimeOffset(2025, 12, 18, 3, 0, 0, TimeSpan.Zero)));
templates.Add(new TemplateNextRunDto(Id: Guid.Parse("DE7241F1-5C62-4164-A3DC-99B946350E10"), NextRun: new DateTimeOffset(2026, 2, 16, 23, 30, 0, TimeSpan.Zero)));
templates.Add(new TemplateNextRunDto(Id: Guid.Parse("94A7375E-D1BD-49B7-9186-D26E85F1CF74"), NextRun: new DateTimeOffset(2025, 12, 18, 3, 0, 0, TimeSpan.Zero)));
templates.Add(new TemplateNextRunDto(Id: Guid.Parse("B3681F5F-10A5-425C-BBEA-EA2B85FE0967"), NextRun: new DateTimeOffset(2025, 12, 18, 3, 0, 0, TimeSpan.Zero)));
templates.Add(new TemplateNextRunDto(Id: Guid.Parse("3259B408-48A3-4995-AF9A-097477ECAB81"), NextRun: new DateTimeOffset(2025, 12, 18, 3, 0, 0, TimeSpan.Zero)));