feat(aihitSyncer): RemoveFromCacheAsync после обновления атрибутов ЭК

This commit is contained in:
Mikhail Kuznetsov
2026-06-04 14:14:10 +10:00
parent 1f4d338422
commit 0e8dea4c48
4 changed files with 105 additions and 109 deletions

View File

@@ -1,29 +1,12 @@
using Elastic.CommonSchema.Serilog;
using PARR.Core;
using PARR.DAL;
using PARR.EsppApi;
using PARR.Infrastructure;
using PARR.TemplateMatcher;
using PARR.Test;
using PARR.Test.NextRun;
using Serilog;
/*IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services) =>
{
//services.InstallEsppApiServices(hostContext.Configuration);
//services.InstallBllServices(hostContext.Configuration);
services.InstallDalServices(hostContext.Configuration);
//services.InstallTemplateDistributorSerivces(hostContext.Configuration);
services.AddHostedService<Worker>();
})
.UseSerilog((hostContext, services, config) =>
{
config
.WriteTo.Console()
.ReadFrom.Configuration(hostContext.Configuration);
})
.Build();*/
var builder = Host.CreateApplicationBuilder();
builder.Services.AddLogging(config =>
@@ -42,12 +25,17 @@ builder.Services.AddLogging(config =>
config.AddSerilog(logger.CreateLogger());
});
builder.Services.AddDalServices(builder.Configuration);
builder.Services.AddCoreServices(builder.Configuration);
builder.Services.AddInfrastructureServices(builder.Configuration);
builder.Services.InstallTemplateMatcherSerivces(builder.Configuration);
// builder.Services.AddDalServices(builder.Configuration);
// builder.Services.AddCoreServices(builder.Configuration);
// builder.Services.AddInfrastructureServices(builder.Configuration);
builder.Services.InstallEsppApiServices(builder.Configuration);
builder.Configuration.AddTemplateMatcherConfigurations(builder.Services);
builder.Configuration.AddDalConfigurations(builder.Services);
builder.Services.AddTemplateMatcherSettings(builder.Configuration);
builder.Services.AddDallSettings(builder.Configuration);
builder.Services.AddTransient<NextRunTest>();

View File

@@ -1,9 +1,13 @@
using Microsoft.EntityFrameworkCore;
using PARR.Core.Common.Interfaces;
using PARR.Core.Repositories.Interfaces.Job;
using PARR.Domain.Cache;
using PARR.Domain.Entities.Base.History;
using PARR.Domain.Enums;
using PARR.EsppApi;
using PARR.EsppApi.Constants;
using PARR.EsppApi.Models.Query;
using PARR.TemplateMatcher;
using PARR.Test.NextRun;
namespace PARR.Test
@@ -37,16 +41,11 @@ namespace PARR.Test
//var bbb = aaa.ToOffset(new TimeSpan(3, 0, 0));
#region NextRunTest
await TemplateMatcherTest();
using (var scope = serviceProvider.CreateScope())
{
var service = scope.ServiceProvider.GetService<NextRunTest>();
await service!.Test();
}
#endregion
//await NextRunTest();
#region test
@@ -161,21 +160,46 @@ namespace PARR.Test
#endregion
////test interval
//await intervalService.IntervalInitAsync(async () =>
//{
// _logger.LogInformation("---Выполняю метод---");
// await Task.Delay(29*1000);
// _logger.LogInformation("===Выполнил метод===");
//}, new TimeSpan(0, 0, 30));
//await TestEsppApi();
//await StopDiscontinuedOrdersInEspp();
}
#region TemplateMatcher
private async Task TemplateMatcherTest()
{
await using var scope = serviceProvider.CreateAsyncScope();
var templateMatcher = scope.ServiceProvider.GetRequiredService<ITemplateMatcher>();
var groupRepository = scope.ServiceProvider.GetRequiredService<IJobGroupRepository>();
var groups = await groupRepository.Get().AsNoTracking()
.Where(t => t.GroupType != null && t.GroupType.Code == JobGroupTypesEnum.Group)
.Select(t => t.Id).ToHashSetAsync();
foreach (var groupId in groups)
{
await templateMatcher.SyncTemplatesForJobGroup(groupId,
new HistoryInitiator
{
InitiatorIp = "10.99.246.156",
InitiatorParrComponentId = ParrComponentsEnum.Master,
InitiatorComment = "Тестовый проект. Синхронизация Группированых работ"
}
);
}
return;
}
#endregion
private async Task NextRunTest()
{
using (var scope = serviceProvider.CreateScope())
{
var service = scope.ServiceProvider.GetService<NextRunTest>();
await service!.Test();
}
}
private async Task TestEsppApi()
{