CheckingApproveController.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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.Web.Controls.Mvc;
  9. using Bowin.Common.JSON;
  10. using EMIS.Utility;
  11. using EMIS.Web.Controls;
  12. using EMIS.ViewModel;
  13. using EMIS.ViewModel.WorkflowManage;
  14. using EMIS.ViewModel.StudentManage.OnlineChecking;
  15. using EMIS.CommonLogic.StudentManage.OnlineChecking;
  16. namespace EMIS.Web.Controllers.StudentManage.OnlineChecking
  17. {
  18. [Authorization]
  19. public class CheckingApproveController : Controller
  20. {
  21. public Lazy<ICheckingApproveServices> CheckingApproveServices { get; set; }
  22. /// <summary>
  23. /// 校对审核页面
  24. /// </summary>
  25. /// <returns></returns>
  26. public ActionResult List()
  27. {
  28. return View();
  29. }
  30. /// <summary>
  31. /// 校对审核页面列表查询
  32. /// </summary>
  33. /// <param name="pararms"></param>
  34. /// <returns></returns>
  35. [HttpPost]
  36. public ActionResult List(QueryParamsModel pararms)
  37. {
  38. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  39. var campusID = pararms.getExtraGuid("CampusDropdown");
  40. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  41. var gradeID = pararms.getExtraInt("DictionaryGrade") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGrade");
  42. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  43. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  44. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  45. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  46. var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
  47. return base.Json(CheckingApproveServices.Value.GetCheckingApproveViewGrid(configuretView, campusID, collegeID, gradeID, standardID,
  48. educationID, learningformID, learnSystem, approvalStatus, (int)pararms.page, (int)pararms.rows));
  49. }
  50. /// <summary>
  51. /// 编辑
  52. /// </summary>
  53. /// <param name="studentContrastID"></param>
  54. /// <returns></returns>
  55. [HttpGet]
  56. public ActionResult Edit(Guid? studentContrastID)
  57. {
  58. CheckingContrastView checkingContrastView = new CheckingContrastView();
  59. if (studentContrastID.HasValue && studentContrastID != Guid.Empty)
  60. {
  61. checkingContrastView = CheckingApproveServices.Value.GetStudentContrastView(studentContrastID);
  62. }
  63. return View(checkingContrastView);
  64. }
  65. /// <summary>
  66. /// 编辑
  67. /// </summary>
  68. /// <param name="checkingContrastView"></param>
  69. /// <returns></returns>
  70. [HttpPost]
  71. public ActionResult Edit(CheckingContrastView checkingContrastView)
  72. {
  73. try
  74. {
  75. return Json(new ReturnMessage()
  76. {
  77. IsSuccess = true,
  78. Message = "保存成功。"
  79. });
  80. }
  81. catch (Exception ex)
  82. {
  83. return Json(new ReturnMessage()
  84. {
  85. IsSuccess = false,
  86. Message = "保存失败,原因:" + ex.Message + "。"
  87. });
  88. }
  89. }
  90. /// <summary>
  91. /// 审核(单个页面)
  92. /// </summary>
  93. /// <param name="studentContrastID"></param>
  94. /// <returns></returns>
  95. [HttpGet]
  96. public ActionResult Approve(Guid? studentContrastID)
  97. {
  98. var studentContrastView = CheckingApproveServices.Value.GetStudentContrastView(studentContrastID);
  99. if (studentContrastView == null)
  100. {
  101. return RedirectToAction("MsgShow", "Common", new
  102. {
  103. WindowID = Request["WindowID"],
  104. msg = "操作失败,原因:数据有误。",
  105. url = Url.Action("List").AddMenuParameter()
  106. });
  107. }
  108. var endStatusList = CheckingApproveServices.Value.GetBackpointStatus();
  109. var correctEndStatusID = CheckingApproveServices.Value.GetCorrectEndStatus();
  110. endStatusList.Add(correctEndStatusID);
  111. foreach (var endStatus in endStatusList)
  112. {
  113. if (studentContrastView.ApprovalStatus == endStatus)
  114. {
  115. return RedirectToAction("MsgShow", "Common", new
  116. {
  117. WindowID = Request["WindowID"],
  118. msg = "无法对已结束的流程进行审核。",
  119. url = Url.Action("List").AddMenuParameter()
  120. });
  121. }
  122. }
  123. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  124. var actionViewList = CheckingApproveServices.Value.GetActionView((Guid)studentContrastID, user.UserID);
  125. if (actionViewList == null || actionViewList.Count() <= 0)
  126. {
  127. return RedirectToAction("MsgShow", "Common", new
  128. {
  129. WindowID = Request["WindowID"],
  130. msg = "对不起,您没权限操作。",
  131. url = Url.Action("List").AddMenuParameter()
  132. });
  133. }
  134. var dropList = actionViewList.Select(x => new DropdownListItem { Text = x.ActionName, Value = x.ToJson() }).ToList();
  135. ViewBag.ListAction = dropList;
  136. return View(studentContrastView);
  137. }
  138. /// <summary>
  139. /// 审核(单个页面)
  140. /// </summary>
  141. /// <param name="checkingContrastView"></param>
  142. /// <returns></returns>
  143. [HttpPost]
  144. public ActionResult Approve(CheckingContrastView checkingContrastView)
  145. {
  146. try
  147. {
  148. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  149. string action = Request.Form["ddlAction"];
  150. if (string.IsNullOrEmpty(action))
  151. {
  152. throw new Exception("请选择处理动作");
  153. }
  154. var actionID = action.JsonToObject<ActionView>().ActionID;
  155. List<Guid?> list = new List<Guid?>();
  156. list.Add(checkingContrastView.StudentContrastID);
  157. CheckingApproveServices.Value.CheckingApproveConfirm(list, user.UserID, actionID, checkingContrastView.Comment);
  158. return Json(new ReturnMessage()
  159. {
  160. IsSuccess = true,
  161. Message = "审核成功。"
  162. });
  163. }
  164. catch (Exception ex)
  165. {
  166. return Json(new ReturnMessage()
  167. {
  168. IsSuccess = false,
  169. Message = "审核失败,原因:" + ex.Message
  170. });
  171. }
  172. }
  173. /// <summary>
  174. /// 查询对应的流程环节动作List(ActionView)
  175. /// </summary>
  176. /// <param name="studentContrastID"></param>
  177. /// <returns></returns>
  178. [HttpPost]
  179. public ActionResult ApprovalHandle(Guid? studentContrastID)
  180. {
  181. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  182. var actionViewList = CheckingApproveServices.Value.GetActionView((Guid)studentContrastID, user.UserID);
  183. var dropList = actionViewList.Select(x => new DropdownListItem { Text = x.ActionName, Value = x.ToJson() }).ToList();
  184. return View(dropList);
  185. }
  186. /// <summary>
  187. /// 审批确定(批量)
  188. /// </summary>
  189. /// <param name="studentContrastIDs"></param>
  190. /// <param name="actionID"></param>
  191. /// <param name="comment"></param>
  192. /// <returns></returns>
  193. [HttpPost]
  194. public ActionResult ApproveConfirm(string studentContrastIDs, Guid actionID, string comment)
  195. {
  196. try
  197. {
  198. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  199. List<Guid?> list = studentContrastIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  200. CheckingApproveServices.Value.CheckingApproveConfirm(list, user.UserID, actionID, comment);
  201. return Json(new ReturnMessage()
  202. {
  203. IsSuccess = true,
  204. Message = "审核成功。"
  205. });
  206. }
  207. catch (Exception ex)
  208. {
  209. return Json(new ReturnMessage()
  210. {
  211. IsSuccess = false,
  212. Message = "审核失败,原因:" + ex.Message
  213. });
  214. }
  215. }
  216. /// <summary>
  217. /// 删除
  218. /// </summary>
  219. /// <param name="studentContrastIDs"></param>
  220. /// <returns></returns>
  221. [HttpPost]
  222. public ActionResult Delete(string studentContrastIDs)
  223. {
  224. try
  225. {
  226. List<Guid?> list = studentContrastIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  227. CheckingApproveServices.Value.StudentContrastDelete(list);
  228. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  229. }
  230. catch (Exception ex)
  231. {
  232. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + ex.Message });
  233. }
  234. }
  235. /// <summary>
  236. /// 校对明细页面
  237. /// </summary>
  238. /// <returns></returns>
  239. public ActionResult CheckingDetailList()
  240. {
  241. return View();
  242. }
  243. /// <summary>
  244. /// 校对明细页面
  245. /// </summary>
  246. /// <param name="pararms"></param>
  247. /// <returns></returns>
  248. [HttpPost]
  249. public ActionResult CheckingDetailList(QueryParamsModel pararms)
  250. {
  251. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  252. var studentContrastID = Request["studentContrastID"].ParseStrTo<Guid>();
  253. return Json(CheckingApproveServices.Value.GetCheckingDetailViewGrid(configuretView, studentContrastID, (int)pararms.page, (int)pararms.rows));
  254. }
  255. /// <summary>
  256. /// 导出校对明细Excel
  257. /// </summary>
  258. /// <returns></returns>
  259. [HttpPost]
  260. public ActionResult Excel_CheckingDetail()
  261. {
  262. NpoiExcelHelper neh = new NpoiExcelHelper();
  263. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  264. var studentContrastID = Request["studentContrastID"].ParseStrTo<Guid>();
  265. var dt = CheckingApproveServices.Value.GetCheckingDetailViewList(configuretView, studentContrastID)
  266. .Select(x => new
  267. {
  268. x.StudentNo,
  269. x.Name,
  270. x.Description,
  271. x.CheckingTypeName,
  272. x.CheckingBeforeContent,
  273. x.CheckingAfterContent,
  274. x.IP,
  275. x.ModifyTime
  276. }).ToTable();
  277. string[] liststring = {
  278. "学号", "姓名", "校对名称", "校对类型", "校对前内容", "校对后内容", "IP地址", "申请时间"
  279. };
  280. neh.Export(dt, liststring, "校对明细信息" + DateTime.Now.ToString("yyyyMMdd"));
  281. return Json(new ReturnMessage()
  282. {
  283. IsSuccess = true,
  284. Message = "导出成功。"
  285. });
  286. }
  287. /// <summary>
  288. /// 查询对应的校对信息Style
  289. /// </summary>
  290. /// <typeparam name="T"></typeparam>
  291. /// <param name="before"></param>
  292. /// <param name="after"></param>
  293. /// <returns></returns>
  294. public static string GetCheckingStyle<T>(T before, T after) where T : IComparable<T>
  295. {
  296. if (before == null && after == null)
  297. {
  298. return string.Empty;
  299. }
  300. else if ((before == null && after != null) || (before != null && after == null) || before.CompareTo(after) != 0)
  301. {
  302. return "mark";
  303. }
  304. else
  305. {
  306. return string.Empty;
  307. }
  308. }
  309. /// <summary>
  310. /// 查询对应的校对信息Style
  311. /// </summary>
  312. /// <typeparam name="T"></typeparam>
  313. /// <param name="before"></param>
  314. /// <param name="after"></param>
  315. /// <returns></returns>
  316. public static string GetCheckingStyle<T>(T? before, T? after) where T : struct, IComparable<T>
  317. {
  318. if ((before.HasValue && !after.HasValue) || (!before.HasValue && after.HasValue))
  319. {
  320. return "mark";
  321. }
  322. else
  323. {
  324. if (before.HasValue && after.HasValue)
  325. {
  326. return GetCheckingStyle(before.Value, after.Value);
  327. }
  328. else
  329. {
  330. return string.Empty;
  331. }
  332. }
  333. }
  334. /// <summary>
  335. /// Excel导出
  336. /// </summary>
  337. /// <returns></returns>
  338. [HttpPost]
  339. public ActionResult Excel()
  340. {
  341. NpoiExcelHelper neh = new NpoiExcelHelper();
  342. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  343. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  344. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  345. var gradeID = Request.Form["DictionaryGrade"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo<int>();
  346. var standardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
  347. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  348. var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  349. var learnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  350. var approvalStatus = Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>();
  351. var dt = CheckingApproveServices.Value.GetCheckingApproveViewList(configuretView, campusID, collegeID, gradeID, standardID,
  352. educationID, learningformID, learnSystem, approvalStatus)
  353. .Select(x => new
  354. {
  355. x.StudentNo,
  356. x.Name,
  357. x.SexName,
  358. BirthDate = (x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyyMMdd") : ""),
  359. x.NationName,
  360. x.PoliticsName,
  361. x.CertificatesTypeName,
  362. x.IDNumber,
  363. x.StandardCode,
  364. x.StandardID,
  365. x.StandardName,
  366. x.EducationName,
  367. x.LearningformName,
  368. LearnSystem = x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : "",
  369. x.FacultymajorCode,
  370. x.FacultymajorName,
  371. x.GradeID,
  372. x.GrademajorCode,
  373. x.GrademajorName,
  374. x.ClassmajorNo,
  375. x.ClassmajorName,
  376. x.ClassNum,
  377. x.StudentTypeName,
  378. x.InSchoolStatusName,
  379. x.StudentStatusName,
  380. x.CollegeNo,
  381. x.CollegeName,
  382. x.CampusCode,
  383. x.CampusName,
  384. x.SemesterName,
  385. x.StartSchoolyearCode,
  386. x.GraduateSchoolyearCode,
  387. PlanningGraduateDate = (x.PlanningGraduateDate.HasValue ? x.PlanningGraduateDate.Value.ToString("yyyyMMdd") : ""),
  388. GraduateDate = (x.GraduateDate.HasValue ? x.GraduateDate.Value.ToString("yyyyMMdd") : ""),
  389. x.UsedName,
  390. x.Country,
  391. x.Place,
  392. x.BornPlace,
  393. x.ExamineeType,
  394. EntranceDate = (x.EntranceDate.HasValue ? x.EntranceDate.Value.ToString("yyyyMMdd") : ""),
  395. x.LiteracyLevelName,
  396. x.CultureModelName,
  397. x.IsDreamProjectName,
  398. x.Email,
  399. x.Telephone,
  400. x.Mobile,
  401. x.ZIPCode,
  402. x.WeChatNum,
  403. x.QQ,
  404. x.HealthStateName,
  405. x.BloodGroupName,
  406. x.Specialty,
  407. x.Height,
  408. x.Weight,
  409. x.DirectorName,
  410. x.Score,
  411. x.EntranceWayName,
  412. x.FeaturesName,
  413. x.TerritorialName,
  414. x.Area,
  415. x.HomeAddress,
  416. x.WorkUnit,
  417. x.Address,
  418. x.Recipient,
  419. x.Dormitory,
  420. x.BankName,
  421. x.CardNo,
  422. x.Career,
  423. x.IsProofreadName,
  424. x.CheckingCount,
  425. x.IP,
  426. ModifyTime = (x.ModifyTime.HasValue ? x.ModifyTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""),
  427. x.ApprovalStatusName,
  428. x.Comment
  429. }).ToTable();
  430. string[] liststring = {
  431. "学号", "姓名", "性别", "出生日期", "民族", "政治面貌", "证件类型", "证件号码", "专业代码",
  432. "专业ID(Value)", "专业名称", RSL.Get("EducationID"), "学习形式", "学制", "院系专业编号",
  433. "院系专业名称", "年级", "年级专业编号", "年级专业名称", "班级编号", "班级名称", "班序", "学生类别",
  434. "在校状态", "学籍状态", RSL.Get("CollegeCode"), RSL.Get("College"), RSL.Get("CampusCode"),
  435. RSL.Get("Campus"), "入学学期", "入学学年学期", "毕业学期", "预计毕业日期", "毕业日期", "曾用名",
  436. "国籍", "籍贯", "出生地", "考生类别", "入学日期", "文化程度", "培养方式",
  437. "圆梦计划", "电子邮箱", "家庭电话", "移动电话", "邮政编码", "微信号", "QQ", "健康状况", "血型",
  438. "特长", "身高(cm)", "体重(kg)", "导师姓名", "总分", "入学方式", "考生特征", "生源所属地", "来源地区",
  439. "家庭住址", "工作单位", "通信地址", "收件人" , "宿舍地址", "开户银行", "银行卡号", "在校经历", "是否核对",
  440. "校对数", "IP地址", "申请时间", "审核状态", "处理意见"
  441. };
  442. neh.Export(dt, liststring, "校对审核信息" + DateTime.Now.ToString("yyyyMMdd"));
  443. return Json(new ReturnMessage()
  444. {
  445. IsSuccess = true,
  446. Message = "导出成功。"
  447. });
  448. }
  449. }
  450. }