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; using Learun.Application.WorkFlow; 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(); private NWFProcessIBLL nWFProcessIBLL = new NWFProcessBLL(); #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) { //[{"AttemperId":"3ec8df23-c045-428c-b37c-c370b73f53ef","Day":"5","LessonTime":"53","LessonDate":"2024-03-08","SchooldId":"207fa1a9-160c-4943-a89b-8fa4db0547ce","Academicyear":"23-24","Semester":"2","DeptNo":"01","Deptname":"","MajorNo":"GZ13","LessonNo":"GZ1303001","Curriculum":"爵士舞","TeachClassNo":"G2201010303","ClassName":"22高职男班(舞蹈表演)","Empno":"2224","Teacher":"魏志勇","ClassRoomNo":"3102","ClassRoom":"舞蹈楼102","LessonSortNo":"1"},{"AttemperId":"e4970ebb-1af5-4298-b03c-f8014e1adb06","Day":"5","LessonTime":"53","LessonDate":"2024-03-08","SchooldId":"207fa1a9-160c-4943-a89b-8fa4db0547ce","Academicyear":"23-24","Semester":"2","DeptNo":"01","Deptname":"","MajorNo":"GZ13","LessonNo":"GZ1302005","Curriculum":"中国古典舞身韵","TeachClassNo":"G2201010303","ClassName":"22高职男班(舞蹈表演)","Empno":"5526","Teacher":"焦晓天","ClassRoomNo":"3102","ClassRoom":"舞蹈楼102","LessonSortNo":"1"}] //"CreateUserId":"System","CreateUserName":"超级管理员","CreateTime":"2024-06-25 13:14:35","AttemperType":"02","AttemperTimeType":"","NewAcademicYearNo":"","NewSemester":"","NewDeptNo":"","NewMajorNo":"","NewLessonNo":"","NewTeachClassNo":"","NewEmpNo":"","NewClassroomNo":"","AttemperStartTime":"","AttemperEndTime":"","AttemperRemark":"22" JObject jo = (JObject)JsonConvert.DeserializeObject(strEntity); ArrangeLessonTermAttemperEntity entity = strEntity.ToObject(); if (entity.AttemperType == "01") { //调课 } else if (entity.AttemperType == "02") { //停课 } else if (entity.AttemperType == "03") { //换课 } #region 旧逻辑 //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; //} #endregion foreach (var item in jo["query"]) { ArrangeLessonTermAttemperEntity itementity = new ArrangeLessonTermAttemperEntity(); itementity.CreateUserId = entity.CreateUserId; itementity.CreateUserName = entity.CreateUserName; itementity.CreateTime = entity.CreateTime; itementity.AttemperRemark = entity.AttemperRemark; itementity.AttemperType = entity.AttemperType;//调课类型 itementity.NewAcademicYearNo= entity.NewAcademicYearNo; itementity.NewSemester = entity.NewSemester; itementity.NewDeptNo = entity.NewDeptNo; itementity.NewMajorNo = entity.NewMajorNo; itementity.NewLessonNo = entity.NewLessonNo; itementity.NewTeachClassNo = entity.NewTeachClassNo; itementity.NewEmpNo = entity.NewEmpNo; itementity.NewClassroomNo = entity.NewClassroomNo; itementity.AcademicYearNo = item["Academicyear"].ToString(); itementity.Semester = item["Semester"].ToString(); itementity.DeptNo = item["DeptNo"].ToString(); itementity.MajorNo = item["MajorNo"].ToString(); itementity.LessonNo = item["LessonNo"].ToString(); itementity.TeachClassNo = item["TeachClassNo"].ToString(); itementity.EmpNo = item["Empno"].ToString(); itementity.ClassroomNo = item["ClassRoomNo"].ToString(); itementity.AttemperTimeType = entity.AttemperTimeType;//调度时限 itementity.AttemperStartTime = entity.AttemperStartTime; itementity.AttemperEndTime = entity.AttemperEndTime; itementity.Status = 0; itementity.CheckStatus = 0; arrangeLessonTermAttemperIBLL.SaveEntity(keyValue, itementity); } 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("提交成功!"); } public ActionResult ModifyStatuss(string keyValue, int status, string processId) { var gids = arrangeLessonTermAttemperIBLL.ModifyStatuss(keyValue, status, processId); if (gids.Any()) { var userInfo = LoginUserInfo.Get(); var schemeCode = "ArrangeLessonTermAttemper"; var level = 1; foreach (var gid in gids) { try { nWFProcessIBLL.CreateFlow(schemeCode, gid, "", level, "", userInfo); //return Success("流程创建成功"); } catch (System.Exception ex) { nWFProcessIBLL.SaveDraft(gid, schemeCode, userInfo); //return Fail(ex.Message); } } } return Success("提交成功!"); } #endregion } }