StudentEncourageController.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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 StudentEncourageController : Controller
  21. {
  22. public Lazy<IStudentEncourageServices> StudentEncourageServices { 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 encourageNameID = pararms.getExtraInt("DictionaryEncourageName") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEncourageName");
  49. var encourageTypeID = pararms.getExtraInt("DictionaryEncourageType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEncourageType");
  50. var encourageLevelID = pararms.getExtraInt("DictionaryEncourageLevel") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEncourageLevel");
  51. var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
  52. var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
  53. return base.Json(StudentEncourageServices.Value.GetStudentEncourageViewGrid(configuretView, schoolyearID, campusID, collegeID, gradeID, standardID, educationID,
  54. learningformID, learnSystem, encourageNameID, encourageTypeID, encourageLevelID, inSchoolStatus, approvalStatus, (int)pararms.page, (int)pararms.rows));
  55. }
  56. /// <summary>
  57. /// 复制新增
  58. /// </summary>
  59. /// <param name="studentEncourageID"></param>
  60. /// <returns></returns>
  61. public ActionResult CopyAdd(Guid studentEncourageID)
  62. {
  63. var studentEncourageView = new StudentEncourageView();
  64. studentEncourageView = StudentEncourageServices.Value.GetStudentEncourageView(studentEncourageID);
  65. return View("Edit", studentEncourageView);
  66. }
  67. /// <summary>
  68. /// 复制新增
  69. /// </summary>
  70. /// <param name="studentEncourageView"></param>
  71. /// <returns></returns>
  72. [HttpPost]
  73. public ActionResult CopyAdd(StudentEncourageView studentEncourageView)
  74. {
  75. studentEncourageView.StudentEncourageID = Guid.Empty;
  76. return this.Edit(studentEncourageView);
  77. }
  78. /// <summary>
  79. /// 编辑(新增、修改)
  80. /// </summary>
  81. /// <param name="studentEncourageID"></param>
  82. /// <returns></returns>
  83. [HttpGet]
  84. public ActionResult Edit(Guid? studentEncourageID)
  85. {
  86. var studentEncourageView = new StudentEncourageView();
  87. if (studentEncourageID.HasValue && studentEncourageID != Guid.Empty)
  88. {
  89. studentEncourageView = StudentEncourageServices.Value.GetStudentEncourageView(studentEncourageID);
  90. }
  91. else
  92. {
  93. studentEncourageView.EncourageDate = DateTime.Now;
  94. }
  95. return View(studentEncourageView);
  96. }
  97. /// <summary>
  98. /// 编辑(新增、修改)
  99. /// </summary>
  100. /// <param name="studentEncourageView"></param>
  101. /// <returns></returns>
  102. [HttpPost]
  103. public ActionResult Edit(StudentEncourageView studentEncourageView)
  104. {
  105. try
  106. {
  107. StudentEncourageServices.Value.StudentEncourageEdit(studentEncourageView);
  108. return Json(new ReturnMessage()
  109. {
  110. IsSuccess = true,
  111. Message = "保存成功。"
  112. });
  113. }
  114. catch (Exception ex)
  115. {
  116. return Json(new ReturnMessage()
  117. {
  118. IsSuccess = false,
  119. Message = "保存失败,原因:" + ex.Message
  120. });
  121. }
  122. }
  123. /// <summary>
  124. /// 删除
  125. /// </summary>
  126. /// <param name="studentEncourageIDs"></param>
  127. /// <returns></returns>
  128. [HttpPost]
  129. public ActionResult Delete(string studentEncourageIDs)
  130. {
  131. try
  132. {
  133. List<Guid?> list = studentEncourageIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  134. StudentEncourageServices.Value.StudentEncourageDelete(list);
  135. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  136. }
  137. catch (Exception ex)
  138. {
  139. return base.Json(new ReturnMessage() { IsSuccess = false, Message = "删除失败,原因:" + ex.Message });
  140. }
  141. }
  142. /// <summary>
  143. /// 提交
  144. /// </summary>
  145. /// <param name="studentEncourageIDs"></param>
  146. /// <returns></returns>
  147. [HttpPost]
  148. public ActionResult Submit(string studentEncourageIDs)
  149. {
  150. try
  151. {
  152. List<Guid> list = studentEncourageIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  153. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  154. string result = StudentEncourageServices.Value.StudentEncourageSubmit(list, user.UserID, "");
  155. return Json(new ReturnMessage()
  156. {
  157. IsSuccess = true,
  158. Message = "提交成功" + result + "。"
  159. });
  160. }
  161. catch (Exception ex)
  162. {
  163. return Json(new ReturnMessage()
  164. {
  165. IsSuccess = false,
  166. Message = "提交失败,原因:" + ex.Message
  167. });
  168. }
  169. }
  170. /// <summary>
  171. /// 审核页面(单个)
  172. /// </summary>
  173. /// <param name="studentEncourageID"></param>
  174. /// <returns></returns>
  175. [HttpGet]
  176. public ActionResult Approve(Guid? studentEncourageID)
  177. {
  178. var studentEncourageView = StudentEncourageServices.Value.GetStudentEncourageView(studentEncourageID);
  179. if (studentEncourageView == null)
  180. {
  181. return RedirectToAction("MsgShow", "Common", new
  182. {
  183. WindowID = Request["WindowID"],
  184. msg = "操作失败,原因:数据有误。",
  185. url = Url.Action("List").AddMenuParameter()
  186. });
  187. }
  188. //对已结束的流程状态进行判断(包括正常结束、非正常结束[BP]标识)
  189. var endStatusList = StudentEncourageServices.Value.GetBackpointStatus();
  190. var correctEndStatusID = StudentEncourageServices.Value.GetCorrectEndStatus();
  191. endStatusList.Add(correctEndStatusID);
  192. foreach (var endStatus in endStatusList)
  193. {
  194. if (studentEncourageView.ApprovalStatus == endStatus)
  195. {
  196. return RedirectToAction("MsgShow", "Common", new
  197. {
  198. WindowID = Request["WindowID"],
  199. msg = "无法对已结束的流程进行审核。",
  200. url = Url.Action("List").AddMenuParameter()
  201. });
  202. }
  203. }
  204. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  205. //根据当前环节ID、用户ID查询下一步审批动作信息List(ActionView)
  206. var actionViewList = StudentEncourageServices.Value.GetActionView((Guid)studentEncourageID, user.UserID);
  207. if (actionViewList == null || actionViewList.Count() <= 0)
  208. {
  209. return RedirectToAction("MsgShow", "Common", new
  210. {
  211. WindowID = Request["WindowID"],
  212. msg = "对不起,您没权限操作。",
  213. url = Url.Action("List").AddMenuParameter()
  214. });
  215. }
  216. var dropList = actionViewList.Select(x => new DropdownListItem
  217. {
  218. Text = x.ActionName,
  219. Value = x.ToJson()
  220. }).ToList();
  221. ViewBag.ListAction = dropList;
  222. return View(studentEncourageView);
  223. }
  224. /// <summary>
  225. /// 审核页面(单个)
  226. /// </summary>
  227. /// <param name="studentEncourageView"></param>
  228. /// <returns></returns>
  229. [HttpPost]
  230. public ActionResult Approve(StudentEncourageView studentEncourageView)
  231. {
  232. try
  233. {
  234. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  235. string action = Request.Form["ddlAction"];
  236. if (string.IsNullOrEmpty(action))
  237. {
  238. throw new Exception("请选择处理动作");
  239. }
  240. var actionID = action.JsonToObject<ActionView>().ActionID;
  241. List<Guid?> list = new List<Guid?>();
  242. list.Add(studentEncourageView.StudentEncourageID);
  243. StudentEncourageServices.Value.StudentEncourageApproveConfirm(list, user.UserID, actionID, studentEncourageView.Comment);
  244. return Json(new ReturnMessage()
  245. {
  246. IsSuccess = true,
  247. Message = "审核成功。"
  248. });
  249. }
  250. catch (Exception ex)
  251. {
  252. return Json(new ReturnMessage()
  253. {
  254. IsSuccess = false,
  255. Message = "审核失败,原因:" + ex.Message
  256. });
  257. }
  258. }
  259. /// <summary>
  260. /// 查询对应的流程环节动作List(ActionView)
  261. /// </summary>
  262. /// <param name="studentEncourageID"></param>
  263. /// <returns></returns>
  264. [HttpPost]
  265. public ActionResult ApprovalHandle(Guid? studentEncourageID)
  266. {
  267. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  268. //根据当前环节ID、用户ID查询下一步审批动作信息List(ActionView)
  269. var actionViewList = StudentEncourageServices.Value.GetActionView((Guid)studentEncourageID, user.UserID);
  270. var dropList = actionViewList.Select(x => new DropdownListItem { Text = x.ActionName, Value = x.ToJson() }).ToList();
  271. return View(dropList);
  272. }
  273. /// <summary>
  274. /// 审批确定(批量)
  275. /// </summary>
  276. /// <param name="studentEncourageIDs"></param>
  277. /// <param name="actionID"></param>
  278. /// <param name="comment"></param>
  279. /// <returns></returns>
  280. [HttpPost]
  281. public ActionResult ApproveConfirm(string studentEncourageIDs, Guid actionID, string comment)
  282. {
  283. try
  284. {
  285. List<Guid?> list = studentEncourageIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  286. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  287. StudentEncourageServices.Value.StudentEncourageApproveConfirm(list, user.UserID, actionID, comment);
  288. return Json(new ReturnMessage()
  289. {
  290. IsSuccess = true,
  291. Message = "审核成功。"
  292. });
  293. }
  294. catch (Exception ex)
  295. {
  296. return Json(new ReturnMessage()
  297. {
  298. IsSuccess = false,
  299. Message = "审核失败,原因:" + ex.Message
  300. });
  301. }
  302. }
  303. /// <summary>
  304. /// 撤销页面(单个)
  305. /// </summary>
  306. /// <param name="studentEncourageID"></param>
  307. /// <returns></returns>
  308. [HttpGet]
  309. public ActionResult Cancel(Guid? studentEncourageID)
  310. {
  311. var studentEncourageView = new StudentEncourageView();
  312. if (studentEncourageID.HasValue && studentEncourageID != Guid.Empty)
  313. {
  314. studentEncourageView = StudentEncourageServices.Value.GetStudentEncourageView(studentEncourageID);
  315. }
  316. return View(studentEncourageView);
  317. }
  318. /// <summary>
  319. /// 撤销页面(单个)
  320. /// </summary>
  321. /// <param name="studentEncourageView"></param>
  322. /// <returns></returns>
  323. [HttpPost]
  324. public ActionResult Cancel(StudentEncourageView studentEncourageView)
  325. {
  326. try
  327. {
  328. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  329. List<Guid?> list = new List<Guid?>();
  330. list.Add(studentEncourageView.StudentEncourageID);
  331. StudentEncourageServices.Value.StudentEncourageCancelConfirm(list, user.UserID, studentEncourageView.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="studentEncourageIDs"></param>
  351. /// <param name="comment"></param>
  352. /// <returns></returns>
  353. [HttpPost]
  354. public ActionResult CancelConfirm(string studentEncourageIDs, string comment)
  355. {
  356. try
  357. {
  358. List<Guid?> list = studentEncourageIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  359. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  360. StudentEncourageServices.Value.StudentEncourageCancelConfirm(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 encourageNameID = Request.Form["DictionaryEncourageName"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEncourageName"].ParseStrTo<int>();
  396. var encourageTypeID = Request.Form["DictionaryEncourageType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEncourageType"].ParseStrTo<int>();
  397. var encourageLevelID = Request.Form["DictionaryEncourageLevel"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEncourageLevel"].ParseStrTo<int>();
  398. var inSchoolStatus = Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>();
  399. var approvalStatus = Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>();
  400. var dt = StudentEncourageServices.Value.GetStudentEncourageViewList(configuretView, schoolyearID, campusID, collegeID, gradeID, standardID, educationID,
  401. learningformID, learnSystem, encourageNameID, encourageTypeID, encourageLevelID, inSchoolStatus, approvalStatus)
  402. .Select(x => new
  403. {
  404. x.SchoolyearCode,
  405. x.StudentNo,
  406. x.Name,
  407. x.SexName,
  408. x.InSchoolStatusName,
  409. x.StudentStatusName,
  410. x.GradeID,
  411. x.StandardCode,
  412. x.StandardID,
  413. x.StandardName,
  414. x.EducationName,
  415. x.LearningformName,
  416. LearnSystem = x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : null,
  417. x.ClassmajorNo,
  418. x.ClassmajorName,
  419. x.GrademajorCode,
  420. x.GrademajorName,
  421. x.CollegeNo,
  422. x.CollegeName,
  423. x.CampusCode,
  424. x.CampusName,
  425. x.EncourageName,
  426. x.EncourageTypeName,
  427. x.EncourageLevelName,
  428. x.DocNo,
  429. x.Unit,
  430. EncourageDate = x.EncourageDate.HasValue ? x.EncourageDate.Value.ToString("yyyy-MM-dd") : "",
  431. x.Amount,
  432. x.Reason,
  433. x.ApprovalStatusName
  434. }).ToTable();
  435. string[] liststring = {
  436. "学年学期", "学号", "姓名", "性别", "在校状态", "学籍状态", "年级", "专业代码", "专业ID(Value)", "专业名称",
  437. RSL.Get("EducationID"), "学习形式", "学制", "班级编号", "班级名称", "年级专业编号", "年级专业名称",
  438. RSL.Get("CollegeCode"), RSL.Get("CollegeName"), RSL.Get("CampusCode"), RSL.Get("CampusName"), "奖励名称", "奖励类型",
  439. "奖励级别", "奖励文号", "颁奖单位", "奖励日期", "奖励金额", "奖励原因", "审批状态"
  440. };
  441. neh.Export(dt, liststring, "学生奖励信息" + DateTime.Now.ToString("yyyyMMdd"));
  442. return Json(new ReturnMessage()
  443. {
  444. IsSuccess = true,
  445. Message = "导出成功。"
  446. });
  447. }
  448. catch (Exception ex)
  449. {
  450. return Json(new ReturnMessage()
  451. {
  452. IsSuccess = false,
  453. Message = "导出失败,原因:" + ex.Message
  454. });
  455. }
  456. }
  457. }
  458. }