|
- using Learun.Util;
- using System.Data;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
- using System.Web.Mvc;
- using System.Collections.Generic;
- using System;
- using System.Linq;
- using Newtonsoft.Json;
-
- namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
- {
- /// <summary>
- /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
- /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
- /// 创 建:超级管理员
- /// 日 期:2022-04-14 18:12
- /// 描 述:考试记录表
- /// </summary>
- public class Exam_ExamPlanController : MvcControllerBase
- {
- private Exam_ExamPlanIBLL exam_ExamPlanIBLL = new Exam_ExamPlanBLL();
- private Exam_ExamPlanLessonIBLL exam_ExamPlanLessonIBLL = new Exam_ExamPlanLessonBLL();
- private Exam_ExamPlanClassIBLL exam_ExamPlanClassIBLL = new Exam_ExamPlanClassBLL();
- private Exam_ExamPlanRoomIBLL exam_ExamPlanRoomIBLL = new Exam_ExamPlanRoomBLL();
-
- #region 视图功能
-
- /// <summary>
- /// 主页面
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Index()
- {
- return View();
- }
- /// <summary>
- /// 表单页
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Form()
- {
- return View();
- }
- /// <summary>
- /// 表单页
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult GenerateForm()
- {
- return View();
- }
- /// <summary>
- /// 表单页
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult ClearForm()
- {
- return View();
- }
- /// <summary>
- /// 安排时间
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult FormTime()
- {
- return View();
- }
- #endregion
-
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表数据
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetPageList(string pagination, string queryJson)
- {
- Pagination paginationobj = pagination.ToObject<Pagination>();
- var data = exam_ExamPlanIBLL.GetPageList(paginationobj, queryJson);
- var jsonData = new
- {
- rows = data,
- total = paginationobj.total,
- page = paginationobj.page,
- records = paginationobj.records
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 获取表单数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetFormData(string keyValue)
- {
- var Exam_ExamPlanData = exam_ExamPlanIBLL.GetExam_ExamPlanEntity(keyValue);
- var jsonData = new
- {
- Exam_ExamPlan = Exam_ExamPlanData,
- };
- return Success(jsonData);
- }
-
- /// <summary>
- /// 安排时间
- /// </summary>
- /// <param name="EPId"></param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetPlanTimeList(string EPId)
- {
- var data = exam_ExamPlanIBLL.GetPlanTimeList(EPId);
- return Success(data);
- }
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult DeleteForm(string keyValue)
- {
- exam_ExamPlanIBLL.DeleteEntity(keyValue);
- return Success("删除成功!");
- }
- /// <summary>
- /// 生成排考名单
- /// </summary>
- /// <param name="keyValue"></param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult Generate(string keyValue)
- {
- var data = exam_ExamPlanIBLL.IsGenerate(keyValue);
- if (!data.flag)
- {
- return Fail(data.str);
- }
-
- exam_ExamPlanIBLL.Generate(keyValue);
- return Success("生成成功!");
- }
-
- /// <summary>
- /// 安排考试
- /// </summary>
- /// <param name="EPId"></param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult SavePlanTime(string EPId, List<Exam_ExamPlanTimeEntity> list)
- {
- if (list.Count <= 0)
- {
- return Fail("请安排时间!");
- }
-
- foreach (var entity in list)
- {
- DateTime time;
- if (!DateTime.TryParse(entity.ExamTimeStart, out time))
- {
- return Fail("开始时间格式不正确!");
- }
- if (!DateTime.TryParse(entity.ExamTimeEnd, out time))
- {
- return Fail("结束时间格式不正确!");
- }
-
- var startTime = Convert.ToDateTime(entity.ExamDate.Value.ToString("yyyy-MM-dd") + " " + entity.ExamTimeStart);
- var endTime = Convert.ToDateTime(entity.ExamDate.Value.ToString("yyyy-MM-dd") + " " + entity.ExamTimeEnd);
- if (endTime <= startTime)
- {
- return Fail("结束时间必须大于开始时间!");
- }
- //考试时长
- entity.ExamTimeLength = (endTime - startTime).TotalMinutes;
- }
- exam_ExamPlanIBLL.SavePlanTime(EPId, list);
- return Success("保存成功!");
- }
-
- /// <summary>
- /// 清除排考名单/清除所有排考记录
- /// </summary>
- /// <param name="keyValue">排考记录主表Id</param>
- /// <param name="type">1:清除排考名单;2:清除所有排考记录</param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult ClearGenerate(string keyValue, int type)
- {
- exam_ExamPlanIBLL.ClearGenerate(keyValue, type);
- return Success("操作成功!");
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <param name="strEntity">实体</param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveForm(string keyValue, string strEntity)
- {
- Exam_ExamPlanEntity entity = strEntity.ToObject<Exam_ExamPlanEntity>();
- exam_ExamPlanIBLL.SaveEntity(keyValue, entity);
- if (string.IsNullOrEmpty(keyValue))
- {
- }
- return Success("保存成功!");
- }
-
- /// <summary>
- /// 生成排考名单
- /// </summary>
- /// <param name="AcademicYearNo"></param>
- /// <param name="Semester"></param>
- /// <param name="PlanType"></param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult GenerateForm(string AcademicYearNo, string Semester, string PlanType)
- {
- int res = exam_ExamPlanIBLL.ClaerForm(AcademicYearNo, Semester, PlanType);
- return Success("清空(" + res + ")条数据成功!");
- }
- /// <summary>
- /// 清除排考名单
- /// </summary>
- /// <param name="AcademicYearNo"></param>
- /// <param name="Semester"></param>
- /// <param name="PlanType"></param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult ClearForm(string AcademicYearNo, string Semester, string PlanType)
- {
- int res = exam_ExamPlanIBLL.GenerateForm(AcademicYearNo, Semester, PlanType);
- return Success("清空(" + res + ")条数据成功!");
- }
- /// <summary>
- /// 一键安排课程
- /// </summary>
- /// <param name="keyValue"></param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult PlanLessonByEPId(string keyValue)
- {
- exam_ExamPlanLessonIBLL.InitExamPlanLesson(keyValue);
- return Success("操作成功!");
- }
- /// <summary>
- /// 一键安排班级
- /// </summary>
- /// <param name="keyValue"></param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult PlanClassByEPId(string keyValue)
- {
- var count = exam_ExamPlanLessonIBLL.GetListByEPId(keyValue).Count();
- if (count <= 0)
- {
- return Fail("请先安排课程!");
- }
-
- exam_ExamPlanClassIBLL.PlanClassByEPId(keyValue);
- return Success("操作成功!");
- }
- /// <summary>
- /// 自动生成考试课程排考时间
- /// </summary>
- /// <param name="keyValue"></param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult PlanLessonTimeByEPId(string keyValue)
- {
- var count = exam_ExamPlanLessonIBLL.GetListByEPId(keyValue).Count();
- if (count <= 0)
- {
- return Fail("请先安排课程!");
- }
- var res = exam_ExamPlanLessonIBLL.PlanLessonTimeByEPId(keyValue);
- if (res.flag)
- {
- return Success("操作成功!");
- }
- else
- {
- return Fail(res.msg);
- }
-
- return Success("操作成功!");
- }
-
- /// <summary>
- /// 一键安排考场
- /// </summary>
- /// <param name="keyValue"></param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult PlanRoomByEPId(string keyValue)
- {
- var res = exam_ExamPlanRoomIBLL.PlanRoomByEPId(keyValue);
- if (!res.flag)
- {
- return Fail(res.str);
- }
-
- return Success("操作成功!");
- }
-
- /// <summary>
- /// 一键安排监考老师
- /// </summary>
- /// <param name="keyValue"></param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult PlanTeacherByEPId(string keyValue)
- {
- var res = exam_ExamPlanRoomIBLL.PlanTeacherByEPId(keyValue);
- if (!res.flag)
- {
- return Fail(res.str);
- }
-
- return Success("操作成功!");
- }
-
- /// <summary>
- /// 审核所有考试课程
- /// </summary>
- /// <param name="keyValue"></param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult CheckAllPlanLesson(string keyValue)
- {
- var res = exam_ExamPlanLessonIBLL.CheckAllPlanLesson(keyValue);
- if (!res.flag)
- {
- return Fail(res.str);
- }
-
- return Success("操作成功!");
- }
- #endregion
-
- }
- }
|