S8MasterDataAdapter.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Admin.NET.Plugin.AiDOP.Entity.S0.Manufacturing;
  2. using Admin.NET.Plugin.AiDOP.Entity.S0.Warehouse;
  3. namespace Admin.NET.Plugin.AiDOP.Service.S8;
  4. public class S8MasterDataAdapter : ITransient
  5. {
  6. private readonly SqlSugarRepository<AdoS0DepartmentMaster> _deptRep;
  7. private readonly SqlSugarRepository<AdoS0EmployeeMaster> _empRep;
  8. private readonly SqlSugarRepository<AdoS0LineMaster> _lineRep;
  9. public S8MasterDataAdapter(
  10. SqlSugarRepository<AdoS0DepartmentMaster> deptRep,
  11. SqlSugarRepository<AdoS0EmployeeMaster> empRep,
  12. SqlSugarRepository<AdoS0LineMaster> lineRep)
  13. {
  14. _deptRep = deptRep;
  15. _empRep = empRep;
  16. _lineRep = lineRep;
  17. }
  18. public async Task<object> GetDepartmentsAsync(long? factoryRefId) =>
  19. await _deptRep.AsQueryable()
  20. .WhereIF(factoryRefId.HasValue, x => x.FactoryRefId == factoryRefId!.Value)
  21. .Take(500)
  22. .Select(x => new { id = x.Id, code = x.Department, name = x.Descr ?? x.Department })
  23. .ToListAsync();
  24. public async Task<object> GetEmployeesAsync(long? factoryRefId) =>
  25. await _empRep.AsQueryable()
  26. .WhereIF(factoryRefId.HasValue, x => x.FactoryRefId == factoryRefId!.Value)
  27. .Take(500)
  28. .Select(x => new { id = x.Id, name = x.Name ?? x.Employee, empCode = x.Employee })
  29. .ToListAsync();
  30. public async Task<object> GetLinesAsync(long? factoryRefId) =>
  31. await _lineRep.AsQueryable()
  32. .WhereIF(factoryRefId.HasValue, x => x.FactoryRefId == factoryRefId!.Value)
  33. .Take(500)
  34. .Select(x => new { id = x.Id, code = x.Line, name = x.Describe ?? x.Line })
  35. .ToListAsync();
  36. }