ChangeApproveController.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Common.Utility;
  7. using Bowin.Common.Data;
  8. using Bowin.Web.Controls.Mvc;
  9. using Bowin.Common.JSON;
  10. using EMIS.Utility;
  11. using EMIS.Web.Controls;
  12. using EMIS.ViewModel;
  13. using EMIS.ViewModel.WorkflowManage;
  14. using EMIS.ViewModel.StudentManage.StudentChange;
  15. using EMIS.CommonLogic.StudentManage.StudentChange;
  16. namespace EMIS.Web.Controllers.StudentManage.StudentChange
  17. {
  18. [Authorization]
  19. public class ChangeApproveController : Controller
  20. {
  21. public Lazy<IChangeApproveServices> ChangeApproveServices { get; set; }
  22. /// <summary>
  23. /// 异动审核页面
  24. /// </summary>
  25. /// <returns></returns>
  26. public ActionResult List()
  27. {
  28. return View();
  29. }
  30. /// <summary>
  31. /// 异动审核列表查询
  32. /// </summary>
  33. /// <param name="pararms"></param>
  34. /// <returns></returns>
  35. [HttpPost]
  36. public ActionResult List(QueryParamsModel pararms)
  37. {
  38. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  39. var campusID = pararms.getExtraGuid("CampusDropdown");
  40. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  41. var gradeID = pararms.getExtraInt("DictionaryGrade") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGrade");
  42. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  43. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  44. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  45. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  46. var classmajorID = pararms.getExtraGuid("ClassmajorComboGrid");
  47. var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  48. var changeTypeID = pararms.getExtraInt("DictionaryChangeType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryChangeType");
  49. var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
  50. var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
  51. return base.Json(ChangeApproveServices.Value.GetChangeApproveViewGrid(configuretView, campusID, collegeID, gradeID, standardID,
  52. educationID, learningformID, learnSystem, classmajorID, schoolyearID, changeTypeID, inSchoolStatus, approvalStatus, (int)pararms.page, (int)pararms.rows));
  53. }
  54. /// <summary>
  55. /// 编辑
  56. /// </summary>
  57. /// <param name="studentChangeID"></param>
  58. /// <returns></returns>
  59. [HttpGet]
  60. public ActionResult Edit(Guid? studentChangeID)
  61. {
  62. StudentChangeView studentChangeView = new StudentChangeView();
  63. if (studentChangeID.HasValue && studentChangeID != Guid.Empty)
  64. {
  65. studentChangeView = ChangeApproveServices.Value.GetStudentChangeView(studentChangeID);
  66. }
  67. return View(studentChangeView);
  68. }
  69. /// <summary>
  70. /// 编辑
  71. /// </summary>
  72. /// <param name="studentChangeView"></param>
  73. /// <returns></returns>
  74. [HttpPost]
  75. public ActionResult Edit(StudentChangeView studentChangeView)
  76. {
  77. try
  78. {
  79. return Json(new ReturnMessage()
  80. {
  81. IsSuccess = true,
  82. Message = "保存成功。"
  83. });
  84. }
  85. catch (Exception ex)
  86. {
  87. return Json(new ReturnMessage()
  88. {
  89. IsSuccess = false,
  90. Message = "保存失败,原因:" + ex.Message + "。"
  91. });
  92. }
  93. }
  94. /// <summary>
  95. /// 删除
  96. /// </summary>
  97. /// <param name="studentChangeIDs"></param>
  98. /// <returns></returns>
  99. [HttpPost]
  100. public ActionResult Delete(string studentChangeIDs)
  101. {
  102. try
  103. {
  104. List<Guid?> list = studentChangeIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  105. ChangeApproveServices.Value.ChangeApproveDelete(list);
  106. return Json(new ReturnMessage()
  107. {
  108. IsSuccess = true,
  109. Message = "删除成功。"
  110. });
  111. }
  112. catch (Exception ex)
  113. {
  114. return Json(new ReturnMessage()
  115. {
  116. IsSuccess = false,
  117. Message = "删除失败,原因:" + ex.Message
  118. });
  119. }
  120. }
  121. /// <summary>
  122. /// 审核(单个页面)
  123. /// </summary>
  124. /// <param name="studentChangeID"></param>
  125. /// <returns></returns>
  126. [HttpGet]
  127. public ActionResult Approve(Guid? studentChangeID)
  128. {
  129. var studentChangeView = ChangeApproveServices.Value.GetStudentChangeView(studentChangeID);
  130. if (studentChangeView == null)
  131. {
  132. return RedirectToAction("MsgShow", "Common", new
  133. {
  134. WindowID = Request["WindowID"],
  135. msg = "操作失败,原因:数据有误。",
  136. url = Url.Action("List").AddMenuParameter()
  137. });
  138. }
  139. var endStatusList = ChangeApproveServices.Value.GetBackpointStatus();
  140. var correctEndStatusID = ChangeApproveServices.Value.GetCorrectEndStatus();
  141. endStatusList.Add(correctEndStatusID);
  142. foreach (var endStatus in endStatusList)
  143. {
  144. if (studentChangeView.ApprovalStatus == endStatus)
  145. {
  146. return RedirectToAction("MsgShow", "Common", new
  147. {
  148. WindowID = Request["WindowID"],
  149. msg = "无法对已结束的流程进行审核。",
  150. url = Url.Action("List").AddMenuParameter()
  151. });
  152. }
  153. }
  154. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  155. var actionViewList = ChangeApproveServices.Value.GetActionView((Guid)studentChangeID, user.UserID);
  156. if (actionViewList == null || actionViewList.Count() <= 0)
  157. {
  158. return RedirectToAction("MsgShow", "Common", new
  159. {
  160. WindowID = Request["WindowID"],
  161. msg = "对不起,您没权限操作。",
  162. url = Url.Action("List").AddMenuParameter()
  163. });
  164. }
  165. var dropList = actionViewList.Select(x => new DropdownListItem { Text = x.ActionName, Value = x.ToJson() }).ToList();
  166. ViewBag.ListAction = dropList;
  167. return View(studentChangeView);
  168. }
  169. /// <summary>
  170. /// 审核(单个页面)
  171. /// </summary>
  172. /// <param name="studentChangeView"></param>
  173. /// <returns></returns>
  174. [HttpPost]
  175. public ActionResult Approve(StudentChangeView studentChangeView)
  176. {
  177. try
  178. {
  179. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  180. string action = Request.Form["ddlAction"];
  181. if (string.IsNullOrEmpty(action))
  182. {
  183. throw new Exception("请选择处理动作");
  184. }
  185. var actionID = action.JsonToObject<ActionView>().ActionID;
  186. List<Guid?> list = new List<Guid?>();
  187. list.Add(studentChangeView.StudentChangeID);
  188. ChangeApproveServices.Value.ChangeApproveConfirm(list, user.UserID, actionID, studentChangeView.Comment);
  189. return Json(new ReturnMessage()
  190. {
  191. IsSuccess = true,
  192. Message = "审核成功。"
  193. });
  194. }
  195. catch (Exception ex)
  196. {
  197. return Json(new ReturnMessage()
  198. {
  199. IsSuccess = false,
  200. Message = "审核失败,原因:" + ex.Message
  201. });
  202. }
  203. }
  204. /// <summary>
  205. /// 查询对应的流程环节动作List(ActionView)
  206. /// </summary>
  207. /// <param name="studentChangeID"></param>
  208. /// <returns></returns>
  209. [HttpPost]
  210. public ActionResult ApprovalHandle(Guid? studentChangeID)
  211. {
  212. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  213. var actionViewList = ChangeApproveServices.Value.GetActionView((Guid)studentChangeID, user.UserID);
  214. var dropList = actionViewList.Select(x => new DropdownListItem { Text = x.ActionName, Value = x.ToJson() }).ToList();
  215. return View(dropList);
  216. }
  217. /// <summary>
  218. /// 审批确定(批量)
  219. /// </summary>
  220. /// <param name="studentChangeIDs"></param>
  221. /// <param name="actionID"></param>
  222. /// <param name="comment"></param>
  223. /// <returns></returns>
  224. [HttpPost]
  225. public ActionResult ApproveConfirm(string studentChangeIDs, Guid actionID, string comment)
  226. {
  227. try
  228. {
  229. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  230. List<Guid?> list = studentChangeIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  231. ChangeApproveServices.Value.ChangeApproveConfirm(list, user.UserID, actionID, comment);
  232. return Json(new ReturnMessage()
  233. {
  234. IsSuccess = true,
  235. Message = "审核成功。"
  236. });
  237. }
  238. catch (Exception ex)
  239. {
  240. return Json(new ReturnMessage()
  241. {
  242. IsSuccess = false,
  243. Message = "审核失败,原因:" + ex.Message
  244. });
  245. }
  246. }
  247. /// <summary>
  248. /// Excel导出
  249. /// </summary>
  250. /// <returns></returns>
  251. [HttpPost]
  252. public ActionResult Excel()
  253. {
  254. NpoiExcelHelper neh = new NpoiExcelHelper();
  255. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  256. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  257. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  258. var gradeID = Request.Form["DictionaryGrade"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo<int>();
  259. var standardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
  260. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  261. var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  262. var learnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  263. var classmajorID = Request.Form["ClassmajorComboGrid"].ParseStrTo<Guid>();
  264. var schoolyearID = Request.Form["SchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  265. var changeTypeID = Request.Form["DictionaryChangeType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryChangeType"].ParseStrTo<int>();
  266. var inSchoolStatus = Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>();
  267. var approvalStatus = Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>();
  268. var dt = ChangeApproveServices.Value.GetChangeApproveViewList(configuretView, campusID, collegeID, gradeID, standardID, educationID, learningformID,
  269. learnSystem, classmajorID, schoolyearID, changeTypeID, inSchoolStatus, approvalStatus)
  270. .Select(x => new
  271. {
  272. x.StudentNo,
  273. x.Name,
  274. x.SexName,
  275. BirthDate = (x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyyMMdd") : ""),
  276. x.NationName,
  277. x.PoliticsName,
  278. x.InSchoolStatusName,
  279. x.StudentStatusName,
  280. x.GradeID,
  281. x.SemesterName,
  282. x.StandardCode,
  283. x.StandardID,
  284. x.StandardName,
  285. x.EducationName,
  286. x.LearningformName,
  287. LearnSystem = x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : "",
  288. x.ClassNum,
  289. x.ClassmajorNo,
  290. x.ClassmajorName,
  291. x.GrademajorCode,
  292. x.GrademajorName,
  293. x.FacultymajorCode,
  294. x.FacultymajorName,
  295. x.CollegeNo,
  296. x.CollegeName,
  297. x.CampusCode,
  298. x.CampusName,
  299. x.StartSchoolyearCode,
  300. x.SchoolyearCode,
  301. x.GraduateSchoolyearCode,
  302. x.ChangeTypeName,
  303. x.BeforeStandardName,
  304. x.BeforeClassmajorName,
  305. x.BeforeInSchoolStatusName,
  306. x.BeforeStudentStatusName,
  307. x.AfterStandardName,
  308. x.AfterClassmajorName,
  309. x.AfterInSchoolStatusName,
  310. x.AfterStudentStatusName,
  311. x.ReturnSchoolyearCode,
  312. x.ChangeApplyTypeName,
  313. x.ChangeReasonName,
  314. ChangeDate = (x.ChangeDate.HasValue ? x.ChangeDate.Value.ToString("yyyyMMdd") : ""),
  315. x.Description,
  316. x.ReportStatusName,
  317. x.ApprovalStatusName,
  318. x.Remark
  319. }).ToTable();
  320. string[] liststring = {
  321. "学号", "姓名", "性别", "出生日期", "民族", "政治面貌", "在校状态", "学籍状态", "年级", "入学学期",
  322. "专业代码", "专业ID(Value)", "专业名称", RSL.Get("EducationID"), "学习形式", "学制", "班序",
  323. "班级编号", "班级名称", "年级专业编号", "年级专业名称", "院系专业编号", "院系专业名称",
  324. RSL.Get("CollegeCode"), RSL.Get("College"), RSL.Get("CampusCode"), RSL.Get("Campus"), "入学学年学期",
  325. "异动学期", "毕业学期", "异动类型", "异动前专业", "异动前班级", "在校状态(前)", "学籍状态(前)",
  326. "异动后专业", "异动后班级", "在校状态(后)", "学籍状态(后)", "返校学期", "异动渠道", "异动原因", "异动日期",
  327. "申请说明", "注册状态", "审核状态", "备注"
  328. };
  329. neh.Export(dt, liststring, "异动审核信息" + DateTime.Now.ToString("yyyyMMdd"));
  330. return Json(new ReturnMessage()
  331. {
  332. IsSuccess = true,
  333. Message = "导出成功。"
  334. });
  335. }
  336. }
  337. }