feat(dal): Реализован сервис UnitFilterService для получения Unit, для которых требуется создать или уже создан шаблон по Job.Id
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
using Elastic.CommonSchema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.DomainServices;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
using PARR.DAL.DomainServices.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
using PARR.EsppApi;
|
||||
using PARR.EsppApi.Constants;
|
||||
using PARR.EsppApi.Models.Query;
|
||||
using System.Net.WebSockets;
|
||||
|
||||
namespace PARR.Test
|
||||
{
|
||||
@@ -39,85 +35,29 @@ namespace PARR.Test
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
#region test
|
||||
using (var scope = serviceProvider.CreateScope())
|
||||
{
|
||||
var unitService = scope.ServiceProvider.GetService<IUnitService>();
|
||||
//using (var scope = serviceProvider.CreateScope())
|
||||
//{
|
||||
// var unitFilterService = scope.ServiceProvider.GetService<IUnitFilterService>();
|
||||
|
||||
var unitsQuery = unitService!.Get()
|
||||
.Include(t => t.UnitValues)
|
||||
.ThenInclude(t => t.Field)
|
||||
.Include(t => t.UnitValues)
|
||||
.ThenInclude(t => t.Value)
|
||||
.Where(t => /*EF.Functions.Like(t.Name, "%-ГВЦ") &&*/
|
||||
t.UnitValues.Any(v =>
|
||||
v.Field!.AihitName == "ПОДКАТЕГОРИЯ_ЭК" && v.Value!.Value == "система хранения данных (схд)")
|
||||
&& t.UnitValues.Any(v =>
|
||||
v.Field!.AihitName == "ТИП_ЭК" && v.Value!.Value == "коммутатор")
|
||||
//&& t.UnitValues.Any(v =>
|
||||
// v.Field!.AihitName == "АКТИВЕН" && v.Value!.Value == "1")
|
||||
&& t.UnitValues.Any(v =>
|
||||
v.Field!.AihitName == "НЕУНИКАЛЬНЫЙ_ЭК" && v.Value!.Value == "0")
|
||||
&& !t.UnitValues.Any(v =>
|
||||
v.Field!.AihitName == "СТАТУС" && v.Value!.Value == "6-Выведен из эксплуатации")
|
||||
);
|
||||
// if (unitFilterService == null)
|
||||
// return;
|
||||
|
||||
var v1 = await unitsQuery
|
||||
.Include(t => t.ParentUnits)
|
||||
.ThenInclude(t => t.ParentUnit)
|
||||
.ThenInclude(t => t.UnitValues)
|
||||
.ThenInclude(t => t.Field)
|
||||
.Include(t => t.ParentUnits)
|
||||
.ThenInclude(t => t.ParentUnit)
|
||||
.ThenInclude(t => t.UnitValues)
|
||||
.ThenInclude(t => t.Value)
|
||||
.ToListAsync();
|
||||
var res = v1
|
||||
.Where(t => (t.ParentUnits == null || t.ParentUnits.Count == 0) || !t.ParentUnits!.Any(a => a.ParentUnit != null && a.ParentUnit!.BaseFields!.NotUnique == "1"))
|
||||
.OrderBy(t => t.Name).ToList();
|
||||
var service = scope.ServiceProvider.GetService<ITemplateNameGeneratorService>();
|
||||
foreach (var item in res)
|
||||
{
|
||||
var name = await service!.GetTemplateNameAsync(Guid.Parse("926793f7-c6d3-4f08-b5ce-517ce1a1ac37"), item.Id);
|
||||
}
|
||||
/*var service = scope.ServiceProvider.GetService<ITemplateNameGeneratorService>();
|
||||
// var jobId = Guid.Parse("58b28517-8178-4683-a519-22f5989c9912");
|
||||
// var unitsId = await unitFilterService.GetUnitsIdByJobFilterAsync(jobId);
|
||||
|
||||
var ttt = await service.GetTemplateNameAsync(Guid.Parse("ba05948b-b040-48cc-ab77-0accc9c223a0"), Guid.Parse("d4a86f24-6975-4614-98ab-431f26e3eb69"));*/
|
||||
//var service = scope.ServiceProvider.GetService<ITemplateService>();
|
||||
//var templates = await service.Get()
|
||||
// .Include(t => t.ApplicationsInWork)
|
||||
// .ThenInclude(t=>t.Work)
|
||||
// //.Select(s => new { s.Id, s.Host, s.HostId, s.JobId, s.UnitId })
|
||||
// .Where(t => t.JobId == Guid.Parse("ba05948b-b040-48cc-ab77-0accc9c223a0")
|
||||
// ).ToListAsync();
|
||||
// var unitService = scope.ServiceProvider.GetService<IUnitService>();
|
||||
|
||||
//var workNames = templates.Select(t=>t.ApplicationsInWork!.Work!.TemplateSuffix).Distinct();
|
||||
// if (unitService == null)
|
||||
// return;
|
||||
|
||||
//var jobService = scope.ServiceProvider.GetService<IJobService>();
|
||||
//var jobs = await jobService!.Get().Where(t => workNames.Any(tt => tt == t.Name)).ToListAsync();
|
||||
////var hostsName = templates.Select(t => t.Host!.Ek);
|
||||
////var unitService = scope.ServiceProvider.GetService<IUnitService>();
|
||||
////var units = await unitService.Get()
|
||||
//// //.Select(s => new { s.Id, s.Name })
|
||||
//// .Where(t => hostsName.Any(tt => tt == t.Name))
|
||||
//// .ToListAsync();
|
||||
// var tForCreate = await unitFilterService.GetUnitsIdForExistTemplatesByJobFilterAsync(jobId);
|
||||
// if (tForCreate == null)
|
||||
// return;
|
||||
|
||||
//foreach (var t in templates) {
|
||||
|
||||
// var workName = t.ApplicationsInWork!.Work!.TemplateSuffix;
|
||||
// //var unitId = units.FirstOrDefault(u => u.Name == hostName);
|
||||
// var jobId = jobs.FirstOrDefault(t => t.Name == workName);
|
||||
// if (jobId != null)
|
||||
// t.JobId = jobId.Id;
|
||||
//}
|
||||
|
||||
//await service.CommitAsync();
|
||||
// var units = await unitService
|
||||
// .Get().AsNoTracking()
|
||||
// .Where(t => tForCreate.Any(x => x == t.Id)).ToListAsync();
|
||||
}
|
||||
|
||||
//var tName = "ДВС-ЭИТИ-ПТК-ПАРР__ВРТ-VCD-02-ДВС__ПРОЧЕЕ(РАБОТЫ)";
|
||||
//var prefix = "ЭИТИ-ПТК-ПАРР";
|
||||
////templateName.Contains(settingsFromDb.TemplatePrefixWithoutVariable, StringComparison.CurrentCultureIgnoreCase)
|
||||
//var res = tName.Contains(prefix);
|
||||
|
||||
#endregion
|
||||
|
||||
#region unit
|
||||
|
||||
Reference in New Issue
Block a user