Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

377 wiersze
12 KiB

  1. using Learun.Util;
  2. using System.Data;
  3. using Learun.Application.TwoDevelopment.EducationalAdministration;
  4. using System.Web.Mvc;
  5. using System.Collections.Generic;
  6. using System;
  7. using System.Linq;
  8. using Newtonsoft.Json;
  9. namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  13. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2022-04-14 18:12
  16. /// 描 述:考试记录表
  17. /// </summary>
  18. public class Exam_ExamPlanController : MvcControllerBase
  19. {
  20. private Exam_ExamPlanIBLL exam_ExamPlanIBLL = new Exam_ExamPlanBLL();
  21. private Exam_ExamPlanLessonIBLL exam_ExamPlanLessonIBLL = new Exam_ExamPlanLessonBLL();
  22. private Exam_ExamPlanClassIBLL exam_ExamPlanClassIBLL = new Exam_ExamPlanClassBLL();
  23. private Exam_ExamPlanRoomIBLL exam_ExamPlanRoomIBLL = new Exam_ExamPlanRoomBLL();
  24. #region 视图功能
  25. /// <summary>
  26. /// 主页面
  27. /// <summary>
  28. /// <returns></returns>
  29. [HttpGet]
  30. public ActionResult Index()
  31. {
  32. return View();
  33. }
  34. /// <summary>
  35. /// 表单页
  36. /// <summary>
  37. /// <returns></returns>
  38. [HttpGet]
  39. public ActionResult Form()
  40. {
  41. return View();
  42. }
  43. /// <summary>
  44. /// 表单页
  45. /// <summary>
  46. /// <returns></returns>
  47. [HttpGet]
  48. public ActionResult GenerateForm()
  49. {
  50. return View();
  51. }
  52. /// <summary>
  53. /// 表单页
  54. /// <summary>
  55. /// <returns></returns>
  56. [HttpGet]
  57. public ActionResult ClearForm()
  58. {
  59. return View();
  60. }
  61. /// <summary>
  62. /// 安排时间
  63. /// <summary>
  64. /// <returns></returns>
  65. [HttpGet]
  66. public ActionResult FormTime()
  67. {
  68. return View();
  69. }
  70. #endregion
  71. #region 获取数据
  72. /// <summary>
  73. /// 获取页面显示列表数据
  74. /// </summary>
  75. /// <param name="pagination">分页参数</param>
  76. /// <param name="queryJson">查询参数</param>
  77. /// <returns></returns>
  78. [HttpGet]
  79. [AjaxOnly]
  80. public ActionResult GetPageList(string pagination, string queryJson)
  81. {
  82. Pagination paginationobj = pagination.ToObject<Pagination>();
  83. var data = exam_ExamPlanIBLL.GetPageList(paginationobj, queryJson);
  84. var jsonData = new
  85. {
  86. rows = data,
  87. total = paginationobj.total,
  88. page = paginationobj.page,
  89. records = paginationobj.records
  90. };
  91. return Success(jsonData);
  92. }
  93. /// <summary>
  94. /// 获取表单数据
  95. /// </summary>
  96. /// <param name="keyValue">主键</param>
  97. /// <returns></returns>
  98. [HttpGet]
  99. [AjaxOnly]
  100. public ActionResult GetFormData(string keyValue)
  101. {
  102. var Exam_ExamPlanData = exam_ExamPlanIBLL.GetExam_ExamPlanEntity(keyValue);
  103. var jsonData = new
  104. {
  105. Exam_ExamPlan = Exam_ExamPlanData,
  106. };
  107. return Success(jsonData);
  108. }
  109. /// <summary>
  110. /// 安排时间
  111. /// </summary>
  112. /// <param name="EPId"></param>
  113. /// <returns></returns>
  114. [HttpGet]
  115. [AjaxOnly]
  116. public ActionResult GetPlanTimeList(string EPId)
  117. {
  118. var data = exam_ExamPlanIBLL.GetPlanTimeList(EPId);
  119. return Success(data);
  120. }
  121. #endregion
  122. #region 提交数据
  123. /// <summary>
  124. /// 删除实体数据
  125. /// </summary>
  126. /// <param name="keyValue">主键</param>
  127. /// <returns></returns>
  128. [HttpPost]
  129. [AjaxOnly]
  130. public ActionResult DeleteForm(string keyValue)
  131. {
  132. exam_ExamPlanIBLL.DeleteEntity(keyValue);
  133. return Success("删除成功!");
  134. }
  135. /// <summary>
  136. /// 生成排考名单
  137. /// </summary>
  138. /// <param name="keyValue"></param>
  139. /// <returns></returns>
  140. [HttpPost]
  141. [AjaxOnly]
  142. public ActionResult Generate(string keyValue)
  143. {
  144. var data = exam_ExamPlanIBLL.IsGenerate(keyValue);
  145. if (!data.flag)
  146. {
  147. return Fail(data.str);
  148. }
  149. exam_ExamPlanIBLL.Generate(keyValue);
  150. return Success("生成成功!");
  151. }
  152. /// <summary>
  153. /// 安排考试
  154. /// </summary>
  155. /// <param name="EPId"></param>
  156. /// <returns></returns>
  157. [HttpPost]
  158. [AjaxOnly]
  159. public ActionResult SavePlanTime(string EPId, List<Exam_ExamPlanTimeEntity> list)
  160. {
  161. if (list.Count <= 0)
  162. {
  163. return Fail("请安排时间!");
  164. }
  165. foreach (var entity in list)
  166. {
  167. DateTime time;
  168. if (!DateTime.TryParse(entity.ExamTimeStart, out time))
  169. {
  170. return Fail("开始时间格式不正确!");
  171. }
  172. if (!DateTime.TryParse(entity.ExamTimeEnd, out time))
  173. {
  174. return Fail("结束时间格式不正确!");
  175. }
  176. var startTime = Convert.ToDateTime(entity.ExamDate.Value.ToString("yyyy-MM-dd") + " " + entity.ExamTimeStart);
  177. var endTime = Convert.ToDateTime(entity.ExamDate.Value.ToString("yyyy-MM-dd") + " " + entity.ExamTimeEnd);
  178. if (endTime <= startTime)
  179. {
  180. return Fail("结束时间必须大于开始时间!");
  181. }
  182. //考试时长
  183. entity.ExamTimeLength = (endTime - startTime).TotalMinutes;
  184. }
  185. exam_ExamPlanIBLL.SavePlanTime(EPId, list);
  186. return Success("保存成功!");
  187. }
  188. /// <summary>
  189. /// 清除排考名单/清除所有排考记录
  190. /// </summary>
  191. /// <param name="keyValue">排考记录主表Id</param>
  192. /// <param name="type">1:清除排考名单;2:清除所有排考记录</param>
  193. /// <returns></returns>
  194. [HttpPost]
  195. [AjaxOnly]
  196. public ActionResult ClearGenerate(string keyValue, int type)
  197. {
  198. exam_ExamPlanIBLL.ClearGenerate(keyValue, type);
  199. return Success("操作成功!");
  200. }
  201. /// <summary>
  202. /// 保存实体数据(新增、修改)
  203. /// </summary>
  204. /// <param name="keyValue">主键</param>
  205. /// <param name="strEntity">实体</param>
  206. /// <returns></returns>
  207. [HttpPost]
  208. [ValidateAntiForgeryToken]
  209. [AjaxOnly]
  210. public ActionResult SaveForm(string keyValue, string strEntity)
  211. {
  212. Exam_ExamPlanEntity entity = strEntity.ToObject<Exam_ExamPlanEntity>();
  213. exam_ExamPlanIBLL.SaveEntity(keyValue, entity);
  214. if (string.IsNullOrEmpty(keyValue))
  215. {
  216. }
  217. return Success("保存成功!");
  218. }
  219. /// <summary>
  220. /// 生成排考名单
  221. /// </summary>
  222. /// <param name="AcademicYearNo"></param>
  223. /// <param name="Semester"></param>
  224. /// <param name="PlanType"></param>
  225. /// <returns></returns>
  226. [HttpPost]
  227. [ValidateAntiForgeryToken]
  228. [AjaxOnly]
  229. public ActionResult GenerateForm(string AcademicYearNo, string Semester, string PlanType)
  230. {
  231. int res = exam_ExamPlanIBLL.ClaerForm(AcademicYearNo, Semester, PlanType);
  232. return Success("清空(" + res + ")条数据成功!");
  233. }
  234. /// <summary>
  235. /// 清除排考名单
  236. /// </summary>
  237. /// <param name="AcademicYearNo"></param>
  238. /// <param name="Semester"></param>
  239. /// <param name="PlanType"></param>
  240. /// <returns></returns>
  241. [HttpPost]
  242. [ValidateAntiForgeryToken]
  243. [AjaxOnly]
  244. public ActionResult ClearForm(string AcademicYearNo, string Semester, string PlanType)
  245. {
  246. int res = exam_ExamPlanIBLL.GenerateForm(AcademicYearNo, Semester, PlanType);
  247. return Success("清空(" + res + ")条数据成功!");
  248. }
  249. /// <summary>
  250. /// 一键安排课程
  251. /// </summary>
  252. /// <param name="keyValue"></param>
  253. /// <returns></returns>
  254. [HttpPost]
  255. [AjaxOnly]
  256. public ActionResult PlanLessonByEPId(string keyValue)
  257. {
  258. exam_ExamPlanLessonIBLL.InitExamPlanLesson(keyValue);
  259. return Success("操作成功!");
  260. }
  261. /// <summary>
  262. /// 一键安排班级
  263. /// </summary>
  264. /// <param name="keyValue"></param>
  265. /// <returns></returns>
  266. [HttpPost]
  267. [AjaxOnly]
  268. public ActionResult PlanClassByEPId(string keyValue)
  269. {
  270. var count = exam_ExamPlanLessonIBLL.GetListByEPId(keyValue).Count();
  271. if (count <= 0)
  272. {
  273. return Fail("请先安排课程!");
  274. }
  275. exam_ExamPlanClassIBLL.PlanClassByEPId(keyValue);
  276. return Success("操作成功!");
  277. }
  278. /// <summary>
  279. /// 自动生成考试课程排考时间
  280. /// </summary>
  281. /// <param name="keyValue"></param>
  282. /// <returns></returns>
  283. [HttpPost]
  284. [AjaxOnly]
  285. public ActionResult PlanLessonTimeByEPId(string keyValue)
  286. {
  287. var count = exam_ExamPlanLessonIBLL.GetListByEPId(keyValue).Count();
  288. if (count <= 0)
  289. {
  290. return Fail("请先安排课程!");
  291. }
  292. var res = exam_ExamPlanLessonIBLL.PlanLessonTimeByEPId(keyValue);
  293. if (res.flag)
  294. {
  295. return Success("操作成功!");
  296. }
  297. else
  298. {
  299. return Fail(res.msg);
  300. }
  301. return Success("操作成功!");
  302. }
  303. /// <summary>
  304. /// 一键安排考场
  305. /// </summary>
  306. /// <param name="keyValue"></param>
  307. /// <returns></returns>
  308. [HttpPost]
  309. [AjaxOnly]
  310. public ActionResult PlanRoomByEPId(string keyValue)
  311. {
  312. var res = exam_ExamPlanRoomIBLL.PlanRoomByEPId(keyValue);
  313. if (!res.flag)
  314. {
  315. return Fail(res.str);
  316. }
  317. return Success("操作成功!");
  318. }
  319. /// <summary>
  320. /// 一键安排监考老师
  321. /// </summary>
  322. /// <param name="keyValue"></param>
  323. /// <returns></returns>
  324. [HttpPost]
  325. [AjaxOnly]
  326. public ActionResult PlanTeacherByEPId(string keyValue)
  327. {
  328. var res = exam_ExamPlanRoomIBLL.PlanTeacherByEPId(keyValue);
  329. if (!res.flag)
  330. {
  331. return Fail(res.str);
  332. }
  333. return Success("操作成功!");
  334. }
  335. /// <summary>
  336. /// 审核所有考试课程
  337. /// </summary>
  338. /// <param name="keyValue"></param>
  339. /// <returns></returns>
  340. [HttpPost]
  341. [AjaxOnly]
  342. public ActionResult CheckAllPlanLesson(string keyValue)
  343. {
  344. var res = exam_ExamPlanLessonIBLL.CheckAllPlanLesson(keyValue);
  345. if (!res.flag)
  346. {
  347. return Fail(res.str);
  348. }
  349. return Success("操作成功!");
  350. }
  351. #endregion
  352. }
  353. }