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.

StuLeaveManagementService.cs 10 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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 ");
  33. //strSql.Append("SELECT t.*,s.StuName as CreateUserName,s.ClassNo,s.DeptNo,s.MajorNo,c.ClassDiredctorNo,c.ClassTutorNo ");
  34. strSql.Append(" FROM StuLeaveManagement t ");
  35. strSql.Append(" left join StuInfoBasic s on t.CreateUserNo=s.StuNo ");
  36. //strSql.Append(" left join ClassInfo c on s.ClassNo=c.ClassNo ");
  37. strSql.Append(" WHERE 1=1 ");
  38. var queryParam = queryJson.ToJObject();
  39. // 虚拟参数
  40. var dp = new DynamicParameters(new { });
  41. if (!queryParam["LeaveType"].IsEmpty())
  42. {
  43. dp.Add("LeaveType", queryParam["LeaveType"].ToString(), DbType.String);
  44. strSql.Append(" AND t.LeaveType = @LeaveType ");
  45. }
  46. if (!queryParam["CheckStatus"].IsEmpty())
  47. {
  48. dp.Add("CheckStatus", queryParam["CheckStatus"].ToString(), DbType.String);
  49. strSql.Append(" AND t.CheckStatus = @CheckStatus ");
  50. }
  51. if (!queryParam["StuNo"].IsEmpty())
  52. {
  53. dp.Add("StuNo", queryParam["StuNo"].ToString(), DbType.String);
  54. strSql.Append(" AND t.CreateUserNo = @StuNo ");
  55. }
  56. //班级班主任/辅导员/系主任
  57. //if (!queryParam["ClassManagerNo"].IsEmpty())
  58. //{
  59. // dp.Add("ClassManagerNo", queryParam["ClassManagerNo"].ToString(), DbType.String);
  60. // strSql.Append(" AND (c.ClassDiredctorNo = @ClassManagerNo or c.ClassTutorNo = @ClassManagerNo ");
  61. // //登录用户是否是系主任:若是,展示大于2天的请假记录;
  62. // var deptDirectorRoleId = Config.GetValue("DeptDirectorRoleId");
  63. // if (deptDirectorRoleId != null)
  64. // {
  65. // var loginInfoRoleIds = LoginUserInfo.Get().roleIds;
  66. // if (loginInfoRoleIds.IndexOf(',') == -1)
  67. // {
  68. // if (loginInfoRoleIds == deptDirectorRoleId)
  69. // {
  70. // strSql.Append(" or t.LeaveDay>2 )");
  71. // }
  72. // else
  73. // {
  74. // strSql.Append(" ) ");
  75. // }
  76. // }
  77. // else
  78. // {
  79. // if (loginInfoRoleIds.Split(',').Contains(deptDirectorRoleId))
  80. // {
  81. // strSql.Append(" or t.LeaveDay>2 )");
  82. // }
  83. // else
  84. // {
  85. // strSql.Append(" ) ");
  86. // }
  87. // }
  88. // }
  89. // else
  90. // {
  91. // strSql.Append(" ) ");
  92. // }
  93. //}
  94. return this.BaseRepository("CollegeMIS").FindList<StuLeaveManagementEntity>(strSql.ToString(), dp, pagination);
  95. }
  96. catch (Exception ex)
  97. {
  98. if (ex is ExceptionEx)
  99. {
  100. throw;
  101. }
  102. else
  103. {
  104. throw ExceptionEx.ThrowServiceException(ex);
  105. }
  106. }
  107. }
  108. /// <summary>
  109. /// 获取StuLeaveManagement表实体数据
  110. /// </summary>
  111. /// <param name="keyValue">主键</param>
  112. /// <returns></returns>
  113. public StuLeaveManagementEntity GetStuLeaveManagementEntity(string keyValue)
  114. {
  115. try
  116. {
  117. return this.BaseRepository("CollegeMIS").FindEntity<StuLeaveManagementEntity>(keyValue);
  118. }
  119. catch (Exception ex)
  120. {
  121. if (ex is ExceptionEx)
  122. {
  123. throw;
  124. }
  125. else
  126. {
  127. throw ExceptionEx.ThrowServiceException(ex);
  128. }
  129. }
  130. }
  131. /// <summary>
  132. /// 获取主表实体数据
  133. /// </summary>
  134. /// <param name="processId">流程实例ID</param>
  135. /// <returns></returns>
  136. public StuLeaveManagementEntity GetEntityByProcessId(string processId)
  137. {
  138. try
  139. {
  140. return this.BaseRepository("CollegeMIS").FindEntity<StuLeaveManagementEntity>(t => t.ProcessId == processId);
  141. }
  142. catch (Exception ex)
  143. {
  144. if (ex is ExceptionEx)
  145. {
  146. throw;
  147. }
  148. else
  149. {
  150. throw ExceptionEx.ThrowServiceException(ex);
  151. }
  152. }
  153. }
  154. #endregion
  155. #region 提交数据
  156. /// <summary>
  157. /// 删除实体数据
  158. /// </summary>
  159. /// <param name="keyValue">主键</param>
  160. public void DeleteEntity(string keyValue)
  161. {
  162. try
  163. {
  164. this.BaseRepository("CollegeMIS").Delete<StuLeaveManagementEntity>(t => t.Id == keyValue);
  165. }
  166. catch (Exception ex)
  167. {
  168. if (ex is ExceptionEx)
  169. {
  170. throw;
  171. }
  172. else
  173. {
  174. throw ExceptionEx.ThrowServiceException(ex);
  175. }
  176. }
  177. }
  178. /// <summary>
  179. /// 保存实体数据(新增、修改)
  180. /// </summary>
  181. /// <param name="keyValue">主键</param>
  182. /// <param name="entity">实体</param>
  183. public void SaveEntity(string keyValue, StuLeaveManagementEntity entity)
  184. {
  185. try
  186. {
  187. if (!string.IsNullOrEmpty(keyValue))
  188. {
  189. entity.Modify(keyValue);
  190. this.BaseRepository("CollegeMIS").Update(entity);
  191. }
  192. else
  193. {
  194. entity.Create();
  195. this.BaseRepository("CollegeMIS").Insert(entity);
  196. }
  197. }
  198. catch (Exception ex)
  199. {
  200. if (ex is ExceptionEx)
  201. {
  202. throw;
  203. }
  204. else
  205. {
  206. throw ExceptionEx.ThrowServiceException(ex);
  207. }
  208. }
  209. }
  210. /// <summary>
  211. /// 提交实体数据
  212. /// </summary>
  213. /// <param name="keyValue">主键</param>
  214. public void DoSubmit(string keyValue, string status, string processId)
  215. {
  216. try
  217. {
  218. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuLeaveManagement set CheckStatus='" + status + "',ProcessId='" + processId + "' where Id='" + keyValue + "' ");
  219. }
  220. catch (Exception ex)
  221. {
  222. if (ex is ExceptionEx)
  223. {
  224. throw;
  225. }
  226. else
  227. {
  228. throw ExceptionEx.ThrowServiceException(ex);
  229. }
  230. }
  231. }
  232. /// <summary>
  233. /// 审核实体数据
  234. /// </summary>
  235. /// <param name="keyValue">主键</param>
  236. public void ChangeStatusByProcessId(string status, string processId, string userId)
  237. {
  238. try
  239. {
  240. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuLeaveManagement set CheckStatus='" + status + "',CheckUserId='" + userId + "',CheckTime='" + DateTime.Now + "' where ProcessId='" + processId + "' ");
  241. }
  242. catch (Exception ex)
  243. {
  244. if (ex is ExceptionEx)
  245. {
  246. throw;
  247. }
  248. else
  249. {
  250. throw ExceptionEx.ThrowServiceException(ex);
  251. }
  252. }
  253. }
  254. #endregion
  255. /// <summary>
  256. /// 未销假次数
  257. /// </summary>
  258. /// <param name="CreateUserNo"></param>
  259. /// <returns></returns>
  260. public int CreateUserNo(string CreateUserNo)
  261. {
  262. try
  263. {
  264. var HisTime = DateTime.Now.AddDays(-30);
  265. StringBuilder sb = new StringBuilder();
  266. sb.Append(@"SELECT count(*) as num FROM StuLeaveManagement t
  267. left join StuCancelLeaveManagement t2 on t.Id=t2.LeaveId WHERE 1=1 and(t2.CheckStatus !=2 or t2.CheckStatus is null)
  268. and t.checktime <='" + DateTime.Now + "' and t.checktime >='" + HisTime + "' and t.CreateUserNo='" + CreateUserNo + "' ");
  269. var data = this.BaseRepository("CollegeMIS").FindList<StuLeaveManagementEntity>(sb.ToString());
  270. if (data.Count() > 0)
  271. {
  272. foreach (var item in data)
  273. {
  274. return Convert.ToInt32(item.num);
  275. }
  276. }
  277. return 0;
  278. }
  279. catch (Exception e)
  280. {
  281. Console.WriteLine(e);
  282. throw;
  283. }
  284. }
  285. }
  286. }