MinorGraduationApproveController.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.ViewModel;
  7. using EMIS.Web.Controls;
  8. using Bowin.Web.Controls.Mvc;
  9. using EMIS.CommonLogic.MinorGraduation.MinorGraduationManage;
  10. using Bowin.Common.JSON;
  11. using EMIS.ViewModel.MinorGraduation.MinorGraduationManage;
  12. using EMIS.ViewModel.WorkflowManage;
  13. using Bowin.Common.Utility;
  14. using Bowin.Common.Exceptions;
  15. using Bowin.Common.Data;
  16. namespace EMIS.Web.Controllers.MinorGraduation.MinorGraduationManage
  17. {
  18. [Authorization]
  19. public class MinorGraduationApproveController : Controller
  20. {
  21. //
  22. // GET: /MinorGraduationApprove/
  23. public IMinorGraduationApplyServices minorGraduationApplyServices { get; set; }
  24. public ActionResult List()
  25. {
  26. return View();
  27. }
  28. [HttpPost]
  29. public ActionResult List(QueryParamsModel pararms)
  30. {
  31. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  32. var gradSchoolyearID = pararms.getExtraGuid("GradSchoolyearDropdown");
  33. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  34. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  35. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  36. //毕业类型
  37. var graduationTypeID = pararms.getExtraInt("DictionaryGraduationType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGraduationType");
  38. //在校状态
  39. var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
  40. //毕业结论
  41. var graduationResult = pararms.getExtraInt("DictionaryGraduationResult") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGraduationResult");
  42. //审核状态
  43. var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
  44. return base.Json(minorGraduationApplyServices.GetMinorGraduationApproveViewGrid(configuretView, gradSchoolyearID, collegeID, yearID,
  45. standardID, graduationTypeID, inSchoolStatus, graduationResult, approvalStatus, (int)pararms.page, (int)pararms.rows));
  46. }
  47. [HttpPost]
  48. public ActionResult Excel()
  49. {
  50. NpoiExcelHelper neh = new NpoiExcelHelper();
  51. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  52. //var gradSchoolyearID = Request.Form["GradSchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["GradSchoolyearDropdown"].ParseStrTo<Guid>();
  53. var gradSchoolyearID = Request.Form["GradSchoolyearDropdown"].ParseStrTo<Guid>();
  54. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  55. var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  56. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  57. //毕业类型
  58. var graduationTypeID = Request.Form["DictionaryGraduationType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGraduationType"].ParseStrTo<int>();
  59. //在校状态
  60. var inSchoolStatus = Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>();
  61. //毕业结论
  62. var graduationResult = Request.Form["DictionaryGraduationResult"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGraduationResult"].ParseStrTo<int>();
  63. //审核状态
  64. var approvalStatus = Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>();
  65. var minorGraduationApplyIDString = Request.Form["SelectedID"];
  66. var minorGraduationApplyIDList = minorGraduationApplyIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  67. var dt = minorGraduationApplyServices.GetMinorGraduationApproveViewList(configuretView, gradSchoolyearID, collegeID, yearID,
  68. standardID, graduationTypeID, inSchoolStatus, graduationResult, approvalStatus, minorGraduationApplyIDList)
  69. .Select(x => new
  70. {
  71. x.GraduatingSemesterCode,
  72. x.StudentNo,
  73. x.UserName,
  74. x.SexName,
  75. x.GraduationTypeName,
  76. x.ClassminorName,
  77. x.InSchoolStatusName,
  78. x.CollegeName,
  79. x.MinorGraduationResultName,
  80. x.ApprovalResult,
  81. x.Remark,
  82. x.ApprovalStatusName
  83. }).ToTable();
  84. string[] liststring = {
  85. "毕业学期", "学号", "姓名", "性别", "毕业类型", "辅修班级", "在校状态", "院系所", "毕业结论", "预审说明", "备注", "审核状态"
  86. };
  87. neh.Export(dt, liststring, "辅修毕业审核信息" + DateTime.Now.ToString("yyyyMMdd"));
  88. return Json(new ReturnMessage()
  89. {
  90. IsSuccess = true,
  91. Message = "导出成功。"
  92. });
  93. }
  94. /// <summary>
  95. /// 审核(单个页面)
  96. /// </summary>
  97. /// <param name="graduationApplyID"></param>
  98. /// <returns></returns>
  99. [HttpGet]
  100. public ActionResult Approve(Guid? minorGraduationApplyID)
  101. {
  102. //查询对应的毕业审核信息
  103. var minorGraduationApproveView = minorGraduationApplyServices.GetMinorGraduationApproveView(minorGraduationApplyID);
  104. if (minorGraduationApproveView == null)
  105. {
  106. return RedirectToAction("MsgShow", "Common", new
  107. {
  108. WindowID = Request["WindowID"],
  109. msg = "操作失败,原因:数据有误。",
  110. url = Url.Action("List").AddMenuParameter()
  111. });
  112. }
  113. //对已结束的流程状态进行判断(包括正常结束、非正常结束[BP]标识)
  114. var endStatusList = minorGraduationApplyServices.GetBackpointStatus();
  115. var correctEndStatusID = minorGraduationApplyServices.GetCorrectEndStatus();
  116. endStatusList.Add(correctEndStatusID);
  117. foreach (var endStatus in endStatusList)
  118. {
  119. if (minorGraduationApproveView.ApprovalStatus == endStatus)
  120. {
  121. return RedirectToAction("MsgShow", "Common", new
  122. {
  123. WindowID = Request["WindowID"],
  124. msg = "无法对已结束的流程进行审核。",
  125. url = Url.Action("List").AddMenuParameter()
  126. });
  127. }
  128. }
  129. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  130. //根据当前环节ID、用户ID查询下一步审批动作信息List(ActionView)
  131. var actionViewList = minorGraduationApplyServices.GetActionView((Guid)minorGraduationApplyID, user.UserID);
  132. if (actionViewList == null || actionViewList.Count() <= 0)
  133. {
  134. return RedirectToAction("MsgShow", "Common", new
  135. {
  136. WindowID = Request["WindowID"],
  137. msg = "对不起,您没权限操作。",
  138. url = Url.Action("List").AddMenuParameter()
  139. });
  140. }
  141. var dropList = actionViewList.Select(x => new DropdownListItem { Text = x.ActionName, Value = x.ToJson() }).ToList();
  142. ViewBag.ListAction = dropList;
  143. return View(minorGraduationApproveView);
  144. }
  145. /// <summary>
  146. /// 审核(单个页面)
  147. /// </summary>
  148. /// <param name="graduationApplyView"></param>
  149. /// <returns></returns>
  150. [HttpPost]
  151. public ActionResult Approve(MinorGraduationApplyView minorGraduationApplyView)
  152. {
  153. try
  154. {
  155. List<Guid?> list = new List<Guid?>();
  156. list.Add(minorGraduationApplyView.MinorGraduationApplyID);
  157. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  158. string action = Request.Form["ddlAction"];
  159. if (string.IsNullOrEmpty(action))
  160. {
  161. throw new Exception("请选择处理动作");
  162. }
  163. var actionID = action.JsonToObject<ActionView>().ActionID;
  164. minorGraduationApplyServices.MinorGraduationApproveConfirm(list, user.UserID, actionID, minorGraduationApplyView.Comment);
  165. return Json(new ReturnMessage()
  166. {
  167. IsSuccess = true,
  168. Message = "审核成功。"
  169. });
  170. }
  171. catch (Exception ex)
  172. {
  173. return Json(new ReturnMessage()
  174. {
  175. IsSuccess = false,
  176. Message = "审核失败,原因:" + ex.Message + "。"
  177. });
  178. }
  179. }
  180. /// <summary>
  181. /// 查询对应的流程环节动作List(ActionView)
  182. /// </summary>
  183. /// <param name="graduationApplyID"></param>
  184. /// <returns></returns>
  185. [HttpPost]
  186. public ActionResult ApprovalHandle(Guid? minorGraduationApplyID)
  187. {
  188. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  189. //根据当前环节ID、用户ID查询下一步审批动作信息List(ActionView)
  190. var actionViewList = minorGraduationApplyServices.GetActionView((Guid)minorGraduationApplyID, user.UserID);
  191. var dropList = actionViewList.Select(x => new DropdownListItem
  192. {
  193. Text = x.ActionName,
  194. Value = x.ToJson()
  195. }).ToList();
  196. return View(dropList);
  197. }
  198. /// <summary>
  199. /// 审批确定(批量)
  200. /// </summary>
  201. /// <param name="graduationApplyIDs"></param>
  202. /// <param name="actionID"></param>
  203. /// <param name="comment"></param>
  204. /// <returns></returns>
  205. [HttpPost]
  206. public ActionResult ApproveConfirm(string minorGraduationApplyIDs, Guid actionID, string comment)
  207. {
  208. try
  209. {
  210. List<Guid?> list = minorGraduationApplyIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  211. .Select(x => (Guid?)new Guid(x)).ToList();
  212. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  213. minorGraduationApplyServices.MinorGraduationApproveConfirm(list, user.UserID, actionID, comment);
  214. return Json(new ReturnMessage()
  215. {
  216. IsSuccess = true,
  217. Message = "审核成功。"
  218. });
  219. }
  220. catch (Exception ex)
  221. {
  222. return Json(new ReturnMessage()
  223. {
  224. IsSuccess = false,
  225. Message = "审核失败,原因:" + ex.Message
  226. });
  227. }
  228. }
  229. }
  230. }