feat(templateMatcher): реализован функционал переиспользования неиспользуемых шаблонов, пока без обезличивания имени шаблона.
This commit is contained in:
@@ -3,10 +3,8 @@ using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.DomainServices.Interfaces;
|
||||
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.NetworkInformation;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
|
||||
@@ -17,19 +15,16 @@ namespace PARR.DAL.DomainServices.Implementations
|
||||
private readonly ILogger<UnitFilterService> logger;
|
||||
private readonly IJobService jobService;
|
||||
private readonly IUnitService unitService;
|
||||
private readonly ITemplateService templateService;
|
||||
|
||||
public UnitFilterService(
|
||||
ILogger<UnitFilterService> logger,
|
||||
IJobService jobService,
|
||||
IUnitService unitService,
|
||||
ITemplateService templateService
|
||||
IUnitService unitService
|
||||
)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.jobService = jobService;
|
||||
this.unitService = unitService;
|
||||
this.templateService = templateService;
|
||||
}
|
||||
|
||||
|
||||
@@ -287,35 +282,5 @@ namespace PARR.DAL.DomainServices.Implementations
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public async Task<IEnumerable<Guid>> GetUnitsIdByJobFilterWithTemplateStatusAsync(
|
||||
Guid jobId,
|
||||
bool mustHaveTemplate,
|
||||
int? takeCount = null
|
||||
)
|
||||
{
|
||||
var unitIds = await GetUnitsIdByJobFilterAsync(jobId, takeCount);
|
||||
if (unitIds == null || !unitIds.Any())
|
||||
return Array.Empty<Guid>();
|
||||
|
||||
var unitIdSet = unitIds.ToHashSet();
|
||||
|
||||
// Получаем UnitId, для которых уже есть шаблоны по этому jobId
|
||||
var existingUnitIds = await templateService
|
||||
.Get()
|
||||
.AsNoTracking()
|
||||
.Where(template =>
|
||||
template.JobId == jobId &&
|
||||
unitIdSet.Contains(template.UnitId))
|
||||
.Select(template => template.UnitId)
|
||||
.ToListAsync();
|
||||
|
||||
var existingSet = existingUnitIds.ToHashSet();
|
||||
|
||||
return mustHaveTemplate
|
||||
? existingSet
|
||||
: unitIdSet.Except(existingSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user