Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

179 lignes
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.Text;
  8. namespace Learun.Application.TwoDevelopment.PersonnelManagement
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-11-19 15:30
  15. /// 描 述:值班安排
  16. /// </summary>
  17. public class DutyScheduleService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<DutyScheduleEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. var adms = this.BaseRepository().getDbConnection().Database;
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@" t.* ,u.F_Account,u.F_RealName ");
  33. strSql.Append($" FROM DutySchedule t left join {adms}.dbo.LR_Base_User u on t.Person=u.F_UserId ");
  34. strSql.Append(" WHERE 1=1 ");
  35. var queryParam = queryJson.ToJObject();
  36. // 虚拟参数
  37. var dp = new DynamicParameters(new { });
  38. if (!queryParam["keyword"].IsEmpty())
  39. {
  40. dp.Add("keyword", "%" + queryParam["keyword"].ToString() + "%", DbType.String);
  41. strSql.Append(" AND u.F_RealName Like @keyword ");
  42. }
  43. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  44. {
  45. dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  46. dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
  47. strSql.Append(" AND ( t.StartTime >= @startTime AND t.EndTime <= @endTime ) ");
  48. }
  49. return this.BaseRepository("CollegeMIS").FindList<DutyScheduleEntity>(strSql.ToString(), dp, pagination);
  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. /// 获取DutySchedule表实体数据
  65. /// <param name="keyValue">主键</param>
  66. /// <summary>
  67. /// <returns></returns>
  68. public DutyScheduleEntity GetDutyScheduleEntity(string keyValue)
  69. {
  70. try
  71. {
  72. return this.BaseRepository("CollegeMIS").FindEntity<DutyScheduleEntity>(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 IEnumerable<DutyScheduleEntity> GetList()
  91. {
  92. try
  93. {
  94. var adms = this.BaseRepository().getDbConnection().Database;
  95. var strSql = new StringBuilder();
  96. strSql.Append("SELECT ");
  97. strSql.Append(@" t.*, u.F_Account,F_RealName ");
  98. strSql.Append($" FROM DutySchedule t left join {adms}.dbo.LR_Base_User u on t.Person=u.F_UserId ");
  99. return this.BaseRepository("CollegeMIS").FindList<DutyScheduleEntity>(strSql.ToString());
  100. }
  101. catch (Exception ex)
  102. {
  103. if (ex is ExceptionEx)
  104. throw;
  105. else
  106. throw ExceptionEx.ThrowServiceException(ex);
  107. }
  108. }
  109. #endregion
  110. #region 提交数据
  111. /// <summary>
  112. /// 删除实体数据
  113. /// <param name="keyValue">主键</param>
  114. /// <summary>
  115. /// <returns></returns>
  116. public void DeleteEntity(string keyValue)
  117. {
  118. try
  119. {
  120. this.BaseRepository("CollegeMIS").Delete<DutyScheduleEntity>(t => t.ID == keyValue);
  121. }
  122. catch (Exception ex)
  123. {
  124. if (ex is ExceptionEx)
  125. {
  126. throw;
  127. }
  128. else
  129. {
  130. throw ExceptionEx.ThrowServiceException(ex);
  131. }
  132. }
  133. }
  134. /// <summary>
  135. /// 保存实体数据(新增、修改)
  136. /// <param name="keyValue">主键</param>
  137. /// <summary>
  138. /// <returns></returns>
  139. public void SaveEntity(string keyValue, DutyScheduleEntity entity)
  140. {
  141. try
  142. {
  143. if (!string.IsNullOrEmpty(keyValue))
  144. {
  145. entity.Modify(keyValue);
  146. this.BaseRepository("CollegeMIS").Update(entity);
  147. }
  148. else
  149. {
  150. entity.Create();
  151. entity.CreateTime = DateTime.Now;
  152. this.BaseRepository("CollegeMIS").Insert(entity);
  153. }
  154. }
  155. catch (Exception ex)
  156. {
  157. if (ex is ExceptionEx)
  158. {
  159. throw;
  160. }
  161. else
  162. {
  163. throw ExceptionEx.ThrowServiceException(ex);
  164. }
  165. }
  166. }
  167. #endregion
  168. }
  169. }