using Learun.Util; using System.Data; using Learun.Application.TwoDevelopment.EducationalAdministration; using System.Web.Mvc; using System.Collections.Generic; using System.Linq; using System; using Newtonsoft.Json.Linq; using Newtonsoft.Json; namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers { /// /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园 /// Copyright (c) 2013-2018 北京泉江科技有限公司 /// 创 建:超级管理员 /// 日 期:2019-09-26 10:47 /// 描 述:教学调度 /// public class ArrangeLessonTermAttemperController : MvcControllerBase { private ArrangeLessonTermAttemperIBLL arrangeLessonTermAttemperIBLL = new ArrangeLessonTermAttemperBLL(); private ArrangeLessonTermAttemperChildIBLL arrangeLessonTermAttemperChildIBLL = new ArrangeLessonTermAttemperChildBLL(); private ArrangeLessonTermIBLL arrangeLessonTermIBLL = new ArrangeLessonTermBLL(); #region 视图功能 /// /// 主页面 /// /// [HttpGet] public ActionResult Index() { return View(); } /// /// 表单页 /// /// [HttpGet] public ActionResult Form() { return View(); } /// /// 表单查看页 /// /// [HttpGet] public ActionResult FormView() { return View(); } #endregion #region 获取数据 /// /// 获取页面显示列表数据 /// /// 查询参数 /// [HttpGet] [AjaxOnly] public ActionResult GetPageList(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var data = arrangeLessonTermAttemperIBLL.GetPageList(paginationobj, queryJson); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records }; return Success(jsonData); } /// /// 获取表单数据 /// /// [HttpGet] [AjaxOnly] public ActionResult GetFormData(string keyValue) { var ArrangeLessonTermAttemperData = arrangeLessonTermAttemperIBLL.GetArrangeLessonTermAttemperEntity(keyValue); ArrangeLessonTermAttemperData.NewF_SchoolId = ArrangeLessonTermAttemperData.F_SchoolId; ArrangeLessonTermAttemperData.NewAcademicYearNo = ArrangeLessonTermAttemperData.AcademicYearNo; ArrangeLessonTermAttemperData.NewSemester = ArrangeLessonTermAttemperData.Semester; var jsonData = new { ArrangeLessonTermAttemper = ArrangeLessonTermAttemperData, }; return Success(jsonData); } /// /// 获取表单数据 /// /// [HttpGet] [AjaxOnly] public ActionResult GetFormDataByProcessId(string processId) { var ArrangeLessonTermAttemperData = arrangeLessonTermAttemperIBLL.GetEntityByProcessId(processId); ArrangeLessonTermAttemperData.NewF_SchoolId = ArrangeLessonTermAttemperData.F_SchoolId; ArrangeLessonTermAttemperData.NewAcademicYearNo = ArrangeLessonTermAttemperData.AcademicYearNo; ArrangeLessonTermAttemperData.NewSemester = ArrangeLessonTermAttemperData.Semester; var jsonData = new { ArrangeLessonTermAttemper = ArrangeLessonTermAttemperData, }; return Success(jsonData); } #endregion #region 提交数据 /// /// 删除实体数据 /// 主键 /// /// [HttpPost] [AjaxOnly] public ActionResult DeleteForm(string keyValue) { arrangeLessonTermAttemperIBLL.DeleteEntity(keyValue); return Success("删除成功!"); } /// /// 保存实体数据(新增、修改) /// 主键 /// /// [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult SaveForm(string keyValue, string strEntity) { ArrangeLessonTermAttemperEntity entity = strEntity.ToObject(); if (entity.AttemperType == "03") { //if (entity.F_SchoolId != entity.NewF_SchoolId || entity.AcademicYearNo != entity.NewAcademicYearNo || entity.Semester != entity.NewSemester) if (entity.AcademicYearNo != entity.NewAcademicYearNo || entity.Semester != entity.NewSemester) { return Fail("校区、学年、学期不一致!"); } } if (entity.AttemperType=="04") { JObject jo = (JObject)JsonConvert.DeserializeObject(strEntity); List query = new List(); string[] targetjieci = jo["tardata"]["targetjieci"].ToString().TrimEnd(';').Split(';'); string targettime = jo["tardata"]["targettime"].ToString(); string lastdata = ""; int i = 0; int index = 0; foreach (var item in jo["predata"]) { //index++; if (string.IsNullOrEmpty(lastdata) || lastdata != item["LessonTime"].ToString()) { lastdata = item["LessonTime"].ToString(); if ( index >= jo["predata"].Count()/2) { i++; } } DateTime NewLessonDate = Convert.ToDateTime(jo["tardata"]["targettime"].ToString()); string newlessontime = Convert.ToInt32(NewLessonDate.DayOfWeek).ToString()+ targetjieci[i].Replace("节",""); ArrangeLessonTermAttrmperChildEntity term = new ArrangeLessonTermAttrmperChildEntity { LessonId = !string.IsNullOrEmpty(keyValue) ? item["LessonId"].ToString(): item["AltId"].ToString(), LessonDate = Convert.ToDateTime(item["LessonDate"].ToString()), LessonTime = item["LessonTime"].ToString(), NewLessonDate =NewLessonDate , NewLessonTime = newlessontime }; query.Add(term); index++; } entity.query = query; } entity.Status = 0; entity.CheckStatus = 0; arrangeLessonTermAttemperIBLL.SaveEntity(keyValue, entity); return Success("保存成功!"); } #endregion #region 扩展数据 /// /// 课程下拉框信息【教学调度】 /// /// [HttpGet] [AjaxOnly] public ActionResult GetLessonDataInTerm() { var data = arrangeLessonTermIBLL.GetLessonDataInTerm("").OrderBy(x => x.value); return Success(data); } /// /// 获取调课数据 /// /// 数据源编号 /// sql查询条件语句 /// 数据源请求条件字串 /// [HttpGet] [AjaxOnly] public ActionResult GetchildData(string code) { var data = arrangeLessonTermAttemperChildIBLL.GetPageList(new Pagination { page=1,rows=10}, "{'AttemperId':'"+code+"'}"); return JsonResult(data); } /// /// 提交课程异动记录 /// /// 课程异动主键 /// 审核状态 /// 流程Id /// public ActionResult ModifyStatus(string keyValue, int status, string processId) { arrangeLessonTermAttemperIBLL.ModifyStatus(keyValue, status, processId); return Success("提交成功!"); } #endregion } }