TeachersOrderExamineController.cs 11 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 EMIS.CommonLogic.TeachingMaterial;
  9. using Bowin.Web.Controls.Mvc;
  10. using EMIS.ViewModel.WorkflowManage;
  11. using Bowin.Common.Utility;
  12. using Bowin.Common.JSON;
  13. using Bowin.Common.Data;
  14. using EMIS.ViewModel.TeachingMaterial;
  15. using EMIS.Utility;
  16. using EMIS.CommonLogic.CalendarManage;
  17. using EMIS.Utility.FormValidate;
  18. namespace EMIS.Web.Controllers.TeachingMaterial
  19. {
  20. [Authorization]
  21. public class TeachersOrderExamineController : Controller
  22. {
  23. public ITeachersOrderExamineServices TeachersOrderExamineServices { get; set; }
  24. public ISchoolYearServices schoolYearServices { get; set; }
  25. /// <summary>
  26. /// 页面列表查询
  27. /// </summary>
  28. /// <returns></returns>
  29. [HttpGet]
  30. public ActionResult List()
  31. {
  32. //默认加载当前校历下学年学期的下一个学期
  33. var schoolYearView = schoolYearServices.GetSchoolYearIsCurrent(true);
  34. var schoolyear = schoolYearServices.GetSchoolYearViewListAfterCurrent().OrderBy(x => x.Code).Where(x => x.Value > schoolYearView.Value).FirstOrDefault();
  35. ViewBag.SchoolYearID = schoolyear.SchoolYearID;
  36. return View();
  37. }
  38. /// <summary>
  39. /// 列表查询
  40. /// </summary>
  41. /// <param name="pararms"></param>
  42. /// <returns></returns>
  43. [HttpPost]
  44. public ActionResult List(QueryParamsModel pararms)
  45. {
  46. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  47. //避开全选值
  48. Guid? publishID = null;
  49. Guid? coursematerialID = null;
  50. publishID = pararms.getExtraGuid("PublishDropdown");
  51. coursematerialID = pararms.getExtraGuid("CourseDropdown");
  52. var schoolYearID = pararms.getExtraGuid("SchoolYearDropdown");
  53. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  54. var approvalStatus = pararms.getExtraInt("StatusDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StatusDropdown");
  55. return base.Json(TeachersOrderExamineServices.GetTeachersOrderViewGrid(configuretView, schoolYearID, collegeID, coursematerialID, publishID, approvalStatus, (int)pararms.page, (int)pararms.rows));
  56. }
  57. #region 3.0 获取下一步环节
  58. /// <summary>
  59. /// 获取下一步动作
  60. /// </summary>
  61. /// <param name="planApplicationIDs"></param>
  62. /// <returns></returns>
  63. [HttpGet]
  64. public ActionResult ApprovalHandle(string teachersOrderIDs)
  65. {
  66. try
  67. {
  68. if (string.IsNullOrEmpty(teachersOrderIDs))
  69. {
  70. teachersOrderIDs = Session["teachersOrderIDs"].ToString();
  71. }
  72. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  73. if (!string.IsNullOrEmpty(teachersOrderIDs))
  74. {
  75. Guid teachersOrderID = new Guid(teachersOrderIDs.Split(',')[0]);
  76. List<ActionView> listAction = TeachersOrderExamineServices.GetAuditingActionView(teachersOrderID, user.UserID).OrderBy(x => x.ActionID).ToList();
  77. List<DropdownListItem> list = new List<DropdownListItem>();
  78. foreach (var item in listAction)
  79. {
  80. DropdownListItem dli = new DropdownListItem { Text = item.ActionName, Value = item.ToJson() };
  81. list.Add(dli);
  82. }
  83. ViewData["teachersOrderIDs"] = teachersOrderIDs;
  84. ViewData["listAction"] = list;
  85. }
  86. }
  87. catch (Exception ex)
  88. {
  89. return RedirectToAction("MsgShow", "Common", new
  90. {
  91. WindowID = Request["WindowID"],
  92. msg = "操作失败原因:" + ex.Message,
  93. url = Url.Action("List").AddMenuParameter()
  94. });
  95. }
  96. return View();
  97. }
  98. [HttpPost]
  99. public ActionResult ApprovalHandle()
  100. {
  101. string teachersOrderIDs = Request.Form["teachersOrderIDs"].ToString();
  102. Session["teachersOrderIDs"] = teachersOrderIDs;
  103. return Json("成功", JsonRequestBehavior.AllowGet);
  104. }
  105. #endregion
  106. #region 4.0 提交审核
  107. [HttpPost]
  108. public ActionResult Approve(string teachersOrderIDs, Guid actionID, string comment)
  109. {
  110. var teachersOrderIDList = teachersOrderIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  111. var curUserID = CustomPrincipal.Current.UserID;
  112. if (teachersOrderIDList.Count == 0)
  113. {
  114. return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行审核。" });
  115. }
  116. try
  117. {
  118. this.TeachersOrderExamineServices.Approve(teachersOrderIDList, curUserID, actionID, string.IsNullOrEmpty(comment) ? "同意" : comment);
  119. return Json(new ReturnMessage { IsSuccess = true, Message = "审核成功。" });
  120. }
  121. catch (Exception ex)
  122. {
  123. return Json(new ReturnMessage { IsSuccess = false, Message = "审核失败:" + ex.Message });
  124. }
  125. }
  126. #endregion
  127. #region 5.0 获取流程流转步骤
  128. /// <summary>
  129. /// 获取流程步骤详细信息
  130. /// </summary>
  131. /// <param name="pararms"></param>
  132. /// <returns></returns>
  133. [HttpPost]
  134. public ActionResult ApproveWorkflowList(Guid? teachersOrderID)
  135. {
  136. return base.Json(TeachersOrderExamineServices.GetWorkflowApproveHistoryView(teachersOrderID));
  137. }
  138. #endregion
  139. #region 6.0 导出Excel
  140. /// <summary>
  141. /// 导出Excel
  142. /// </summary>
  143. /// <returns></returns>
  144. [HttpPost]
  145. public ActionResult Excel()
  146. {
  147. //避开全选值
  148. Guid? publishID = null;
  149. Guid? coursematerialID = null;
  150. bool? isLate = null;
  151. publishID = Request.Form["PublishDropdown"].ParseStrTo<Guid>();
  152. coursematerialID = Request.Form["CourseDropdown"].ParseStrTo<Guid>();
  153. var schoolYearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
  154. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  155. var approvalStatus = Request.Form["StatusDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StatusDropdown"].ParseStrTo<int>();
  156. NpoiExcelHelper neh = new NpoiExcelHelper();
  157. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  158. var dt = TeachersOrderExamineServices.GetTeachersOrderExamineViewExcel(configuretView, schoolYearID, collegeID, coursematerialID, publishID, approvalStatus).Select(x => new
  159. {
  160. x.SchoolyearName,
  161. x.TeachingMaterialCode,
  162. x.CoursematerialCode,
  163. x.CoursematerialName,
  164. x.CoursematerialLevelName,
  165. x.CoursematerialTypeName,
  166. x.ISBN,
  167. x.TeachingMaterialName,
  168. x.PublishTime,
  169. x.PublishName,
  170. x.Author,
  171. x.OrderQty,
  172. x.OrderUserName,
  173. x.CollegeName,
  174. x.OrderDate,
  175. x.OrderDesc,
  176. x.ApproveStatusName
  177. }).ToTable();
  178. string[] liststring = { "学年学期","教材编号","课程代码","课程名称","课程级别","课程科类","ISBN","教材名称"
  179. ,"版本时间","出版单位","作者","征订数量","征订人",RSL.Get("College"),"征订日期","征订说明","审核状态 "};
  180. neh.Export(dt, liststring, "征订审核信息");
  181. return RedirectToAction("MsgShow", "Common", new
  182. {
  183. msg = "导出成功!",
  184. url = Url.Content("~/TeachersOrder/List").AddMenuParameter()
  185. });
  186. }
  187. #endregion
  188. /// <summary>
  189. /// 编辑
  190. /// </summary>
  191. /// <param name="teachersOrderID"></param>
  192. /// <returns></returns>
  193. [HttpGet]
  194. public ActionResult Edit(Guid? teachersOrderID)
  195. {
  196. List<DropdownListItem> list = new List<DropdownListItem>();
  197. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  198. TeachersOrderView teachersOrderView = new TeachersOrderView();
  199. if (teachersOrderID.HasValue)
  200. teachersOrderView = TeachersOrderExamineServices.GetTeachersOrderExamineView(teachersOrderID);
  201. List<ActionView> listAction = TeachersOrderExamineServices.GetAuditingActionView((Guid)teachersOrderID, user.UserID);
  202. foreach (var item in listAction)
  203. {
  204. DropdownListItem dli = new DropdownListItem { Text = item.ActionName, Value = item.ToJson() };
  205. list.Add(dli);
  206. }
  207. ViewData["listAction"] = list;
  208. ViewData["endStatus"] = TeachersOrderExamineServices.GetCorrectEndStatus();
  209. return View(teachersOrderView);
  210. }
  211. /// <summary>
  212. /// 编辑
  213. /// </summary>
  214. /// <param name="specialtyApplyID"></param>
  215. /// <returns></returns>
  216. [HttpPost]
  217. public ActionResult Edit(TeachersOrderView teachersOrderView)
  218. {
  219. try
  220. {
  221. List<Guid> list = new List<Guid>();
  222. string action = Request.Form["ddlAction"];
  223. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  224. ActionView actionView = action.JsonToObject<ActionView>();
  225. string comment = Request.Form["txtOpinioncomment"];
  226. list.Add(teachersOrderView.TeachersOrderID);
  227. TeachersOrderExamineServices.ApproveTeachersOrderExamine(list, user.UserID, actionView, comment);
  228. return RedirectToAction("MsgShow", "Common", new
  229. {
  230. msg = "审核成功!",
  231. url = Url.Content("~/TeachersOrderExamine/List").AddMenuParameter()
  232. });
  233. }
  234. catch (Exception ex)
  235. {
  236. return RedirectToAction("MsgShow", "Common", new
  237. {
  238. msg = "审核失败,原因:" + ex.Message,
  239. url = Url.Content("~/TeachersOrderExamine/List").AddMenuParameter()
  240. });
  241. }
  242. }
  243. }
  244. }