StudentPunishController.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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 EMIS.Utility;
  12. using EMIS.Web.Controls;
  13. using EMIS.ViewModel;
  14. using EMIS.ViewModel.WorkflowManage;
  15. using EMIS.ViewModel.StudentManage.StudentProfile;
  16. using EMIS.CommonLogic.StudentManage.StudentProfile;
  17. namespace EMIS.Web.Controllers.StudentManage.StudentProfile
  18. {
  19. [Authorization]
  20. public class StudentPunishController : Controller
  21. {
  22. public Lazy<IStudentPunishServices> StudentPunishServices { get; set; }
  23. /// <summary>
  24. /// 学生处分页面
  25. /// </summary>
  26. /// <returns></returns>
  27. public ActionResult List()
  28. {
  29. return View();
  30. }
  31. /// <summary>
  32. /// 学生处分列表查询
  33. /// </summary>
  34. /// <param name="pararms"></param>
  35. /// <returns></returns>
  36. [HttpPost]
  37. public ActionResult List(QueryParamsModel pararms)
  38. {
  39. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  40. var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  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 punishTypeID = pararms.getExtraInt("DictionaryPunishType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryPunishType");
  49. var punishLevelID = pararms.getExtraInt("DictionaryPunishLevel") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryPunishLevel");
  50. var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
  51. var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
  52. return base.Json(StudentPunishServices.Value.GetStudentPunishViewGrid(configuretView, schoolyearID, campusID, collegeID, gradeID, standardID, educationID,
  53. learningformID, learnSystem, punishTypeID, punishLevelID, inSchoolStatus, approvalStatus, (int)pararms.page, (int)pararms.rows));
  54. }
  55. /// <summary>
  56. /// 复制新增
  57. /// </summary>
  58. /// <param name="studentPunishID"></param>
  59. /// <returns></returns>
  60. public ActionResult CopyAdd(Guid studentPunishID)
  61. {
  62. var studentPunishView = new StudentPunishView();
  63. studentPunishView = StudentPunishServices.Value.GetStudentPunishView(studentPunishID);
  64. return View("Edit", studentPunishView);
  65. }
  66. /// <summary>
  67. /// 复制新增
  68. /// </summary>
  69. /// <param name="studentPunishView"></param>
  70. /// <returns></returns>
  71. [HttpPost]
  72. public ActionResult CopyAdd(StudentPunishView studentPunishView)
  73. {
  74. studentPunishView.StudentPunishID = Guid.Empty;
  75. return this.Edit(studentPunishView);
  76. }
  77. /// <summary>
  78. /// 编辑(新增、修改)
  79. /// </summary>
  80. /// <param name="studentPunishID"></param>
  81. /// <returns></returns>
  82. [HttpGet]
  83. public ActionResult Edit(Guid? studentPunishID)
  84. {
  85. var studentPunishView = new StudentPunishView();
  86. if (studentPunishID.HasValue && studentPunishID != Guid.Empty)
  87. {
  88. studentPunishView = StudentPunishServices.Value.GetStudentPunishView(studentPunishID);
  89. }
  90. else
  91. {
  92. studentPunishView.PunishDate = DateTime.Now;
  93. }
  94. return View(studentPunishView);
  95. }
  96. /// <summary>
  97. /// 编辑(新增、修改)
  98. /// </summary>
  99. /// <param name="studentPunishView"></param>
  100. /// <returns></returns>
  101. [HttpPost]
  102. public ActionResult Edit(StudentPunishView studentPunishView)
  103. {
  104. try
  105. {
  106. StudentPunishServices.Value.StudentPunishEdit(studentPunishView);
  107. return Json(new ReturnMessage()
  108. {
  109. IsSuccess = true,
  110. Message = "保存成功。"
  111. });
  112. }
  113. catch (Exception ex)
  114. {
  115. return Json(new ReturnMessage()
  116. {
  117. IsSuccess = false,
  118. Message = "保存失败,原因:" + ex.Message
  119. });
  120. }
  121. }
  122. /// <summary>
  123. /// 删除
  124. /// </summary>
  125. /// <param name="studentPunishIDs"></param>
  126. /// <returns></returns>
  127. [HttpPost]
  128. public ActionResult Delete(string studentPunishIDs)
  129. {
  130. try
  131. {
  132. List<Guid?> list = studentPunishIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  133. StudentPunishServices.Value.StudentPunishDelete(list);
  134. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  135. }
  136. catch (Exception ex)
  137. {
  138. return base.Json(new ReturnMessage() { IsSuccess = false, Message = "删除失败,原因:" + ex.Message });
  139. }
  140. }
  141. /// <summary>
  142. /// 提交
  143. /// </summary>
  144. /// <param name="studentPunishIDs"></param>
  145. /// <returns></returns>
  146. [HttpPost]
  147. public ActionResult Submit(string studentPunishIDs)
  148. {
  149. try
  150. {
  151. List<Guid> list = studentPunishIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  152. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  153. string result = StudentPunishServices.Value.StudentPunishSubmit(list, user.UserID, "");
  154. return Json(new ReturnMessage()
  155. {
  156. IsSuccess = true,
  157. Message = "提交成功" + result + "。"
  158. });
  159. }
  160. catch (Exception ex)
  161. {
  162. return Json(new ReturnMessage()
  163. {
  164. IsSuccess = false,
  165. Message = "提交失败,原因:" + ex.Message
  166. });
  167. }
  168. }
  169. /// <summary>
  170. /// 审核页面(单个)
  171. /// </summary>
  172. /// <param name="studentPunishID"></param>
  173. /// <returns></returns>
  174. [HttpGet]
  175. public ActionResult Approve(Guid? studentPunishID)
  176. {
  177. var studentPunishView = StudentPunishServices.Value.GetStudentPunishView(studentPunishID);
  178. if (studentPunishView == null)
  179. {
  180. return RedirectToAction("MsgShow", "Common", new
  181. {
  182. WindowID = Request["WindowID"],
  183. msg = "操作失败,原因:数据有误。",
  184. url = Url.Action("List").AddMenuParameter()
  185. });
  186. }
  187. //对已结束的流程状态进行判断(包括正常结束、非正常结束[BP]标识)
  188. var endStatusList = StudentPunishServices.Value.GetBackpointStatus();
  189. var correctEndStatusID = StudentPunishServices.Value.GetCorrectEndStatus();
  190. endStatusList.Add(correctEndStatusID);
  191. foreach (var endStatus in endStatusList)
  192. {
  193. if (studentPunishView.ApprovalStatus == endStatus)
  194. {
  195. return RedirectToAction("MsgShow", "Common", new
  196. {
  197. WindowID = Request["WindowID"],
  198. msg = "无法对已结束的流程进行审核。",
  199. url = Url.Action("List").AddMenuParameter()
  200. });
  201. }
  202. }
  203. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  204. //根据当前环节ID、用户ID查询下一步审批动作信息List(ActionView)
  205. var actionViewList = StudentPunishServices.Value.GetActionView((Guid)studentPunishID, user.UserID);
  206. if (actionViewList == null || actionViewList.Count() <= 0)
  207. {
  208. return RedirectToAction("MsgShow", "Common", new
  209. {
  210. WindowID = Request["WindowID"],
  211. msg = "对不起,您没权限操作。",
  212. url = Url.Action("List").AddMenuParameter()
  213. });
  214. }
  215. var dropList = actionViewList.Select(x => new DropdownListItem
  216. {
  217. Text = x.ActionName,
  218. Value = x.ToJson()
  219. }).ToList();
  220. ViewBag.ListAction = dropList;
  221. return View(studentPunishView);
  222. }
  223. /// <summary>
  224. /// 审核页面(单个)
  225. /// </summary>
  226. /// <param name="studentPunishView"></param>
  227. /// <returns></returns>
  228. [HttpPost]
  229. public ActionResult Approve(StudentPunishView studentPunishView)
  230. {
  231. try
  232. {
  233. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  234. string action = Request.Form["ddlAction"];
  235. if (string.IsNullOrEmpty(action))
  236. {
  237. throw new Exception("请选择处理动作");
  238. }
  239. var actionID = action.JsonToObject<ActionView>().ActionID;
  240. List<Guid?> list = new List<Guid?>();
  241. list.Add(studentPunishView.StudentPunishID);
  242. StudentPunishServices.Value.StudentPunishApproveConfirm(list, user.UserID, actionID, studentPunishView.Comment);
  243. return Json(new ReturnMessage()
  244. {
  245. IsSuccess = true,
  246. Message = "审核成功。"
  247. });
  248. }
  249. catch (Exception ex)
  250. {
  251. return Json(new ReturnMessage()
  252. {
  253. IsSuccess = false,
  254. Message = "审核失败,原因:" + ex.Message
  255. });
  256. }
  257. }
  258. /// <summary>
  259. /// 查询对应的流程环节动作List(ActionView)
  260. /// </summary>
  261. /// <param name="studentPunishID"></param>
  262. /// <returns></returns>
  263. [HttpPost]
  264. public ActionResult ApprovalHandle(Guid? studentPunishID)
  265. {
  266. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  267. //根据当前环节ID、用户ID查询下一步审批动作信息List(ActionView)
  268. var actionViewList = StudentPunishServices.Value.GetActionView((Guid)studentPunishID, user.UserID);
  269. var dropList = actionViewList.Select(x => new DropdownListItem { Text = x.ActionName, Value = x.ToJson() }).ToList();
  270. return View(dropList);
  271. }
  272. /// <summary>
  273. /// 审批确定(批量)
  274. /// </summary>
  275. /// <param name="studentPunishIDs"></param>
  276. /// <param name="actionID"></param>
  277. /// <param name="comment"></param>
  278. /// <returns></returns>
  279. [HttpPost]
  280. public ActionResult ApproveConfirm(string studentPunishIDs, Guid actionID, string comment)
  281. {
  282. try
  283. {
  284. List<Guid?> list = studentPunishIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  285. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  286. StudentPunishServices.Value.StudentPunishApproveConfirm(list, user.UserID, actionID, comment);
  287. return Json(new ReturnMessage()
  288. {
  289. IsSuccess = true,
  290. Message = "审核成功。"
  291. });
  292. }
  293. catch (Exception ex)
  294. {
  295. return Json(new ReturnMessage()
  296. {
  297. IsSuccess = false,
  298. Message = "审核失败,原因:" + ex.Message
  299. });
  300. }
  301. }
  302. /// <summary>
  303. /// 撤销页面(单个)
  304. /// </summary>
  305. /// <param name="studentPunishID"></param>
  306. /// <returns></returns>
  307. [HttpGet]
  308. public ActionResult Cancel(Guid? studentPunishID)
  309. {
  310. var studentPunishView = new StudentPunishView();
  311. if (studentPunishID.HasValue && studentPunishID != Guid.Empty)
  312. {
  313. studentPunishView = StudentPunishServices.Value.GetStudentPunishView(studentPunishID);
  314. }
  315. studentPunishView.CancelDate = DateTime.Now;
  316. return View(studentPunishView);
  317. }
  318. /// <summary>
  319. /// 撤销页面(单个)
  320. /// </summary>
  321. /// <param name="studentPunishView"></param>
  322. /// <returns></returns>
  323. [HttpPost]
  324. public ActionResult Cancel(StudentPunishView studentPunishView)
  325. {
  326. try
  327. {
  328. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  329. List<Guid?> list = new List<Guid?>();
  330. list.Add(studentPunishView.StudentPunishID);
  331. StudentPunishServices.Value.StudentPunishCancelConfirm(list, user.UserID, studentPunishView.CancelDocNo, studentPunishView.CancelDate, studentPunishView.Comment);
  332. return Json(new ReturnMessage()
  333. {
  334. IsSuccess = true,
  335. Message = "撤销成功。"
  336. });
  337. }
  338. catch (Exception ex)
  339. {
  340. return Json(new ReturnMessage()
  341. {
  342. IsSuccess = false,
  343. Message = "撤销失败,原因:" + ex.Message
  344. });
  345. }
  346. }
  347. /// <summary>
  348. /// 撤销确定(批量)
  349. /// </summary>
  350. /// <param name="studentPunishIDs"></param>
  351. /// <param name="comment"></param>
  352. /// <returns></returns>
  353. [HttpPost]
  354. public ActionResult CancelConfirm(string studentPunishIDs, string comment)
  355. {
  356. try
  357. {
  358. List<Guid?> list = studentPunishIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  359. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  360. StudentPunishServices.Value.StudentPunishCancelConfirm(list, user.UserID, comment);
  361. return Json(new ReturnMessage()
  362. {
  363. IsSuccess = true,
  364. Message = "撤销成功。"
  365. });
  366. }
  367. catch (Exception ex)
  368. {
  369. return Json(new ReturnMessage()
  370. {
  371. IsSuccess = false,
  372. Message = "撤销失败,原因:" + ex.Message
  373. });
  374. }
  375. }
  376. /// <summary>
  377. /// Excel导出
  378. /// </summary>
  379. /// <returns></returns>
  380. [HttpPost]
  381. public ActionResult Excel()
  382. {
  383. try
  384. {
  385. NpoiExcelHelper neh = new NpoiExcelHelper();
  386. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  387. var schoolyearID = Request.Form["SchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  388. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  389. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  390. var gradeID = Request.Form["DictionaryGrade"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo<int>();
  391. var standardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
  392. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  393. var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  394. var learnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  395. var punishTypeID = Request.Form["DictionaryPunishType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryPunishType"].ParseStrTo<int>();
  396. var punishLevelID = Request.Form["DictionaryPunishLevel"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryPunishLevel"].ParseStrTo<int>();
  397. var inSchoolStatus = Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>();
  398. var approvalStatus = Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>();
  399. var dt = StudentPunishServices.Value.GetStudentPunishViewList(configuretView, schoolyearID, campusID, collegeID, gradeID, standardID, educationID,
  400. learningformID, learnSystem, punishTypeID, punishLevelID, inSchoolStatus, approvalStatus)
  401. .Select(x => new
  402. {
  403. x.SchoolyearCode,
  404. x.StudentNo,
  405. x.Name,
  406. x.SexName,
  407. x.InSchoolStatusName,
  408. x.StudentStatusName,
  409. x.GradeID,
  410. x.StandardCode,
  411. x.StandardID,
  412. x.StandardName,
  413. x.EducationName,
  414. x.LearningformName,
  415. LearnSystem = x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : null,
  416. x.ClassmajorNo,
  417. x.ClassmajorName,
  418. x.GrademajorCode,
  419. x.GrademajorName,
  420. x.CollegeNo,
  421. x.CollegeName,
  422. x.CampusCode,
  423. x.CampusName,
  424. x.PunishTypeName,
  425. x.PunishLevelName,
  426. x.DocNo,
  427. PunishDate = x.PunishDate.HasValue ? x.PunishDate.Value.ToString("yyyy-MM-dd") : "",
  428. x.Reason,
  429. x.CancelDocNo,
  430. CancelDate = x.CancelDate.HasValue ? x.CancelDate.Value.ToString("yyyy-MM-dd") : "",
  431. x.ApprovalStatusName
  432. }).ToTable();
  433. string[] liststring = {
  434. "学年学期", "学号", "姓名", "性别", "在校状态", "学籍状态", "年级", "专业代码", "专业ID(Value)", "专业名称",
  435. RSL.Get("EducationID"), "学习形式", "学制", "班级编号", "班级名称", "年级专业编号", "年级专业名称",
  436. RSL.Get("CollegeCode"), RSL.Get("CollegeName"), RSL.Get("CampusCode"), RSL.Get("CampusName"), "处分类型",
  437. "处分级别", "处分文号", "处分日期", "处分原因", "撤销文号", "撤销日期", "审批状态"
  438. };
  439. neh.Export(dt, liststring, "学生处分信息" + DateTime.Now.ToString("yyyyMMdd"));
  440. return Json(new ReturnMessage()
  441. {
  442. IsSuccess = true,
  443. Message = "导出成功。"
  444. });
  445. }
  446. catch (Exception ex)
  447. {
  448. return Json(new ReturnMessage()
  449. {
  450. IsSuccess = false,
  451. Message = "导出失败,原因:" + ex.Message
  452. });
  453. }
  454. }
  455. }
  456. }