using Learun.Util; using System.Data; using Learun.Application.TwoDevelopment.EducationalAdministration; using System.Web.Mvc; using System.Collections.Generic; using System; using System.Linq; namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers { /// /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架 /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司 /// 创 建:超级管理员 /// 日 期:2022-04-15 15:03 /// 描 述:排考安排课程 /// public class Exam_ExamPlanLessonController : MvcControllerBase { private Exam_ExamPlanLessonIBLL exam_ExamPlanLessonIBLL = new Exam_ExamPlanLessonBLL(); private Exam_ExamPlanClassIBLL exam_ExamPlanClassIBLL = new Exam_ExamPlanClassBLL(); private Exam_ExamStudentIBLL exam_ExamStudentIBLL = new Exam_ExamStudentBLL(); private Exam_ExamPlanRoomIBLL exam_ExamPlanRoomIBLL = new Exam_ExamPlanRoomBLL(); #region 视图功能 /// /// 主页面 /// /// 排考记录主表Id /// [HttpGet] public ActionResult Index(string EPId) { exam_ExamPlanLessonIBLL.InitExamPlanLesson(EPId); return View(); } /// /// 表单页 /// /// [HttpGet] public ActionResult Form() { return View(); } [HttpGet] public ActionResult FormClass() { return View(); } [HttpGet] public ActionResult FormRoom() { return View(); } [HttpGet] public ActionResult FormTeacher() { return View(); } [HttpGet] public ActionResult FormRoomTeacher() { return View(); } #endregion #region 获取数据 /// /// 获取班级分页列表 /// /// /// /// [HttpGet] [AjaxOnly] public ActionResult GetClassInfoPageList(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var data = exam_ExamStudentIBLL.GetPageListForExam(paginationobj, queryJson); //var stuList = StuInfoBasicIBLL.GetAllList(); //foreach (var item in data) //{ // item.StuNum = stuList.Count(x => x.ClassNo == item.ClassNo); //} var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records }; return Success(jsonData); } /// /// 获取页面显示列表数据 /// /// 分页参数 /// 查询参数 /// [HttpGet] [AjaxOnly] public ActionResult GetListForClass(string queryJson) { var data = exam_ExamPlanClassIBLL.GetList(queryJson); return Success(data); } /// /// 获取页面显示列表数据 /// /// 分页参数 /// 查询参数 /// [HttpGet] [AjaxOnly] public ActionResult GetListForRoom(string pagination, string queryJson) { var data = exam_ExamPlanRoomIBLL.GetList(queryJson); return Success(data); } /// /// 获取页面显示列表数据 /// /// 分页参数 /// 查询参数 /// [HttpGet] [AjaxOnly] public ActionResult GetPageList(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var data = exam_ExamPlanLessonIBLL.GetPageList(paginationobj, queryJson); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records }; return Success(jsonData); } /// /// 排考计划 /// /// /// /// [HttpGet] [AjaxOnly] public ActionResult GetPageListForLesson(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var data = exam_ExamPlanLessonIBLL.GetPageListForLesson(paginationobj, queryJson); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records }; return Success(jsonData); } [HttpGet] [AjaxOnly] public ActionResult GetFormRoom(string keyValue) { var data = exam_ExamPlanRoomIBLL.GetEntity(keyValue); var jsonData = new { Exam_ExamPlanRoom = data, }; return Success(jsonData); } /// /// 获取表单数据 /// /// 主键 /// [HttpGet] [AjaxOnly] public ActionResult GetFormData(string keyValue) { var Exam_ExamPlanLessonData = exam_ExamPlanLessonIBLL.GetExam_ExamPlanLessonEntity(keyValue); if (!string.IsNullOrEmpty(Exam_ExamPlanLessonData.ExamTime)) { var etime = Exam_ExamPlanLessonData.ExamTime.Split('-'); Exam_ExamPlanLessonData.ExamTimeStart = etime[0]; Exam_ExamPlanLessonData.ExamTimeEnd = etime[1]; } if ((Exam_ExamPlanLessonData.ClassNum == null || Exam_ExamPlanLessonData.ClassNum <= 0) || (Exam_ExamPlanLessonData.SeatCount == null || Exam_ExamPlanLessonData.SeatCount <= 0)) { exam_ExamPlanLessonIBLL.UpdateClassNumAndStuCount(Exam_ExamPlanLessonData.EPLId); } var jsonData = new { Exam_ExamPlanLesson = Exam_ExamPlanLessonData, }; return Success(jsonData); } /// /// 获取左侧树形数据 /// /// [HttpGet] [AjaxOnly] public ActionResult GetTree(string EPId) { var data = exam_ExamPlanLessonIBLL.GetTree(EPId); return Success(data); } [HttpGet] [AjaxOnly] public ActionResult ValidateRoom(string EPLId, string ClassroomNo) { var data = exam_ExamPlanRoomIBLL.ValidateRoom(EPLId, ClassroomNo); return Success(data); } /// /// 获取考试记录安排时间数据 /// /// [HttpGet] [AjaxOnly] public ActionResult GetExamDateSel(string EPLId) { var data = exam_ExamPlanLessonIBLL.GetExamDateSel(EPLId); return Success(data); } #endregion #region 提交数据 /// /// 初始化Exam_ExamPlanLesson,如果表中没有数据,将考试课程表数据添加进去 /// /// 排考记录主表Id /// [HttpPost] [AjaxOnly] public ActionResult InitExamPlanLesson(string EPId) { exam_ExamPlanLessonIBLL.InitExamPlanLesson(EPId); return Success("初始化成功!"); } /// /// 删除实体数据 /// /// 主键 /// [HttpPost] [AjaxOnly] public ActionResult DeleteForm(string keyValue) { exam_ExamPlanLessonIBLL.DeleteEntity(keyValue); return Success("删除成功!"); } [HttpPost] [AjaxOnly] public ActionResult DeleteClass(string keyValue) { exam_ExamPlanClassIBLL.DeleteEntity(keyValue); return Success("删除成功!"); } [HttpPost] [AjaxOnly] public ActionResult DeleteRoom(string keyValue) { exam_ExamPlanRoomIBLL.DeleteEntity(keyValue); return Success("删除成功!"); } /// /// 审核 /// /// 主键 /// [HttpPost] [AjaxOnly] public ActionResult Check(string keyValue, int ELCheckMark) { if (ELCheckMark == 1) { var entity = exam_ExamPlanLessonIBLL.GetExam_ExamPlanLessonEntity(keyValue); if (entity.ExamDate == null || entity.ExamTime == null) { return Fail("请先设置考试时间!"); } if ((entity.RealClassNum == null || entity.RealClassNum == 0) || (entity.SeatCount == null || entity.SeatCount == 0)) { return Fail("请先安排班级和考场!"); } if (entity.SeatCount < entity.RealStuCount) { return Fail("考场座位数不足!"); } } exam_ExamPlanLessonIBLL.Check(keyValue, ELCheckMark); return Success("操作成功!"); } /// /// 保存实体数据(新增、修改) /// 设置考试时间 /// /// 主键 /// 实体 /// [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult SaveForm(string keyValue, string strEntity) { Exam_ExamPlanLessonEntity entity = strEntity.ToObject(); DateTime time; bool flag = DateTime.TryParse(entity.ExamTimeStart, out time); if (!flag) { return Fail("考试开始时间格式不正确!"); } if (!DateTime.TryParse(entity.ExamTimeEnd, out time)) { return Fail("考试结束时间格式不正确!"); } if (!string.IsNullOrEmpty(entity.ExamTimeStart) && !string.IsNullOrEmpty(entity.ExamTimeEnd)) { entity.ExamTime = entity.ExamTimeStart.Trim() + "-" + entity.ExamTimeEnd; } entity.EPLId = keyValue; //判断考试时间是否冲突,同一专业同一时间段只能安排一门考试课程 var res = exam_ExamPlanLessonIBLL.IsAllowSave(entity); if (!res.flag && !string.IsNullOrEmpty(res.str)) { return Fail(res.str); } //保存 exam_ExamPlanLessonIBLL.SaveEntity(keyValue, entity); return Success("保存成功!"); } [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult SaveClass(string EPLId, string strEntity) { var list = strEntity.ToObject>(); //判断排考班级的考试时间是否冲突 var res = exam_ExamPlanClassIBLL.IsExamConflict(list); if (res.flag && !string.IsNullOrEmpty(res.msg)) { return Fail(res.msg); } exam_ExamPlanClassIBLL.SaveList(list); return Success("保存成功!"); } [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult SaveRoomAndTeacher(string keyValue, string strEntity, string Exam_ExamPlanTeacherList) { var entity = strEntity.ToObject(); var teacherList = Exam_ExamPlanTeacherList.ToObject>(); entity.EmpNo = string.Join(",", teacherList.Select(x => x.EmpNo).ToList()); entity.EmpName = string.Join(",", teacherList.Select(x => x.EmpName).ToList()); exam_ExamPlanRoomIBLL.SaveEntity(keyValue, entity); return Success("保存成功!"); } #endregion } }