Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

239 linhas
8.0 KiB

  1. using Nancy;
  2. using Learun.Util;
  3. using System.Collections.Generic;
  4. using Learun.Application.TwoDevelopment.EducationalAdministration;
  5. using static Learun.Application.WebApi.Modules.StuInfoFreshApi;
  6. using System;
  7. using System.IO;
  8. using System.Linq;
  9. using Learun.Application.Base.SystemModule;
  10. using Learun.Application.OA;
  11. using Learun.Application.OA.File.FileInfo;
  12. using Learun.Application.TwoDevelopment.LogisticsManagement;
  13. using Learun.Application.TwoDevelopment.LR_Desktop;
  14. using Learun.Application.WorkFlow;
  15. using Microsoft.Ajax.Utilities;
  16. namespace Learun.Application.WebApi
  17. {
  18. ///2022.11.14
  19. /// <summary>
  20. /// 学生请假
  21. /// </summary>
  22. public class StuLeaveManagementApi : BaseApi
  23. {
  24. private StuLeaveManagementIBLL stuLeaveManagementIBLL = new StuLeaveManagementBLL();
  25. private NWFProcessIBLL nWFProcessIBLL = new NWFProcessBLL();
  26. /// <summary>
  27. /// 注册接口
  28. /// <summary>
  29. public StuLeaveManagementApi()
  30. : base("/Learun/adms/EducationalAdministration/StuLeaveManagement")
  31. {
  32. Get["/pagelist"] = GetPageList;
  33. Get["/form"] = GetForm;
  34. Post["/delete"] = DeleteForm;
  35. Post["/save"] = SaveForm;
  36. //判断是否可以审核
  37. Get["/ischeck"] = IsCheck;
  38. //学生请假--教师审核列表
  39. Get["/checkpagelist"] = GetCheckPageList;
  40. //审核学生请假
  41. Post["/savecheck"] = SaveCheckForm;
  42. Post["/submit"] = Submit;
  43. Get["/shList"] = GetshList;
  44. }
  45. #region 获取数据
  46. /// <summary>
  47. /// 获取页面显示列表分页数据
  48. /// <summary>
  49. /// <param name="_"></param>
  50. /// <returns></returns>
  51. public Response GetPageList(dynamic _)
  52. {
  53. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  54. var data = stuLeaveManagementIBLL.GetPageList(parameter.pagination, parameter.queryJson);
  55. var jsonData = new
  56. {
  57. rows = data,
  58. total = parameter.pagination.total,
  59. page = parameter.pagination.page,
  60. records = parameter.pagination.records
  61. };
  62. return Success(jsonData);
  63. }
  64. /// <summary>
  65. /// 获取页面显示列表数据
  66. /// <summary>
  67. /// <param name="_"></param>
  68. /// <returns></returns>
  69. public Response GetshList(dynamic _)
  70. {
  71. StuLeaveManagementEntity parameter = this.GetReqData<StuLeaveManagementEntity>();
  72. var stuLeaveManagementData = stuLeaveManagementIBLL.GetEntityByProcessId(parameter.ProcessId);
  73. var jsonData = new
  74. {
  75. stuLeaveManagement = stuLeaveManagementData,
  76. };
  77. return Success(jsonData);
  78. }
  79. /// <summary>
  80. /// 学生请假--教师审核列表
  81. /// <summary>
  82. /// <param name="_"></param>
  83. /// <returns></returns>
  84. public Response GetCheckPageList(dynamic _)
  85. {
  86. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  87. var data = stuLeaveManagementIBLL.GetCheckPageList(parameter.pagination, parameter.queryJson);
  88. var jsonData = new
  89. {
  90. rows = data,
  91. total = parameter.pagination.total,
  92. page = parameter.pagination.page,
  93. records = parameter.pagination.records
  94. };
  95. return Success(jsonData);
  96. }
  97. /// <summary>
  98. /// 获取表单数据
  99. /// <summary>
  100. /// <param name="_"></param>
  101. /// <returns></returns>
  102. public Response GetForm(dynamic _)
  103. {
  104. string keyValue = this.GetReqData();
  105. var StuLeaveManagementData = stuLeaveManagementIBLL.GetStuLeaveManagementEntity(keyValue);
  106. var jsonData = new
  107. {
  108. StuLeaveManagement = StuLeaveManagementData,
  109. };
  110. return Success(jsonData);
  111. }
  112. #endregion
  113. #region 提交数据
  114. /// <summary>
  115. /// 删除实体数据
  116. /// <param name="_"></param>
  117. /// <summary>
  118. /// <returns></returns>
  119. public Response DeleteForm(dynamic _)
  120. {
  121. string keyValue = this.GetReqData();
  122. stuLeaveManagementIBLL.DeleteEntity(keyValue);
  123. return Success("删除成功!");
  124. }
  125. /// <summary>
  126. /// 保存实体数据(新增、修改)
  127. /// <param name="_"></param>
  128. /// <summary>
  129. /// <returns></returns>
  130. public Response SaveForm(dynamic _)
  131. {
  132. var loginInfo = LoginUserInfo.Get();
  133. ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
  134. StuLeaveManagementEntity entity = parameter.strEntity.ToObject<StuLeaveManagementEntity>();
  135. if (string.IsNullOrEmpty(parameter.keyValue))
  136. {
  137. entity.CreateUserId = loginInfo.userId;
  138. entity.CreateUserNo = loginInfo.account;
  139. entity.CreateTime = DateTime.Now;
  140. }
  141. stuLeaveManagementIBLL.SaveEntity(parameter.keyValue, entity);
  142. return Success("保存成功!");
  143. }
  144. /// <summary>
  145. /// 判断是否可以审核
  146. /// <summary>
  147. /// <param name="_"></param>
  148. /// <returns></returns>
  149. public Response IsCheck(dynamic _)
  150. {
  151. string keyValue = this.GetReqData();
  152. var stuLeaveManagementData = stuLeaveManagementIBLL.GetStuLeaveManagementEntity(keyValue);
  153. bool isDeptDirector = false; //登录用户是否是系主任标识
  154. var deptDirectorRoleId = Config.GetValue("DeptDirectorRoleId");
  155. var loginInfoRoleIds = LoginUserInfo.Get().roleIds;
  156. if (loginInfoRoleIds.IndexOf(',') == -1)
  157. {
  158. if (loginInfoRoleIds == deptDirectorRoleId)
  159. {
  160. isDeptDirector = true;
  161. }
  162. }
  163. else
  164. {
  165. if (loginInfoRoleIds.Split(',').Contains(deptDirectorRoleId))
  166. {
  167. isDeptDirector = true;
  168. }
  169. }
  170. if (stuLeaveManagementData.LeaveDay > 2 && !isDeptDirector)
  171. {
  172. return Fail("该请假申请大于2天,需要由系主任审核!");
  173. }
  174. return Success("");
  175. }
  176. /// <summary>
  177. /// 审核学生请假
  178. /// <param name="_"></param>
  179. /// <summary>
  180. /// <returns></returns>
  181. public Response SaveCheckForm(dynamic _)
  182. {
  183. var loginInfo = LoginUserInfo.Get();
  184. ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
  185. StuLeaveManagementEntity entity = parameter.strEntity.ToObject<StuLeaveManagementEntity>();
  186. entity.CheckUserId = loginInfo.userId;
  187. entity.CheckUserNo = loginInfo.account;
  188. entity.CheckTime = DateTime.Now;
  189. stuLeaveManagementIBLL.SaveEntity(parameter.keyValue, entity);
  190. return Success("保存成功!");
  191. }
  192. /// <summary>
  193. /// 提交
  194. /// <param name="_"></param>
  195. /// <summary>
  196. /// <returns></returns>
  197. public Response Submit(dynamic _)
  198. {
  199. string keyValue = this.GetReqData();
  200. var processId = Guid.NewGuid().ToString();
  201. stuLeaveManagementIBLL.ChangeStatusById(keyValue, 1, processId);
  202. UserInfo userInfo = LoginUserInfo.Get();
  203. nWFProcessIBLL.CreateFlow("StuLeaveManagement", processId, "", 1, "", userInfo);
  204. return Success("提交成功!");
  205. }
  206. #endregion
  207. #region 私有类
  208. /// <summary>
  209. /// 表单实体类
  210. /// <summary>
  211. private class ReqFormEntity
  212. {
  213. public string keyValue { get; set; }
  214. public string strEntity { get; set; }
  215. }
  216. #endregion
  217. }
  218. }