feat(aihitMainSyncer): реализована логика синхронизации таблиц unit.* с данными из АИХ ИТ

This commit is contained in:
Mikhail Kuznetsov
2025-05-21 11:53:07 +10:00
parent 1ce8fcb284
commit 0fd0b4881f
13 changed files with 177 additions and 78 deletions

View File

@@ -19,5 +19,17 @@ namespace PARR.DAL.Services.Implementations.Unit
{
this.dataContext = dataContext;
}
public async Task<UnitFieldValue?> GetByValueNameAsync(string? value)
{
var query = EntitySet
.Include(v => v.FieldValues);
if (string.IsNullOrWhiteSpace(value))
return await query.FirstOrDefaultAsync(uf => uf.Value == null);
return await query.FirstOrDefaultAsync(uf => uf.Value!.ToLower() == value.ToLower());
}
}
}

View File

@@ -20,18 +20,20 @@ namespace PARR.DAL.Services.Implementations.Unit
}
public async Task<Models.Unit.Unit?> GetUnitWithFieldsAsync(string name)
public async Task<Models.Unit.Unit?> GetUnitByName(string name)
{
return await GetUnitWithIncludeFields()
return await GetUnitWithFieldsAndValues()
.FirstOrDefaultAsync(u => u.Name.ToLower() == name.ToLower());
}
private IQueryable<Models.Unit.Unit> GetUnitWithIncludeFields()
private IQueryable<Models.Unit.Unit> GetUnitWithFieldsAndValues()
{
return EntitySet
.Include(t => t.UnitFields)
.ThenInclude(f => f.UnitField);
.Include(u => u.UnitFields)
.ThenInclude(f => f.UnitField)
.Include(u => u.UnitValues)
.ThenInclude(v => v.Value);
}
}
}