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.
 
 
 
 
 
 

228 lines
7.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.Text;
  8. namespace Learun.Application.TwoDevelopment.PersonnelManagement
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  12. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2021-03-03 11:29
  15. /// 描 述:教师请假管理
  16. /// </summary>
  17. public class TeacherLeaveManagementService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// </summary>
  23. /// <param name="pagination">分页参数</param>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<TeacherLeaveManagementEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT t.* ");
  32. strSql.Append(" FROM TeacherLeaveManagement t ");
  33. strSql.Append(" WHERE 1=1 ");
  34. var queryParam = queryJson.ToJObject();
  35. // 虚拟参数
  36. var dp = new DynamicParameters(new { });
  37. if (!queryParam["LeaveType"].IsEmpty())
  38. {
  39. dp.Add("LeaveType", queryParam["LeaveType"].ToString(), DbType.String);
  40. strSql.Append(" AND t.LeaveType = @LeaveType ");
  41. }
  42. if (!queryParam["CreateUserId"].IsEmpty())
  43. {
  44. dp.Add("CreateUserId", queryParam["CreateUserId"].ToString(), DbType.String);
  45. strSql.Append(" AND t.CreateUserId = @CreateUserId ");
  46. }
  47. if (!queryParam["Telephone"].IsEmpty())
  48. {
  49. dp.Add("Telephone", "%" + queryParam["Telephone"].ToString() + "%", DbType.String);
  50. strSql.Append(" AND t.Telephone Like @Telephone ");
  51. }
  52. return this.BaseRepository("CollegeMIS").FindList<TeacherLeaveManagementEntity>(strSql.ToString(), dp, pagination);
  53. }
  54. catch (Exception ex)
  55. {
  56. if (ex is ExceptionEx)
  57. {
  58. throw;
  59. }
  60. else
  61. {
  62. throw ExceptionEx.ThrowServiceException(ex);
  63. }
  64. }
  65. }
  66. /// <summary>
  67. /// 获取TeacherLeaveManagement表实体数据
  68. /// </summary>
  69. /// <param name="keyValue">主键</param>
  70. /// <returns></returns>
  71. public TeacherLeaveManagementEntity GetTeacherLeaveManagementEntity(string keyValue)
  72. {
  73. try
  74. {
  75. return this.BaseRepository("CollegeMIS").FindEntity<TeacherLeaveManagementEntity>(keyValue);
  76. }
  77. catch (Exception ex)
  78. {
  79. if (ex is ExceptionEx)
  80. {
  81. throw;
  82. }
  83. else
  84. {
  85. throw ExceptionEx.ThrowServiceException(ex);
  86. }
  87. }
  88. }
  89. /// <summary>
  90. /// 获取主表实体数据
  91. /// </summary>
  92. /// <param name="processId">流程实例ID</param>
  93. /// <returns></returns>
  94. public TeacherLeaveManagementEntity GetEntityByProcessId(string processId)
  95. {
  96. try
  97. {
  98. return this.BaseRepository("CollegeMIS").FindEntity<TeacherLeaveManagementEntity>(t => t.ProcessId == processId);
  99. }
  100. catch (Exception ex)
  101. {
  102. if (ex is ExceptionEx)
  103. {
  104. throw;
  105. }
  106. else
  107. {
  108. throw ExceptionEx.ThrowServiceException(ex);
  109. }
  110. }
  111. }
  112. #endregion
  113. #region 提交数据
  114. /// <summary>
  115. /// 删除实体数据
  116. /// </summary>
  117. /// <param name="keyValue">主键</param>
  118. public void DeleteEntity(string keyValue)
  119. {
  120. try
  121. {
  122. this.BaseRepository("CollegeMIS").Delete<TeacherLeaveManagementEntity>(t => t.Id == keyValue);
  123. }
  124. catch (Exception ex)
  125. {
  126. if (ex is ExceptionEx)
  127. {
  128. throw;
  129. }
  130. else
  131. {
  132. throw ExceptionEx.ThrowServiceException(ex);
  133. }
  134. }
  135. }
  136. /// <summary>
  137. /// 保存实体数据(新增、修改)
  138. /// </summary>
  139. /// <param name="keyValue">主键</param>
  140. /// <param name="entity">实体</param>
  141. /// <returns></returns>
  142. public void SaveEntity(string keyValue, TeacherLeaveManagementEntity entity)
  143. {
  144. try
  145. {
  146. if (!string.IsNullOrEmpty(keyValue))
  147. {
  148. entity.Modify(keyValue);
  149. this.BaseRepository("CollegeMIS").Update(entity);
  150. }
  151. else
  152. {
  153. entity.Create();
  154. this.BaseRepository("CollegeMIS").Insert(entity);
  155. }
  156. }
  157. catch (Exception ex)
  158. {
  159. if (ex is ExceptionEx)
  160. {
  161. throw;
  162. }
  163. else
  164. {
  165. throw ExceptionEx.ThrowServiceException(ex);
  166. }
  167. }
  168. }
  169. /// <summary>
  170. /// 提交实体数据
  171. /// </summary>
  172. /// <param name="keyValue">主键</param>
  173. public void DoSubmit(string keyValue, string status, string processId)
  174. {
  175. try
  176. {
  177. this.BaseRepository("CollegeMIS").ExecuteBySql("update TeacherLeaveManagement set CheckStatus='" + status + "',ProcessId='" + processId + "' where Id='" + keyValue + "' ");
  178. }
  179. catch (Exception ex)
  180. {
  181. if (ex is ExceptionEx)
  182. {
  183. throw;
  184. }
  185. else
  186. {
  187. throw ExceptionEx.ThrowServiceException(ex);
  188. }
  189. }
  190. }
  191. /// <summary>
  192. /// 审核实体数据
  193. /// </summary>
  194. /// <param name="keyValue">主键</param>
  195. public void ChangeStatusByProcessId(string status, string processId, string userId)
  196. {
  197. try
  198. {
  199. this.BaseRepository("CollegeMIS").ExecuteBySql("update TeacherLeaveManagement set CheckStatus='" + status + "',CheckUserId='" + userId + "',CheckTime='" + DateTime.Now + "' where ProcessId='" + processId + "' ");
  200. }
  201. catch (Exception ex)
  202. {
  203. if (ex is ExceptionEx)
  204. {
  205. throw;
  206. }
  207. else
  208. {
  209. throw ExceptionEx.ThrowServiceException(ex);
  210. }
  211. }
  212. }
  213. #endregion
  214. }
  215. }