using Admin.NET.Plugin.AiDOP.Entity.S0.Manufacturing; using Admin.NET.Plugin.AiDOP.Entity.S0.Warehouse; namespace Admin.NET.Plugin.AiDOP.Service.S8; public class S8MasterDataAdapter : ITransient { private readonly SqlSugarRepository _deptRep; private readonly SqlSugarRepository _empRep; private readonly SqlSugarRepository _lineRep; public S8MasterDataAdapter( SqlSugarRepository deptRep, SqlSugarRepository empRep, SqlSugarRepository lineRep) { _deptRep = deptRep; _empRep = empRep; _lineRep = lineRep; } public async Task GetDepartmentsAsync(long? factoryRefId) => await _deptRep.AsQueryable() .WhereIF(factoryRefId.HasValue, x => x.FactoryRefId == factoryRefId!.Value) .Take(500) .Select(x => new { id = x.Id, code = x.Department, name = x.Descr ?? x.Department }) .ToListAsync(); public async Task GetEmployeesAsync(long? factoryRefId) => await _empRep.AsQueryable() .WhereIF(factoryRefId.HasValue, x => x.FactoryRefId == factoryRefId!.Value) .Take(500) .Select(x => new { id = x.Id, name = x.Name ?? x.Employee, empCode = x.Employee }) .ToListAsync(); public async Task GetLinesAsync(long? factoryRefId) => await _lineRep.AsQueryable() .WhereIF(factoryRefId.HasValue, x => x.FactoryRefId == factoryRefId!.Value) .Take(500) .Select(x => new { id = x.Id, code = x.Line, name = x.Describe ?? x.Line }) .ToListAsync(); }