From 2f07ccd67c9ed6e77ef37c667eb45e1e1fa5fd2b Mon Sep 17 00:00:00 2001 From: Mikhail Kuznetsov Date: Tue, 9 Dec 2025 17:53:54 +1000 Subject: [PATCH] =?UTF-8?q?fix(dal):=20UnitInValueService=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20include=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D1=81=20Value,?= =?UTF-8?q?=20=D1=87=D1=82=D0=BE=D0=B1=D1=8B=20=D0=BF=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D1=8F=D1=82=D1=8C=20=D0=BD=D0=B5=20=D1=82=D0=BE?= =?UTF-8?q?=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=BF=D0=BE=20id=20=D0=BD=D0=BE=20?= =?UTF-8?q?=D0=B8=20=D0=BD=D0=B5=D0=BF=D0=BE=D1=81=D1=80=D0=B5=D0=B4=D1=81?= =?UTF-8?q?=D1=82=D0=B2=D0=B5=D0=BD=D0=BD=D0=BE=20=D0=BF=D0=BE=20=D0=B7?= =?UTF-8?q?=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DomainServices/Implementations/ShortcodesService.cs | 2 +- .../DomainServices/Implementations/UnitFilterService.cs | 9 --------- .../Services/Implementations/Unit/UnitInValueService.cs | 6 ++++-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/PARR.DAL/DomainServices/Implementations/ShortcodesService.cs b/PARR.DAL/DomainServices/Implementations/ShortcodesService.cs index 24a45144..dc8ad1ae 100644 --- a/PARR.DAL/DomainServices/Implementations/ShortcodesService.cs +++ b/PARR.DAL/DomainServices/Implementations/ShortcodesService.cs @@ -78,7 +78,7 @@ namespace PARR.DAL.DomainServices.Implementations // 3. %СВЯЗИ% — отдельная обработка if (shortcodesInMask.Any(m => string.Equals(m.Value, "%СВЯЗИ%", StringComparison.OrdinalIgnoreCase))) { - var relatedUnitNames = await unitFilterService.GetRelatedUnitNamesAsync(jobId, unitId);//GetRelatedUnitNamesAsync(job, unit); + var relatedUnitNames = await unitFilterService.GetRelatedUnitNamesAsync(jobId, unitId); var linksText = string.Join("\n", relatedUnitNames); resultName = Regex.Replace(resultName, "%СВЯЗИ%", linksText, RegexOptions.IgnoreCase); } diff --git a/PARR.DAL/DomainServices/Implementations/UnitFilterService.cs b/PARR.DAL/DomainServices/Implementations/UnitFilterService.cs index d6c071e9..d04180dc 100644 --- a/PARR.DAL/DomainServices/Implementations/UnitFilterService.cs +++ b/PARR.DAL/DomainServices/Implementations/UnitFilterService.cs @@ -1,6 +1,5 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; -using PARR.DAL.Context; using PARR.DAL.Contracts; using PARR.DAL.DomainServices.Interfaces; using PARR.DAL.Models.Job; @@ -154,19 +153,11 @@ namespace PARR.DAL.DomainServices.Implementations continue; } - // --- НОВАЯ ЛОГИКА: Используем новые сервисы --- - List relevantLinks; if (rf.IsParent) - { - // u - родитель, его ребёнок - unitId relevantLinks = await unitInUnitService.GetByChildIdAsync(unitId); - } else - { - // u - ребёнок, его родитель - unitId relevantLinks = await unitInUnitService.GetByParentIdAsync(unitId); - } logger.LogDebug("Найдено {Count} связей через UnitInUnitService.", relevantLinks.Count); diff --git a/PARR.DAL/Services/Implementations/Unit/UnitInValueService.cs b/PARR.DAL/Services/Implementations/Unit/UnitInValueService.cs index 6af29be5..25f2b41b 100644 --- a/PARR.DAL/Services/Implementations/Unit/UnitInValueService.cs +++ b/PARR.DAL/Services/Implementations/Unit/UnitInValueService.cs @@ -22,14 +22,16 @@ namespace PARR.DAL.Services.Implementations.Unit public async Task> GetByUnitIdAsync(Guid unitId) { - return await dataContext.UnitInValues + return await dataContext.UnitInValues.AsNoTracking() + .Include(t => t.Value) .Where(uv => uv.UnitId == unitId) .ToListAsync(); } public async Task> GetByUnitIdsAsync(IEnumerable unitIds) { - return await dataContext.UnitInValues + return await dataContext.UnitInValues.AsNoTracking() + .Include(t=>t.Value) .Where(uv => unitIds.Contains(uv.UnitId)) .ToListAsync(); }