barCodeInfoService.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using SqlSugar;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using wms.sqlsugar.model.pt;
  8. using WMS.BZModels;
  9. using WMS.BZModels.Dto.PT.BarcodeDtos;
  10. using WMS.Info;
  11. using WMS.BZSqlSugar;
  12. namespace WMS.BZServices.PT
  13. {
  14. public class barCodeInfoService
  15. {
  16. private readonly Repository<BillInvinit> _invinit;
  17. public barCodeInfoService(Repository<BillInvinit> invinit)
  18. {
  19. _invinit = invinit;
  20. }
  21. public PagedInfo<BarcodeDto> GetPageList(Pagination pagination, BarcodeQueryDto barcodeQuery)
  22. {
  23. if (pagination.sord.ToUpper() != "ASC")
  24. {
  25. pagination.sidx = pagination.sidx.IsEmpty() ? "AddTime DESC" : pagination.sidx + " DESC";
  26. }
  27. if (pagination.sidx.IsEmpty())
  28. {
  29. pagination.sidx = "AddTime DESC";
  30. }
  31. var predicate = Expressionable.Create<BillInvinit>();
  32. predicate = predicate.AndIF(!string.IsNullOrEmpty(barcodeQuery?.KeyWord), m => m.ContGrpBarCode.Contains(barcodeQuery.KeyWord) || m.InDocsNo.Contains(barcodeQuery.KeyWord)
  33. || m.MatCode.Contains(barcodeQuery.KeyWord) || m.SuppCode.Contains(barcodeQuery.KeyWord) || m.BoilerNo.Contains(barcodeQuery.KeyWord) || m.PackNo.Contains(barcodeQuery.KeyWord)
  34. || m.RodBarCode.Contains(barcodeQuery.KeyWord));
  35. predicate = predicate.AndIF(!string.IsNullOrEmpty(barcodeQuery?.ContGrpBarCode), m => m.ContGrpBarCode.ToString().Contains(barcodeQuery.ContGrpBarCode));
  36. predicate = predicate.AndIF(!string.IsNullOrEmpty(barcodeQuery?.RodBarCode), m => m.RodBarCode.Contains(barcodeQuery.RodBarCode));
  37. predicate = predicate.AndIF(!string.IsNullOrEmpty(barcodeQuery?.MatCode), m => m.MatCode.Contains(barcodeQuery.MatCode));
  38. predicate = predicate.AndIF(!string.IsNullOrEmpty(barcodeQuery?.SuppCode), m => m.SuppCode.Contains(barcodeQuery.SuppCode));
  39. predicate = predicate.AndIF(!string.IsNullOrEmpty(barcodeQuery?.InDocsNo), m => m.InDocsNo.Contains(barcodeQuery.InDocsNo));
  40. predicate = predicate.AndIF(!string.IsNullOrEmpty(barcodeQuery?.BoilerNo), m => m.BoilerNo.Contains(barcodeQuery.BoilerNo));
  41. predicate = predicate.AndIF(!string.IsNullOrEmpty(barcodeQuery?.PackNo), m => m.PackNo.Contains(barcodeQuery.PackNo));
  42. predicate = predicate.AndIF(barcodeQuery != null && barcodeQuery.AddTimeFrom.HasValue, (m) => m.AddTime >= barcodeQuery.AddTimeFrom);
  43. predicate = predicate.AndIF(barcodeQuery != null && barcodeQuery.AddTimeTo.HasValue, (m) => m.AddTime <= barcodeQuery.AddTimeTo);
  44. predicate = predicate.AndIF(barcodeQuery != null && barcodeQuery.EndTimeBegin.HasValue, (m) => m.EditTime >= barcodeQuery.EndTimeBegin);
  45. predicate = predicate.AndIF(barcodeQuery != null && barcodeQuery.EndTimeEnd.HasValue, (m) => m.EditTime <= barcodeQuery.EndTimeEnd);
  46. var list = _invinit.Queryable().Where(predicate.ToExpression())
  47. .ToPage<BillInvinit, BarcodeDto>(pagination);
  48. return list;
  49. }
  50. }
  51. }