feat(dal,api): IMatchingStatusService - управление статусами matcher`a. Отображение статусов в АПИ, нельзя повторно из апи отправить задание мэтчеру если сейчас идет matching

This commit is contained in:
Mikhail Trubnikov
2026-01-16 11:04:26 +10:00
parent 3205c1db8e
commit 99a491ede8
14 changed files with 303 additions and 91 deletions

View File

@@ -9,6 +9,8 @@ using PARR.BLL.Domain.Mq;
using PARR.BLL.Services.Interfaces;
using PARR.Common.Domain;
using PARR.Constants;
using PARR.DAL.Cache.Services;
using PARR.DAL.DomainServices.Interfaces;
using System.Text.Json;
namespace PARR.API.Controllers.V1
@@ -20,13 +22,15 @@ namespace PARR.API.Controllers.V1
private readonly IUriService uriService;
private readonly MqSettings mqSettings;
private readonly IClientService clientService;
private readonly IMatchingStatusService matchingStatusService;
public SyncTaskController(
ILogger<SyncTaskController> logger,
IMqService mqService,
IUriService uriService,
MqSettings mqSettings,
IClientService clientService
IClientService clientService,
IMatchingStatusService matchingStatusService
)
{
this.logger = logger;
@@ -34,6 +38,7 @@ namespace PARR.API.Controllers.V1
this.uriService = uriService;
this.mqSettings = mqSettings;
this.clientService = clientService;
this.matchingStatusService = matchingStatusService;
}
/// <summary>
@@ -45,6 +50,14 @@ namespace PARR.API.Controllers.V1
//todo: Валидатор! Валидатор то забыли!!!
// проверяем, если уже идет синхронизация по этому объекту, то ахтунг, ошибка
var matchingStatus = await matchingStatusService.GetStatusAsync(request.ObjectId, request.EntityType);
if (matchingStatus.IsMatchingObject)
{
logger.LogWarning("Прекращена попытка повторного формирования задания для matcher. objectId: {objectId}, entityType: {entityType}, action: {action}", request.ObjectId, request.EntityType, request.Action);
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Уже выполняется задание синхронизации этого объекта" } }));
}
//24b3529a-dd43-444a-b10e-ac54fefd046a
var matchTemplateTask = new TemplateMatcherMq
{