You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

178 lines
5.2 KiB

  1. using Dapper;
  2. using Learun.DataBase.Repository;
  3. using Learun.Util;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Text;
  9. namespace Learun.Application.TwoDevelopment.LogisticsManagement
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2019-05-05 15:44
  16. /// 描 述:宿舍卫生管理
  17. /// </summary>
  18. public class SanitationService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<Acc_SanitationEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"
  33. t.ID,
  34. t.Grade,
  35. t.GradedUser,
  36. t.GradedTime,
  37. t.Remark
  38. ");
  39. strSql.Append(" FROM Acc_Sanitation t ");
  40. strSql.Append(" WHERE 1=1 ");
  41. var queryParam = queryJson.ToJObject();
  42. // 虚拟参数
  43. var dp = new DynamicParameters(new { });
  44. if (!queryParam["RoomID"].IsEmpty())
  45. {
  46. dp.Add("RoomID", queryParam["RoomID"].ToString(), DbType.String);
  47. strSql.Append(" AND t.RoomID =@RoomID ");
  48. }
  49. return this.BaseRepository("CollegeMIS").FindList<Acc_SanitationEntity>(strSql.ToString(), dp, pagination).OrderByDescending(a=>a.GradedTime).ToList();
  50. }
  51. catch (Exception ex)
  52. {
  53. if (ex is ExceptionEx)
  54. {
  55. throw;
  56. }
  57. else
  58. {
  59. throw ExceptionEx.ThrowServiceException(ex);
  60. }
  61. }
  62. }
  63. /// <summary>
  64. /// 获取Acc_Sanitation表实体数据
  65. /// <param name="keyValue">主键</param>
  66. /// <summary>
  67. /// <returns></returns>
  68. public Acc_SanitationEntity GetAcc_SanitationEntity(string keyValue)
  69. {
  70. try
  71. {
  72. return this.BaseRepository("CollegeMIS").FindEntity<Acc_SanitationEntity>(keyValue);
  73. }
  74. catch (Exception ex)
  75. {
  76. if (ex is ExceptionEx)
  77. {
  78. throw;
  79. }
  80. else
  81. {
  82. throw ExceptionEx.ThrowServiceException(ex);
  83. }
  84. }
  85. }
  86. /// <summary>
  87. /// 获取树形数据(不包含床位的树数据)
  88. /// </summary>
  89. /// <returns></returns>
  90. public List<Acc_DormitoryBuildEntity> GetSqlTree()
  91. {
  92. try
  93. {
  94. return this.BaseRepository("CollegeMIS").FindList<Acc_DormitoryBuildEntity>().Where(a=>a.BuildType!="5").OrderBy(a => a.Name).ToList();
  95. }
  96. catch (Exception ex)
  97. {
  98. if (ex is ExceptionEx)
  99. {
  100. throw;
  101. }
  102. else
  103. {
  104. throw ExceptionEx.ThrowServiceException(ex);
  105. }
  106. }
  107. }
  108. #endregion
  109. #region 提交数据
  110. /// <summary>
  111. /// 删除实体数据
  112. /// <param name="keyValue">主键</param>
  113. /// <summary>
  114. /// <returns></returns>
  115. public void DeleteEntity(string keyValue)
  116. {
  117. try
  118. {
  119. this.BaseRepository("CollegeMIS").Delete<Acc_SanitationEntity>(t => t.ID == keyValue);
  120. }
  121. catch (Exception ex)
  122. {
  123. if (ex is ExceptionEx)
  124. {
  125. throw;
  126. }
  127. else
  128. {
  129. throw ExceptionEx.ThrowServiceException(ex);
  130. }
  131. }
  132. }
  133. /// <summary>
  134. /// 保存实体数据(新增、修改)
  135. /// <param name="keyValue">主键</param>
  136. /// <summary>
  137. /// <returns></returns>
  138. public void SaveEntity(string keyValue, Acc_SanitationEntity entity)
  139. {
  140. try
  141. {
  142. if (!string.IsNullOrEmpty(keyValue))
  143. {
  144. entity.Modify(keyValue);
  145. this.BaseRepository("CollegeMIS").Update(entity);
  146. }
  147. else
  148. {
  149. entity.Create();
  150. this.BaseRepository("CollegeMIS").Insert(entity);
  151. }
  152. }
  153. catch (Exception ex)
  154. {
  155. if (ex is ExceptionEx)
  156. {
  157. throw;
  158. }
  159. else
  160. {
  161. throw ExceptionEx.ThrowServiceException(ex);
  162. }
  163. }
  164. }
  165. #endregion
  166. }
  167. }