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.
 
 
 
 
 
 

229 lines
7.5 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.EducationalAdministration
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  12. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2021-03-26 11:35
  15. /// 描 述:学生销假管理
  16. /// </summary>
  17. public class StuCancelLeaveManagementService : 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<StuCancelLeaveManagementEntity> 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.CreateUserNo as CreateUserNoInLeave,t.CreateUserId as CreateUserIdInLeave,t.CreateTime as CreateTimeInLeave,t.CheckStatus as CheckStatusInLeave,t2.* ");
  32. strSql.Append(" FROM StuLeaveManagement t ");
  33. strSql.Append(" left join StuCancelLeaveManagement 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["LeaveType"].IsEmpty())
  39. {
  40. dp.Add("LeaveType",queryParam["LeaveType"].ToString(), DbType.String);
  41. strSql.Append(" AND t.LeaveType = @LeaveType ");
  42. }
  43. if (!queryParam["CheckStatus"].IsEmpty())
  44. {
  45. dp.Add("CheckStatus", queryParam["CheckStatus"].ToString(), DbType.String);
  46. strSql.Append(" AND t.CheckStatus = @CheckStatus ");
  47. }
  48. if (!queryParam["StuNo"].IsEmpty())
  49. {
  50. dp.Add("StuNo", queryParam["StuNo"].ToString(), DbType.String);
  51. strSql.Append(" AND t2.CreateUserNo = @StuNo ");
  52. }
  53. return this.BaseRepository("CollegeMIS").FindList<StuCancelLeaveManagementEntity>(strSql.ToString(),dp, pagination);
  54. }
  55. catch (Exception ex)
  56. {
  57. if (ex is ExceptionEx)
  58. {
  59. throw;
  60. }
  61. else
  62. {
  63. throw ExceptionEx.ThrowServiceException(ex);
  64. }
  65. }
  66. }
  67. /// <summary>
  68. /// 获取StuCancelLeaveManagement表实体数据
  69. /// </summary>
  70. /// <param name="keyValue">主键</param>
  71. /// <returns></returns>
  72. public StuCancelLeaveManagementEntity GetStuCancelLeaveManagementEntity(string keyValue)
  73. {
  74. try
  75. {
  76. return this.BaseRepository("CollegeMIS").FindEntity<StuCancelLeaveManagementEntity>(keyValue);
  77. }
  78. catch (Exception ex)
  79. {
  80. if (ex is ExceptionEx)
  81. {
  82. throw;
  83. }
  84. else
  85. {
  86. throw ExceptionEx.ThrowServiceException(ex);
  87. }
  88. }
  89. }
  90. /// <summary>
  91. /// 获取主表实体数据
  92. /// </summary>
  93. /// <param name="processId">流程实例ID</param>
  94. /// <returns></returns>
  95. public StuCancelLeaveManagementEntity GetEntityByProcessId(string processId)
  96. {
  97. try
  98. {
  99. return this.BaseRepository("CollegeMIS").FindEntity<StuCancelLeaveManagementEntity>(t => t.ProcessId == processId);
  100. }
  101. catch (Exception ex)
  102. {
  103. if (ex is ExceptionEx)
  104. {
  105. throw;
  106. }
  107. else
  108. {
  109. throw ExceptionEx.ThrowServiceException(ex);
  110. }
  111. }
  112. }
  113. #endregion
  114. #region 提交数据
  115. /// <summary>
  116. /// 删除实体数据
  117. /// </summary>
  118. /// <param name="keyValue">主键</param>
  119. public void DeleteEntity(string keyValue)
  120. {
  121. try
  122. {
  123. this.BaseRepository("CollegeMIS").Delete<StuCancelLeaveManagementEntity>(t=>t.Id == keyValue);
  124. }
  125. catch (Exception ex)
  126. {
  127. if (ex is ExceptionEx)
  128. {
  129. throw;
  130. }
  131. else
  132. {
  133. throw ExceptionEx.ThrowServiceException(ex);
  134. }
  135. }
  136. }
  137. /// <summary>
  138. /// 保存实体数据(新增、修改)
  139. /// </summary>
  140. /// <param name="keyValue">主键</param>
  141. /// <param name="entity">实体</param>
  142. public void SaveEntity(string keyValue, StuCancelLeaveManagementEntity 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 StuCancelLeaveManagement 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 StuCancelLeaveManagement 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. }