|
- 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 DocumentFormat.OpenXml.Office.CustomUI;
-
- namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创 建:超级管理员
- /// 日 期:2019-08-21 17:28
- /// 描 述:成绩比例设置
- /// </summary>
- public class ClassPlanController : MvcControllerBase
- {
- private ClassPlanIBLL classPlanIBLL = new ClassPlanBLL();
- private ClassInfoIBLL classInfoIBLL = new ClassInfoBLL();
- private TeachClassIBLL teachClassIBLL = new TeachClassBLL();
-
- #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 IndexSchool()
- {
- 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 = classPlanIBLL.GetPageList(paginationobj, queryJson);
- var jsonData = new
- {
- rows = data,
- total = paginationobj.total,
- page = paginationobj.page,
- records = paginationobj.records
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 全校开课计划
- /// </summary>
- /// <param name="pagination"></param>
- /// <param name="queryJson"></param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetPageListForSchool(string pagination, string queryJson)
- {
- Pagination paginationobj = pagination.ToObject<Pagination>();
- var data = classPlanIBLL.GetPageListForSchool(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 ClassPlanData = classPlanIBLL.GetClassPlanEntity(keyValue);
- var jsonData = new
- {
- ClassPlan = ClassPlanData,
- };
- return Success(jsonData);
- }
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult DeleteForm(string keyValue)
- {
- classPlanIBLL.DeleteEntity(keyValue);
- return Success("删除成功!");
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <param name="strEntity">实体</param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveForm(string keyValue, string strEntity)
- {
- OpenLessonPlanEntity entity = strEntity.ToObject<OpenLessonPlanEntity>();
- if (!string.IsNullOrEmpty(keyValue))
- {
- entity.AmendDate = DateTime.Now;
- }
- entity.State = 0;
- entity.IsAllowEdit = true;
- entity.LessonSortNo = "1";
- entity.CheckMark = "1";
- entity.MakeDate = DateTime.Now;
- var model = classPlanIBLL.GetRepetitions(entity.F_SchoolId, entity.AcademicYearNo, entity.Semester, entity.DeptNo, entity.MajorNo, entity.Grade, entity.LessonNo);
- if (model != null)
- {
- if (keyValue != model.ID.ToString())
- {
- return Fail("此课程已重复!不可再次添加此课程");
- }
- }
- classPlanIBLL.SaveEntity(keyValue, entity);
-
- return Success("保存成功!");
- }
- #endregion
-
- #region 扩展数据
- /// <summary>
- /// 排课
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult CourseArranging(string keyValue)
- {
- var entity = classPlanIBLL.GetListById(keyValue);
-
- List<TeachClassEntity> TeachList = new List<TeachClassEntity>();
-
- for (int i = 0; i < entity.Count; i++)
- {
- var lessonList = classInfoIBLL.GetAllClass().
- Where(x => x.DeptNo == entity[i].DeptNo && x.MajorNo == entity[i].MajorNo && x.Grade == entity[i].Grade)
- .OrderBy(x => x.ClassNo).Select(field1 => new { field1.ClassNo, field1.ClassName }).ToList();
- if (lessonList.Count > 0)
- {
- for (int j = 0; j < lessonList.Count; j++)
- {
- TeachClassEntity TeachEntity = new TeachClassEntity();
- TeachEntity.TeachClassNo = lessonList[j].ClassNo;
- TeachEntity.AcademicYearNo = entity[i].AcademicYearNo;
- TeachEntity.DeptNo = entity[i].DeptNo;
- TeachEntity.MajorNo = entity[i].MajorNo;
- TeachEntity.Grade = entity[i].Grade;
- TeachEntity.Semester = entity[i].Semester;
- TeachEntity.LessonNo = entity[i].LessonNo;
- TeachEntity.StuNum = entity[i].StuNum;
- TeachEntity.LessonSortNo = entity[i].LessonSortNo;
- TeachEntity.F_SchoolId = entity[i].F_SchoolId;
-
- TeachList.Add(TeachEntity);
- }
- }
- else
- {
- return Fail("排课失败!暂无排课班级");
- }
- }
- teachClassIBLL.SaveEntityList(TeachList);
- classPlanIBLL.SaveEntityList(keyValue, entity);
- return Success("排课成功");
- }
-
- #endregion
- }
- }
|