ScoreController.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.ViewModel;
  7. using EMIS.Web.Controls;
  8. using EMIS.CommonLogic.ScoreManage;
  9. using Bowin.Web.Controls.Mvc;
  10. using EMIS.ViewModel.ScoreManage;
  11. using EMIS.Utility;
  12. using System.Dynamic;
  13. using EMIS.Entities;
  14. using Bowin.Common.Mvc;
  15. using EMIS.ViewModel.CacheManage;
  16. using Bowin.Common.JSON;
  17. using Bowin.Common.Utility;
  18. using Bowin.Common.Data;
  19. using Bowin.Common.Linq;
  20. using System.IO;
  21. using EMIS.CommonLogic.CalendarManage;
  22. using System.Data;
  23. using EMIS.CommonLogic.SystemServices;
  24. using EMIS.CommonLogic.DQPSystem;
  25. using EMIS.ViewModel.DQPSystem;
  26. using System.Text;
  27. using Aspose.Cells;
  28. namespace EMIS.Web.Controllers.ScoreManage
  29. {
  30. [Authorization]
  31. public class ScoreController : Controller
  32. {
  33. public Lazy<IScoreServices> scoreServices { get; set; }
  34. public Lazy<IFinalExaminationServices> finalExaminationServices { get; set; }
  35. public Lazy<IScoreParameterSettingServices> scoreParameterSettingServices { get; set; }
  36. public Lazy<IScoreParamterCollegeSettingServices> ScoreParamterCollegeSettingServices { get; set; }
  37. public Lazy<ICreditFormulaServices> creditFormulaServices { get; set; }
  38. public Lazy<IGradePointFormulaServices> gradePointFormulaServices { get; set; }
  39. public Lazy<IScoreFormulaServices> scoreFormulaServices { get; set; }
  40. public Lazy<ISchoolYearServices> SchoolYearServices { get; set; }
  41. public IExaminationSuspensionServices ExaminationSuspensionServices { get; set; }
  42. public IExaminationExemptionServices ExaminationExemptionServices { get; set; }
  43. public INotPassStudentServices notPassStudentServices { get; set; }
  44. public IMisconductServices MisconductServices { get; set; }
  45. public IImportScoreServices ImportScoreServices { get; set; }
  46. public IParameterServices ParameterServices { get; set; }
  47. public ISOCScoreServices SOCScoreServices { get; set; }
  48. /// <summary>
  49. /// 报表
  50. /// </summary>
  51. /// <param name="FinalExaminationID"></param>
  52. /// <returns></returns>
  53. public ActionResult Report(Guid? FinalExaminationID)
  54. {
  55. ViewBag.FinalExaminationID = FinalExaminationID;
  56. return View();
  57. }
  58. /// <summary>
  59. /// 多报表
  60. /// </summary>
  61. /// <param name="FinalExaminationID"></param>
  62. /// <returns></returns>
  63. public ActionResult ScoreReport(Guid? FinalExaminationID)
  64. {
  65. ViewBag.FinalExaminationID = FinalExaminationID;
  66. return View();
  67. }
  68. /// <summary>
  69. /// 成绩录入页面
  70. /// </summary>
  71. /// <returns></returns>
  72. public ActionResult List()
  73. {
  74. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; //获取当前登录人
  75. ViewBag.UserName = curUser.Name;
  76. var schoolYear = SchoolYearServices.Value.GetSchoolYearIsCurrent(true);
  77. ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年
  78. return View();
  79. }
  80. [HttpPost]
  81. public ActionResult List(QueryParamsModel pararms)
  82. {
  83. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  84. var collegeID = pararms.getExtraGuid("CollegeComboGrid");
  85. var departmentID = pararms.getExtraGuid("DepartmentComboGrid");
  86. var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid");
  87. var courseTypeID = pararms.getExtraInt("DictionaryCourseType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryCourseType");
  88. var examsCategoryID = pararms.getExtraInt("DictionaryExamsCategory") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryExamsCategory");
  89. var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  90. var approvalStatus = pararms.getExtraInt("DictionaryScoreState") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryScoreState");
  91. var gradeYearID = pararms.getExtraInt("DictionaryGrade") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGrade");
  92. var isCheck = "true";//只显示录入人为登录人的信息
  93. return Json(scoreServices.Value.GetFinalExaminationViewGrid(configuretView, collegeID, departmentID, schoolyearID, coursematerialID, courseTypeID, examsCategoryID, approvalStatus, gradeYearID, isCheck, (int)pararms.page, (int)pararms.rows));
  94. }
  95. /// <summary>
  96. /// 成绩录入页面
  97. /// </summary>
  98. /// <param name="finalExaminationID"></param>
  99. /// <returns></returns>
  100. public ActionResult Edit(Guid? finalExaminationID)
  101. {
  102. ScoreEditView scoreEditView = new ScoreEditView();
  103. if (finalExaminationID.HasValue)
  104. {
  105. scoreEditView = new ScoreEditView(finalExaminationServices.Value.GetFinalExaminationView(finalExaminationID));
  106. scoreEditView.ResultType = scoreServices.Value.GetScoreType(finalExaminationID);
  107. }
  108. var scoreParameterSetting = scoreParameterSettingServices.Value.GetScoreParameterSettingList(finalExaminationID);
  109. if (scoreParameterSetting != null)
  110. {
  111. scoreEditView.ScoreFormulaID = scoreEditView.ScoreFormulaID ?? scoreParameterSetting.ScoreFormulaID;
  112. scoreEditView.CreditFormulaID = scoreEditView.CreditFormulaID ?? scoreParameterSetting.CreditFormulaID;
  113. scoreEditView.GradePointFormulaID = scoreEditView.GradePointFormulaID ?? scoreParameterSetting.GradePointFormulaID;
  114. scoreEditView.IsTotalFormula = scoreParameterSetting.IsTotalFormula;
  115. scoreEditView.IsCreditFormula = scoreParameterSetting.IsCreditFormula;
  116. scoreEditView.IsGradePointFormula = scoreParameterSetting.IsGradePointFormula;
  117. scoreEditView.CustomScoreFormula = scoreFormulaServices.Value.GetCustomerScoreFormula();
  118. scoreEditView.ExamsStateSetting = scoreServices.Value.GetExamsStateSettingList();
  119. }
  120. scoreEditView.NormalExamsID = scoreServices.Value.GetNormalExamsID();
  121. scoreEditView.ExaminationSuspensonID = scoreServices.Value.GetExaminationSuspensionID();
  122. scoreEditView.ExaminationExemptionID = scoreServices.Value.GetExaminationExemptionID();
  123. scoreEditView.MisconductIDList = scoreServices.Value.GetMisconductIDList();
  124. var collegeScoreParameterSetting = ScoreParamterCollegeSettingServices.Value.GetScoreParameterCollegeSettingView(scoreEditView.CollegeID, scoreEditView.GradeYearID);
  125. if (collegeScoreParameterSetting != null)
  126. {
  127. scoreEditView.FixScoreTypeID = collegeScoreParameterSetting.ScoreTypeID;
  128. }
  129. scoreEditView.ScoreDigitCount = ParameterServices.GetParameterValue<int>(CF_ParameterType.ScoreDigitCount) ?? 1;
  130. return View(scoreEditView);
  131. }
  132. /// <summary>
  133. /// 成绩提交
  134. /// </summary>
  135. /// <param name="finalExaminationView"></param>
  136. /// <returns></returns>
  137. [HttpPost]
  138. public ActionResult Submit(ScoreEditView finalExaminationView)
  139. {
  140. try
  141. {
  142. var dgScoreDetailList = DataGrid.GetTableData<StudentScoreInputView>("dgScoreDetailList");
  143. //因为成绩保存和提交调用同样的方法,参数传1表示成绩提交
  144. scoreServices.Value.Submit(finalExaminationView, dgScoreDetailList);
  145. return Json(new ReturnMessage()
  146. {
  147. IsSuccess = true,
  148. Message = "提交成功。"
  149. });
  150. }
  151. catch (Exception ex)
  152. {
  153. return Json(new ReturnMessage()
  154. {
  155. IsSuccess = false,
  156. Message = "提交失败,原因:" + ex.Message
  157. });
  158. }
  159. }
  160. /// <summary>
  161. /// 申请重录页面
  162. /// </summary>
  163. /// <param name="finalExaminationID"></param>
  164. /// <returns></returns>
  165. public ActionResult RebutSubmit(Guid? finalExaminationID)
  166. {
  167. ScoreEditView scoreEditView = new ScoreEditView();
  168. if (finalExaminationID.HasValue)
  169. {
  170. scoreEditView = new ScoreEditView(finalExaminationServices.Value.GetFinalExaminationView(finalExaminationID));
  171. }
  172. var scoreParameterSetting = scoreParameterSettingServices.Value.GetScoreParameterSettingList(finalExaminationID);
  173. if (scoreParameterSetting != null)
  174. {
  175. scoreEditView.ScoreFormulaID = scoreEditView.ScoreFormulaID ?? scoreParameterSetting.ScoreFormulaID;
  176. scoreEditView.CreditFormulaID = scoreEditView.CreditFormulaID ?? scoreParameterSetting.CreditFormulaID;
  177. scoreEditView.GradePointFormulaID = scoreEditView.GradePointFormulaID ?? scoreParameterSetting.GradePointFormulaID;
  178. scoreEditView.IsTotalFormula = scoreParameterSetting.IsTotalFormula;
  179. scoreEditView.IsCreditFormula = scoreParameterSetting.IsCreditFormula;
  180. scoreEditView.IsGradePointFormula = scoreParameterSetting.IsGradePointFormula;
  181. scoreEditView.CustomScoreFormula = scoreFormulaServices.Value.GetCustomerScoreFormula();
  182. scoreEditView.ExamsStateSetting = scoreServices.Value.GetExamsStateSettingList();
  183. }
  184. scoreEditView.NormalExamsID = scoreServices.Value.GetNormalExamsID();
  185. scoreEditView.ExaminationSuspensonID = scoreServices.Value.GetExaminationSuspensionID();
  186. scoreEditView.ExaminationExemptionID = scoreServices.Value.GetExaminationExemptionID();
  187. scoreEditView.MisconductIDList = scoreServices.Value.GetMisconductIDList();
  188. scoreEditView.ScoreDigitCount = ParameterServices.GetParameterValue<int>(CF_ParameterType.ScoreDigitCount) ?? 1;
  189. return View(scoreEditView);
  190. }
  191. [HttpPost]
  192. public ActionResult RebutSubmit(string UserID, Guid? finalExaminationID)
  193. {
  194. try
  195. {
  196. List<Guid?> list = new List<Guid?>();
  197. for (int i = 0; i < UserID.Split(',').Length; i++)
  198. {
  199. if (!string.IsNullOrEmpty(UserID.Split(',')[i]))
  200. {
  201. Guid FinalExaminationID = new Guid(UserID.Split(',')[i]);
  202. list.Add(FinalExaminationID);
  203. }
  204. }
  205. scoreServices.Value.Rebut(list, finalExaminationID);
  206. return Json(new ReturnMessage()
  207. {
  208. IsSuccess = true,
  209. Message = "申请重录学生成绩成功,待审核通过后,可重新录入成绩。"
  210. });
  211. }
  212. catch (Exception ex)
  213. {
  214. return Json(new ReturnMessage()
  215. {
  216. IsSuccess = true,
  217. Message = "申请重录学生成绩失败,原因:" + ex.Message + "!"
  218. });
  219. }
  220. }
  221. /// <summary>
  222. /// 保存
  223. /// </summary>
  224. /// <param name="finalExaminationID"></param>
  225. /// <returns></returns>
  226. [HttpPost]
  227. public ActionResult ScoreSave(ScoreEditView finalExaminationView)
  228. {
  229. try
  230. {
  231. var scoreDetailList = DataGrid.GetTableData<StudentScoreInputView>("dgScoreDetailList");
  232. //因为成绩保存和提交调用同样的方法,参数传null表示成绩保存
  233. scoreServices.Value.ScoreSave(finalExaminationView, scoreDetailList);
  234. return Json(new ReturnMessage()
  235. {
  236. IsSuccess = true,
  237. Message = "保存成功。"
  238. });
  239. }
  240. catch (Exception ex)
  241. {
  242. return Json(new ReturnMessage()
  243. {
  244. IsSuccess = true,
  245. Message = "保存失败,原因:" + ex.Message
  246. });
  247. }
  248. }
  249. /// <summary>
  250. /// 重置
  251. /// </summary>
  252. /// <param name="finalExaminationID"></param>
  253. /// <returns></returns>
  254. [HttpPost]
  255. public ActionResult Delete(Guid? finalExaminationID)
  256. {
  257. try
  258. {
  259. scoreServices.Value.ScoreResettingDelete(finalExaminationID);
  260. return Json("成功");
  261. }
  262. catch (Exception ex)
  263. {
  264. return Json("重置失败,原因:" + ex.Message);
  265. }
  266. }
  267. [HttpPost]
  268. public ActionResult GetStudentScoreInputView(Guid? finalExaminationID)
  269. {
  270. var queryStudent = scoreServices.Value.GetStudentScoreInputViewGrid(finalExaminationID);
  271. return Json(queryStudent);
  272. }
  273. /// <summary>
  274. /// 导出
  275. /// </summary>
  276. /// <returns></returns>
  277. [HttpPost]
  278. public ActionResult Excel()
  279. {
  280. NpoiExcelHelper neh = new NpoiExcelHelper();
  281. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  282. var isCheck = Request.Form["isCheck"] == null ? "true" : Request.Form["isCheck"];
  283. var collegeID = Request.Form["CollegeComboGrid"].ParseStrTo<Guid>();
  284. var departmentID = Request.Form["DepartmentComboGrid"].ParseStrTo<Guid>();
  285. var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo<Guid>();
  286. var courseTypeID = Request.Form["DictionaryCourseType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseType"].ParseStrTo<int>();
  287. var examsCategoryID = Request.Form["DictionaryExamsCategory"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryExamsCategory"].ParseStrTo<int>();
  288. var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  289. var approvalStatus = Request.Form["DictionaryScoreState"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryScoreState"].ParseStrTo<int>();
  290. var gradeYearID = Request.Form["DictionaryGrade"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo<int>();
  291. var dt = scoreServices.Value.GetFinalExaminationViewList(configuretView, collegeID, departmentID, schoolyearID, coursematerialID, courseTypeID, examsCategoryID, approvalStatus, gradeYearID, isCheck).Select(x => new
  292. {
  293. x.SchoolyearCode,
  294. x.GradeYearID,
  295. x.CourseCode,
  296. x.CourseName,
  297. x.CourseTypeName,
  298. x.ExamsCategoryName,
  299. x.CreatorUserName,
  300. x.EntryDeadlineTime,
  301. x.ClassName,
  302. x.SAPunlogStudentCount,
  303. x.StudentCount,
  304. x.ApprovalStatusName,
  305. x.Remarks
  306. }).ToTable();
  307. string[] liststring = { "学年学期", "年级", "课程代码", "课程名称", "课程类型", "考试性质","录入人", "录入截止日期", "录入班级",
  308. "未录入学生数", "学生数", "状态", "审核说明" };
  309. neh.Export(dt, liststring, "成绩录入信息");
  310. return RedirectToAction("MsgShow", "Common", new
  311. {
  312. msg = "导出成功!",
  313. url = Url.Action("List").AddMenuParameter()
  314. });
  315. }
  316. /// <summary>
  317. /// 导入
  318. /// </summary>
  319. /// <param name="errorFile"></param>
  320. /// <returns></returns>
  321. public ActionResult Import()
  322. {
  323. return View(new ExcelImportResult());
  324. }
  325. [HttpPost]
  326. public ActionResult Export(Guid? finalExaminationID)
  327. {
  328. NpoiExcelHelper neh = new NpoiExcelHelper();
  329. var queryStudent = scoreServices.Value.GetStudentScoreInputViewGrid(finalExaminationID);
  330. var scoreTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType);
  331. var dt = new DataTable();
  332. var columns = new List<string> { "学号", "姓名", "考试性质" };
  333. foreach (var item in scoreTypes)
  334. {
  335. columns.Add(item.Name);
  336. }
  337. columns.ForEach(x => dt.Columns.Add(x));
  338. foreach (var scoreView in queryStudent.rows)
  339. {
  340. var dataRow = dt.NewRow();
  341. dataRow["学号"] = scoreView.LoginID;
  342. dataRow["姓名"] = scoreView.UserName;
  343. dataRow["考试性质"] = scoreView.ExamsCategoryName;
  344. foreach (var item in scoreTypes)
  345. {
  346. dataRow[item.Name] = scoreView.ScoreDetail[item.Value.ToString()].Score;
  347. }
  348. dt.Rows.Add(dataRow);
  349. }
  350. neh.Export(dt, columns.ToArray(), "学生成绩信息");
  351. return RedirectToAction("MsgShow", "Common", new
  352. {
  353. msg = "导出成功!",
  354. url = Url.Action("Import").AddMenuParameter()
  355. });
  356. }
  357. [HttpPost]
  358. public ActionResult Import(Guid? finalExaminationID)
  359. {
  360. try
  361. {
  362. var file = Request.Files.Get("file");
  363. var accept = new[] { ".xls" };
  364. var p = Path.GetExtension(file.FileName);
  365. if (!accept.Contains(p))
  366. {
  367. throw new Exception("只允许上传xls格式的Excel文件!");
  368. }
  369. string sourceWebPath = FileUploadHelper.UploadFile(file);
  370. var sourcePhysicalPath = Server.MapPath(sourceWebPath);
  371. var result = scoreServices.Value.ScoreImport(sourcePhysicalPath, finalExaminationID);
  372. return View(result);
  373. }
  374. catch (Exception ex)
  375. {
  376. return RedirectToAction("MsgShow", "Common", new
  377. {
  378. WindowID = Request["WindowID"],
  379. msg = "操作失败,原因:" + ex.Message,
  380. url = Url.Action("Edit").AddMenuParameter()
  381. });
  382. }
  383. }
  384. private string GetScoreFormula(Guid? scoreFormulaID)
  385. {
  386. string reulst = string.Empty;
  387. ER_ScoreFormula scoreFormula = scoreFormulaServices.Value.GetScoreFormula(scoreFormulaID);
  388. var scoreType = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ScoreType.ToString());
  389. if (scoreFormula != null)
  390. {
  391. reulst += "{\"ScoreFormulaID\":\"" + scoreFormula.ScoreFormulaID + "\",";
  392. foreach (var st in scoreType)
  393. {
  394. ER_ScoreFormulaDetail scoreFormulaDetail = scoreFormula.ER_ScoreFormulaDetail.ToList().Where(x => x.ScoreType == st.Value).FirstOrDefault();
  395. if (scoreFormulaDetail != null)
  396. reulst += "\"Formula_" + st.Value + "\":\"" + scoreFormulaDetail.Percentage + "\",";
  397. else
  398. reulst += "\"Formula_" + st.Value + "\":\"0\",";
  399. }
  400. reulst = reulst.Substring(0, reulst.Length - 1) + "}";
  401. }
  402. return reulst;
  403. }
  404. private string GetCreditFormula(Guid? CreditFormulaID)
  405. {
  406. string reulst = string.Empty;
  407. ER_CreditFormula creditFormula = creditFormulaServices.Value.GetCreditFormula(CreditFormulaID);
  408. if (creditFormula != null)
  409. {
  410. ER_CreditFormula erCreditFormula = new ER_CreditFormula();
  411. erCreditFormula.CreditFormulaID = creditFormula.CreditFormulaID;
  412. erCreditFormula.Name = creditFormula.Name;
  413. erCreditFormula.Scores = creditFormula.Scores;
  414. reulst = erCreditFormula.ToJson();
  415. }
  416. return reulst;
  417. }
  418. private string GradePointFormula(Guid? GradePointFormulaID)
  419. {
  420. string reulst = string.Empty;
  421. ER_GradePointFormula gradePointFormula = gradePointFormulaServices.Value.GetGradePointFormula(GradePointFormulaID);
  422. if (gradePointFormula != null)
  423. {
  424. GradePointView gradePointFormulaView = new GradePointView();
  425. gradePointFormulaView.GradePointFormulaID = gradePointFormula.GradePointFormulaID;
  426. gradePointFormulaView.Name = gradePointFormula.Name;
  427. gradePointFormulaView.GradePointlimit = gradePointFormula.GradePointlimit;
  428. gradePointFormulaView.GradePointFloor = gradePointFormula.GradePointFloor;
  429. reulst = gradePointFormulaView.ToJson();
  430. }
  431. return reulst;
  432. }
  433. public ActionResult NotPassStudent()
  434. {
  435. var schoolYear = SchoolYearServices.Value.GetSchoolYearIsCurrent(true);
  436. ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.Years.ToString();//默认当前学年
  437. return View();
  438. }
  439. [HttpPost]
  440. public ActionResult NotPassStudent(QueryParamsModel pararms)
  441. {
  442. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  443. var campusID = pararms.getExtraGuid("CampusDropdown");
  444. var years = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  445. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  446. var classMajorID = pararms.getExtraGuid("ClassmajorDropdown");
  447. return Json(notPassStudentServices.GetNotPassStudentGrid(configuretView, campusID, years, standardID, classMajorID, (int)pararms.page, (int)pararms.rows));
  448. }
  449. [HttpPost]
  450. public ActionResult SetScoreBySOCScore(Guid? finalExaminationID)
  451. {
  452. try
  453. {
  454. var socScoreList = SOCScoreServices.GetScoreBySOCScore(finalExaminationID);
  455. return Json(new ReturnMessage<List<SOCCourseScoreView>>()
  456. {
  457. IsSuccess = true,
  458. Message = "同步成功,共同步" + socScoreList.Count + "条记录。",
  459. Data = socScoreList
  460. });
  461. }
  462. catch (Exception ex)
  463. {
  464. return Json(new ReturnMessage()
  465. {
  466. IsSuccess = true,
  467. Message = "同步失败:" + ex.Message
  468. });
  469. }
  470. }
  471. [HttpPost]
  472. public ActionResult StudentResult(List<Guid?> finalExaminationIDList)
  473. {
  474. NpoiExcelHelper neh = new NpoiExcelHelper();
  475. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  476. var isCheck = Request.Form["isCheck"] == null ? "true" : Request.Form["isCheck"];
  477. var collegeID = Request.Form["CollegeComboGrid"].ParseStrTo<Guid>();
  478. var departmentID = Request.Form["DepartmentComboGrid"].ParseStrTo<Guid>();
  479. var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo<Guid>();
  480. var courseTypeID = Request.Form["DictionaryCourseType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseType"].ParseStrTo<int>();
  481. var examsCategoryID = Request.Form["DictionaryExamsCategory"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryExamsCategory"].ParseStrTo<int>();
  482. var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  483. var approvalStatus = Request.Form["DictionaryScoreState"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryScoreState"].ParseStrTo<int>();
  484. var gradeYearID = Request.Form["DictionaryGrade"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo<int>();
  485. var finalExaminationList = scoreServices.Value.GetFinalExaminationViewList(configuretView, collegeID, departmentID, schoolyearID, coursematerialID, courseTypeID, examsCategoryID, approvalStatus, gradeYearID, null, finalExaminationIDList).ToList();
  486. var scoreFormulaList = scoreServices.Value.GetScoreFormulaList();
  487. AsposeExcelHelper excel = new AsposeExcelHelper();
  488. List<PageItem> pageList = new List<PageItem>();
  489. List<CellItem> cellItems = new List<CellItem>();
  490. foreach (var finalExamination in finalExaminationList)
  491. {
  492. var scoreFormula = scoreFormulaList.FirstOrDefault(x => x.ScoreFormulaID == finalExamination.ScoreFormulaID);
  493. CellItem cell = new CellItem();
  494. cell.Row = 1;
  495. cell.Col = 1;
  496. cell.Value = "学时:" + finalExamination.TotalHours.ToString();
  497. cellItems.Add(cell);
  498. CellItem cell1 = new CellItem();
  499. cell1.Row = 1;
  500. cell1.Col = 3;
  501. cell1.Value = finalExamination.ExamsDatetime == null ? "":finalExamination.ExamsDatetime.Value.ToLongDateString();
  502. cellItems.Add(cell1);
  503. CellItem cell2 = new CellItem();
  504. cell2.Row = 1;
  505. cell2.Col = 9;
  506. cell2.Value = DateTime.Now.ToShortDateString();
  507. cellItems.Add(cell2);
  508. CellItem cell3 = new CellItem();
  509. cell3.Row = 1;
  510. cell3.Col = 11;
  511. cell3.Value = scoreFormula == null ? "" : scoreFormula.Name;
  512. cellItems.Add(cell3);
  513. CellItem cell4 = new CellItem();
  514. cell4.Row = 2;
  515. cell4.Col = 1;
  516. cell4.Value = "系部:" + finalExamination.CollegeName;
  517. cellItems.Add(cell4);
  518. CellItem cell5 = new CellItem();
  519. cell5.Row = 2;
  520. cell5.Col = 5;
  521. cell5.Value = finalExamination.ClassName;
  522. cellItems.Add(cell5);
  523. CellItem cell6 = new CellItem();
  524. cell6.Row = 2;
  525. cell6.Col = 11;
  526. cell6.Value = finalExamination.ExamsCategoryName;
  527. cellItems.Add(cell6);
  528. var studentsScoreList = scoreServices.Value.GetStudentScoreInputViewGrid(finalExamination.FinalExaminationID).rows.ToList();
  529. var leftList = studentsScoreList.Where(x => x.No % 2 == 1).ToList();
  530. var rightList = studentsScoreList.Where(x => x.No % 2 == 0).ToList();
  531. string[][] leftvs = leftList.Select((data, i) => new string[]{
  532. data.No.ToString(),
  533. data.LoginID,
  534. data.UserName,
  535. data.ScoreDetail.FirstOrDefault(x => x.Value.ScoreTypeID == (int)CF_ScoreType.Peacetime).Value.Score.ToString(),
  536. data.ScoreDetail.FirstOrDefault(x => x.Value.ScoreTypeID == (int)CF_ScoreType.Technique).Value.Score.ToString(),
  537. data.ScoreDetail.FirstOrDefault(x => x.Value.ScoreTypeID == (int)CF_ScoreType.Theoretical).Value.Score.ToString(),
  538. data.TotalScore.ToString(),
  539. "",
  540. "",
  541. "",
  542. "",
  543. "",
  544. "",
  545. "",
  546. ""
  547. }).ToArray();
  548. string[][] rightvs = rightList.Select((data, i) => new string[]{
  549. "",
  550. "",
  551. "",
  552. "",
  553. "",
  554. "",
  555. "",
  556. "",
  557. data.No.ToString(),
  558. data.LoginID,
  559. data.UserName,
  560. data.ScoreDetail.FirstOrDefault(x => x.Value.ScoreTypeID == (int)CF_ScoreType.Peacetime).Value.Score.ToString(),
  561. data.ScoreDetail.FirstOrDefault(x => x.Value.ScoreTypeID == (int)CF_ScoreType.Technique).Value.Score.ToString(),
  562. data.ScoreDetail.FirstOrDefault(x => x.Value.ScoreTypeID == (int)CF_ScoreType.Theoretical).Value.Score.ToString(),
  563. data.TotalScore.ToString()
  564. }).ToArray();
  565. for (var i = 0; i < rightvs.Count(); i++)
  566. {
  567. for (var j = 8; j < leftvs[i].Length; j++)
  568. {
  569. leftvs[i][j] = rightvs[i][j];
  570. }
  571. }
  572. int fen90 = 0;
  573. int fen80 = 0;
  574. int fen70 = 0;
  575. int fen60 = 0;
  576. int fen0 = 0;
  577. fen90 = studentsScoreList.Where(x => x.TotalScore >= 90).Count();
  578. fen80 = studentsScoreList.Where(x => x.TotalScore >= 80 && x.TotalScore < 90).Count();
  579. fen70 = studentsScoreList.Where(x => x.TotalScore >= 70 && x.TotalScore < 80).Count();
  580. fen60 = studentsScoreList.Where(x => x.TotalScore >= 60 && x.TotalScore < 70).Count();
  581. fen0 = studentsScoreList.Where(x => x.TotalScore <= 60).Count();
  582. CellItem cell7 = new CellItem();
  583. cell7.Row = 6;
  584. cell7.Col = 2;
  585. cell7.Value = "90分以上:" + fen90.ToString() + " 80-90分:" + fen80.ToString() + " 70-80分:" + fen70.ToString() + " 60-70分:" + fen60.ToString() + " 60分以下:" + fen0.ToString();
  586. cellItems.Add(cell7);
  587. pageList.Add(new PageItem
  588. {
  589. CellItemList = cellItems,
  590. ListItemList = new List<ListItem>
  591. {
  592. new ListItem(){ StartRow=4,StartColumn=0,EndColumn=14,Values=leftvs },
  593. }
  594. });
  595. }
  596. var newExcelName = Guid.NewGuid().ToString() + DateTime.Now.Ticks.ToString() + ".xlsx";
  597. FileInfo file = new FileInfo(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + "studentResult.xlsx"));
  598. file.CopyTo(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + newExcelName));
  599. FileInfo newfile = new FileInfo(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + newExcelName));
  600. var stream = new FileStream(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + newExcelName), FileMode.Open);
  601. var excelNewStream = excel.ExportToTemplate(stream, pageList);
  602. var fileName = ExcelToPDF.ExportToFile(excelNewStream, Const.LOCAL_SETTING_UPLOAD_FILEPATH);
  603. var url = HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Host + ":" + HttpContext.Request.Url.Port + Url.Content("~/").TrimEnd('/');
  604. //var host = HttpContext.Request.Url;
  605. var fileUrl = url + fileName.Substring(1, fileName.Length - 1);
  606. stream.Close();
  607. newfile.Delete();
  608. return Json(new ReturnMessage()
  609. {
  610. IsSuccess = true,
  611. Message = fileUrl,
  612. });
  613. }
  614. [HttpPost]
  615. public ActionResult ReportTest()
  616. {
  617. //ExcelForPDF.Worksheet
  618. AsposeExcelHelper excel = new AsposeExcelHelper();
  619. var pageList = new List<PageItem>();
  620. var stream = new FileStream(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + "scorePDF.xlsx"), FileMode.Open);
  621. var excelNewStream = excel.ExportToTemplate(stream, pageList);
  622. var fileName = ExcelToPDF.ExportToFile(excelNewStream, Const.LOCAL_SETTING_UPLOAD_FILEPATH);
  623. var url = HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Host + ":" + HttpContext.Request.Url.Port + Url.Content("~/").TrimEnd('/');
  624. //var host = HttpContext.Request.Url;
  625. var fileUrl = url + fileName.Substring(1, fileName.Length - 1);
  626. return Json(new ReturnMessage()
  627. {
  628. IsSuccess = true,
  629. Message = fileUrl,
  630. });
  631. //File(Server.MapPath(fileName), "application/x-pdf", "测试" + DateTime.Now.ToString("yyyyMMdd") + ".pdf");
  632. }
  633. }
  634. }