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.
 
 
 
 
 
 

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