You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Exam_ExamPlanController.cs 11 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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.GetPlanTimeList(keyValue);
  145. if (data.Count() <= 0)
  146. {
  147. return Fail("请先安排时间!");
  148. }
  149. if (!exam_ExamPlanIBLL.IsGenerate(keyValue))
  150. {
  151. return Fail("请先安排考试!");
  152. }
  153. exam_ExamPlanIBLL.Generate(keyValue);
  154. return Success("生成成功!");
  155. }
  156. /// <summary>
  157. /// 安排考试
  158. /// </summary>
  159. /// <param name="EPId"></param>
  160. /// <returns></returns>
  161. [HttpPost]
  162. [AjaxOnly]
  163. public ActionResult SavePlanTime(string EPId, List<Exam_ExamPlanTimeEntity> list)
  164. {
  165. if (list.Count <= 0)
  166. {
  167. return Fail("请安排时间!");
  168. }
  169. foreach (var entity in list)
  170. {
  171. DateTime time;
  172. if (!DateTime.TryParse(entity.ExamTimeStart, out time))
  173. {
  174. return Fail("开始时间格式不正确!");
  175. }
  176. if (!DateTime.TryParse(entity.ExamTimeEnd, out time))
  177. {
  178. return Fail("结束时间格式不正确!");
  179. }
  180. var startTime = Convert.ToDateTime(entity.ExamDate.Value.ToString("yyyy-MM-dd") + " " + entity.ExamTimeStart);
  181. var endTime = Convert.ToDateTime(entity.ExamDate.Value.ToString("yyyy-MM-dd") + " " + entity.ExamTimeEnd);
  182. if (endTime <= startTime)
  183. {
  184. return Fail("结束时间必须大于开始时间!");
  185. }
  186. //考试时长
  187. entity.ExamTimeLength = (endTime - startTime).TotalMinutes;
  188. }
  189. exam_ExamPlanIBLL.SavePlanTime(EPId, list);
  190. return Success("保存成功!");
  191. }
  192. /// <summary>
  193. /// 清除排考名单/清除所有排考记录
  194. /// </summary>
  195. /// <param name="keyValue">排考记录主表Id</param>
  196. /// <param name="type">1:清除排考名单;2:清除所有排考记录</param>
  197. /// <returns></returns>
  198. [HttpPost]
  199. [AjaxOnly]
  200. public ActionResult ClearGenerate(string keyValue, int type)
  201. {
  202. exam_ExamPlanIBLL.ClearGenerate(keyValue, type);
  203. return Success("操作成功!");
  204. }
  205. /// <summary>
  206. /// 保存实体数据(新增、修改)
  207. /// </summary>
  208. /// <param name="keyValue">主键</param>
  209. /// <param name="strEntity">实体</param>
  210. /// <returns></returns>
  211. [HttpPost]
  212. [ValidateAntiForgeryToken]
  213. [AjaxOnly]
  214. public ActionResult SaveForm(string keyValue, string strEntity)
  215. {
  216. Exam_ExamPlanEntity entity = strEntity.ToObject<Exam_ExamPlanEntity>();
  217. exam_ExamPlanIBLL.SaveEntity(keyValue, entity);
  218. if (string.IsNullOrEmpty(keyValue))
  219. {
  220. }
  221. return Success("保存成功!");
  222. }
  223. /// <summary>
  224. /// 生成排考名单
  225. /// </summary>
  226. /// <param name="AcademicYearNo"></param>
  227. /// <param name="Semester"></param>
  228. /// <param name="PlanType"></param>
  229. /// <returns></returns>
  230. [HttpPost]
  231. [ValidateAntiForgeryToken]
  232. [AjaxOnly]
  233. public ActionResult GenerateForm(string AcademicYearNo, string Semester, string PlanType)
  234. {
  235. int res = exam_ExamPlanIBLL.ClaerForm(AcademicYearNo, Semester, PlanType);
  236. return Success("清空(" + res + ")条数据成功!");
  237. }
  238. /// <summary>
  239. /// 清除排考名单
  240. /// </summary>
  241. /// <param name="AcademicYearNo"></param>
  242. /// <param name="Semester"></param>
  243. /// <param name="PlanType"></param>
  244. /// <returns></returns>
  245. [HttpPost]
  246. [ValidateAntiForgeryToken]
  247. [AjaxOnly]
  248. public ActionResult ClearForm(string AcademicYearNo, string Semester, string PlanType)
  249. {
  250. int res = exam_ExamPlanIBLL.GenerateForm(AcademicYearNo, Semester, PlanType);
  251. return Success("清空(" + res + ")条数据成功!");
  252. }
  253. /// <summary>
  254. /// 一键安排课程
  255. /// </summary>
  256. /// <param name="keyValue"></param>
  257. /// <returns></returns>
  258. [HttpPost]
  259. [AjaxOnly]
  260. public ActionResult PlanLessonByEPId(string keyValue)
  261. {
  262. exam_ExamPlanLessonIBLL.InitExamPlanLesson(keyValue);
  263. return Success("操作成功!");
  264. }
  265. /// <summary>
  266. /// 一键安排班级
  267. /// </summary>
  268. /// <param name="keyValue"></param>
  269. /// <returns></returns>
  270. [HttpPost]
  271. [AjaxOnly]
  272. public ActionResult PlanClassByEPId(string keyValue)
  273. {
  274. var count = exam_ExamPlanLessonIBLL.GetListByEPId(keyValue).Count();
  275. if (count <= 0)
  276. {
  277. return Fail("请先安排课程!");
  278. }
  279. exam_ExamPlanClassIBLL.PlanClassByEPId(keyValue);
  280. return Success("操作成功!");
  281. }
  282. /// <summary>
  283. /// 自动生成考试课程排考时间
  284. /// </summary>
  285. /// <param name="keyValue"></param>
  286. /// <returns></returns>
  287. [HttpPost]
  288. [AjaxOnly]
  289. public ActionResult PlanLessonTimeByEPId(string keyValue)
  290. {
  291. var count = exam_ExamPlanLessonIBLL.GetListByEPId(keyValue).Count();
  292. if (count <= 0)
  293. {
  294. return Fail("请先安排课程!");
  295. }
  296. var res = exam_ExamPlanLessonIBLL.PlanLessonTimeByEPId(keyValue);
  297. if (res.flag)
  298. {
  299. return Success("操作成功!");
  300. }
  301. else
  302. {
  303. return Fail(res.msg);
  304. }
  305. return Success("操作成功!");
  306. }
  307. /// <summary>
  308. /// 一键安排考场
  309. /// </summary>
  310. /// <param name="keyValue"></param>
  311. /// <returns></returns>
  312. [HttpPost]
  313. [AjaxOnly]
  314. public ActionResult PlanRoomByEPId(string keyValue)
  315. {
  316. var res = exam_ExamPlanRoomIBLL.PlanRoomByEPId(keyValue);
  317. if (!res.flag)
  318. {
  319. return Fail(res.str);
  320. }
  321. return Success("操作成功!");
  322. }
  323. /// <summary>
  324. /// 一键安排监考老师
  325. /// </summary>
  326. /// <param name="keyValue"></param>
  327. /// <returns></returns>
  328. [HttpPost]
  329. [AjaxOnly]
  330. public ActionResult PlanTeacherByEPId(string keyValue)
  331. {
  332. var res = exam_ExamPlanRoomIBLL.PlanTeacherByEPId(keyValue);
  333. if (!res.flag)
  334. {
  335. return Fail(res.str);
  336. }
  337. return Success("操作成功!");
  338. }
  339. #endregion
  340. }
  341. }