PlanApprovalController.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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.CultureplanManage.PlanManagement;
  10. using EMIS.ViewModel.BaseWorkflow;
  11. using Bowin.Common.JSON;
  12. using EMIS.ViewModel.CultureplanManage.PlanManagement;
  13. using Bowin.Common.Utility;
  14. using Bowin.Common.Data;
  15. using EMIS.Utility;
  16. using EMIS.Utility.FormValidate;
  17. namespace EMIS.Web.Controllers.CultureplanManage.PlanManagement
  18. {
  19. [Authorization]
  20. public class PlanApprovalController : Controller
  21. {
  22. public IPlanApplicationServices planApplicationServices { get; set; }
  23. //
  24. // GET: /PlanApproval/
  25. public ActionResult List()
  26. {
  27. return View();
  28. }
  29. /// <summary>
  30. /// 列表查询
  31. /// </summary>
  32. /// <param name="pararms"></param>
  33. /// <returns></returns>
  34. [HttpPost]
  35. public ActionResult List(QueryParamsModel pararms)
  36. {
  37. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  38. var campusID = pararms.getExtraGuid("CampusDropdown");
  39. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  40. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  41. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  42. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  43. var learningFormID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  44. var schoolyear = pararms.getExtraGuid("SchoolyearDropdown");
  45. var grademajorID = pararms.getExtraGuid("GrademajorComboGrid");
  46. var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
  47. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  48. return this.Json(planApplicationServices.GetPlanApprovalViewGrid(configuretView, campusID, collegeID, yearID, standardID, educationID, learningFormID, schoolyear, approvalStatus,grademajorID,LearnSystem, (int)pararms.page, (int)pararms.rows));
  49. }
  50. /// <summary>
  51. /// 编辑
  52. /// </summary>
  53. /// <param name="planApplicationID"></param>
  54. /// <returns></returns>
  55. [HttpGet]
  56. public ActionResult Edit(Guid? planApplicationID)
  57. {
  58. List<DropdownListItem> list = new List<DropdownListItem>();
  59. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  60. PlanApplicationView planApplicationView = new PlanApplicationView();
  61. if (planApplicationID.HasValue)
  62. planApplicationView = planApplicationServices.GetPlanApplicationView(planApplicationID);
  63. List<ActionView> listAction = planApplicationServices.GetAuditingActionView((Guid)planApplicationID, user.UserID);
  64. foreach (var item in listAction)
  65. {
  66. DropdownListItem dli = new DropdownListItem { Text = item.ActionName, Value = item.ToJson() };
  67. list.Add(dli);
  68. }
  69. ViewData["listAction"] = list;
  70. return View(planApplicationView);
  71. }
  72. /// <summary>
  73. /// 编辑
  74. /// </summary>
  75. /// <param name="specialtyApplyID"></param>
  76. /// <returns></returns>
  77. [HttpPost]
  78. public ActionResult Edit(PlanApplicationView planApplicationView)
  79. {
  80. try
  81. {
  82. List<Guid> list = new List<Guid>();
  83. string action = Request.Form["ddlAction"];
  84. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  85. ActionView actionView = action.JsonToObject<ActionView>();
  86. string comment = Request.Form["txtOpinioncomment"];
  87. list.Add(planApplicationView.PlanApplicationID);
  88. planApplicationServices.ApprovePlanApplicationApply(list, user.UserID, actionView, comment, planApplicationView);
  89. return Json(new ReturnMessage()
  90. {
  91. IsSuccess = true,
  92. Message = "审核成功!"
  93. });
  94. }
  95. catch (Exception ex)
  96. {
  97. return Json(new ReturnMessage()
  98. {
  99. IsSuccess = false,
  100. Message = "审核失败,原因::" + ex.Message
  101. });
  102. }
  103. }
  104. /// <summary>
  105. /// 审批确定(批量)
  106. /// </summary>
  107. /// <param name="planApplicationIDs"></param>
  108. /// <param name="actionID"></param>
  109. /// <param name="comment"></param>
  110. /// <returns></returns>
  111. [HttpPost]
  112. public ActionResult Approve(string planApplicationIDs, Guid actionID, string comment)
  113. {
  114. var planApplicationIDList = planApplicationIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  115. var curUserID = CustomPrincipal.Current.UserID;
  116. if (planApplicationIDList.Count == 0)
  117. {
  118. return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行审核。" });
  119. }
  120. try
  121. {
  122. this.planApplicationServices.Approve(planApplicationIDList, curUserID, actionID, comment);
  123. return Json(new ReturnMessage { IsSuccess = true, Message = "审核成功。" });
  124. }
  125. catch (Exception ex)
  126. {
  127. return Json(new ReturnMessage { IsSuccess = false, Message = "审核失败:" + ex.Message });
  128. }
  129. }
  130. /// <summary>
  131. /// 获取下一步动作
  132. /// </summary>
  133. /// <param name="planApplicationIDs"></param>
  134. /// <returns></returns>
  135. [HttpGet]
  136. public ActionResult ApprovalHandle(string planApplicationIDs)
  137. {
  138. if (string.IsNullOrEmpty(planApplicationIDs))
  139. {
  140. planApplicationIDs = Session["planApplicationIDs"].ToString();
  141. }
  142. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  143. if (!string.IsNullOrEmpty(planApplicationIDs))
  144. {
  145. List<Guid> listguid = new List<Guid>();
  146. Guid planApplicationID = new Guid(planApplicationIDs.Split(',')[0]);
  147. List<ActionView> listAction = planApplicationServices.GetAuditingActionView(planApplicationID, user.UserID);
  148. List<DropdownListItem> list = new List<DropdownListItem>();
  149. if (listAction.Count == 0)
  150. {
  151. return RedirectToAction("MsgShow", "Common", new
  152. {
  153. WindowID = Request["WindowID"],
  154. msg = "对不起,您无权限进行审核操作。"
  155. });
  156. }
  157. foreach (var item in listAction)
  158. {
  159. DropdownListItem dli = new DropdownListItem { Text = item.ActionName, Value = item.ToJson() };
  160. list.Add(dli);
  161. }
  162. ViewData["planApplicationIDs"] = planApplicationIDs;
  163. ViewData["listAction"] = list;
  164. }
  165. else
  166. {
  167. return RedirectToAction("MsgShow", "Common", new
  168. {
  169. WindowID = Request["WindowID"],
  170. msg = "请选择需要审核的数据。"
  171. });
  172. }
  173. return View();
  174. }
  175. /// <summary>
  176. ///
  177. /// </summary>
  178. /// <returns></returns>
  179. [HttpPost]
  180. public ActionResult ApprovalHandle()
  181. {
  182. string planApplicationIDs = Request.Form["planApplicationIDs"].ToString();
  183. Session["planApplicationIDs"] = planApplicationIDs;
  184. return Json("成功", JsonRequestBehavior.AllowGet);
  185. }
  186. /// <summary>
  187. /// 获取流程步骤详细信息
  188. /// </summary>
  189. /// <param name="pararms"></param>
  190. /// <returns></returns>
  191. [HttpPost]
  192. public ActionResult ApproveWorkflowList(Guid? planApplicationID)
  193. {
  194. return base.Json(planApplicationServices.GetWorkflowApproveHistoryView(planApplicationID));
  195. }
  196. /// <summary>
  197. /// 导出Excel
  198. /// </summary>
  199. /// <returns></returns>
  200. [HttpPost]
  201. public ActionResult Excel()
  202. {
  203. NpoiExcelHelper neh = new NpoiExcelHelper();
  204. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  205. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  206. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  207. var yearID = Request.Form["DictionarySchoolyear"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyear"].ParseStrTo<int>();
  208. var standardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
  209. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  210. var learningFormID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  211. var schoolyear = Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  212. var grademajorID = Request.Form["GrademajorComboGrid"].ParseStrTo<Guid>();
  213. var approvalStatus = Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>();
  214. var LearnSystem = "";
  215. //Request.Form["DictionaryLearnSystem"].ToString();
  216. var dt = planApplicationServices.GetPlanApprovalViewList(configuretView, campusID, collegeID, yearID,
  217. standardID, educationID, learningFormID, schoolyear, approvalStatus, grademajorID, LearnSystem).Select(x => new
  218. {
  219. x.SchoolyearCode,
  220. x.GrademajorCode,
  221. x.GrademajorName,
  222. x.CourseCode,
  223. x.CourseName,
  224. x.CourseTypeName,
  225. x.HandleModeName,
  226. x.Totalhours,
  227. x.TheoryCourse,
  228. x.Practicehours,
  229. x.Trialhours,
  230. x.Credit,
  231. x.SchoolcodeName,
  232. x.SchoolyearNumName,
  233. x.StarttermName,
  234. x.CollegeName,
  235. x.CreateTime,
  236. x.ApprovalStatusName
  237. }).ToTable();
  238. string[] liststring = { "学年学期","年级专业代码", "年级专业名称","课程代码", "课程名称", "课程类型","处理方式",
  239. "总学时","理论学时","实践学时", "实验学时","学分","学期","开课学年", "开课学期",
  240. RSL.Get("College"), "申请时间", "审批状态" };
  241. neh.Export(dt, liststring, "计划审核信息");
  242. return Json(new ReturnMessage()
  243. {
  244. IsSuccess = true,
  245. Message = "导出成功!"
  246. });
  247. }
  248. }
  249. }