feat(aihitRelationshipsSyncer): refactoring

This commit is contained in:
Mikhail Kuznetsov
2025-06-04 12:43:52 +10:00
parent 50ef7dee5c
commit b82a1de8bf

View File

@@ -91,18 +91,18 @@ namespace PARR.AIHITRelationshipsSyncer.Services.Implementations
private async Task RemoveWasteRelationships(IEnumerable<IGrouping<string?, AihitData>> groupedData)
{
var parentNames = groupedData.Select(t => t.Key);
var parentNames = groupedData.Select(t => t.Key?.ToLower().Trim());
var units = await unitService.Get()
.Include(t => t.ChildUnits).ToListAsync();
var parentsToDeleteChild = units.Where(t => parentNames.All(a => t.Name != a) && t.ChildUnits.Any());
var parentsToDeleteChild = units.Where(t => parentNames.All(a => t.Name.ToLower() != a) && t.ChildUnits.Any());
if (parentsToDeleteChild.Any())
{
foreach (var unit in parentsToDeleteChild)
{
unit.ChildUnits.Clear();
DeleteChilds(unit, unit.ChildUnits);
}
}
}
@@ -143,7 +143,7 @@ namespace PARR.AIHITRelationshipsSyncer.Services.Implementations
DateCreated = DateTimeOffset.UtcNow,
}
);
logger.LogInformation($"----- Создан связь Unit {unit.Name} - {childUnit.Name}-----");
logger.LogInformation($"----- Создана связь Unit {unit.Name} - {childUnit.Name}-----");
}
if (!isChanged)