WcsDeviceprotocolService.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.Core.APPBLL;
  8. using WMS.Info;
  9. using WMS.Util;
  10. namespace WMS.Core.ServiceCore
  11. {
  12. public class WcsDeviceprotocolService
  13. {
  14. /// <summary>
  15. /// 获取分页数据
  16. /// <summary>
  17. /// <returns></returns>
  18. public IEnumerable<dynamic> GetPageList(Pagination pagination, string queryJson)
  19. {
  20. SqlSugarClient client = null;
  21. try
  22. {
  23. client = WCSDbCore.GetDbCtx();
  24. int count = 0;
  25. var queryParam = queryJson.ToJObject();
  26. var db = client.Queryable<WcsDeviceprotocolEntity>();
  27. if (!queryParam["keyword"].IsEmpty())
  28. {
  29. string kw = queryParam["keyword"].ToString();
  30. db.Where(ord => ord.Devicecode.Contains(kw));
  31. }
  32. if (pagination.sord.ToUpper() != "ASC")
  33. {
  34. pagination.sidx = pagination.sidx + " DESC";
  35. }
  36. var list = db.OrderBy(pagination.sidx).Select<dynamic>(@"*").ToPageList(pagination.page, pagination.rows, ref count);
  37. pagination.records = count;
  38. return list;
  39. }
  40. catch (Exception ex)
  41. {
  42. throw ex;
  43. }
  44. finally
  45. {
  46. client.Dispose();
  47. }
  48. }
  49. /// <summary>
  50. /// 获取数据
  51. /// <summary>
  52. /// <returns></returns>
  53. public IEnumerable<WcsDeviceprotocolEntity> GetListByDevicecode(string Devicecode)
  54. {
  55. var client = WCSDbCore.GetDbCtx();
  56. var db = client.Queryable<WcsDeviceprotocolEntity>();
  57. var lists = db.Where(o => o.Devicecode == Devicecode).ToList();
  58. return lists;
  59. }
  60. /// <summary>
  61. /// 获取实体数据
  62. /// <param name="id">主键</param>
  63. /// <summary>
  64. /// <returns></returns>
  65. public WcsDeviceprotocolEntity GetEntity(int id)
  66. {
  67. return WCSDbCore.GetDbCtx().Queryable<WcsDeviceprotocolEntity>().Where(it => it.Id == id).First();
  68. }
  69. /// <summary>
  70. /// 获取实体数据
  71. /// <param name="Devicecode"></param>
  72. /// <summary>
  73. /// <returns></returns>
  74. public IEnumerable<WcsDeviceprotocolEntity> GetEntityByDevicecode(string Devicecode)
  75. {
  76. return WCSDbCore.GetDbCtx().Queryable<WcsDeviceprotocolEntity>().Where(it => it.Devicecode == Devicecode).ToList();
  77. }
  78. /// <summary>
  79. /// 删除实体数据
  80. /// <param name="id">主键</param>
  81. /// <summary>
  82. /// <returns></returns>
  83. public void DeleteEntity(int id)
  84. {
  85. WCSDbCore.GetDbCtx().Deleteable<WcsDeviceprotocolEntity>().Where(it => it.Id == id).ExecuteCommand();
  86. }
  87. /// <summary>
  88. /// 删除数据
  89. /// <param name="Devicecode">主键</param>
  90. /// <summary>
  91. /// <returns></returns>
  92. public void DeleteByDevicecode(string Devicecode)
  93. {
  94. WCSDbCore.GetDbCtx().Deleteable<WcsDeviceprotocolEntity>().Where(it => it.Devicecode == Devicecode).ExecuteCommand();
  95. }
  96. }
  97. }