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.
 
 
 
 
 
 

196 lines
6.7 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.EducationalAdministration
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  13. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2020-11-27 10:05
  16. /// 描 述:学生请假管理
  17. /// </summary>
  18. public class StuLeaveManagementService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// </summary>
  24. /// <param name="pagination">查询参数</param>
  25. /// <param name="queryJson">查询参数</param>
  26. /// <returns></returns>
  27. public IEnumerable<StuLeaveManagementEntity> GetPageList(Pagination pagination, string queryJson)
  28. {
  29. try
  30. {
  31. var strSql = new StringBuilder();
  32. strSql.Append("SELECT t.*,s.StuName as CreateUserName,s.ClassNo,s.DeptNo,s.MajorNo,c.ClassDiredctorNo,c.ClassTutorNo ");
  33. strSql.Append(" FROM StuLeaveManagement t left join StuInfoBasic s on t.CreateUserNo=s.StuNo left join ClassInfo c on s.ClassNo=c.ClassNo ");
  34. strSql.Append(" WHERE 1=1 ");
  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 t.CreateUserNo = @StuNo ");
  52. }
  53. //班级班主任/辅导员/系主任
  54. if (!queryParam["ClassManagerNo"].IsEmpty())
  55. {
  56. dp.Add("ClassManagerNo", queryParam["ClassManagerNo"].ToString(), DbType.String);
  57. strSql.Append(" AND (c.ClassDiredctorNo = @ClassManagerNo or c.ClassTutorNo = @ClassManagerNo ");
  58. //登录用户是否是系主任:若是,展示大于2天的请假记录;
  59. var deptDirectorRoleId = Config.GetValue("DeptDirectorRoleId");
  60. if (deptDirectorRoleId != null)
  61. {
  62. var loginInfoRoleIds = LoginUserInfo.Get().roleIds;
  63. if (loginInfoRoleIds.IndexOf(',') == -1)
  64. {
  65. if (loginInfoRoleIds == deptDirectorRoleId)
  66. {
  67. strSql.Append(" or t.LeaveDay>2 )");
  68. }
  69. else
  70. {
  71. strSql.Append(" ) ");
  72. }
  73. }
  74. else
  75. {
  76. if (loginInfoRoleIds.Split(',').Contains(deptDirectorRoleId))
  77. {
  78. strSql.Append(" or t.LeaveDay>2 )");
  79. }
  80. else
  81. {
  82. strSql.Append(" ) ");
  83. }
  84. }
  85. }
  86. else
  87. {
  88. strSql.Append(" ) ");
  89. }
  90. }
  91. return this.BaseRepository("CollegeMIS").FindList<StuLeaveManagementEntity>(strSql.ToString(),dp, pagination);
  92. }
  93. catch (Exception ex)
  94. {
  95. if (ex is ExceptionEx)
  96. {
  97. throw;
  98. }
  99. else
  100. {
  101. throw ExceptionEx.ThrowServiceException(ex);
  102. }
  103. }
  104. }
  105. /// <summary>
  106. /// 获取StuLeaveManagement表实体数据
  107. /// </summary>
  108. /// <param name="keyValue">主键</param>
  109. /// <returns></returns>
  110. public StuLeaveManagementEntity GetStuLeaveManagementEntity(string keyValue)
  111. {
  112. try
  113. {
  114. return this.BaseRepository("CollegeMIS").FindEntity<StuLeaveManagementEntity>(keyValue);
  115. }
  116. catch (Exception ex)
  117. {
  118. if (ex is ExceptionEx)
  119. {
  120. throw;
  121. }
  122. else
  123. {
  124. throw ExceptionEx.ThrowServiceException(ex);
  125. }
  126. }
  127. }
  128. #endregion
  129. #region 提交数据
  130. /// <summary>
  131. /// 删除实体数据
  132. /// </summary>
  133. /// <param name="keyValue">主键</param>
  134. public void DeleteEntity(string keyValue)
  135. {
  136. try
  137. {
  138. this.BaseRepository("CollegeMIS").Delete<StuLeaveManagementEntity>(t=>t.Id == keyValue);
  139. }
  140. catch (Exception ex)
  141. {
  142. if (ex is ExceptionEx)
  143. {
  144. throw;
  145. }
  146. else
  147. {
  148. throw ExceptionEx.ThrowServiceException(ex);
  149. }
  150. }
  151. }
  152. /// <summary>
  153. /// 保存实体数据(新增、修改)
  154. /// </summary>
  155. /// <param name="keyValue">主键</param>
  156. /// <param name="entity">实体</param>
  157. public void SaveEntity(string keyValue, StuLeaveManagementEntity entity)
  158. {
  159. try
  160. {
  161. if (!string.IsNullOrEmpty(keyValue))
  162. {
  163. entity.Modify(keyValue);
  164. this.BaseRepository("CollegeMIS").Update(entity);
  165. }
  166. else
  167. {
  168. entity.Create();
  169. this.BaseRepository("CollegeMIS").Insert(entity);
  170. }
  171. }
  172. catch (Exception ex)
  173. {
  174. if (ex is ExceptionEx)
  175. {
  176. throw;
  177. }
  178. else
  179. {
  180. throw ExceptionEx.ThrowServiceException(ex);
  181. }
  182. }
  183. }
  184. #endregion
  185. }
  186. }