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.
 
 
 
 
 
 

239 line
8.1 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-04 14:21
  15. /// 描 述:教师销假管理
  16. /// </summary>
  17. public class TeacherCancelLeaveManagementService : 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<TeacherCancelLeaveManagementEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT t.Id as IdInLeave,t.LeaveType,t.StartTime,t.EndTime,t.LeaveDay,t.LeaveReason,t.Telephone,t.CreateUserId as CreateUserIdInLeave,t.CreateTime as CreateTimeInLeave,t.CheckStatus as CheckStatusInLeave,t2.* ");
  32. strSql.Append(" FROM TeacherLeaveManagement t ");
  33. strSql.Append(" left join TeacherCancelLeaveManagement t2 on t.Id=t2.LeaveId ");
  34. strSql.Append(" WHERE 1=1 and t.CheckStatus='2' ");
  35. var queryParam = queryJson.ToJObject();
  36. // 虚拟参数
  37. var dp = new DynamicParameters(new { });
  38. if (!queryParam["CancelLeaveType"].IsEmpty())
  39. {
  40. dp.Add("CancelLeaveType",queryParam["CancelLeaveType"].ToString(), DbType.String);
  41. strSql.Append(" AND t2.CancelLeaveType = @CancelLeaveType ");
  42. }
  43. if (!queryParam["CreateUserId"].IsEmpty())
  44. {
  45. dp.Add("CreateUserId",queryParam["CreateUserId"].ToString(), DbType.String);
  46. strSql.Append(" AND t2.CreateUserId = @CreateUserId ");
  47. }
  48. if (!queryParam["LeaveType"].IsEmpty())
  49. {
  50. dp.Add("LeaveType", queryParam["LeaveType"].ToString(), DbType.String);
  51. strSql.Append(" AND t.LeaveType = @LeaveType ");
  52. }
  53. if (!queryParam["Telephone"].IsEmpty())
  54. {
  55. dp.Add("Telephone", "%" + queryParam["Telephone"].ToString() + "%", DbType.String);
  56. strSql.Append(" AND t.Telephone Like @Telephone ");
  57. }
  58. if (!queryParam["CreateUserIdInLeave"].IsEmpty())
  59. {
  60. dp.Add("CreateUserIdInLeave", queryParam["CreateUserIdInLeave"].ToString(), DbType.String);
  61. strSql.Append(" AND t.CreateUserId = @CreateUserIdInLeave ");
  62. }
  63. return this.BaseRepository("CollegeMIS").FindList<TeacherCancelLeaveManagementEntity>(strSql.ToString(),dp, pagination);
  64. }
  65. catch (Exception ex)
  66. {
  67. if (ex is ExceptionEx)
  68. {
  69. throw;
  70. }
  71. else
  72. {
  73. throw ExceptionEx.ThrowServiceException(ex);
  74. }
  75. }
  76. }
  77. /// <summary>
  78. /// 获取TeacherCancelLeaveManagement表实体数据
  79. /// </summary>
  80. /// <param name="keyValue">主键</param>
  81. /// <returns></returns>
  82. public TeacherCancelLeaveManagementEntity GetTeacherCancelLeaveManagementEntity(string keyValue)
  83. {
  84. try
  85. {
  86. return this.BaseRepository("CollegeMIS").FindEntity<TeacherCancelLeaveManagementEntity>(keyValue);
  87. }
  88. catch (Exception ex)
  89. {
  90. if (ex is ExceptionEx)
  91. {
  92. throw;
  93. }
  94. else
  95. {
  96. throw ExceptionEx.ThrowServiceException(ex);
  97. }
  98. }
  99. }
  100. /// <summary>
  101. /// 获取主表实体数据
  102. /// </summary>
  103. /// <param name="processId">流程实例ID</param>
  104. /// <returns></returns>
  105. public TeacherCancelLeaveManagementEntity GetEntityByProcessId(string processId)
  106. {
  107. try
  108. {
  109. return this.BaseRepository("CollegeMIS").FindEntity<TeacherCancelLeaveManagementEntity>(t=>t.ProcessId == processId);
  110. }
  111. catch (Exception ex)
  112. {
  113. if (ex is ExceptionEx)
  114. {
  115. throw;
  116. }
  117. else
  118. {
  119. throw ExceptionEx.ThrowServiceException(ex);
  120. }
  121. }
  122. }
  123. #endregion
  124. #region 提交数据
  125. /// <summary>
  126. /// 删除实体数据
  127. /// </summary>
  128. /// <param name="keyValue">主键</param>
  129. public void DeleteEntity(string keyValue)
  130. {
  131. try
  132. {
  133. this.BaseRepository("CollegeMIS").Delete<TeacherCancelLeaveManagementEntity>(t=>t.Id == keyValue);
  134. }
  135. catch (Exception ex)
  136. {
  137. if (ex is ExceptionEx)
  138. {
  139. throw;
  140. }
  141. else
  142. {
  143. throw ExceptionEx.ThrowServiceException(ex);
  144. }
  145. }
  146. }
  147. /// <summary>
  148. /// 保存实体数据(新增、修改)
  149. /// </summary>
  150. /// <param name="keyValue">主键</param>
  151. /// <param name="entity">实体</param>
  152. /// <returns></returns>
  153. public void SaveEntity(string keyValue, TeacherCancelLeaveManagementEntity entity)
  154. {
  155. try
  156. {
  157. if (!string.IsNullOrEmpty(keyValue))
  158. {
  159. entity.Modify(keyValue);
  160. this.BaseRepository("CollegeMIS").Update(entity);
  161. }
  162. else
  163. {
  164. entity.Create();
  165. this.BaseRepository("CollegeMIS").Insert(entity);
  166. }
  167. }
  168. catch (Exception ex)
  169. {
  170. if (ex is ExceptionEx)
  171. {
  172. throw;
  173. }
  174. else
  175. {
  176. throw ExceptionEx.ThrowServiceException(ex);
  177. }
  178. }
  179. }
  180. /// <summary>
  181. /// 提交实体数据
  182. /// </summary>
  183. /// <param name="keyValue">主键</param>
  184. public void DoSubmit(string keyValue, string status, string processId)
  185. {
  186. try
  187. {
  188. this.BaseRepository("CollegeMIS").ExecuteBySql("update TeacherCancelLeaveManagement set CheckStatus='" + status + "',ProcessId='" + processId + "' where Id='" + keyValue + "' ");
  189. }
  190. catch (Exception ex)
  191. {
  192. if (ex is ExceptionEx)
  193. {
  194. throw;
  195. }
  196. else
  197. {
  198. throw ExceptionEx.ThrowServiceException(ex);
  199. }
  200. }
  201. }
  202. /// <summary>
  203. /// 审核实体数据
  204. /// </summary>
  205. /// <param name="keyValue">主键</param>
  206. public void ChangeStatusByProcessId(string status, string processId, string userId)
  207. {
  208. try
  209. {
  210. this.BaseRepository("CollegeMIS").ExecuteBySql("update TeacherCancelLeaveManagement set CheckStatus='" + status + "',CheckUserId='" + userId + "',CheckTime='" + DateTime.Now + "' where ProcessId='" + processId + "' ");
  211. }
  212. catch (Exception ex)
  213. {
  214. if (ex is ExceptionEx)
  215. {
  216. throw;
  217. }
  218. else
  219. {
  220. throw ExceptionEx.ThrowServiceException(ex);
  221. }
  222. }
  223. }
  224. #endregion
  225. }
  226. }