feat(dal,api): IMatchingStatusService - управление статусами matcher`a. Отображение статусов в АПИ, нельзя повторно из апи отправить задание мэтчеру если сейчас идет matching
This commit is contained in:
@@ -16,6 +16,7 @@ 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.Contracts;
|
||||
using PARR.DAL.DomainModels;
|
||||
using PARR.DAL.DomainServices.Interfaces;
|
||||
@@ -24,7 +25,6 @@ using PARR.DAL.Models.Job;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
@@ -45,6 +45,7 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly MqSettings mqSettings;
|
||||
private readonly IClientService clientService;
|
||||
private readonly IJobAutoControlService jobAutoControlService;
|
||||
private readonly IMatchingStatusService matchingStatusService;
|
||||
|
||||
public JobController(
|
||||
ILogger<JobController> logger,
|
||||
@@ -59,7 +60,8 @@ namespace PARR.API.Controllers.V1
|
||||
IMqService mqService,
|
||||
MqSettings mqSettings,
|
||||
IClientService clientService,
|
||||
IJobAutoControlService jobAutoControlService
|
||||
IJobAutoControlService jobAutoControlService,
|
||||
IMatchingStatusService matchingStatusService
|
||||
)
|
||||
{
|
||||
this.logger = logger;
|
||||
@@ -72,6 +74,7 @@ namespace PARR.API.Controllers.V1
|
||||
this.mqSettings = mqSettings;
|
||||
this.clientService = clientService;
|
||||
this.jobAutoControlService = jobAutoControlService;
|
||||
this.matchingStatusService = matchingStatusService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -124,6 +127,11 @@ namespace PARR.API.Controllers.V1
|
||||
{
|
||||
//jobResponse.TemplatesCount = await templateService.Get().CountAsync(t => t.JobId == jobResponse.Id);
|
||||
jobResponse.TemplatesCount = await GetCountTemplatesAsync(jobResponse.Id);
|
||||
|
||||
if (filter.IsFull)
|
||||
{
|
||||
jobResponse.MatchingStatus = await GetMatchingStatusAsync(jobResponse.Id);
|
||||
}
|
||||
}
|
||||
|
||||
var paginationResponse = new PagedResponse<JobResponse>(response, true).GetPaginatedProps(paginationFilter, query);
|
||||
@@ -159,6 +167,7 @@ namespace PARR.API.Controllers.V1
|
||||
var response = mapper.Map<JobResponse>(job);
|
||||
|
||||
response.TemplatesCount = await GetCountTemplatesAsync(id); //await templateService.Get().CountAsync(t => t.JobId == id);
|
||||
response.MatchingStatus = await GetMatchingStatusAsync(id);
|
||||
|
||||
//var statistics = await GetStatisticsAsync(response.Id);
|
||||
//BindStatistics(response, statistics);
|
||||
@@ -234,6 +243,7 @@ namespace PARR.API.Controllers.V1
|
||||
var response = mapper.Map<JobResponse>(createdJob);
|
||||
// так как мы только что создали Job, то у него нет шаблонов, смело ставим = 0 (ускоряем запрос)
|
||||
response.TemplatesCount = 0;
|
||||
response.MatchingStatus = await GetMatchingStatusAsync(response.Id);
|
||||
|
||||
return Created(locationUri, new Response<JobResponse>(response, true));
|
||||
}
|
||||
@@ -355,6 +365,7 @@ namespace PARR.API.Controllers.V1
|
||||
|
||||
var response = mapper.Map<JobResponse>(updatedJob);
|
||||
response.TemplatesCount = await GetCountTemplatesAsync(id); //await templateService.Get().CountAsync(t => t.JobId == id);
|
||||
response.MatchingStatus = await GetMatchingStatusAsync(id);
|
||||
|
||||
//не используется
|
||||
//var statistics = await GetStatisticsAsync(response.Id);
|
||||
@@ -657,6 +668,18 @@ namespace PARR.API.Controllers.V1
|
||||
return await templateService.Get().CountAsync(t => t.JobId == jobId && t.StatusTypeId == TemplateStatusTypeEnum.Used);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получить статус matching`a
|
||||
/// </summary>
|
||||
/// <param name="jobId"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<MatchingStatusResponse?> GetMatchingStatusAsync(Guid jobId)
|
||||
{
|
||||
var statusMatching = await matchingStatusService.GetStatusAsync(jobId, SyncTaskEntityTypeEnum.Job);
|
||||
|
||||
return mapper.Map<MatchingStatusResponse>(statusMatching);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user