MinorRegistApproveController.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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.MinorManage.MinorApply;
  10. using Bowin.Common.JSON;
  11. using EMIS.ViewModel.MinorManage.MinorApply;
  12. using EMIS.ViewModel.WorkflowManage;
  13. using Bowin.Common.Utility;
  14. using Bowin.Common.Data;
  15. namespace EMIS.Web.Controllers.MinorManage.MinorApply
  16. {
  17. [Authorization]
  18. public class MinorRegistApproveController : Controller
  19. {
  20. //
  21. // GET: /MinorApply/
  22. public IMinorApplyServices minorApplyServices { get; set; }
  23. public ActionResult List()
  24. {
  25. return View();
  26. }
  27. [HttpPost]
  28. public ActionResult List(QueryParamsModel pararms)
  29. {
  30. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  31. var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  32. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  33. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  34. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  35. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
  36. var minorStandardID = pararms.getExtraInt("MinorStandardDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("MinorStandardDropDown");
  37. var approvalStatus = -1;
  38. return base.Json(minorApplyServices.MinorApplyViewGrid(configuretView, schoolyearID, collegeID, yearID, standardID, classmajorID, minorStandardID, approvalStatus, (int)pararms.page, (int)pararms.rows));
  39. }
  40. public ActionResult Excel()
  41. {
  42. NpoiExcelHelper neh = new NpoiExcelHelper();
  43. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  44. var schoolyearID = Request.Form["SchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  45. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  46. var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  47. var standardID = Request.Form["StandardDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDropDown"].ParseStrTo<int>();
  48. var classmajorID = Request.Form["ClassmajorDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["ClassmajorDropdown"].ParseStrTo<Guid>();
  49. var minorStandardID = Request.Form["MinorStandardDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["MinorStandardDropDown"].ParseStrTo<int>();
  50. var approvalStatus = -1;
  51. var minorApplyIDString = Request.Form["SelectedID"];
  52. var minorApplyIDList = minorApplyIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  53. var dt = minorApplyServices.GetMinorApplyViewList(configuretView, schoolyearID, collegeID, yearID, standardID, classmajorID, minorStandardID, approvalStatus, minorApplyIDList)
  54. .Select(x => new
  55. {
  56. x.SchoolyearCode,
  57. x.GrademajorName,
  58. x.ClassmajorName,
  59. x.LoginID,
  60. x.UserName,
  61. x.GrademinorCode,
  62. x.GrademinorName,
  63. x.RecordStatusStr
  64. }).ToTable();
  65. string[] liststring = { "学年学期", "年级专业", "班级名称", "学号", "姓名", "辅修专业代码", "辅修专业名称", "状态"};
  66. neh.Export(dt, liststring, "辅修报名信息" + DateTime.Now.ToString("yyyyMMdd"));
  67. return Json(new ReturnMessage()
  68. {
  69. IsSuccess = true,
  70. Message = "导出成功。"
  71. });
  72. }
  73. /// <summary>
  74. /// 审核(单个页面)
  75. /// </summary>
  76. /// <param name="graduationApplyID"></param>
  77. /// <returns></returns>
  78. [HttpGet]
  79. public ActionResult Approve(string minorApplyID)
  80. {
  81. //查询对应的审核信息
  82. var minorID = new Guid(minorApplyID);
  83. var minorApplyView = minorApplyServices.GetMinorApplyView(minorID);
  84. if (minorApplyView == null)
  85. {
  86. return RedirectToAction("MsgShow", "Common", new
  87. {
  88. WindowID = Request["WindowID"],
  89. msg = "操作失败,原因:数据有误。",
  90. url = Url.Action("List").AddMenuParameter()
  91. });
  92. }
  93. //对已结束的流程状态进行判断(包括正常结束、非正常结束[BP]标识)
  94. var endStatusList = minorApplyServices.GetBackpointStatus();
  95. var correctEndStatusID = minorApplyServices.GetCorrectEndStatus();
  96. endStatusList.Add(correctEndStatusID);
  97. foreach (var endStatus in endStatusList)
  98. {
  99. if (minorApplyView.RecordStatus == endStatus)
  100. {
  101. return RedirectToAction("MsgShow", "Common", new
  102. {
  103. WindowID = Request["WindowID"],
  104. msg = "无法对已结束的流程进行审核。",
  105. url = Url.Action("List").AddMenuParameter()
  106. });
  107. }
  108. }
  109. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  110. //根据当前环节ID、用户ID查询下一步审批动作信息List(ActionView)
  111. var actionViewList = minorApplyServices.GetActionView((Guid)minorID, user.UserID);
  112. if (actionViewList == null || actionViewList.Count() <= 0)
  113. {
  114. return RedirectToAction("MsgShow", "Common", new
  115. {
  116. WindowID = Request["WindowID"],
  117. msg = "对不起,您没权限操作。",
  118. url = Url.Action("List").AddMenuParameter()
  119. });
  120. }
  121. var dropList = actionViewList.Select(x => new DropdownListItem { Text = x.ActionName, Value = x.ToJson() }).ToList();
  122. ViewData["listAction"] = dropList;
  123. ViewData["minorApplyID"] = minorApplyID;
  124. return View(minorApplyView);
  125. }
  126. /// <summary>
  127. /// 审核(单个页面)
  128. /// </summary>
  129. /// <param name="graduationApplyView"></param>
  130. /// <returns></returns>
  131. [HttpPost]
  132. public ActionResult Approve(MinorApplyView minorApplyView)
  133. {
  134. try
  135. {
  136. List<Guid?> list = new List<Guid?>();
  137. list.Add(minorApplyView.StudentMinorRegistID);
  138. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  139. string action = Request.Form["ddlAction"];
  140. if (string.IsNullOrEmpty(action))
  141. {
  142. throw new Exception("请选择处理动作");
  143. }
  144. var actionID = action.JsonToObject<ActionView>().ActionID;
  145. minorApplyServices.MinorApproveConfirm(list, user.UserID, actionID, minorApplyView.Comment);
  146. return Json(new ReturnMessage()
  147. {
  148. IsSuccess = true,
  149. Message = "审核成功。"
  150. });
  151. }
  152. catch (Exception ex)
  153. {
  154. return Json(new ReturnMessage()
  155. {
  156. IsSuccess = false,
  157. Message = "审核失败,原因:" + ex.Message + "。"
  158. });
  159. }
  160. }
  161. [HttpPost]
  162. public ActionResult ApproveConfirm(string minorRegistRegistIDs, Guid actionID, string comment)
  163. {
  164. try
  165. {
  166. List<Guid?> list = minorRegistRegistIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  167. .Select(x => (Guid?)new Guid(x)).ToList();
  168. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  169. minorApplyServices.MinorApproveConfirm(list, user.UserID, actionID, comment);
  170. return Json(new ReturnMessage()
  171. {
  172. IsSuccess = true,
  173. Message = "审核成功。"
  174. });
  175. }
  176. catch (Exception ex)
  177. {
  178. return Json(new ReturnMessage()
  179. {
  180. IsSuccess = false,
  181. Message = "审核失败,原因:" + ex.Message + "。"
  182. });
  183. }
  184. }
  185. }
  186. }