SpecialtyAuditingController.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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.Common.Linq;
  9. using Bowin.Common.JSON;
  10. using Bowin.Web.Controls.Mvc;
  11. using Bowin.Common.Exceptions;
  12. using EMIS.Web.Controls;
  13. using EMIS.Utility;
  14. using EMIS.ViewModel;
  15. using EMIS.ViewModel.WorkflowManage;
  16. using EMIS.ViewModel.EnrollManage.SpecialtyManage;
  17. using EMIS.CommonLogic.EnrollManage.SpecialtyManage;
  18. namespace EMIS.Web.Controllers.EnrollManage.SpecialtyManage
  19. {
  20. [Authorization]
  21. public class SpecialtyAuditingController : Controller
  22. {
  23. public ISpecialtyApplyServices specialtyApplyServices { get; set; }
  24. /// <summary>
  25. /// 专业审核页面
  26. /// </summary>
  27. /// <returns></returns>
  28. public ActionResult List()
  29. {
  30. return View();
  31. }
  32. /// <summary>
  33. /// 专业审核页面列表查询
  34. /// </summary>
  35. /// <param name="pararms"></param>
  36. /// <returns></returns>
  37. [HttpPost]
  38. public ActionResult List(QueryParamsModel pararms)
  39. {
  40. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  41. var campusID = pararms.getExtraGuid("CampusDropdown");
  42. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  43. var gradeID = pararms.getExtraInt("DictionaryGrade") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGrade");
  44. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  45. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  46. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  47. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  48. var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
  49. return base.Json(specialtyApplyServices.GetSpecialtyAuditingViewGrid(configuretView, campusID, collegeID, gradeID, standardID, educationID,
  50. learningformID, learnSystem, approvalStatus, (int)pararms.page, (int)pararms.rows));
  51. }
  52. /// <summary>
  53. /// 编辑
  54. /// </summary>
  55. /// <param name="specialtyApplyID"></param>
  56. /// <returns></returns>
  57. [HttpGet]
  58. public ActionResult Edit(Guid? specialtyApplyID)
  59. {
  60. SpecialtyApplyView specialtyApplyView = new SpecialtyApplyView();
  61. if (specialtyApplyID.HasValue && specialtyApplyID != Guid.Empty)
  62. {
  63. specialtyApplyView = specialtyApplyServices.GetSpecialtyApplyView(specialtyApplyID);
  64. }
  65. return View(specialtyApplyView);
  66. }
  67. /// <summary>
  68. /// 编辑
  69. /// </summary>
  70. /// <param name="specialtyApplyView"></param>
  71. /// <returns></returns>
  72. [HttpPost]
  73. public ActionResult Edit(SpecialtyApplyView specialtyApplyView)
  74. {
  75. try
  76. {
  77. return Json(new ReturnMessage()
  78. {
  79. IsSuccess = true,
  80. Message = "保存成功。"
  81. });
  82. }
  83. catch (Exception ex)
  84. {
  85. return Json(new ReturnMessage()
  86. {
  87. IsSuccess = false,
  88. Message = "保存失败,原因:" + ex.Message + "。"
  89. });
  90. }
  91. }
  92. /// <summary>
  93. /// 删除
  94. /// </summary>
  95. /// <param name="specialtyApplyIDs"></param>
  96. /// <returns></returns>
  97. [HttpPost]
  98. public ActionResult Delete(string specialtyApplyIDs)
  99. {
  100. try
  101. {
  102. List<Guid?> list = specialtyApplyIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  103. specialtyApplyServices.SpecialtyApplyDelete(list);
  104. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  105. }
  106. catch (Exception ex)
  107. {
  108. string mge = ex.Message;
  109. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  110. if (num != null)
  111. {
  112. if (num.Number == 547)
  113. {
  114. mge = "请先删除与其关联的数据,如:招生专业等。";
  115. }
  116. }
  117. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + mge });
  118. }
  119. }
  120. /// <summary>
  121. /// 审核(单个页面)
  122. /// </summary>
  123. /// <param name="specialtyApplyID"></param>
  124. /// <returns></returns>
  125. [HttpGet]
  126. public ActionResult Approve(Guid? specialtyApplyID)
  127. {
  128. //查询对应的专业审核信息
  129. var specialtyApplyView = specialtyApplyServices.GetSpecialtyApplyView(specialtyApplyID);
  130. if (specialtyApplyView == null)
  131. {
  132. return RedirectToAction("MsgShow", "Common", new
  133. {
  134. WindowID = Request["WindowID"],
  135. msg = "操作失败,原因:数据有误。",
  136. url = Url.Action("List").AddMenuParameter()
  137. });
  138. }
  139. //对已结束的流程状态进行判断(包括正常结束、非正常结束[BP]标识)
  140. var endStatusList = specialtyApplyServices.GetBackpointStatus();
  141. var correctEndStatusID = specialtyApplyServices.GetCorrectEndStatus();
  142. endStatusList.Add(correctEndStatusID);
  143. foreach (var endStatus in endStatusList)
  144. {
  145. if (specialtyApplyView.ApprovalStatus == endStatus)
  146. {
  147. return RedirectToAction("MsgShow", "Common", new
  148. {
  149. WindowID = Request["WindowID"],
  150. msg = "无法对已结束的流程进行审核。",
  151. url = Url.Action("List").AddMenuParameter()
  152. });
  153. }
  154. }
  155. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  156. //根据当前环节ID、用户ID查询下一步审批动作信息List(ActionView)
  157. var actionViewList = specialtyApplyServices.GetActionView((Guid)specialtyApplyID, user.UserID);
  158. if (actionViewList == null || actionViewList.Count() <= 0)
  159. {
  160. return RedirectToAction("MsgShow", "Common", new
  161. {
  162. WindowID = Request["WindowID"],
  163. msg = "对不起,您没权限操作。",
  164. url = Url.Action("List").AddMenuParameter()
  165. });
  166. }
  167. var dropList = actionViewList.Select(x => new DropdownListItem
  168. {
  169. Text = x.ActionName,
  170. Value = x.ToJson()
  171. }).ToList();
  172. ViewBag.ListAction = dropList;
  173. return View(specialtyApplyView);
  174. }
  175. /// <summary>
  176. /// 审核(单个页面)
  177. /// </summary>
  178. /// <param name="specialtyApplyView"></param>
  179. /// <returns></returns>
  180. [HttpPost]
  181. public ActionResult Approve(SpecialtyApplyView specialtyApplyView)
  182. {
  183. try
  184. {
  185. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  186. string action = Request.Form["ddlAction"];
  187. if (string.IsNullOrEmpty(action))
  188. {
  189. throw new Exception("请选择处理动作");
  190. }
  191. var actionID = action.JsonToObject<ActionView>().ActionID;
  192. List<Guid?> list = new List<Guid?>();
  193. list.Add(specialtyApplyView.SpecialtyApplyID);
  194. specialtyApplyServices.SpecialtyApproveConfirm(list, user.UserID, actionID, specialtyApplyView.Comment);
  195. return Json(new ReturnMessage()
  196. {
  197. IsSuccess = true,
  198. Message = "审核成功。"
  199. });
  200. }
  201. catch (Exception ex)
  202. {
  203. return Json(new ReturnMessage()
  204. {
  205. IsSuccess = false,
  206. Message = "审核失败,原因:" + ex.Message
  207. });
  208. }
  209. }
  210. /// <summary>
  211. /// 查询对应的流程环节动作List(ActionView)
  212. /// </summary>
  213. /// <param name="specialtyApplyID"></param>
  214. /// <returns></returns>
  215. [HttpPost]
  216. public ActionResult ApprovalHandle(Guid? specialtyApplyID)
  217. {
  218. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  219. //根据当前环节ID、用户ID查询下一步审批动作信息List(ActionView)
  220. var actionViewList = specialtyApplyServices.GetActionView((Guid)specialtyApplyID, user.UserID);
  221. var dropList = actionViewList.Select(x => new DropdownListItem { Text = x.ActionName, Value = x.ToJson() }).ToList();
  222. return View(dropList);
  223. }
  224. /// <summary>
  225. /// 审批确定(批量)
  226. /// </summary>
  227. /// <param name="specialtyApplyIDs"></param>
  228. /// <param name="actionID"></param>
  229. /// <param name="comment"></param>
  230. /// <returns></returns>
  231. [HttpPost]
  232. public ActionResult ApproveConfirm(string specialtyApplyIDs, Guid actionID, string comment)
  233. {
  234. try
  235. {
  236. List<Guid?> list = specialtyApplyIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  237. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  238. specialtyApplyServices.SpecialtyApproveConfirm(list, user.UserID, actionID, comment);
  239. return Json(new ReturnMessage()
  240. {
  241. IsSuccess = true,
  242. Message = "审核成功。"
  243. });
  244. }
  245. catch (Exception ex)
  246. {
  247. return Json(new ReturnMessage()
  248. {
  249. IsSuccess = false,
  250. Message = "审核失败,原因:" + ex.Message
  251. });
  252. }
  253. }
  254. /// <summary>
  255. /// 查询流程步骤详细信息(暂时不用)
  256. /// </summary>
  257. /// <param name="pararms"></param>
  258. /// <returns></returns>
  259. [HttpPost]
  260. public ActionResult ApproveWorkflowList(Guid? specialtyApplyID)
  261. {
  262. return base.Json(specialtyApplyServices.GetWorkflowApproveHistoryView(specialtyApplyID));
  263. }
  264. /// <summary>
  265. /// Excel导出
  266. /// </summary>
  267. /// <param name="pararms"></param>
  268. /// <returns></returns>
  269. [HttpPost]
  270. public ActionResult Excel()
  271. {
  272. NpoiExcelHelper neh = new NpoiExcelHelper();
  273. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  274. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  275. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  276. var gradeID = Request.Form["DictionaryGrade"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo<int>();
  277. var standardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
  278. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  279. var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  280. var learnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  281. var approvalStatus = Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>();
  282. var dt = specialtyApplyServices.GetSpecialtyAuditingViewList(configuretView, campusID, collegeID, gradeID, standardID, educationID, learningformID, learnSystem, approvalStatus)
  283. .Select(x => new
  284. {
  285. x.Code,
  286. x.StandardID,
  287. x.StandardName,
  288. x.GradeID,
  289. x.SemesterName,
  290. x.EducationName,
  291. x.LearningformName,
  292. LearnSystem = x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : null,
  293. x.ScienceclassName,
  294. x.PropertyName,
  295. x.StandardTitleName,
  296. x.StandardLevelName,
  297. x.CreateTime,
  298. x.CreateUserName,
  299. x.ApprovalStatusName,
  300. x.CollegeCode,
  301. x.CollegeName,
  302. x.CampusCode,
  303. x.CampusName
  304. }).ToTable();
  305. string[] liststring = {
  306. "专业代码", "专业ID(Value)", "专业名称", "年级", "学期", RSL.Get("EducationID"), "学习形式", "学制", "专业科类",
  307. "专业属性", "专业称号", "称号级别", "申请时间", "申请人", "状态", RSL.Get("CollegeCode"), RSL.Get("CollegeName"),
  308. RSL.Get("CampusCode"), RSL.Get("CampusName")
  309. };
  310. neh.Export(dt, liststring, "专业审核信息" + DateTime.Now.ToString("yyyyMMdd"));
  311. return Json(new ReturnMessage()
  312. {
  313. IsSuccess = true,
  314. Message = "导出成功。"
  315. });
  316. }
  317. }
  318. }