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.
 
 
 
 
 
 

284 lines
9.9 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. if (!queryParam["users"].IsEmpty())
  54. {
  55. dp.Add("users", queryParam["users"].ToString(), DbType.String);
  56. strSql.Append(" AND t.CreateUserNo = @users ");
  57. }
  58. return this.BaseRepository("CollegeMIS").FindList<StuCancelLeaveManagementEntity>(strSql.ToString(),dp, pagination);
  59. }
  60. catch (Exception ex)
  61. {
  62. if (ex is ExceptionEx)
  63. {
  64. throw;
  65. }
  66. else
  67. {
  68. throw ExceptionEx.ThrowServiceException(ex);
  69. }
  70. }
  71. }
  72. /// <summary>
  73. /// 统计
  74. /// </summary>
  75. /// <param name="queryJson">查询参数</param>
  76. /// <returns></returns>
  77. public IEnumerable<StuCancelLeaveManagementEntity> GetPageList( string queryJson)
  78. {
  79. try
  80. {
  81. var strSql = new StringBuilder();
  82. strSql.Append(@"select t.iscampus,t.IsStay,t.leavetype,t.leaveday,s.classno,s.majorno,s.deptno from StuLeaveManagement t
  83. left join stuinfobasic s on s.stuno = t.createuserno ");
  84. strSql.Append(" WHERE 1=1 and t.CheckStatus='2' ");
  85. var queryParam = queryJson.ToJObject();
  86. // 虚拟参数
  87. var dp = new DynamicParameters(new { });
  88. if (!queryParam["LeaveType"].IsEmpty())
  89. {
  90. dp.Add("LeaveType", queryParam["LeaveType"].ToString(), DbType.String);
  91. strSql.Append(" AND t.LeaveType = @LeaveType ");
  92. }
  93. if (!queryParam["ClassNo"].IsEmpty())
  94. {
  95. dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
  96. strSql.Append(" AND s.ClassNo = @ClassNo ");
  97. }
  98. if (!queryParam["MajorNo"].IsEmpty())
  99. {
  100. dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
  101. strSql.Append(" AND s.MajorNo = @MajorNo ");
  102. }
  103. if (!queryParam["DeptNo"].IsEmpty())
  104. {
  105. dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
  106. strSql.Append(" AND s.DeptNo = @DeptNo ");
  107. }
  108. strSql.Append("Group by t.iscampus,t.IsStay,t.leavetype,t.leaveday,s.classno,s.majorno,s.deptno ");
  109. return this.BaseRepository("CollegeMIS").FindList<StuCancelLeaveManagementEntity>(strSql.ToString(), dp);
  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. /// <summary>
  124. /// 获取StuCancelLeaveManagement表实体数据
  125. /// </summary>
  126. /// <param name="keyValue">主键</param>
  127. /// <returns></returns>
  128. public StuCancelLeaveManagementEntity GetStuCancelLeaveManagementEntity(string keyValue)
  129. {
  130. try
  131. {
  132. return this.BaseRepository("CollegeMIS").FindEntity<StuCancelLeaveManagementEntity>(keyValue);
  133. }
  134. catch (Exception ex)
  135. {
  136. if (ex is ExceptionEx)
  137. {
  138. throw;
  139. }
  140. else
  141. {
  142. throw ExceptionEx.ThrowServiceException(ex);
  143. }
  144. }
  145. }
  146. /// <summary>
  147. /// 获取主表实体数据
  148. /// </summary>
  149. /// <param name="processId">流程实例ID</param>
  150. /// <returns></returns>
  151. public StuCancelLeaveManagementEntity GetEntityByProcessId(string processId)
  152. {
  153. try
  154. {
  155. return this.BaseRepository("CollegeMIS").FindEntity<StuCancelLeaveManagementEntity>(t => t.ProcessId == processId);
  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. #endregion
  170. #region 提交数据
  171. /// <summary>
  172. /// 删除实体数据
  173. /// </summary>
  174. /// <param name="keyValue">主键</param>
  175. public void DeleteEntity(string keyValue)
  176. {
  177. try
  178. {
  179. this.BaseRepository("CollegeMIS").Delete<StuCancelLeaveManagementEntity>(t=>t.Id == keyValue);
  180. }
  181. catch (Exception ex)
  182. {
  183. if (ex is ExceptionEx)
  184. {
  185. throw;
  186. }
  187. else
  188. {
  189. throw ExceptionEx.ThrowServiceException(ex);
  190. }
  191. }
  192. }
  193. /// <summary>
  194. /// 保存实体数据(新增、修改)
  195. /// </summary>
  196. /// <param name="keyValue">主键</param>
  197. /// <param name="entity">实体</param>
  198. public void SaveEntity(string keyValue, StuCancelLeaveManagementEntity entity)
  199. {
  200. try
  201. {
  202. if (!string.IsNullOrEmpty(keyValue))
  203. {
  204. entity.Modify(keyValue);
  205. this.BaseRepository("CollegeMIS").Update(entity);
  206. }
  207. else
  208. {
  209. entity.Create();
  210. this.BaseRepository("CollegeMIS").Insert(entity);
  211. }
  212. }
  213. catch (Exception ex)
  214. {
  215. if (ex is ExceptionEx)
  216. {
  217. throw;
  218. }
  219. else
  220. {
  221. throw ExceptionEx.ThrowServiceException(ex);
  222. }
  223. }
  224. }
  225. /// <summary>
  226. /// 提交实体数据
  227. /// </summary>
  228. /// <param name="keyValue">主键</param>
  229. public void DoSubmit(string keyValue, string status, string processId)
  230. {
  231. try
  232. {
  233. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuCancelLeaveManagement set CheckStatus='" + status + "',ProcessId='" + processId + "' where Id='" + keyValue + "' ");
  234. }
  235. catch (Exception ex)
  236. {
  237. if (ex is ExceptionEx)
  238. {
  239. throw;
  240. }
  241. else
  242. {
  243. throw ExceptionEx.ThrowServiceException(ex);
  244. }
  245. }
  246. }
  247. /// <summary>
  248. /// 审核实体数据
  249. /// </summary>
  250. /// <param name="keyValue">主键</param>
  251. public void ChangeStatusByProcessId(string status, string processId, string userId)
  252. {
  253. try
  254. {
  255. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuCancelLeaveManagement set CheckStatus='" + status + "',CheckUserId='" + userId + "',CheckTime='" + DateTime.Now + "' where ProcessId='" + processId + "' ");
  256. }
  257. catch (Exception ex)
  258. {
  259. if (ex is ExceptionEx)
  260. {
  261. throw;
  262. }
  263. else
  264. {
  265. throw ExceptionEx.ThrowServiceException(ex);
  266. }
  267. }
  268. }
  269. #endregion
  270. }
  271. }