You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

239 lines
8.8 KiB

  1. using Learun.Util;
  2. using System.Data;
  3. using Learun.Application.TwoDevelopment.EducationalAdministration;
  4. using System.Web.Mvc;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System;
  8. using Newtonsoft.Json.Linq;
  9. using Newtonsoft.Json;
  10. namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
  11. {
  12. /// <summary>
  13. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  14. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  15. /// 创 建:超级管理员
  16. /// 日 期:2019-09-26 10:47
  17. /// 描 述:教学调度
  18. /// </summary>
  19. public class ArrangeLessonTermAttemperController : MvcControllerBase
  20. {
  21. private ArrangeLessonTermAttemperIBLL arrangeLessonTermAttemperIBLL = new ArrangeLessonTermAttemperBLL();
  22. private ArrangeLessonTermAttemperChildIBLL arrangeLessonTermAttemperChildIBLL = new ArrangeLessonTermAttemperChildBLL();
  23. private ArrangeLessonTermIBLL arrangeLessonTermIBLL = new ArrangeLessonTermBLL();
  24. #region 视图功能
  25. /// <summary>
  26. /// 主页面
  27. /// <summary>
  28. /// <returns></returns>
  29. [HttpGet]
  30. public ActionResult Index()
  31. {
  32. return View();
  33. }
  34. /// <summary>
  35. /// 表单页
  36. /// <summary>
  37. /// <returns></returns>
  38. [HttpGet]
  39. public ActionResult Form()
  40. {
  41. return View();
  42. }
  43. /// <summary>
  44. /// 表单查看页
  45. /// <summary>
  46. /// <returns></returns>
  47. [HttpGet]
  48. public ActionResult FormView()
  49. {
  50. return View();
  51. }
  52. #endregion
  53. #region 获取数据
  54. /// <summary>
  55. /// 获取页面显示列表数据
  56. /// <summary>
  57. /// <param name="queryJson">查询参数</param>
  58. /// <returns></returns>
  59. [HttpGet]
  60. [AjaxOnly]
  61. public ActionResult GetPageList(string pagination, string queryJson)
  62. {
  63. Pagination paginationobj = pagination.ToObject<Pagination>();
  64. var data = arrangeLessonTermAttemperIBLL.GetPageList(paginationobj, queryJson);
  65. var jsonData = new
  66. {
  67. rows = data,
  68. total = paginationobj.total,
  69. page = paginationobj.page,
  70. records = paginationobj.records
  71. };
  72. return Success(jsonData);
  73. }
  74. /// <summary>
  75. /// 获取表单数据
  76. /// <summary>
  77. /// <returns></returns>
  78. [HttpGet]
  79. [AjaxOnly]
  80. public ActionResult GetFormData(string keyValue)
  81. {
  82. var ArrangeLessonTermAttemperData = arrangeLessonTermAttemperIBLL.GetArrangeLessonTermAttemperEntity(keyValue);
  83. ArrangeLessonTermAttemperData.NewF_SchoolId = ArrangeLessonTermAttemperData.F_SchoolId;
  84. ArrangeLessonTermAttemperData.NewAcademicYearNo = ArrangeLessonTermAttemperData.AcademicYearNo;
  85. ArrangeLessonTermAttemperData.NewSemester = ArrangeLessonTermAttemperData.Semester;
  86. var jsonData = new
  87. {
  88. ArrangeLessonTermAttemper = ArrangeLessonTermAttemperData,
  89. };
  90. return Success(jsonData);
  91. }
  92. /// <summary>
  93. /// 获取表单数据
  94. /// <summary>
  95. /// <returns></returns>
  96. [HttpGet]
  97. [AjaxOnly]
  98. public ActionResult GetFormDataByProcessId(string processId)
  99. {
  100. var ArrangeLessonTermAttemperData = arrangeLessonTermAttemperIBLL.GetEntityByProcessId(processId);
  101. ArrangeLessonTermAttemperData.NewF_SchoolId = ArrangeLessonTermAttemperData.F_SchoolId;
  102. ArrangeLessonTermAttemperData.NewAcademicYearNo = ArrangeLessonTermAttemperData.AcademicYearNo;
  103. ArrangeLessonTermAttemperData.NewSemester = ArrangeLessonTermAttemperData.Semester;
  104. var jsonData = new
  105. {
  106. ArrangeLessonTermAttemper = ArrangeLessonTermAttemperData,
  107. };
  108. return Success(jsonData);
  109. }
  110. #endregion
  111. #region 提交数据
  112. /// <summary>
  113. /// 删除实体数据
  114. /// <param name="keyValue">主键</param>
  115. /// <summary>
  116. /// <returns></returns>
  117. [HttpPost]
  118. [AjaxOnly]
  119. public ActionResult DeleteForm(string keyValue)
  120. {
  121. arrangeLessonTermAttemperIBLL.DeleteEntity(keyValue);
  122. return Success("删除成功!");
  123. }
  124. /// <summary>
  125. /// 保存实体数据(新增、修改)
  126. /// <param name="keyValue">主键</param>
  127. /// <summary>
  128. /// <returns></returns>
  129. [HttpPost]
  130. [ValidateAntiForgeryToken]
  131. [AjaxOnly]
  132. public ActionResult SaveForm(string keyValue, string strEntity)
  133. {
  134. ArrangeLessonTermAttemperEntity entity = strEntity.ToObject<ArrangeLessonTermAttemperEntity>();
  135. if (entity.AttemperType == "03")
  136. {
  137. //if (entity.F_SchoolId != entity.NewF_SchoolId || entity.AcademicYearNo != entity.NewAcademicYearNo || entity.Semester != entity.NewSemester)
  138. if (entity.AcademicYearNo != entity.NewAcademicYearNo || entity.Semester != entity.NewSemester)
  139. {
  140. return Fail("校区、学年、学期不一致!");
  141. }
  142. }
  143. if (entity.AttemperType=="04")
  144. {
  145. JObject jo = (JObject)JsonConvert.DeserializeObject(strEntity);
  146. List<ArrangeLessonTermAttrmperChildEntity> query = new List<ArrangeLessonTermAttrmperChildEntity>();
  147. string[] targetjieci = jo["tardata"]["targetjieci"].ToString().TrimEnd(';').Split(';');
  148. string targettime = jo["tardata"]["targettime"].ToString();
  149. string lastdata = "";
  150. int i = 0;
  151. int index = 0;
  152. foreach (var item in jo["predata"])
  153. {
  154. //index++;
  155. if (string.IsNullOrEmpty(lastdata) || lastdata != item["LessonTime"].ToString())
  156. {
  157. lastdata = item["LessonTime"].ToString();
  158. if ( index >= jo["predata"].Count()/2)
  159. {
  160. i++;
  161. }
  162. }
  163. DateTime NewLessonDate = Convert.ToDateTime(jo["tardata"]["targettime"].ToString());
  164. string newlessontime = Convert.ToInt32(NewLessonDate.DayOfWeek).ToString()+ targetjieci[i].Replace("节","");
  165. ArrangeLessonTermAttrmperChildEntity term = new ArrangeLessonTermAttrmperChildEntity
  166. {
  167. LessonId = !string.IsNullOrEmpty(keyValue) ? item["LessonId"].ToString(): item["AltId"].ToString(),
  168. LessonDate = Convert.ToDateTime(item["LessonDate"].ToString()),
  169. LessonTime = item["LessonTime"].ToString(),
  170. NewLessonDate =NewLessonDate ,
  171. NewLessonTime = newlessontime
  172. };
  173. query.Add(term);
  174. index++;
  175. }
  176. entity.query = query;
  177. }
  178. entity.Status = 0;
  179. entity.CheckStatus = 0;
  180. arrangeLessonTermAttemperIBLL.SaveEntity(keyValue, entity);
  181. return Success("保存成功!");
  182. }
  183. #endregion
  184. #region 扩展数据
  185. /// <summary>
  186. /// 课程下拉框信息【教学调度】
  187. /// </summary>
  188. /// <returns></returns>
  189. [HttpGet]
  190. [AjaxOnly]
  191. public ActionResult GetLessonDataInTerm()
  192. {
  193. var data = arrangeLessonTermIBLL.GetLessonDataInTerm("").OrderBy(x => x.value);
  194. return Success(data);
  195. }
  196. /// <summary>
  197. /// 获取调课数据
  198. /// </summary>
  199. /// <param name="code">数据源编号</param>
  200. /// <param name="strWhere">sql查询条件语句</param>
  201. /// <param name="queryJson">数据源请求条件字串</param>
  202. /// <returns></returns>
  203. [HttpGet]
  204. [AjaxOnly]
  205. public ActionResult GetchildData(string code)
  206. {
  207. var data = arrangeLessonTermAttemperChildIBLL.GetPageList(new Pagination { page=1,rows=10}, "{'AttemperId':'"+code+"'}");
  208. return JsonResult(data);
  209. }
  210. /// <summary>
  211. /// 提交课程异动记录
  212. /// </summary>
  213. /// <param name="keyValue">课程异动主键</param>
  214. /// <param name="status">审核状态</param>
  215. /// <param name="processId">流程Id</param>
  216. /// <returns></returns>
  217. public ActionResult ModifyStatus(string keyValue, int status, string processId)
  218. {
  219. arrangeLessonTermAttemperIBLL.ModifyStatus(keyValue, status, processId);
  220. return Success("提交成功!");
  221. }
  222. #endregion
  223. }
  224. }