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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,18 +18,5 @@ namespace PARR.DAL.DomainServices.Interfaces
|
||||
/// <param name="job">Job обязательно должен содержать UnitFilter, Group и GroupType</param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<Guid>?> GetUnitsIdByJobFilterAsync(Job job, int? takeCount = null);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить список Id ЭК в зависимости от параметра mustHaveTemplate
|
||||
/// </summary>
|
||||
/// <param name="jobId"></param>
|
||||
/// <param name="mustHaveTemplate">
|
||||
/// true - ЭК, которые имеют связанные шаблоны
|
||||
/// false - ЭК, для которых шаблоны не созданы
|
||||
/// </param>
|
||||
/// <param name="takeCount"></param>
|
||||
/// <returns>Лист Id ЭК</returns>
|
||||
Task<IEnumerable<Guid>> GetUnitsIdByJobFilterWithTemplateStatusAsync(Guid jobId, bool mustHaveTemplate, int? takeCount = null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,21 +46,6 @@ namespace PARR.DAL.Services.Implementations
|
||||
.ThenInclude(p => p!.Process)
|
||||
.Include(t => t.Job)
|
||||
.ThenInclude(t => t!.Group);
|
||||
|
||||
|
||||
//return Get()
|
||||
// .Include(h => h.Host)
|
||||
// .ThenInclude(t => t!.ResponseArea)
|
||||
// .Include(h => h.Host)
|
||||
// .ThenInclude(t => t!.WorkGroup)
|
||||
// .ThenInclude(t => t!.ResponseArea)
|
||||
// .Include(h => h.Host)
|
||||
// .ThenInclude(t => t!.EkStatus)
|
||||
// .Include(a => a.ApplicationsInWork)
|
||||
// .ThenInclude(w => w!.Work)
|
||||
// .ThenInclude(t => t!.Tnk)
|
||||
// .ThenInclude(s => s!.Subprocess)
|
||||
// .ThenInclude(p => p!.Process);
|
||||
}
|
||||
|
||||
public override Task<bool> CreateAsync(Template obj)
|
||||
|
||||
Reference in New Issue
Block a user