FxInventoryTransactionCore.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.Info;
  8. using WMS.Util;
  9. namespace WMS.Core.ServiceCore
  10. {
  11. public class FxInventoryTransactionCore
  12. {
  13. /// <summary>
  14. /// 获取分页数据
  15. /// <summary>
  16. /// <returns></returns>
  17. public IEnumerable<dynamic> GetInventoryPageList(Pagination pagination, string queryJson)
  18. {
  19. SqlSugarClient client = null;
  20. try
  21. {
  22. client = SysDbCore.GetDbCtx();
  23. int count = 0;
  24. var queryParam = queryJson.ToJObject();
  25. var db = client.Queryable<BILL_INVENTORYTRANSACTION>();
  26. //单据日期
  27. if (!queryParam["Btime"].IsEmpty() && !queryParam["Etime"].IsEmpty())
  28. {
  29. db.Where(ord => ord.F_addTime >= queryParam["Btime"].ToDate() && ord.F_addTime <= queryParam["Etime"].ToDate());
  30. }
  31. if (!queryParam["keyword"].IsEmpty())
  32. {
  33. string matNo = queryParam["keyword"].ToString();
  34. db.Where(ord => ord.F_matNo.Contains(matNo) || ord.F_matName.Contains(matNo));
  35. }
  36. if (!queryParam["F_trayNo"].IsEmpty())
  37. {
  38. string trayNo = queryParam["F_trayNo"].ToString();
  39. db.Where(ord => ord.F_sourceTrayNo.Contains(trayNo) || ord.F_targetTrayNo.Contains(trayNo));
  40. }
  41. if (!queryParam["F_boxNo"].IsEmpty())
  42. {
  43. string boxNo = queryParam["F_boxNo"].ToString();
  44. db.Where(ord => ord.F_boxNo.Contains(boxNo));
  45. }
  46. if (!queryParam["F_matType"].IsEmpty())
  47. {
  48. string matType = queryParam["F_matType"].ToString();
  49. db.Where(ord => ord.F_matType == FuncStr.NullToInt(matType));
  50. }
  51. if (pagination.sord.ToUpper() != "ASC")
  52. {
  53. pagination.sidx = pagination.sidx + " DESC";
  54. }
  55. // (case when regexp_substr(ord.F_NO,'[^_]+',1,2) is null then ord.F_NO else regexp_substr(ord.F_NO,'[^_]+',1,2) end)
  56. var list = db.OrderBy(pagination.sidx).Select<BILL_INVENTORYTRANSACTION>(@"
  57. [F_inventoryNo],
  58. [F_warehouseNo],
  59. [F_projectNo],
  60. [F_matNo],
  61. [F_matName],
  62. [F_matType],
  63. [F_sourceQuantity],
  64. [F_sourceLockQty],
  65. [F_targetQuantity],
  66. [F_targetLockQty],
  67. [F_sourceTrayNo],
  68. [F_targetTrayNo],
  69. [F_batchNo],
  70. [F_memo],
  71. [F_isBonded],
  72. [F_UID],
  73. [F_addUserNo],
  74. [F_addTime],
  75. [F_boxNo],
  76. [F_productDate]").ToPageList(pagination.page, pagination.rows, ref count);
  77. pagination.records = count;
  78. return list;
  79. }
  80. catch (Exception ex)
  81. {
  82. throw ex;
  83. }
  84. finally
  85. {
  86. client.Dispose();
  87. }
  88. }
  89. }
  90. }