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.
 
 
 
 
 
 

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