Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

397 linhas
13 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. namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  12. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2022-04-15 15:03
  15. /// 描 述:排考安排课程
  16. /// </summary>
  17. public class Exam_ExamPlanLessonController : MvcControllerBase
  18. {
  19. private Exam_ExamPlanLessonIBLL exam_ExamPlanLessonIBLL = new Exam_ExamPlanLessonBLL();
  20. private Exam_ExamPlanClassIBLL exam_ExamPlanClassIBLL = new Exam_ExamPlanClassBLL();
  21. private Exam_ExamStudentIBLL exam_ExamStudentIBLL = new Exam_ExamStudentBLL();
  22. private Exam_ExamPlanRoomIBLL exam_ExamPlanRoomIBLL = new Exam_ExamPlanRoomBLL();
  23. #region 视图功能
  24. /// <summary>
  25. /// 主页面
  26. /// </summary>
  27. /// <param name="EPId">排考记录主表Id</param>
  28. /// <returns></returns>
  29. [HttpGet]
  30. public ActionResult Index(string EPId)
  31. {
  32. exam_ExamPlanLessonIBLL.InitExamPlanLesson(EPId);
  33. return View();
  34. }
  35. /// <summary>
  36. /// 表单页
  37. /// <summary>
  38. /// <returns></returns>
  39. [HttpGet]
  40. public ActionResult Form()
  41. {
  42. return View();
  43. }
  44. [HttpGet]
  45. public ActionResult FormClass()
  46. {
  47. return View();
  48. }
  49. [HttpGet]
  50. public ActionResult FormRoom()
  51. {
  52. return View();
  53. }
  54. [HttpGet]
  55. public ActionResult FormTeacher()
  56. {
  57. return View();
  58. }
  59. [HttpGet]
  60. public ActionResult FormRoomTeacher()
  61. {
  62. return View();
  63. }
  64. #endregion
  65. #region 获取数据
  66. /// <summary>
  67. /// 获取班级分页列表
  68. /// </summary>
  69. /// <param name="pagination"></param>
  70. /// <param name="queryJson"></param>
  71. /// <returns></returns>
  72. [HttpGet]
  73. [AjaxOnly]
  74. public ActionResult GetClassInfoPageList(string pagination, string queryJson)
  75. {
  76. Pagination paginationobj = pagination.ToObject<Pagination>();
  77. var data = exam_ExamStudentIBLL.GetPageListForExam(paginationobj, queryJson);
  78. //var stuList = StuInfoBasicIBLL.GetAllList();
  79. //foreach (var item in data)
  80. //{
  81. // item.StuNum = stuList.Count(x => x.ClassNo == item.ClassNo);
  82. //}
  83. var jsonData = new
  84. {
  85. rows = data,
  86. total = paginationobj.total,
  87. page = paginationobj.page,
  88. records = paginationobj.records
  89. };
  90. return Success(jsonData);
  91. }
  92. /// <summary>
  93. /// 获取页面显示列表数据
  94. /// </summary>
  95. /// <param name="pagination">分页参数</param>
  96. /// <param name="queryJson">查询参数</param>
  97. /// <returns></returns>
  98. [HttpGet]
  99. [AjaxOnly]
  100. public ActionResult GetListForClass(string queryJson)
  101. {
  102. var data = exam_ExamPlanClassIBLL.GetList(queryJson);
  103. return Success(data);
  104. }
  105. /// <summary>
  106. /// 获取页面显示列表数据
  107. /// </summary>
  108. /// <param name="pagination">分页参数</param>
  109. /// <param name="queryJson">查询参数</param>
  110. /// <returns></returns>
  111. [HttpGet]
  112. [AjaxOnly]
  113. public ActionResult GetListForRoom(string pagination, string queryJson)
  114. {
  115. var data = exam_ExamPlanRoomIBLL.GetList(queryJson);
  116. return Success(data);
  117. }
  118. /// <summary>
  119. /// 获取页面显示列表数据
  120. /// </summary>
  121. /// <param name="pagination">分页参数</param>
  122. /// <param name="queryJson">查询参数</param>
  123. /// <returns></returns>
  124. [HttpGet]
  125. [AjaxOnly]
  126. public ActionResult GetPageList(string pagination, string queryJson)
  127. {
  128. Pagination paginationobj = pagination.ToObject<Pagination>();
  129. var data = exam_ExamPlanLessonIBLL.GetPageList(paginationobj, queryJson);
  130. var jsonData = new
  131. {
  132. rows = data,
  133. total = paginationobj.total,
  134. page = paginationobj.page,
  135. records = paginationobj.records
  136. };
  137. return Success(jsonData);
  138. }
  139. /// <summary>
  140. /// 排考计划
  141. /// </summary>
  142. /// <param name="pagination"></param>
  143. /// <param name="queryJson"></param>
  144. /// <returns></returns>
  145. [HttpGet]
  146. [AjaxOnly]
  147. public ActionResult GetPageListForLesson(string pagination, string queryJson)
  148. {
  149. Pagination paginationobj = pagination.ToObject<Pagination>();
  150. var data = exam_ExamPlanLessonIBLL.GetPageListForLesson(paginationobj, queryJson);
  151. var jsonData = new
  152. {
  153. rows = data,
  154. total = paginationobj.total,
  155. page = paginationobj.page,
  156. records = paginationobj.records
  157. };
  158. return Success(jsonData);
  159. }
  160. [HttpGet]
  161. [AjaxOnly]
  162. public ActionResult GetFormRoom(string keyValue)
  163. {
  164. var data = exam_ExamPlanRoomIBLL.GetEntity(keyValue);
  165. var jsonData = new
  166. {
  167. Exam_ExamPlanRoom = data,
  168. };
  169. return Success(jsonData);
  170. }
  171. /// <summary>
  172. /// 获取表单数据
  173. /// </summary>
  174. /// <param name="keyValue">主键</param>
  175. /// <returns></returns>
  176. [HttpGet]
  177. [AjaxOnly]
  178. public ActionResult GetFormData(string keyValue)
  179. {
  180. var Exam_ExamPlanLessonData = exam_ExamPlanLessonIBLL.GetExam_ExamPlanLessonEntity(keyValue);
  181. if (!string.IsNullOrEmpty(Exam_ExamPlanLessonData.ExamTime))
  182. {
  183. var etime = Exam_ExamPlanLessonData.ExamTime.Split('-');
  184. Exam_ExamPlanLessonData.ExamTimeStart = etime[0];
  185. Exam_ExamPlanLessonData.ExamTimeEnd = etime[1];
  186. }
  187. if ((Exam_ExamPlanLessonData.ClassNum == null || Exam_ExamPlanLessonData.ClassNum <= 0) ||
  188. (Exam_ExamPlanLessonData.SeatCount == null || Exam_ExamPlanLessonData.SeatCount <= 0))
  189. {
  190. exam_ExamPlanLessonIBLL.UpdateClassNumAndStuCount(Exam_ExamPlanLessonData.EPLId);
  191. }
  192. var jsonData = new
  193. {
  194. Exam_ExamPlanLesson = Exam_ExamPlanLessonData,
  195. };
  196. return Success(jsonData);
  197. }
  198. /// <summary>
  199. /// 获取左侧树形数据
  200. /// </summary>
  201. /// <returns></returns>
  202. [HttpGet]
  203. [AjaxOnly]
  204. public ActionResult GetTree(string EPId)
  205. {
  206. var data = exam_ExamPlanLessonIBLL.GetTree(EPId);
  207. return Success(data);
  208. }
  209. [HttpGet]
  210. [AjaxOnly]
  211. public ActionResult ValidateRoom(string EPLId, string ClassroomNo)
  212. {
  213. var data = exam_ExamPlanRoomIBLL.ValidateRoom(EPLId, ClassroomNo);
  214. return Success(data);
  215. }
  216. /// <summary>
  217. /// 获取考试记录安排时间数据
  218. /// </summary>
  219. /// <returns></returns>
  220. [HttpGet]
  221. [AjaxOnly]
  222. public ActionResult GetExamDateSel(string EPLId)
  223. {
  224. var data = exam_ExamPlanLessonIBLL.GetExamDateSel(EPLId);
  225. return Success(data);
  226. }
  227. #endregion
  228. #region 提交数据
  229. /// <summary>
  230. /// 初始化Exam_ExamPlanLesson,如果表中没有数据,将考试课程表数据添加进去
  231. /// </summary>
  232. /// <param name="EPId">排考记录主表Id</param>
  233. /// <returns></returns>
  234. [HttpPost]
  235. [AjaxOnly]
  236. public ActionResult InitExamPlanLesson(string EPId)
  237. {
  238. exam_ExamPlanLessonIBLL.InitExamPlanLesson(EPId);
  239. return Success("初始化成功!");
  240. }
  241. /// <summary>
  242. /// 删除实体数据
  243. /// </summary>
  244. /// <param name="keyValue">主键</param>
  245. /// <returns></returns>
  246. [HttpPost]
  247. [AjaxOnly]
  248. public ActionResult DeleteForm(string keyValue)
  249. {
  250. exam_ExamPlanLessonIBLL.DeleteEntity(keyValue);
  251. return Success("删除成功!");
  252. }
  253. [HttpPost]
  254. [AjaxOnly]
  255. public ActionResult DeleteClass(string keyValue)
  256. {
  257. exam_ExamPlanClassIBLL.DeleteEntity(keyValue);
  258. return Success("删除成功!");
  259. }
  260. [HttpPost]
  261. [AjaxOnly]
  262. public ActionResult DeleteRoom(string keyValue)
  263. {
  264. exam_ExamPlanRoomIBLL.DeleteEntity(keyValue);
  265. return Success("删除成功!");
  266. }
  267. /// <summary>
  268. /// 审核
  269. /// </summary>
  270. /// <param name="keyValue">主键</param>
  271. /// <returns></returns>
  272. [HttpPost]
  273. [AjaxOnly]
  274. public ActionResult Check(string keyValue, int ELCheckMark)
  275. {
  276. if (ELCheckMark == 1)
  277. {
  278. var entity = exam_ExamPlanLessonIBLL.GetExam_ExamPlanLessonEntity(keyValue);
  279. if (entity.ExamDate == null || entity.ExamTime == null)
  280. {
  281. return Fail("请先设置考试时间!");
  282. }
  283. if ((entity.RealClassNum == null || entity.RealClassNum == 0) ||
  284. (entity.SeatCount == null || entity.SeatCount == 0))
  285. {
  286. return Fail("请先安排班级和考场!");
  287. }
  288. if (entity.SeatCount < entity.RealStuCount)
  289. {
  290. return Fail("考场座位数不足!");
  291. }
  292. }
  293. exam_ExamPlanLessonIBLL.Check(keyValue, ELCheckMark);
  294. return Success("操作成功!");
  295. }
  296. /// <summary>
  297. /// 保存实体数据(新增、修改)
  298. /// 设置考试时间
  299. /// </summary>
  300. /// <param name="keyValue">主键</param>
  301. /// <param name="strEntity">实体</param>
  302. /// <returns></returns>
  303. [HttpPost]
  304. [ValidateAntiForgeryToken]
  305. [AjaxOnly]
  306. public ActionResult SaveForm(string keyValue, string strEntity)
  307. {
  308. Exam_ExamPlanLessonEntity entity = strEntity.ToObject<Exam_ExamPlanLessonEntity>();
  309. DateTime time;
  310. bool flag = DateTime.TryParse(entity.ExamTimeStart, out time);
  311. if (!flag)
  312. {
  313. return Fail("考试开始时间格式不正确!");
  314. }
  315. if (!DateTime.TryParse(entity.ExamTimeEnd, out time))
  316. {
  317. return Fail("考试结束时间格式不正确!");
  318. }
  319. if (!string.IsNullOrEmpty(entity.ExamTimeStart) && !string.IsNullOrEmpty(entity.ExamTimeEnd))
  320. {
  321. entity.ExamTime = entity.ExamTimeStart.Trim() + "-" + entity.ExamTimeEnd;
  322. }
  323. entity.EPLId = keyValue;
  324. //判断考试时间是否冲突,同一专业同一时间段只能安排一门考试课程
  325. var res = exam_ExamPlanLessonIBLL.IsAllowSave(entity);
  326. if (!res.flag && !string.IsNullOrEmpty(res.str))
  327. {
  328. return Fail(res.str);
  329. }
  330. //保存
  331. exam_ExamPlanLessonIBLL.SaveEntity(keyValue, entity);
  332. return Success("保存成功!");
  333. }
  334. [HttpPost]
  335. [ValidateAntiForgeryToken]
  336. [AjaxOnly]
  337. public ActionResult SaveClass(string EPLId, string strEntity)
  338. {
  339. var list = strEntity.ToObject<List<Exam_ExamPlanClassEntity>>();
  340. //判断排考班级的考试时间是否冲突
  341. var res = exam_ExamPlanClassIBLL.IsExamConflict(list);
  342. if (res.flag && !string.IsNullOrEmpty(res.msg))
  343. {
  344. return Fail(res.msg);
  345. }
  346. exam_ExamPlanClassIBLL.SaveList(list);
  347. return Success("保存成功!");
  348. }
  349. [HttpPost]
  350. [ValidateAntiForgeryToken]
  351. [AjaxOnly]
  352. public ActionResult SaveRoomAndTeacher(string keyValue, string strEntity, string Exam_ExamPlanTeacherList)
  353. {
  354. var entity = strEntity.ToObject<Exam_ExamPlanRoomEntity>();
  355. var teacherList = Exam_ExamPlanTeacherList.ToObject<List<Exam_InvigilateTeacherEntity>>();
  356. entity.EmpNo = string.Join(",", teacherList.Select(x => x.EmpNo).ToList());
  357. entity.EmpName = string.Join(",", teacherList.Select(x => x.EmpName).ToList());
  358. exam_ExamPlanRoomIBLL.SaveEntity(keyValue, entity);
  359. return Success("保存成功!");
  360. }
  361. #endregion
  362. }
  363. }