EducationScheduleController.cs 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.Mvc;
  7. using Bowin.Web.Controls.Mvc;
  8. using Bowin.Common.Linq.Entity;
  9. using Bowin.Common.JSON;
  10. using Bowin.Common.Utility;
  11. using Bowin.Common.Data;
  12. using EMIS.CommonLogic.EducationManage;
  13. using EMIS.ViewModel.EducationManage;
  14. using EMIS.CommonLogic.EducationSchedule;
  15. using EMIS.ViewModel;
  16. using EMIS.ViewModel.EducationSchedule;
  17. using EMIS.CommonLogic.SystemServices;
  18. using EMIS.Utility.FormValidate;
  19. using EMIS.CommonLogic.SchedulingManage.ScheduleApproval;
  20. using EMIS.Web.Controls;
  21. using EMIS.CommonLogic.CalendarManage;
  22. namespace EMIS.Web.Controllers.EducationSchedule
  23. {
  24. [Authorization]
  25. public class EducationScheduleController : Controller
  26. {
  27. public IEducationSchedulingClassServices EducationSchedulingClassServices { get; set; }
  28. public IEducationSchedulingAdjustmentServices EducationSchedulingAdjustmentServices { get; set; }
  29. public IEducationSchedulingStopServices EducationSchedulingStopServices { get; set; }
  30. public EMIS.CommonLogic.EducationSchedule.IScheduleServices ScheduleServices { get; set; }
  31. public ICollegeScheduleApprovalServices CollegeScheduleApprovalServices { get; set; }
  32. public IParameterServices ParameterServices { get; set; }
  33. public IUserServices UserServices { get; set; }
  34. public ISchoolYearServices SchoolYearServices { get; set; }
  35. public EMIS.CommonLogic.SchedulingManage.SchedulingSettings.ICollegePriorityServices CollegePriorityServices { get; set; }
  36. protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding, JsonRequestBehavior behavior)
  37. {
  38. return new JsonResult()
  39. {
  40. Data = data,
  41. ContentType = contentType,
  42. ContentEncoding = contentEncoding,
  43. JsonRequestBehavior = behavior,
  44. MaxJsonLength = Int32.MaxValue
  45. };
  46. }
  47. public ActionResult List()
  48. {
  49. return View();
  50. }
  51. public ActionResult DepartmentList()
  52. {
  53. return View();
  54. }
  55. public ActionResult Edit()
  56. {
  57. return View();
  58. }
  59. public ActionResult DepartmentEdit()
  60. {
  61. return View();
  62. }
  63. public ActionResult Setting()
  64. {
  65. return View();
  66. }
  67. public ActionResult SelectGroup()
  68. {
  69. return View();
  70. }
  71. [HttpGet]
  72. public ActionResult Submit()
  73. {
  74. return View();
  75. }
  76. public ActionResult WeekModify()
  77. {
  78. return View();
  79. }
  80. public ActionResult ClassroomScheduleView()
  81. {
  82. return View();
  83. }
  84. public ActionResult ClassroomModify()
  85. {
  86. return View();
  87. }
  88. public ActionResult SetTeacher()
  89. {
  90. return View();
  91. }
  92. public ActionResult PreSelectWeeks()
  93. {
  94. return View();
  95. }
  96. [HttpPost]
  97. public ActionResult TeacherList(QueryParamsModel pararms)
  98. {
  99. var educationSchedulingID = new Guid(Request["EducationSchedulingID"]);
  100. var teacherList = this.ScheduleServices.GetEducationSchedulingTeacherViewList(educationSchedulingID);
  101. return Json(new GridResultSet<EducationSchedulingTeacherListView> { rows = teacherList, total = teacherList.Count });
  102. }
  103. [HttpPost]
  104. public ActionResult Submit(CollegeSubmitView collegeSubmitView)
  105. {
  106. try
  107. {
  108. ScheduleServices.Submit(collegeSubmitView.CollegeID.Value);
  109. return Json(new ReturnMessage()
  110. {
  111. IsSuccess = true,
  112. Message = "提交成功!"
  113. });
  114. }
  115. catch (Exception ex)
  116. {
  117. return Json(new ReturnMessage()
  118. {
  119. IsSuccess = false,
  120. Message = "提交失败:" + ex.Message
  121. });
  122. }
  123. }
  124. public ActionResult Adjustment()
  125. {
  126. return View();
  127. }
  128. public ActionResult AdjustmentList()
  129. {
  130. ViewBag.StartStatusID = this.EducationSchedulingAdjustmentServices.GetStartStatus();
  131. ViewBag.BackpointIDs = this.EducationSchedulingAdjustmentServices.GetBackpointStatus().ToJson();
  132. return View();
  133. }
  134. [HttpPost]
  135. public ActionResult AdjustmentList(QueryParamsModel pararms)
  136. {
  137. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  138. var schoolyearID = pararms.getExtraGuid("ddlSchoolyear");
  139. var coursematerialID = pararms.getExtraGuid("cgbCoursematerial");
  140. var collegeID = pararms.getExtraGuid("ddlCollege");
  141. var teacherID = pararms.getExtraGuid("cgbTeacher");
  142. var classroomID = pararms.getExtraGuid("cbgClassroom");
  143. var applyUserID = pararms.getExtraGuid("cgbApplyUser");
  144. var startTime = pararms.getExtraDateTime("txtStartTime");
  145. var endTime = pararms.getExtraDateTime("txtEndTime");
  146. var recordStatus = pararms.getExtraInt("ddlRecordStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlRecordStatus");
  147. var result = EducationSchedulingAdjustmentServices.GetScheduleAdjustmentViewList(configuretView, schoolyearID, coursematerialID,
  148. collegeID, teacherID, classroomID, applyUserID, startTime, endTime, recordStatus, (int)pararms.page, (int)pararms.rows);
  149. return Json(result);
  150. }
  151. [HttpPost]
  152. public ActionResult Adjustment(QueryParamsModel pararms)
  153. {
  154. var schoolyearID = pararms.getExtraGuid("ddlSchoolyear");
  155. var userID = pararms.getExtraGuid("cgbTeacher");
  156. var coursematerialID = pararms.getExtraGuid("cgbCoursematerial");
  157. var educationMissionClassID = pararms.getExtraGuid("cgbEducationMissionClass");
  158. var weekNum = pararms.getExtraInt("ddlWeekNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlWeekNum");
  159. var weekday = pararms.getExtraInt("ddlWeekDay") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlWeekDay");
  160. var courseTimesID = pararms.getExtraGuid("ddlCourseTimes");
  161. var classroomID = pararms.getExtraGuid("cgbClassroom");
  162. if (!userID.HasValue)
  163. {
  164. return Json(new GridResultSet<ScheduleAdjustmentEditView> { rows = new List<ScheduleAdjustmentEditView>(), total = 0 });
  165. }
  166. var scheduleAdjustmentViewList = this.ScheduleServices.GetTeacherScheduleAdjustmentViewList(schoolyearID ?? Guid.Empty,
  167. userID.Value, coursematerialID, educationMissionClassID, weekNum, weekday, courseTimesID, classroomID);
  168. return Json(new GridResultSet<ScheduleAdjustmentEditView> { rows = scheduleAdjustmentViewList, total = scheduleAdjustmentViewList.Count });
  169. }
  170. [HttpPost]
  171. public ActionResult Stop(QueryParamsModel pararms)
  172. {
  173. var schoolyearID = pararms.getExtraGuid("ddlSchoolyear");
  174. var userID = pararms.getExtraGuid("cgbTeacher");
  175. var coursematerialID = pararms.getExtraGuid("cgbCoursematerial");
  176. var educationMissionClassID = pararms.getExtraGuid("cgbEducationMissionClass");
  177. var weekNum = pararms.getExtraInt("ddlWeekNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlWeekNum");
  178. var weekday = pararms.getExtraInt("ddlWeekDay") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlWeekDay");
  179. var courseTimesID = pararms.getExtraGuid("ddlCourseTimes");
  180. var classroomID = pararms.getExtraGuid("cgbClassroom");
  181. if (!userID.HasValue)
  182. {
  183. return Json(new GridResultSet<ScheduleStopEditView> { rows = new List<ScheduleStopEditView>(), total = 0 });
  184. }
  185. var scheduleAdjustmentViewList = this.ScheduleServices.GetTeacherScheduleStopViewList(schoolyearID ?? Guid.Empty,
  186. userID.Value, coursematerialID, educationMissionClassID, weekNum, weekday, courseTimesID, classroomID);
  187. return Json(new GridResultSet<ScheduleStopEditView> { rows = scheduleAdjustmentViewList, total = scheduleAdjustmentViewList.Count });
  188. }
  189. public ActionResult AdjustmentEdit(Guid? EducationSchedulingAdjustmentID, Guid? EducationSchedulingWeekNumID, Guid? UserID)
  190. {
  191. if (EducationSchedulingWeekNumID.HasValue)
  192. {
  193. var scheduleAdjustmentView = this.ScheduleServices.GetScheduleAdjustmentView(EducationSchedulingWeekNumID.Value);
  194. var user = this.UserServices.GetUserByID(UserID.Value);
  195. scheduleAdjustmentView.ToClassroomTypeID = scheduleAdjustmentView.ClassroomTypeID;
  196. scheduleAdjustmentView.UserID = user.UserID;
  197. scheduleAdjustmentView.ToUserID = scheduleAdjustmentView.UserID;
  198. scheduleAdjustmentView.UserName = user.Name;
  199. return View(scheduleAdjustmentView);
  200. }
  201. else
  202. {
  203. var scheduleAdjustmentView = this.EducationSchedulingAdjustmentServices.GetScheduleAdjustmentEditView(EducationSchedulingAdjustmentID.Value);
  204. return View(scheduleAdjustmentView);
  205. }
  206. }
  207. public ActionResult AdjustmentBatchEdit(int? classroomTypeID, string educationSchedulingWeekNumIDs)
  208. {
  209. ViewBag.EducationSchedulingWeekNumIDs = educationSchedulingWeekNumIDs;
  210. ViewBag.WeekNumDropdownItemList = SchoolYearServices.GetCurrentSchoolyearWeekNumList()
  211. .Select(x => new DropdownListItem { Text = x.ToString(), Value = x.ToString() })
  212. .ToList();
  213. return View();
  214. }
  215. [HttpPost]
  216. public ActionResult AdjustmentBatchEdit(string educationSchedulingWeekNumIDs, Guid fromUserID, int? toWeekNum, int? toWeekday, Guid? toUserID,
  217. Guid? toCoursesTimeID, int? toClassroomType, Guid? toClassroom)
  218. {
  219. try
  220. {
  221. var educationSchedulingWeekNumIDList = educationSchedulingWeekNumIDs.Split(',')
  222. .Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  223. this.EducationSchedulingAdjustmentServices.BatchSave(educationSchedulingWeekNumIDList, fromUserID, toWeekNum, toWeekday, toUserID,
  224. toCoursesTimeID, toClassroomType, toClassroom);
  225. return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" });
  226. }
  227. catch (Exception ex)
  228. {
  229. return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message });
  230. }
  231. }
  232. [HttpPost]
  233. public ActionResult AdjustmentEdit(ScheduleAdjustmentEditView scheduleAdjustment)
  234. {
  235. try
  236. {
  237. this.EducationSchedulingAdjustmentServices.Save(scheduleAdjustment);
  238. return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" });
  239. }
  240. catch (Exception ex)
  241. {
  242. return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message });
  243. }
  244. }
  245. [HttpPost]
  246. public ActionResult AdjustmentDelete(string educationSchedulingAdjustmentIDs)
  247. {
  248. try
  249. {
  250. var adjustmentIDList = educationSchedulingAdjustmentIDs.Split(',')
  251. .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  252. this.EducationSchedulingAdjustmentServices.Delete(adjustmentIDList);
  253. return Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  254. }
  255. catch (Exception ex)
  256. {
  257. return Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + ex.Message });
  258. }
  259. }
  260. [HttpPost]
  261. public ActionResult AdjustmentSubmit(string educationSchedulingAdjustmentIDs)
  262. {
  263. try
  264. {
  265. var adjustmentIDList = educationSchedulingAdjustmentIDs.Split(',')
  266. .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  267. this.EducationSchedulingAdjustmentServices.Submit(adjustmentIDList, CustomPrincipal.Current.UserID);
  268. return Json(new ReturnMessage { IsSuccess = true, Message = "提交成功。" });
  269. }
  270. catch (Exception ex)
  271. {
  272. return Json(new ReturnMessage { IsSuccess = false, Message = "提交失败:" + ex.Message });
  273. }
  274. }
  275. [HttpPost]
  276. public ActionResult AdjustmentExcel()
  277. {
  278. NpoiExcelHelper neh = new NpoiExcelHelper();
  279. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  280. var selectedID = Request.Form["hidEducationSchedulingAdjustmentID"] ?? "";
  281. var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo<Guid>();
  282. var coursematerialID = Request.Form["cgbCoursematerial"].ParseStrTo<Guid>();
  283. var collegeID = Request.Form["ddlCollege"].ParseStrTo<Guid>();
  284. var teacherID = Request.Form["cgbTeacher"].ParseStrTo<Guid>();
  285. var classroomID = Request.Form["cbgClassroom"].ParseStrTo<Guid>();
  286. var applyUserID = Request.Form["cgbApplyUser"].ParseStrTo<Guid>();
  287. var startTime = Request.Form["txtStartTime"].ParseStrTo<DateTime>();
  288. var endTime = Request.Form["txtEndTime"].ParseStrTo<DateTime>();
  289. var recordStatus = Request.Form["ddlRecordStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlRecordStatus"].ParseStrTo<int>();
  290. List<ScheduleAdjustmentView> result;
  291. if (!string.IsNullOrEmpty(selectedID))
  292. {
  293. var adjustmentIDList = selectedID.Split(',')
  294. .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  295. result = EducationSchedulingAdjustmentServices.GetScheduleAdjustmentViewList(adjustmentIDList);
  296. }
  297. else
  298. {
  299. result = EducationSchedulingAdjustmentServices.GetScheduleAdjustmentViewList(configuretView, schoolyearID, coursematerialID,
  300. collegeID, teacherID, classroomID, applyUserID, startTime, endTime, recordStatus);
  301. }
  302. var dt = result.Select(x => new
  303. {
  304. x.SchoolyearCode,
  305. x.CourseCode,
  306. x.CourseName,
  307. x.EducationMissionClassName,
  308. x.TeacherNames,
  309. x.TimeDetail,
  310. x.ClassroomName,
  311. x.ToTeacherNames,
  312. x.ToTimeDetail,
  313. x.ToClassroomName,
  314. x.ApplyUserName,
  315. ApplyTime = x.ApplyTime.HasValue ? x.ApplyTime.Value.ToString("yyyy-MM-dd") : "",
  316. x.RecordStatusName
  317. }).ToTable();
  318. string[] liststring = { "学年学期", "课程代码", "课程名称", "任务班名称", "原任课老师", "原上课时间","原教室",
  319. "任课老师", "上课时间", "教室", "申请人", "申请时间", "状态"};
  320. neh.Export(dt, liststring, "课程调整信息");
  321. return Json(new ReturnMessage()
  322. {
  323. IsSuccess = true,
  324. Message = "保存成功!"
  325. });
  326. }
  327. public ActionResult AdjustmentApprove()
  328. {
  329. ViewBag.DefaultApproveStatusID = EducationSchedulingAdjustmentServices.GetApproveStatusViewList().Select(x => x.ID).FirstOrDefault();
  330. return View();
  331. }
  332. [HttpPost]
  333. public ActionResult AdjustmentApproveList(QueryParamsModel pararms)
  334. {
  335. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  336. var schoolyearID = pararms.getExtraGuid("ddlSchoolyear");
  337. var coursematerialID = pararms.getExtraGuid("cgbCoursematerial");
  338. var collegeID = pararms.getExtraGuid("ddlCollege");
  339. var teacherID = pararms.getExtraGuid("cgbTeacher");
  340. var classroomID = pararms.getExtraGuid("cbgClassroom");
  341. var applyUserID = pararms.getExtraGuid("cgbApplyUser");
  342. var startTime = pararms.getExtraDateTime("txtStartTime");
  343. var endTime = pararms.getExtraDateTime("txtEndTime");
  344. var recordStatus = pararms.getExtraInt("ddlRecordStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlRecordStatus");
  345. var result = EducationSchedulingAdjustmentServices.GetScheduleAdjustmentViewApproveList(configuretView, schoolyearID, coursematerialID,
  346. collegeID, teacherID, classroomID, applyUserID, startTime, endTime, recordStatus, (int)pararms.page, (int)pararms.rows);
  347. return Json(result);
  348. }
  349. [HttpPost]
  350. public ActionResult AdjustmentApprove(string educationSchedulingAdjustmentIDs, Guid actionID, string comment)
  351. {
  352. var adjustmentIDList = educationSchedulingAdjustmentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  353. var curUserID = CustomPrincipal.Current.UserID;
  354. if (adjustmentIDList.Count == 0)
  355. {
  356. return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行审核。" });
  357. }
  358. try
  359. {
  360. this.EducationSchedulingAdjustmentServices.Approve(adjustmentIDList, curUserID, actionID, comment);
  361. return Json(new ReturnMessage { IsSuccess = true, Message = "审核成功。" });
  362. }
  363. catch (Exception ex)
  364. {
  365. return Json(new ReturnMessage { IsSuccess = false, Message = "审核失败:" + ex.Message });
  366. }
  367. }
  368. [HttpPost]
  369. public ActionResult AdjustmentApproveExcel()
  370. {
  371. NpoiExcelHelper neh = new NpoiExcelHelper();
  372. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  373. var selectedID = Request.Form["hidEducationSchedulingAdjustmentID"] ?? "";
  374. var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo<Guid>();
  375. var coursematerialID = Request.Form["cgbCoursematerial"].ParseStrTo<Guid>();
  376. var collegeID = Request.Form["ddlCollege"].ParseStrTo<Guid>();
  377. var teacherID = Request.Form["cgbTeacher"].ParseStrTo<Guid>();
  378. var classroomID = Request.Form["cbgClassroom"].ParseStrTo<Guid>();
  379. var applyUserID = Request.Form["cgbApplyUser"].ParseStrTo<Guid>();
  380. var startTime = Request.Form["txtStartTime"].ParseStrTo<DateTime>();
  381. var endTime = Request.Form["txtEndTime"].ParseStrTo<DateTime>();
  382. var recordStatus = Request.Form["ddlRecordStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlRecordStatus"].ParseStrTo<int>();
  383. List<ScheduleAdjustmentView> result;
  384. if (!string.IsNullOrEmpty(selectedID))
  385. {
  386. var adjustmentIDList = selectedID.Split(',')
  387. .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  388. result = EducationSchedulingAdjustmentServices.GetScheduleAdjustmentViewApproveList(adjustmentIDList);
  389. }
  390. else
  391. {
  392. result = EducationSchedulingAdjustmentServices.GetScheduleAdjustmentViewApproveList(configuretView, schoolyearID, coursematerialID,
  393. collegeID, teacherID, classroomID, applyUserID, startTime, endTime, recordStatus);
  394. }
  395. var dt = result.Select(x => new
  396. {
  397. x.SchoolyearCode,
  398. x.CourseCode,
  399. x.CourseName,
  400. x.EducationMissionClassName,
  401. x.TeacherNames,
  402. x.TimeDetail,
  403. x.ClassroomName,
  404. x.ToTeacherNames,
  405. x.ToTimeDetail,
  406. x.ToClassroomName,
  407. x.ApplyUserName,
  408. ApplyTime = x.ApplyTime.HasValue ? x.ApplyTime.Value.ToString("yyyy-MM-dd") : "",
  409. x.RecordStatusName
  410. }).ToTable();
  411. string[] liststring = { "学年学期", "课程代码", "课程名称", "任务班名称", "原任课老师", "原上课时间","原教室",
  412. "任课老师","上课时间","教室", "申请人", "申请时间", "状态"};
  413. neh.Export(dt, liststring, "课程调整信息");
  414. return Json(new ReturnMessage()
  415. {
  416. IsSuccess = true,
  417. Message = "保存成功!"
  418. });
  419. }
  420. public ActionResult StopList()
  421. {
  422. ViewBag.StartStatusID = this.EducationSchedulingStopServices.GetStartStatus();
  423. ViewBag.BackpointIDs = this.EducationSchedulingStopServices.GetBackpointStatus().ToJson();
  424. return View();
  425. }
  426. public ActionResult StopScheduling()
  427. {
  428. return View();
  429. }
  430. [HttpPost]
  431. public ActionResult StopScheduling(string educationSchedulingStopIDs, Guid? UserID)
  432. {
  433. try
  434. {
  435. var stopIDList = educationSchedulingStopIDs.Split(',')
  436. .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  437. this.EducationSchedulingStopServices.StopSave(stopIDList, UserID);
  438. return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" });
  439. }
  440. catch (Exception ex)
  441. {
  442. return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message });
  443. }
  444. }
  445. public ActionResult StopEdit(Guid? EducationSchedulingStopID, Guid? EducationSchedulingID, Guid? UserID)
  446. {
  447. if (EducationSchedulingID.HasValue)
  448. {
  449. var scheduleAdjustmentView = this.ScheduleServices.GetEducationSchedulingStopView(EducationSchedulingID.Value);
  450. var user = this.UserServices.GetUserByID(UserID.Value);
  451. scheduleAdjustmentView.UserID = user.UserID;
  452. return View(scheduleAdjustmentView);
  453. }
  454. else
  455. {
  456. var scheduleAdjustmentView = this.EducationSchedulingStopServices.GetEducationSchedulingStopView(EducationSchedulingStopID.Value);
  457. return View(scheduleAdjustmentView);
  458. }
  459. }
  460. [HttpPost]
  461. public ActionResult StopList(QueryParamsModel pararms)
  462. {
  463. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  464. var schoolyearID = pararms.getExtraGuid("ddlSchoolyear");
  465. var coursematerialID = pararms.getExtraGuid("cgbCoursematerial");
  466. var collegeID = pararms.getExtraGuid("ddlCollege");
  467. var teacherID = pararms.getExtraGuid("cgbTeacher");
  468. var weekNum = pararms.getExtraInt("ddlWeekNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlWeekNum");
  469. var weekDay = pararms.getExtraInt("WeekDay") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("WeekDay");
  470. var coursesTimeID = pararms.getExtraGuid("Times");
  471. var classroomID = pararms.getExtraGuid("ClassroomID");
  472. var applyUserID = pararms.getExtraGuid("applyUserID");
  473. var starDate = pararms.getExtraDateTime("txtStartDate");
  474. var endDate = pararms.getExtraDateTime("txtEndDate");
  475. var recordStatus = pararms.getExtraInt("ddlRecordStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlRecordStatus");
  476. var result = EducationSchedulingStopServices.GetEducationSchedulingStopViewList(configuretView, schoolyearID, coursematerialID,
  477. collegeID, teacherID, weekNum, weekDay, coursesTimeID, classroomID, applyUserID, starDate, endDate, recordStatus, (int)pararms.page, (int)pararms.rows);
  478. return Json(result);
  479. }
  480. [HttpPost]
  481. public ActionResult StopExcel()
  482. {
  483. NpoiExcelHelper neh = new NpoiExcelHelper();
  484. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  485. var selectedID = Request.Form["hidEducationSchedulingStopID"] ?? "";
  486. var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo<Guid>();
  487. var coursematerialID = Request.Form["cgbCoursematerial"].ParseStrTo<Guid>();
  488. var collegeID = Request.Form["ddlCollege"].ParseStrTo<Guid>();
  489. var teacherID = Request.Form["cgbTeacher"].ParseStrTo<Guid>();
  490. var weekNum = Request.Form["ddlWeekNum"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlWeekNum"].ParseStrTo<int>();
  491. var weekDay = Request.Form["WeekDay"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["WeekDay"].ParseStrTo<int>();
  492. var coursesTimeID = Request.Form["Times"].ParseStrTo<Guid>();
  493. var classroomID = Request.Form["ClassroomID"].ParseStrTo<Guid>();
  494. var applyUserID = Request.Form["applyUserID"].ParseStrTo<Guid>();
  495. var starDate = Request.Form["txtStartDate"].ParseStrTo<DateTime>();
  496. var endDate = Request.Form["txtEndDate"].ParseStrTo<DateTime>();
  497. var recordStatus = Request.Form["ddlRecordStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlRecordStatus"].ParseStrTo<int>();
  498. List<EducationSchedulingStopView> result;
  499. if (!string.IsNullOrEmpty(selectedID))
  500. {
  501. var stopIDList = selectedID.Split(',')
  502. .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  503. result = EducationSchedulingStopServices.GetEducationSchedulingStopViewList(stopIDList);
  504. }
  505. else
  506. {
  507. result = EducationSchedulingStopServices.GetEducationSchedulingStopViewList(configuretView, schoolyearID, coursematerialID,
  508. collegeID, teacherID, weekNum, weekDay, coursesTimeID, classroomID, applyUserID, starDate, endDate, recordStatus);
  509. }
  510. var dt = result.Select(x => new
  511. {
  512. x.SchoolyearCode,
  513. x.CourseCode,
  514. x.CourseName,
  515. x.EducationMissionClassName,
  516. x.TimeDetail,
  517. x.ClassroomName,
  518. x.TeacherNames,
  519. x.RecordStatusName
  520. }).ToTable();
  521. string[] liststring = { "学年学期", "课程代码", "课程名称", "任务班名称", "上课时间","教室", "停课老师", "状态"};
  522. neh.Export(dt, liststring, "停课信息");
  523. return Json(new ReturnMessage()
  524. {
  525. IsSuccess = true,
  526. Message = "保存成功!"
  527. });
  528. }
  529. [HttpPost]
  530. public ActionResult StopDelete(string educationSchedulingStopIDs)
  531. {
  532. try
  533. {
  534. var stopIDList = educationSchedulingStopIDs.Split(',')
  535. .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  536. this.EducationSchedulingStopServices.Delete(stopIDList);
  537. return Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  538. }
  539. catch (Exception ex)
  540. {
  541. return Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + ex.Message });
  542. }
  543. }
  544. [HttpPost]
  545. public ActionResult StopSubmit(string educationSchedulingStopIDs)
  546. {
  547. try
  548. {
  549. var stopIDList = educationSchedulingStopIDs.Split(',')
  550. .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  551. this.EducationSchedulingStopServices.Submit(stopIDList, CustomPrincipal.Current.UserID);
  552. return Json(new ReturnMessage { IsSuccess = true, Message = "提交成功。" });
  553. }
  554. catch (Exception ex)
  555. {
  556. return Json(new ReturnMessage { IsSuccess = false, Message = "提交失败:" + ex.Message });
  557. }
  558. }
  559. [HttpPost]
  560. public ActionResult StopEdit(EducationSchedulingStopView scheduleStop)
  561. {
  562. try
  563. {
  564. this.EducationSchedulingStopServices.Save(scheduleStop);
  565. return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" });
  566. }
  567. catch (Exception ex)
  568. {
  569. return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message });
  570. }
  571. }
  572. public ActionResult StopApprove()
  573. {
  574. ViewBag.DefaultApproveStatusID = EducationSchedulingStopServices.GetApproveStatusViewList().Select(x => x.ID).FirstOrDefault();
  575. return View();
  576. }
  577. [HttpPost]
  578. public ActionResult StopApproveList(QueryParamsModel pararms)
  579. {
  580. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  581. var schoolyearID = pararms.getExtraGuid("ddlSchoolyear");
  582. var coursematerialID = pararms.getExtraGuid("cgbCoursematerial");
  583. var collegeID = pararms.getExtraGuid("ddlCollege");
  584. var teacherID = pararms.getExtraGuid("cgbTeacher");
  585. var weekNum = pararms.getExtraInt("ddlWeekNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlWeekNum");
  586. var weekDay = pararms.getExtraInt("WeekDay") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("WeekDay");
  587. var coursesTimeID = pararms.getExtraGuid("Times");
  588. var classroomID = pararms.getExtraGuid("ClassroomID");
  589. var applyUserID = pararms.getExtraGuid("applyUserID");
  590. var starDate = pararms.getExtraDateTime("txtStartDate");
  591. var endDate = pararms.getExtraDateTime("txtEndDate");
  592. var recordStatus = pararms.getExtraInt("ddlRecordStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlRecordStatus");
  593. var result = EducationSchedulingStopServices.GetEducationSchedulingStopApproveList(configuretView, schoolyearID, coursematerialID,
  594. collegeID, teacherID,weekNum,weekDay,coursesTimeID,classroomID,applyUserID,starDate,endDate, recordStatus, (int)pararms.page, (int)pararms.rows);
  595. return Json(result);
  596. }
  597. [HttpPost]
  598. public ActionResult StopApprove(string educationSchedulingStopIDs, Guid actionID, string comment)
  599. {
  600. var schedulingStopIDList = educationSchedulingStopIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  601. var curUserID = CustomPrincipal.Current.UserID;
  602. if (schedulingStopIDList.Count == 0)
  603. {
  604. return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行审核。" });
  605. }
  606. try
  607. {
  608. this.EducationSchedulingStopServices.Approve(schedulingStopIDList, curUserID, actionID, comment);
  609. return Json(new ReturnMessage { IsSuccess = true, Message = "审核成功。" });
  610. }
  611. catch (Exception ex)
  612. {
  613. return Json(new ReturnMessage { IsSuccess = false, Message = "审核失败:" + ex.Message });
  614. }
  615. }
  616. [HttpPost]
  617. public ActionResult StopApproveExcel()
  618. {
  619. NpoiExcelHelper neh = new NpoiExcelHelper();
  620. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  621. var selectedID = Request.Form["hidEducationSchedulingStopID"] ?? "";
  622. var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo<Guid>();
  623. var coursematerialID = Request.Form["cgbCoursematerial"].ParseStrTo<Guid>();
  624. var collegeID = Request.Form["ddlCollege"].ParseStrTo<Guid>();
  625. var teacherID = Request.Form["cgbTeacher"].ParseStrTo<Guid>();
  626. var weekNum = Request.Form["ddlWeekNum"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlWeekNum"].ParseStrTo<int>();
  627. var weekDay = Request.Form["WeekDay"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["WeekDay"].ParseStrTo<int>();
  628. var coursesTimeID = Request.Form["Times"].ParseStrTo<Guid>();
  629. var classroomID = Request.Form["ClassroomID"].ParseStrTo<Guid>();
  630. var applyUserID = Request.Form["applyUserID"].ParseStrTo<Guid>();
  631. var starDate = Request.Form["txtStartDate"].ParseStrTo<DateTime>();
  632. var endDate = Request.Form["txtEndDate"].ParseStrTo<DateTime>();
  633. var recordStatus = Request.Form["ddlRecordStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlRecordStatus"].ParseStrTo<int>();
  634. List<EducationSchedulingStopView> result;
  635. if (!string.IsNullOrEmpty(selectedID))
  636. {
  637. var stopIDList = selectedID.Split(',')
  638. .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  639. result = EducationSchedulingStopServices.GetEducationSchedulingStopApproveList(stopIDList);
  640. }
  641. else
  642. {
  643. result = EducationSchedulingStopServices.GetEducationSchedulingStopApproveList(configuretView, schoolyearID, coursematerialID,
  644. collegeID, teacherID,weekNum,weekDay,coursesTimeID,classroomID,applyUserID,starDate,endDate, recordStatus);
  645. }
  646. var dt = result.Select(x => new
  647. {
  648. x.SchoolyearCode,
  649. x.CourseCode,
  650. x.CourseName,
  651. x.EducationMissionClassName,
  652. x.TimeDetail,
  653. x.ClassroomName,
  654. x.TeacherNames,
  655. x.RecordStatusName
  656. }).ToTable();
  657. string[] liststring = { "学年学期", "课程代码", "课程名称", "任务班名称", "上课时间", "教室", "停课老师", "状态" };
  658. neh.Export(dt, liststring, "停课信息");
  659. return Json(new ReturnMessage()
  660. {
  661. IsSuccess = true,
  662. Message = "保存成功!"
  663. });
  664. }
  665. [HttpPost]
  666. public ActionResult GetNotUseCoursesTimeDropDown(DropdownListBindType? bindType, Guid schoolyearID,
  667. int weekday, int toWeekday, Guid courseTimeID, int weekNum, int toWeekNum,
  668. Guid? fromTeacherID, Guid? replaceTeacherID, Guid educationMissionClassID)
  669. {
  670. var notUseCourseTimeViewList = this.ScheduleServices.GetNotUseCoursesTimeViewList(schoolyearID, weekday, toWeekday, courseTimeID,
  671. weekNum, toWeekNum, fromTeacherID, replaceTeacherID, educationMissionClassID);
  672. List<DropdownListItem> list = notUseCourseTimeViewList
  673. .Select(x => new DropdownListItem { Text = x.StartDate + "-" + x.EndDate, Value = x.CoursesTimeID.ToString() }).ToList();
  674. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  675. DropdownList.FormatDropdownItemList(dbt, list);
  676. return base.Json(list);
  677. }
  678. [HttpPost]
  679. public ActionResult GetNotUseClassroomList(QueryParamsModel pararms)
  680. {
  681. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  682. Guid schoolyearID = pararms.getExtraGuid("SchoolyearID") ?? Guid.Empty;
  683. int weekday = (pararms.getExtraInt("Weekday") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("Weekday")) ?? -1;
  684. int toWeekday = (pararms.getExtraInt("ToWeekday") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ToWeekday")) ?? -1;
  685. Guid coursesTimeID = pararms.getExtraGuid("CoursesTimeID") ?? Guid.Empty;
  686. Guid toCoursesTimeID = pararms.getExtraGuid("ToCoursesTimeID") ?? Guid.Empty;
  687. int weekNum = (pararms.getExtraInt("WeekNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("WeekNum")) ?? -1;
  688. int toWeekNum = (pararms.getExtraInt("ToWeekNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ToWeekNum")) ?? -1;
  689. int classroomTypeID = (pararms.getExtraInt("ClassroomTypeID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ClassroomTypeID")) ?? -1;
  690. Guid educationMissionClassID = pararms.getExtraGuid("EducationMissionClassID") ?? Guid.Empty;
  691. var notUseClassroomViewList = this.ScheduleServices.GetNotUseClassroomViewList(configuretView, schoolyearID, weekday, toWeekday, coursesTimeID,
  692. toCoursesTimeID, new List<int?> { weekNum }, new List<int?> { toWeekNum }, classroomTypeID, educationMissionClassID, pararms.page, pararms.rows);
  693. return base.Json(notUseClassroomViewList);
  694. }
  695. [HttpPost]
  696. public ActionResult GetEducationSchedulingClass(Guid schoolyearID, Guid classmajorID)
  697. {
  698. var schedulingClassList = EducationSchedulingClassServices.GetEducationSchedulingClassViewList(schoolyearID, classmajorID);
  699. var draggableList = new GridResultSet<EducationSchedulingClassScheduleView>
  700. {
  701. rows = schedulingClassList,
  702. total = schedulingClassList.Count
  703. };
  704. return Json(draggableList);
  705. }
  706. [HttpPost]
  707. public ActionResult GetDepartmentEducationSchedulingClass(Guid schoolyearID, Guid departmentID, string handleModes)
  708. {
  709. var handleModeList = handleModes.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (int?)Convert.ToInt32(x)).ToList();
  710. var schedulingClassList = EducationSchedulingClassServices.GetDepartmentEducationSchedulingClassViewList(schoolyearID, departmentID, handleModeList);
  711. var draggableList = new GridResultSet<EducationSchedulingClassScheduleView>
  712. {
  713. rows = schedulingClassList,
  714. total = schedulingClassList.Count
  715. };
  716. return Json(draggableList);
  717. }
  718. [HttpPost]
  719. public ActionResult GetClassmajorSchedule(Guid schoolyearID, Guid classmajorID)
  720. {
  721. var classmajorSchedule = ScheduleServices.GetClassmajorSchedule(schoolyearID, classmajorID);
  722. return Json(classmajorSchedule);
  723. }
  724. [HttpPost]
  725. public ActionResult GetEducationMissionClassViewBySchedule(Guid? schoolyearID, DateTime date, Guid coursesTimeID, Guid teacherUserID)
  726. {
  727. var educationMissionClassView = ScheduleServices.GetEducationMissionClassViewBySchedule(schoolyearID, date, coursesTimeID, teacherUserID);
  728. return Json(educationMissionClassView);
  729. }
  730. [HttpPost]
  731. public ActionResult GetDepartmentSchedule(Guid schoolyearID, Guid departmentID, string handleModes)
  732. {
  733. var handleModeList = handleModes.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (int?)Convert.ToInt32(x)).ToList();
  734. var departmentSchedule = ScheduleServices.GetDepartmentSchedule(schoolyearID, departmentID, handleModeList);
  735. return Json(departmentSchedule);
  736. }
  737. [HttpPost]
  738. public ActionResult GetAvailableClassroom(Guid schoolYearID, Guid collegeID, string schedulingWeekListStr, int weekday, Guid courseTimeID, int? classroomTypeID, int? studentNum)
  739. {
  740. var schedulingWeekList = schedulingWeekListStr.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (int?)Convert.ToInt32(x)).ToList();
  741. var classroomList = ScheduleServices.GetAvailableClassroomList(collegeID, schoolYearID, schedulingWeekList,
  742. weekday, courseTimeID, studentNum, classroomTypeID);
  743. return Json(classroomList);
  744. }
  745. [HttpPost]
  746. public ActionResult IsEducationSchedulingClassCanAddManualSchedule(Guid educationScheduleClassID, string schedulingWeekListStr, Guid schoolYearID,
  747. int weekday, Guid courseTimeID)
  748. {
  749. try
  750. {
  751. var schedulingWeekList = schedulingWeekListStr.JsonToObject<List<SchedulingWeekListView>>().ToList();
  752. this.ScheduleServices.CheckEducationSchedulingClassCanAddManualSchedule(educationScheduleClassID, schedulingWeekList, schoolYearID,
  753. weekday, courseTimeID);
  754. return Json(new ReturnMessage { IsSuccess = true });
  755. }
  756. catch (Exception ex)
  757. {
  758. if (ex.Data.Count > 0)
  759. {
  760. var data = new List<KeyValuePair<Guid, string>>();
  761. foreach (DictionaryEntry item in ex.Data)
  762. {
  763. data.Add(new KeyValuePair<Guid, string>((Guid)item.Key, item.Value.ToString()));
  764. }
  765. return Json(new ReturnMessage<List<KeyValuePair<Guid, string>>> { IsSuccess = false, Message = ex.Message, Data = data });
  766. }
  767. return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
  768. }
  769. }
  770. [HttpPost]
  771. public ActionResult IsClassroomIsAvailable(Guid collegeID, Guid schoolYearID, string schedulingWeekListStr,
  772. int weekday, Guid courseTimeID, Guid classroomID)
  773. {
  774. var schedulingWeekList = schedulingWeekListStr.Split(',').Where(x => x != null).Select(x => (int?)Convert.ToInt32(x)).ToList();
  775. try
  776. {
  777. ScheduleServices.CheckClassroomIsAvailable(collegeID, schoolYearID, schedulingWeekList, weekday, courseTimeID, classroomID);
  778. return Json(new ReturnMessage { IsSuccess = true });
  779. }
  780. catch (ClassroomConflictException ex)
  781. {
  782. return Json(new ReturnMessage<Guid> { IsSuccess = false, Message = ex.Message, Data = classroomID });
  783. }
  784. catch (Exception ex)
  785. {
  786. return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
  787. }
  788. }
  789. [HttpPost]
  790. public ActionResult IsCourseOnWork(Guid coursematerialID, int weekday, Guid courseTimeID)
  791. {
  792. try
  793. {
  794. this.ScheduleServices.CheckCourseIsOnWork(coursematerialID, weekday, courseTimeID);
  795. return Json(new ReturnMessage { IsSuccess = true });
  796. }
  797. catch (Exception ex)
  798. {
  799. return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
  800. }
  801. }
  802. [HttpPost]
  803. public ActionResult IsTeacherOnWork(Guid educationScheduleClassID, string schedulingWeekListStr, int weekday, Guid courseTimeID)
  804. {
  805. try
  806. {
  807. var schedulingWeekList = schedulingWeekListStr.JsonToObject<List<SchedulingWeekListView>>().ToList();
  808. this.ScheduleServices.CheckTeacherIsOnWork(educationScheduleClassID, schedulingWeekList, weekday, courseTimeID);
  809. return Json(new ReturnMessage { IsSuccess = true });
  810. }
  811. catch (Exception ex)
  812. {
  813. return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
  814. }
  815. }
  816. [HttpPost]
  817. public ActionResult GetTeacherContinuousWorkTime(Guid educationScheduleClassID, string schedulingWeekListStr,
  818. Guid schoolYearID, int weekday)
  819. {
  820. var schedulingWeekList = schedulingWeekListStr.JsonToObject<List<SchedulingWeekListView>>().ToList();
  821. return Json(ScheduleServices.GetTeacherContinuousWorkTime(educationScheduleClassID, schedulingWeekList,
  822. schoolYearID, weekday));
  823. }
  824. [HttpPost]
  825. public ActionResult GetContinuousLimitView()
  826. {
  827. return Json(new ContinuousLimitView
  828. {
  829. TeacherScheduleContinuousCount = ParameterServices.GetParameterValue<int>(CF_ParameterType.TeacherScheduleContinuousCount) ?? 0,
  830. ClassScheduleContinuousCount = ParameterServices.GetParameterValue<int>(CF_ParameterType.ClassScheduleContinuousCount) ?? 0,
  831. ClassCourseScheduleContinuousCount = ParameterServices.GetParameterValue<int>(CF_ParameterType.ClassCourseScheduleContinuousCount) ?? 0
  832. });
  833. }
  834. [HttpPost]
  835. public ActionResult AddScheduling(Guid schoolYearID, Guid educationSchedulingClassID, string weekListStr, string teacherStr, int weekday, Guid courseTimeID, Guid classroomID)
  836. {
  837. try
  838. {
  839. var schedulingWeekList = weekListStr.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (int?)Convert.ToInt32(x)).ToList();
  840. var teacherList = teacherStr.JsonToObject<List<CourseProcessTeacherView>>();
  841. EducationSchedulingView educationSchedulingView = new EducationSchedulingView()
  842. {
  843. SchoolyearID = schoolYearID,
  844. EducationSchedulingClassID = educationSchedulingClassID,
  845. Weekday = weekday,
  846. CoursesTimeID = courseTimeID,
  847. ClassroomID = classroomID
  848. };
  849. ScheduleServices.AddScheduling(educationSchedulingView, schedulingWeekList, teacherList);
  850. return Json(new ReturnMessage { IsSuccess = true });
  851. }
  852. catch (Exception ex)
  853. {
  854. return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
  855. }
  856. }
  857. //[HttpPost]
  858. //public ActionResult DelScheduling(Guid schoolYearID, Guid educationSchedulingClassID, int weekday, Guid courseTimeID)
  859. //{
  860. // try
  861. // {
  862. // ScheduleServices.DelScheduling(schoolYearID, educationSchedulingClassID, weekday, courseTimeID);
  863. // return Json(new ReturnMessage { IsSuccess = true });
  864. // }
  865. // catch (Exception ex)
  866. // {
  867. // return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
  868. // }
  869. //}
  870. [HttpPost]
  871. public ActionResult DelScheduling(Guid educationSchedulingID)
  872. {
  873. try
  874. {
  875. ScheduleServices.DelScheduling(educationSchedulingID);
  876. return Json(new ReturnMessage { IsSuccess = true });
  877. }
  878. catch (Exception ex)
  879. {
  880. return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
  881. }
  882. }
  883. [HttpPost]
  884. public ActionResult DeleteWeeks(Guid educationSchedulingID, string weekListStr)
  885. {
  886. try
  887. {
  888. var deleteWeekList = weekListStr.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (int?)Convert.ToInt32(x)).ToList();
  889. ScheduleServices.DelWeeks(educationSchedulingID, deleteWeekList);
  890. return Json(new ReturnMessage { IsSuccess = true });
  891. }
  892. catch (Exception ex)
  893. {
  894. return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
  895. }
  896. }
  897. [HttpPost]
  898. public ActionResult GetClassroomScheduleViewList(Guid schoolYearID, Guid classroomID)
  899. {
  900. try
  901. {
  902. var classroomScheduleViewList = this.ScheduleServices.GetClassroomScheduleViewList(schoolYearID, classroomID);
  903. return Json(new GridResultSet<ClassroomScheduleView> { rows = classroomScheduleViewList, total = classroomScheduleViewList.Count });
  904. }
  905. catch (Exception ex)
  906. {
  907. throw ex;
  908. }
  909. }
  910. [HttpPost]
  911. public ActionResult ChangeClassroom(Guid educationSchedulingID, Guid classroomID)
  912. {
  913. try
  914. {
  915. ScheduleServices.ChangeClassroom(educationSchedulingID, classroomID);
  916. return Json(new ReturnMessage { IsSuccess = true });
  917. }
  918. catch (Exception ex)
  919. {
  920. return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
  921. }
  922. }
  923. [HttpPost]
  924. public ActionResult SetTeacher(Guid educationSchedulingID)
  925. {
  926. try
  927. {
  928. var teacherViewList = DataGrid.GetTableData<EducationSchedulingTeacherListView>("dgTeacherList");
  929. ScheduleServices.ChangeTeacher(educationSchedulingID, teacherViewList);
  930. return Json(new ReturnMessage { IsSuccess = true, Message = "设置教师成功。" });
  931. }
  932. catch (Exception ex)
  933. {
  934. return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
  935. }
  936. }
  937. [HttpPost]
  938. public ActionResult AutoSchedule(string educationMissionClassIDs)
  939. {
  940. try
  941. {
  942. var educationMissionClassIDList = educationMissionClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  943. ScheduleServices.GenerateSchedule(educationMissionClassIDList);
  944. return Json(new ReturnMessage { IsSuccess = true, Message = "智能排课成功。" });
  945. }
  946. catch (Exception ex)
  947. {
  948. return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
  949. }
  950. }
  951. public ActionResult ClearAutoSchedule()
  952. {
  953. ClearAutoScheduleView viewmodel = new ClearAutoScheduleView();
  954. viewmodel.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID();
  955. return View();
  956. }
  957. [HttpPost]
  958. public ActionResult ClearAutoSchedule(ClearAutoScheduleView viewmodel)
  959. {
  960. try
  961. {
  962. if (viewmodel.Year == DropdownList.SELECT_ALL)
  963. {
  964. viewmodel.Year = null;
  965. }
  966. if (viewmodel.StandardID == DropdownList.SELECT_ALL)
  967. {
  968. viewmodel.StandardID = null;
  969. }
  970. ScheduleServices.ClearAutoSchedule(viewmodel.SchoolyearID, viewmodel.CollegeID, viewmodel.StandardID, viewmodel.Year, viewmodel.ClassmarjorID);
  971. return Json(new ReturnMessage { IsSuccess = true, Message = "清除智能排课结果完成。" });
  972. }
  973. catch (Exception ex)
  974. {
  975. return Json(new ReturnMessage { IsSuccess = false, Message = "清除智能排课结果失败," + ex.Message });
  976. }
  977. }
  978. }
  979. }