fix(dal): UnitInValueService добавлены include для получение данных с Value, чтобы проверять не только по id но и непосредственно по значению
This commit is contained in:
@@ -78,7 +78,7 @@ namespace PARR.DAL.DomainServices.Implementations
|
|||||||
// 3. %СВЯЗИ% — отдельная обработка
|
// 3. %СВЯЗИ% — отдельная обработка
|
||||||
if (shortcodesInMask.Any(m => string.Equals(m.Value, "%СВЯЗИ%", StringComparison.OrdinalIgnoreCase)))
|
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);
|
var linksText = string.Join("\n", relatedUnitNames);
|
||||||
resultName = Regex.Replace(resultName, "%СВЯЗИ%", linksText, RegexOptions.IgnoreCase);
|
resultName = Regex.Replace(resultName, "%СВЯЗИ%", linksText, RegexOptions.IgnoreCase);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.DAL.Context;
|
|
||||||
using PARR.DAL.Contracts;
|
using PARR.DAL.Contracts;
|
||||||
using PARR.DAL.DomainServices.Interfaces;
|
using PARR.DAL.DomainServices.Interfaces;
|
||||||
using PARR.DAL.Models.Job;
|
using PARR.DAL.Models.Job;
|
||||||
@@ -154,19 +153,11 @@ namespace PARR.DAL.DomainServices.Implementations
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- НОВАЯ ЛОГИКА: Используем новые сервисы ---
|
|
||||||
|
|
||||||
List<UnitInUnit> relevantLinks;
|
List<UnitInUnit> relevantLinks;
|
||||||
if (rf.IsParent)
|
if (rf.IsParent)
|
||||||
{
|
|
||||||
// u - родитель, его ребёнок - unitId
|
|
||||||
relevantLinks = await unitInUnitService.GetByChildIdAsync(unitId);
|
relevantLinks = await unitInUnitService.GetByChildIdAsync(unitId);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
// u - ребёнок, его родитель - unitId
|
|
||||||
relevantLinks = await unitInUnitService.GetByParentIdAsync(unitId);
|
relevantLinks = await unitInUnitService.GetByParentIdAsync(unitId);
|
||||||
}
|
|
||||||
|
|
||||||
logger.LogDebug("Найдено {Count} связей через UnitInUnitService.", relevantLinks.Count);
|
logger.LogDebug("Найдено {Count} связей через UnitInUnitService.", relevantLinks.Count);
|
||||||
|
|
||||||
|
|||||||
@@ -22,14 +22,16 @@ namespace PARR.DAL.Services.Implementations.Unit
|
|||||||
|
|
||||||
public async Task<List<UnitInValue>> GetByUnitIdAsync(Guid unitId)
|
public async Task<List<UnitInValue>> GetByUnitIdAsync(Guid unitId)
|
||||||
{
|
{
|
||||||
return await dataContext.UnitInValues
|
return await dataContext.UnitInValues.AsNoTracking()
|
||||||
|
.Include(t => t.Value)
|
||||||
.Where(uv => uv.UnitId == unitId)
|
.Where(uv => uv.UnitId == unitId)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<UnitInValue>> GetByUnitIdsAsync(IEnumerable<Guid> unitIds)
|
public async Task<List<UnitInValue>> GetByUnitIdsAsync(IEnumerable<Guid> unitIds)
|
||||||
{
|
{
|
||||||
return await dataContext.UnitInValues
|
return await dataContext.UnitInValues.AsNoTracking()
|
||||||
|
.Include(t=>t.Value)
|
||||||
.Where(uv => unitIds.Contains(uv.UnitId))
|
.Where(uv => unitIds.Contains(uv.UnitId))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user