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.
 
 
 
 
 
 

181 lines
5.8 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 fb.* ,zb.ID zbid,zb.AType,zb.Grade,zb.GradedUser,zb.GradedTime,zb.Remark demo from Acc_Sanitation zb
  32. left join(
  33. select ci.*, ad.* from Acc_DormitoryBuild ad
  34. left join (
  35. select aa.classno ,aa.classname,fb1.empno as empnoone,fb1.Mobile as MobileOne,
  36. fb2.empno empnoTwo,fb2.Mobile as MobileTwo from classinfo aa
  37. left join empinfo fb1 on aa.classdiredctorno = fb1.EmpNo
  38. left join empinfo fb2 on aa.ClassTutorNo = fb2.EmpNo
  39. )ci on ci.classno = ad.class
  40. )fb on zb.roomid = fb.id 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 zb.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. var loginuser = LoginUserInfo.Get();
  143. entity.CreateUser = loginuser.realName;
  144. entity.CreateTime = DateTime.Now;
  145. if (!string.IsNullOrEmpty(keyValue))
  146. {
  147. entity.Modify(keyValue);
  148. this.BaseRepository("CollegeMIS").Update(entity);
  149. }
  150. else
  151. {
  152. entity.Create();
  153. this.BaseRepository("CollegeMIS").Insert(entity);
  154. }
  155. }
  156. catch (Exception ex)
  157. {
  158. if (ex is ExceptionEx)
  159. {
  160. throw;
  161. }
  162. else
  163. {
  164. throw ExceptionEx.ThrowServiceException(ex);
  165. }
  166. }
  167. }
  168. #endregion
  169. }
  170. }