CompletionListController.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using System.Text;
  7. using Bowin.Web.Controls.Mvc;
  8. using Bowin.Common.Utility;
  9. using Bowin.Common.Data;
  10. using EMIS.Utility;
  11. using EMIS.Web.Controls;
  12. using EMIS.ViewModel;
  13. using EMIS.ViewModel.GraduationManage.GraduationManage;
  14. using EMIS.CommonLogic.GraduationManage.CompletionManage;
  15. namespace EMIS.Web.Controllers.GraduationManage.CompletionManage
  16. {
  17. [Authorization]
  18. public class CompletionListController : Controller
  19. {
  20. public ICompletionListServices CompletionListServices { get; set; }
  21. /// <summary>
  22. /// 结业名单页面
  23. /// </summary>
  24. /// <returns></returns>
  25. public ActionResult List()
  26. {
  27. return View();
  28. }
  29. /// <summary>
  30. /// 结业名单列表查询
  31. /// </summary>
  32. /// <param name="pararms"></param>
  33. /// <returns></returns>
  34. [HttpPost]
  35. public ActionResult List(QueryParamsModel pararms)
  36. {
  37. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  38. var gradSchoolyearID = pararms.getExtraGuid("GradSchoolyearDropdown");
  39. var campusID = pararms.getExtraGuid("CampusDropdown");
  40. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  41. var yearID = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  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. //毕业类型
  47. var graduationTypeID = pararms.getExtraInt("DictionaryGraduationType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGraduationType");
  48. //培养类型
  49. var educationTypeID = pararms.getExtraInt("DictionaryEducationType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducationType");
  50. //在校状态
  51. var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
  52. return base.Json(CompletionListServices.GetCompletionListViewGrid(configuretView, gradSchoolyearID, campusID, collegeID,
  53. yearID, standardID, educationID, learningformID, learnSystem, graduationTypeID, educationTypeID, inSchoolStatus, (int)pararms.page, (int)pararms.rows));
  54. }
  55. /// <summary>
  56. /// 编辑(新增、修改,业务主键:学生信息ID、流程结束状态(已通过))
  57. /// </summary>
  58. /// <param name="graduationApplyID"></param>
  59. /// <returns></returns>
  60. [HttpGet]
  61. public ActionResult Edit(Guid? graduationApplyID)
  62. {
  63. GraduationApplyView graduationApplyView = new GraduationApplyView();
  64. if (graduationApplyID.HasValue && graduationApplyID != Guid.Empty)
  65. {
  66. graduationApplyView = CompletionListServices.GetCompletionListView(graduationApplyID);
  67. }
  68. else
  69. {
  70. graduationApplyView.GraduatingSemesterID = BaseExtensions.GetGradSchoolYearID();
  71. graduationApplyView.ApplySchoolyearID = BaseExtensions.GetCurrentSchoolYearID();
  72. graduationApplyView.GraduationResult = (int)ER_GraduationResult.Completion;
  73. }
  74. return View(graduationApplyView);
  75. }
  76. /// <summary>
  77. /// 编辑(新增、修改,业务主键:学生信息ID、流程结束状态(已通过))
  78. /// </summary>
  79. /// <param name="graduationApplyView"></param>
  80. /// <returns></returns>
  81. [HttpPost]
  82. public ActionResult Edit(GraduationApplyView graduationApplyView)
  83. {
  84. try
  85. {
  86. CompletionListServices.CompletionListEdit(graduationApplyView);
  87. return Json(new ReturnMessage()
  88. {
  89. IsSuccess = true,
  90. Message = "保存成功。"
  91. });
  92. }
  93. catch (Exception ex)
  94. {
  95. return Json(new ReturnMessage()
  96. {
  97. IsSuccess = false,
  98. Message = "保存失败,原因:" + ex.Message
  99. });
  100. }
  101. }
  102. /// <summary>
  103. /// 通用学生成绩报表
  104. /// </summary>
  105. /// <returns></returns>
  106. public ActionResult CompletionScoreReport()
  107. {
  108. return View();
  109. }
  110. /// <summary>
  111. /// 广体学生成绩报表
  112. /// </summary>
  113. /// <returns></returns>
  114. public ActionResult GztyCompletionScoreReport()
  115. {
  116. return View();
  117. }
  118. /// <summary>
  119. /// 工大学生成绩报表
  120. /// </summary>
  121. /// <returns></returns>
  122. public ActionResult HbgdCompletionScoreReport()
  123. {
  124. return View();
  125. }
  126. /// <summary>
  127. /// 结业证书打印
  128. /// </summary>
  129. /// <returns></returns>
  130. public ActionResult Certificate()
  131. {
  132. return View();
  133. }
  134. /// <summary>
  135. /// 删除(事务处理)
  136. /// 注:需考虑对应的在校状态、毕结业证书编号等信息的处理
  137. /// </summary>
  138. /// <param name="graduationApplyIDs"></param>
  139. /// <returns></returns>
  140. [HttpPost]
  141. public ActionResult Delete(string graduationApplyIDs)
  142. {
  143. try
  144. {
  145. List<Guid?> list = graduationApplyIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  146. .Select(x => (Guid?)new Guid(x)).ToList();
  147. CompletionListServices.CompletionListDelete(list);
  148. return base.Json("删除成功。");
  149. }
  150. catch (Exception ex)
  151. {
  152. return base.Json("删除失败,原因:" + ex.Message);
  153. }
  154. }
  155. /// <summary>
  156. /// Excel导出
  157. /// </summary>
  158. /// <returns></returns>
  159. [HttpPost]
  160. public ActionResult Excel()
  161. {
  162. NpoiExcelHelper neh = new NpoiExcelHelper();
  163. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  164. var gradSchoolyearID = Request.Form["GradSchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["GradSchoolyearDropdown"].ParseStrTo<Guid>();
  165. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  166. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  167. var yearID = Request.Form["DictionarySchoolyear"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyear"].ParseStrTo<int>();
  168. var standardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
  169. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  170. var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  171. var learnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  172. //毕业类型
  173. var graduationTypeID = Request.Form["DictionaryGraduationType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGraduationType"].ParseStrTo<int>();
  174. //培养类型
  175. var educationTypeID = Request.Form["DictionaryEducationType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducationType"].ParseStrTo<int>();
  176. //在校状态
  177. var inSchoolStatus = Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>();
  178. var dt = CompletionListServices.GetCompletionListViewList(configuretView, gradSchoolyearID, campusID, collegeID, yearID,
  179. standardID, educationID, learningformID, learnSystem, graduationTypeID, educationTypeID, inSchoolStatus)
  180. .Select(x => new
  181. {
  182. x.GraduatingSemesterCode,
  183. x.StudentNo,
  184. x.UserName,
  185. x.SexName,
  186. x.GraduationTypeName,
  187. BirthDate = x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyyMMdd") : "",
  188. x.StandardID,
  189. x.StandardCode,
  190. x.StandardName,
  191. x.ScienceclassName,
  192. x.SchoolyearID,
  193. x.CampusName,
  194. x.CollegeNo,
  195. x.CollegeName,
  196. x.GrademajorCode,
  197. x.GrademajorName,
  198. x.ClassNo,
  199. x.ClassName,
  200. x.EducationName,
  201. x.LearningformName,
  202. LearnSystem = x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : null,
  203. x.ExamineeNum,
  204. x.NationName,
  205. x.PoliticsName,
  206. x.IDNumber,
  207. EntranceDate = x.EntranceDate.HasValue ? x.EntranceDate.Value.ToString("yyyyMMdd") : "",
  208. x.ZIPCode,
  209. x.Telephone,
  210. x.Address,
  211. x.InSchoolStatusName,
  212. x.StudentStatusName,
  213. x.GraduationResultName,
  214. x.GraduateCardNo,
  215. x.ApprovalResult,
  216. x.Remark
  217. }).ToTable();
  218. string[] liststring = {
  219. "结业学期", "学号", "姓名", "性别", "毕业类型", "出生日期", "专业ID(Value)", "专业代码", "专业名称",
  220. "专业科类", "年级", RSL.Get("CampusName"), RSL.Get("CollegeCode"), RSL.Get("CollegeName"),
  221. "年级专业编号", "年级专业名称", "班级编号", "班级名称", RSL.Get("EducationID"), "学习形式", "学制",
  222. "考生号", "民族", "政治面貌", "身份证号", "入学日期", "邮政编码", "联系电话", "通讯地址", "在校状态",
  223. "学籍状态", "毕业结论", "结业证书编号", "预审说明", "备注"
  224. };
  225. neh.Export(dt, liststring, "结业名单信息" + DateTime.Now.ToString("yyyyMMdd"));
  226. return Json(new ReturnMessage()
  227. {
  228. IsSuccess = true,
  229. Message = "导出成功。"
  230. });
  231. }
  232. /// <summary>
  233. /// 结业证书编号Excel导入
  234. /// </summary>
  235. /// <param name="errorFile"></param>
  236. /// <param name="operationTips"></param>
  237. /// <returns></returns>
  238. [HttpGet]
  239. public ActionResult CompletionNoImport(string errorFile, string operationTips)
  240. {
  241. ViewBag.ErrorFile = errorFile;
  242. if (string.IsNullOrEmpty(operationTips))
  243. {
  244. operationTips = "点击查看失败原因...";
  245. }
  246. ViewBag.operationTips = operationTips;
  247. return View();
  248. }
  249. /// <summary>
  250. /// 结业证书编号Excel导入
  251. /// </summary>
  252. /// <param name="file"></param>
  253. /// <returns></returns>
  254. [HttpPost]
  255. public ActionResult CompletionNoImport(HttpPostedFileBase file)
  256. {
  257. try
  258. {
  259. if (!NpoiExcelHelper.GetIsCompatible(file.FileName))
  260. {
  261. throw new Exception("格式错误,只允许导入xls或xlsx格式的Excel文件。");
  262. }
  263. Dictionary<string, string> cellheader = new Dictionary<string, string>
  264. {
  265. { "StudentNo", "学号" },
  266. { "GraduateCardNo", "结业证书编号" },
  267. { "ErrorMessage", "未导入原因" }
  268. };
  269. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  270. string sourceWebPath = FileUploadHelper.UploadFile(file);
  271. var sourcePhysicalPath = Server.MapPath(sourceWebPath);
  272. List<GraduationApplyView> errList = new List<GraduationApplyView>();
  273. List<GraduationApplyView> dataList = new List<GraduationApplyView>();
  274. int? inCount = 0; //导入个数
  275. int? upCount = 0; //更新个数
  276. int? errCount = 0; //失败个数
  277. //导入
  278. CompletionListServices.CompletionNoImport(cellheader, out inCount, out upCount, out errList, out errCount, sourcePhysicalPath);
  279. System.IO.File.Delete(sourcePhysicalPath);//删除本地缓存文件
  280. if (errList.Count() > 0)
  281. {
  282. //获取错误数据文件路径
  283. string errorWebPath = string.Format("{0}", NpoiExcelHelper.EntityListToExcel2003(cellheader, errList, "结业证书编号导入失败文件", sourcePhysicalPath));
  284. ViewBag.ErrorFile = errorWebPath;
  285. string Errinfo = string.Format("提示:{0}条结业证书编号导入成功,{1}条结业证书编号导入失败,点击查看。", upCount, errCount);
  286. ViewBag.operationTips = Errinfo;
  287. return RedirectToAction("MsgShow", "Common", new
  288. {
  289. WindowID = "none",
  290. msg = Errinfo,
  291. url = Url.Action("CompletionNoImport").AddMenuParameter() + "&errorFile=" + errorWebPath + "&operationTips=" + Errinfo + "&WindowID=" + Request["WindowID"]
  292. });
  293. }
  294. else
  295. {
  296. string successInfo = string.Format("提示:{0}条结业证书编号导入成功。", upCount);
  297. return RedirectToAction("MsgShow", "Common", new
  298. {
  299. WindowID = Request["WindowID"],
  300. msg = successInfo,
  301. url = Url.Action("List").AddMenuParameter()
  302. });
  303. }
  304. }
  305. catch (Exception ex)
  306. {
  307. return RedirectToAction("MsgShow", "Common", new
  308. {
  309. WindowID = "none",
  310. msg = "导入失败,原因:" + ex.Message,
  311. url = Url.Action("CompletionNoImport").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  312. });
  313. }
  314. }
  315. }
  316. }