EducationSchedulingStopServices.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Bowin.Common.Linq;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.ViewModel.EducationSchedule;
  8. using EMIS.ViewModel;
  9. using EMIS.DataLogic.EducationSchedule;
  10. using EMIS.Entities;
  11. using EMIS.CommonLogic.SystemServices;
  12. using System.Linq.Expressions;
  13. namespace EMIS.CommonLogic.EducationSchedule
  14. {
  15. public class EducationSchedulingStopServices : BaseWorkflowServices<ES_EducationSchedulingStop>, IEducationSchedulingStopServices
  16. {
  17. public EducationSchedulingDAL EducationSchedulingDAL { get; set; }
  18. public EducationSchedulingStopDAL EducationSchedulingStopDAL { get; set; }
  19. public IGridResultSet<EducationSchedulingStopView> GetEducationSchedulingStopViewList(ConfiguretView configuretView, Guid? schoolyearID,
  20. Guid? coursematerialID, Guid? collegeID, Guid? userID, int? WeekNum, int? WeekDay, Guid? CoursesTimeID, Guid? ClassroomID, Guid? applyUserID, DateTime? starDate, DateTime? endDate, int? recordStatus, int? pageIndex, int? pageSize)
  21. {
  22. var statusList = this.GetStatusViewList();
  23. Expression<Func<ES_EducationSchedulingStop, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  24. Expression<Func<EM_EducationMission, bool>> missionExp = (x => true);
  25. Expression<Func<EM_EducationMissionClass, bool>> missionClassExp = (x => true);
  26. exp = exp.And(x => x.ES_EducationSchedulingStopTeacher.AsQueryable().Any(
  27. this.GetDataRageExpression<ES_EducationSchedulingStopTeacher>(w => w.UserID)));
  28. if (schoolyearID.HasValue)
  29. {
  30. missionExp = missionExp.And(x => x.SchoolyearID == schoolyearID);
  31. }
  32. if (coursematerialID.HasValue)
  33. {
  34. missionClassExp = missionClassExp.And(x => x.CoursematerialID == coursematerialID);
  35. }
  36. if (collegeID.HasValue)
  37. {
  38. exp = exp.And(x => x.ES_EducationSchedulingStopTeacher.Any(w => w.CF_Staff.CollegeID == collegeID));
  39. }
  40. if (userID.HasValue)
  41. {
  42. exp = exp.And(x => x.ES_EducationSchedulingStopTeacher.Any(w => w.UserID == userID));
  43. }
  44. if(WeekNum.HasValue)
  45. {
  46. exp = exp.And(x => x.WeekNum == WeekNum);
  47. }
  48. if (WeekDay.HasValue)
  49. {
  50. exp = exp.And(x => x.Weekday == WeekDay);
  51. }
  52. if (CoursesTimeID.HasValue)
  53. {
  54. exp = exp.And(x => x.CoursesTimeID == CoursesTimeID);
  55. }
  56. if (ClassroomID.HasValue)
  57. {
  58. exp = exp.And(x => x.ClassroomID == ClassroomID);
  59. }
  60. if(applyUserID.HasValue)
  61. {
  62. exp = exp.And(x => x.CreateUserID == applyUserID);
  63. }
  64. if(starDate.HasValue)
  65. {
  66. exp = exp.And(x => x.ApplyTime >= starDate);
  67. }
  68. if (endDate.HasValue)
  69. {
  70. exp = exp.And(x => x.ApplyTime <= endDate.Value.AddDays(1));
  71. }
  72. if (starDate.HasValue && endDate.HasValue)
  73. {
  74. exp = exp.And(x => x.ApplyTime >= starDate && x.ApplyTime <= endDate.Value.AddDays(1));
  75. }
  76. if (recordStatus.HasValue)
  77. {
  78. exp = exp.And(x => x.RecordStatus == recordStatus);
  79. }
  80. var query = this.EducationSchedulingStopDAL.GetEducationSchedulingStopViewQueryable(exp, missionExp, missionClassExp);
  81. var teacherQuery = this.EducationSchedulingStopDAL.GetEducationSchedulingStopTeacherViewQueryable(
  82. exp, missionExp, missionClassExp);
  83. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  84. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  85. var resultQuery = query.OrderByDescending(x => x.ApplyTime)
  86. .ThenBy(x => x.applyUserName);
  87. var result = resultQuery.ToGridResultSet<EducationSchedulingStopView>(pageIndex, pageSize);
  88. if (pageIndex.HasValue && pageSize.HasValue)
  89. {
  90. var stopIDList = result.rows.Select(x => (Guid?)x.EducationSchedulingStopID).ToList();
  91. var teacherList = teacherQuery.Where(x => stopIDList.Contains(x.EducationSchedulingStopID))
  92. .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name)
  93. .ToList();
  94. result.rows.ForEach(x =>
  95. {
  96. x.TeacherList = teacherList
  97. .Where(w => w.EducationSchedulingStopID == x.EducationSchedulingStopID).ToList();
  98. x.RecordStatusName = statusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name;
  99. });
  100. }
  101. else
  102. {
  103. var teacherList = teacherQuery
  104. .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name).ToList();
  105. result.rows.ForEach(x =>
  106. {
  107. x.TeacherList = teacherList
  108. .Where(w => w.EducationSchedulingStopID == x.EducationSchedulingStopID).ToList();
  109. x.RecordStatusName = statusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name;
  110. });
  111. }
  112. return result;
  113. }
  114. public List<EducationSchedulingStopView> GetEducationSchedulingStopViewList(ConfiguretView configuretView,
  115. Guid? schoolyearID, Guid? coursematerialID, Guid? collegeID, Guid? userID, int? weekNum, int? weekDay, Guid? coursesTimeID, Guid? classroomID, Guid? applyUserID, DateTime? starDate, DateTime? endDate, int? recordStatus)
  116. {
  117. return this.GetEducationSchedulingStopViewList(configuretView, schoolyearID,
  118. coursematerialID, collegeID, userID, weekNum, weekDay, coursesTimeID, classroomID, applyUserID, starDate, endDate, recordStatus, null, null).rows;
  119. }
  120. public EducationSchedulingStopView GetEducationSchedulingStopView(Guid educationSchedulingStopID)
  121. {
  122. var result = this.EducationSchedulingStopDAL
  123. .GetEducationSchedulingStopViewQueryable(x => x.EducationSchedulingStopID == educationSchedulingStopID,
  124. (x => true), (x => true)).FirstOrDefault();
  125. var educationSchedule = this.EducationSchedulingDAL.EducationSchedulingRepository.GetSingle(x =>
  126. x.EM_EducationSchedulingClass.EducationMissionClassID == result.EducationMissionClassID
  127. && x.Weekday == result.Weekday && x.CoursesTimeID == result.CoursesTimeID
  128. && x.ES_EducationSchedulingWeekNum.Any(w => w.WeekNum == result.WeekNum),
  129. (x => x.ES_EducationSchedulingWeekNum));
  130. if (educationSchedule == null)
  131. {
  132. throw new Exception("无法读取停课记录,记录指定的课程安排已被移动或删除。");
  133. }
  134. result.ScheduleWeekNumList = educationSchedule.ES_EducationSchedulingWeekNum.Select(w => w.WeekNum)
  135. .ToList();
  136. return result;
  137. }
  138. public void Save(EducationSchedulingStopView educationSchedulingStopView)
  139. {
  140. ES_EducationScheduling educationSchedule;
  141. educationSchedule = this.EducationSchedulingDAL.EducationSchedulingRepository.GetSingle(x =>
  142. x.EM_EducationSchedulingClass.EducationMissionClassID == educationSchedulingStopView.EducationMissionClassID
  143. && x.Weekday == educationSchedulingStopView.Weekday && x.CoursesTimeID == educationSchedulingStopView.CoursesTimeID
  144. && x.ES_EducationSchedulingWeekNum.Any(w => w.WeekNum == educationSchedulingStopView.WeekNum),
  145. (x => x.EM_EducationSchedulingClass),
  146. (x => x.ES_EducationSchedulingTeacher));
  147. if (educationSchedule == null)
  148. {
  149. throw new Exception("所选排课记录不存在,请退出重新选择。");
  150. }
  151. var startStatusID = this.GetStartStatus();
  152. var backpointStatusList = this.GetBackpointStatus();
  153. var scheduleStop = new ES_EducationSchedulingStop();
  154. if (educationSchedulingStopView.EducationSchedulingStopID != Guid.Empty)
  155. {
  156. scheduleStop = this.EducationSchedulingStopDAL.EducationSchedulingStopRepository
  157. .GetSingle(x => x.EducationSchedulingStopID == educationSchedulingStopView.EducationSchedulingStopID,
  158. (x => x.ES_EducationSchedulingStopTeacher));
  159. if (scheduleStop == null)
  160. {
  161. throw new Exception("数据已经被删除,请退出重新选择。");
  162. }
  163. if (scheduleStop.RecordStatus != startStatusID && !backpointStatusList.Contains(scheduleStop.RecordStatus))
  164. {
  165. throw new Exception("数据已提交,不能修改。");
  166. }
  167. this.SetModifyStatus(scheduleStop);
  168. }
  169. else
  170. {
  171. scheduleStop.EducationSchedulingStopID = Guid.NewGuid();
  172. this.SetNewStatus(scheduleStop);
  173. scheduleStop.RecordStatus = startStatusID;
  174. this.UnitOfWork.Add(scheduleStop);
  175. }
  176. scheduleStop.EducationMissionClassID = educationSchedule.EM_EducationSchedulingClass.EducationMissionClassID;
  177. scheduleStop.Weekday = educationSchedulingStopView.Weekday;
  178. scheduleStop.WeekNum = educationSchedulingStopView.WeekNum;
  179. scheduleStop.CoursesTimeID = educationSchedulingStopView.CoursesTimeID;
  180. scheduleStop.ClassroomID = educationSchedulingStopView.ClassroomID;
  181. if (educationSchedulingStopView.UserID.HasValue)
  182. {
  183. scheduleStop.ES_EducationSchedulingStopTeacher = new HashSet<ES_EducationSchedulingStopTeacher>();
  184. if (educationSchedule.ES_EducationSchedulingTeacher.Any(x => x.UserID == educationSchedulingStopView.UserID
  185. && x.TeachingMethod == (int)EM_TeachingMethod.Lecturer))
  186. {
  187. foreach (var teacher in educationSchedule.ES_EducationSchedulingTeacher)
  188. {
  189. var fromTeacher = new ES_EducationSchedulingStopTeacher();
  190. fromTeacher.EducationSchedulingStopTeacherID = Guid.NewGuid();
  191. fromTeacher.EducationSchedulingStopID = scheduleStop.EducationSchedulingStopID;
  192. fromTeacher.UserID = teacher.UserID;
  193. fromTeacher.TeachingMethod = teacher.TeachingMethod;
  194. this.SetNewStatus(fromTeacher);
  195. scheduleStop.ES_EducationSchedulingStopTeacher.Add(fromTeacher);
  196. }
  197. }
  198. else
  199. {
  200. var teacher = educationSchedule.ES_EducationSchedulingTeacher.FirstOrDefault(x => x.UserID == educationSchedulingStopView.UserID);
  201. var fromTeacher = new ES_EducationSchedulingStopTeacher
  202. {
  203. EducationSchedulingStopTeacherID = Guid.NewGuid(),
  204. EducationSchedulingStopID = scheduleStop.EducationSchedulingStopID,
  205. UserID = teacher.UserID,
  206. TeachingMethod = teacher.TeachingMethod
  207. };
  208. this.SetNewStatus(fromTeacher);
  209. scheduleStop.ES_EducationSchedulingStopTeacher.Add(fromTeacher);
  210. }
  211. }
  212. this.UnitOfWork.Commit();
  213. }
  214. public void StopSave( List<Guid> id,Guid? userID)
  215. {
  216. List<ES_EducationSchedulingWeekNum> educationScheduleWeekNumList = new List<ES_EducationSchedulingWeekNum>();
  217. List<ES_EducationScheduling> educationScheduleList = new List<ES_EducationScheduling>();
  218. List<ES_EducationSchedulingStop> educationSchedulingStopList = new List<ES_EducationSchedulingStop>();
  219. List<ES_EducationSchedulingStopTeacher> educationSchedulingStopTeacherList = new List<ES_EducationSchedulingStopTeacher>();
  220. educationScheduleWeekNumList = this.EducationSchedulingDAL.EducationSchedulingWeekNumRepository.GetList(x => id.Contains(x.EducationSchedulingWeekNumID)).ToList();
  221. var educationScheduleIDs=educationScheduleWeekNumList.Select(x=>x.EducationSchedulingID).ToList();
  222. educationScheduleList = this.EducationSchedulingDAL.EducationSchedulingRepository.GetList(x => educationScheduleIDs.Contains(x.EducationSchedulingID),
  223. (x=>x.EM_EducationSchedulingClass),(x=>x.ES_EducationSchedulingTeacher)).ToList();
  224. educationSchedulingStopList = this.EducationSchedulingStopDAL.EducationSchedulingStopRepository.GetList(x => true).ToList();
  225. educationSchedulingStopTeacherList = this.EducationSchedulingStopDAL.EducationSchedulingStopTeacherRepository.GetList(x => true).ToList();
  226. foreach (var educationScheduleWeek in educationScheduleWeekNumList)
  227. {
  228. var educationSchedule = educationScheduleList.Where(x => x.EducationSchedulingID == educationScheduleWeek.EducationSchedulingID).FirstOrDefault();
  229. if (educationSchedule != null)
  230. {
  231. var ise = educationSchedulingStopList.Where(
  232. x => x.EducationMissionClassID == educationSchedule.EM_EducationSchedulingClass.EducationMissionClassID
  233. && x.Weekday == educationSchedule.Weekday
  234. && x.WeekNum == educationScheduleWeek.WeekNum
  235. && x.CoursesTimeID == educationSchedule.CoursesTimeID
  236. && x.ClassroomID == educationSchedule.ClassroomID
  237. ).ToList();
  238. if (ise.Count>0)
  239. {
  240. foreach(var isee in ise){
  241. var iset = educationSchedulingStopTeacherList.Where(x => x.UserID == userID && x.EducationSchedulingStopID == isee.EducationSchedulingStopID).FirstOrDefault();
  242. if (iset != null)
  243. {
  244. throw new Exception("存在重复数据请勿重复申请。");
  245. }
  246. }
  247. }
  248. var startStatusID = this.GetStartStatus();
  249. var backpointStatusList = this.GetBackpointStatus();
  250. var scheduleStop = new ES_EducationSchedulingStop();
  251. scheduleStop.EducationSchedulingStopID = Guid.NewGuid();
  252. this.SetNewStatus(scheduleStop);
  253. scheduleStop.RecordStatus = startStatusID;
  254. this.UnitOfWork.Add(scheduleStop);
  255. scheduleStop.EducationMissionClassID = educationSchedule.EM_EducationSchedulingClass.EducationMissionClassID;
  256. scheduleStop.Weekday = educationSchedule.Weekday;
  257. scheduleStop.WeekNum = educationScheduleWeek.WeekNum;
  258. scheduleStop.CoursesTimeID = educationSchedule.CoursesTimeID;
  259. scheduleStop.ClassroomID = educationSchedule.ClassroomID;
  260. scheduleStop.ES_EducationSchedulingStopTeacher = new HashSet<ES_EducationSchedulingStopTeacher>();
  261. if (educationSchedule.ES_EducationSchedulingTeacher.Any(x => x.UserID == userID
  262. && x.TeachingMethod == (int)EM_TeachingMethod.Lecturer))
  263. {
  264. foreach (var teacher in educationSchedule.ES_EducationSchedulingTeacher)
  265. {
  266. var fromTeacher = new ES_EducationSchedulingStopTeacher();
  267. fromTeacher.EducationSchedulingStopTeacherID = Guid.NewGuid();
  268. fromTeacher.EducationSchedulingStopID = scheduleStop.EducationSchedulingStopID;
  269. fromTeacher.UserID = teacher.UserID;
  270. fromTeacher.TeachingMethod = teacher.TeachingMethod;
  271. this.SetNewStatus(fromTeacher);
  272. scheduleStop.ES_EducationSchedulingStopTeacher.Add(fromTeacher);
  273. }
  274. }
  275. else
  276. {
  277. var teacher = educationSchedule.ES_EducationSchedulingTeacher.FirstOrDefault(x => x.UserID == userID);
  278. var fromTeacher = new ES_EducationSchedulingStopTeacher
  279. {
  280. EducationSchedulingStopTeacherID = Guid.NewGuid(),
  281. EducationSchedulingStopID = scheduleStop.EducationSchedulingStopID,
  282. UserID = teacher.UserID,
  283. TeachingMethod = teacher.TeachingMethod
  284. };
  285. this.SetNewStatus(fromTeacher);
  286. scheduleStop.ES_EducationSchedulingStopTeacher.Add(fromTeacher);
  287. }
  288. }
  289. }
  290. this.UnitOfWork.Commit();
  291. }
  292. public IGridResultSet<EducationSchedulingStopView> GetEducationSchedulingStopApproveList(ConfiguretView configuretView, Guid? schoolyearID, Guid? coursematerialID, Guid? collegeID, Guid? userID,
  293. int? weekNum, int? weekDay, Guid? coursesTimeID, Guid? classroomID, Guid? applyUserID, DateTime? starDate, DateTime? endDate, int? recordStatus, int? pageIndex, int? pageSize)
  294. {
  295. var statusList = this.GetStatusViewList();
  296. //var appprovalStatusList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  297. Expression<Func<ES_EducationSchedulingStop, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  298. Expression<Func<EM_EducationMission, bool>> missionExp = (x => true);
  299. Expression<Func<EM_EducationMissionClass, bool>> missionClassExp = (x => true);
  300. exp = exp.And(x => x.ES_EducationSchedulingStopTeacher.AsQueryable().Any(
  301. this.GetDataRageExpression<ES_EducationSchedulingStopTeacher>(w => w.UserID))
  302. //&& appprovalStatusList.Contains(x.RecordStatus)
  303. );
  304. if (schoolyearID.HasValue)
  305. {
  306. missionExp = missionExp.And(x => x.SchoolyearID == schoolyearID);
  307. }
  308. if (coursematerialID.HasValue)
  309. {
  310. missionClassExp = missionClassExp.And(x => x.CoursematerialID == coursematerialID);
  311. }
  312. if (collegeID.HasValue)
  313. {
  314. exp = exp.And(x => x.ES_EducationSchedulingStopTeacher.Any(w => w.CF_Staff.CollegeID == collegeID));
  315. }
  316. if (userID.HasValue)
  317. {
  318. exp = exp.And(x => x.ES_EducationSchedulingStopTeacher.Any(w => w.UserID == userID));
  319. }
  320. if (weekNum.HasValue)
  321. {
  322. exp = exp.And(x => x.WeekNum == weekNum);
  323. }
  324. if (weekDay.HasValue)
  325. {
  326. exp = exp.And(x => x.Weekday == weekDay);
  327. }
  328. if (coursesTimeID.HasValue)
  329. {
  330. exp = exp.And(x => x.CoursesTimeID == coursesTimeID);
  331. }
  332. if (classroomID.HasValue)
  333. {
  334. exp = exp.And(x => x.ClassroomID == classroomID);
  335. }
  336. if (applyUserID.HasValue)
  337. {
  338. exp = exp.And(x => x.CreateUserID == applyUserID);
  339. }
  340. if (starDate.HasValue)
  341. {
  342. exp = exp.And(x => x.ApplyTime >= starDate);
  343. }
  344. if (endDate.HasValue)
  345. {
  346. exp = exp.And(x => x.ApplyTime <= endDate.Value.AddDays(1));
  347. }
  348. if (starDate.HasValue && endDate.HasValue)
  349. {
  350. exp = exp.And(x => x.ApplyTime >= starDate && x.ApplyTime <= endDate.Value.AddDays(1));
  351. }
  352. if (recordStatus.HasValue)
  353. {
  354. exp = exp.And(x => x.RecordStatus == recordStatus);
  355. }
  356. var query = this.EducationSchedulingStopDAL.GetEducationSchedulingStopViewQueryable(exp, missionExp, missionClassExp);
  357. var teacherQuery = this.EducationSchedulingStopDAL.GetEducationSchedulingStopTeacherViewQueryable(
  358. exp, missionExp, missionClassExp);
  359. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  360. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  361. var resultQuery = query.OrderByDescending(x => x.ApplyTime)
  362. .ThenBy(x => x.applyUserName);
  363. var result = resultQuery.ToGridResultSet<EducationSchedulingStopView>(pageIndex, pageSize);
  364. if (pageIndex.HasValue && pageSize.HasValue)
  365. {
  366. var stopIDList = result.rows.Select(x => (Guid?)x.EducationSchedulingStopID).ToList();
  367. var teacherList = teacherQuery.Where(x => stopIDList.Contains(x.EducationSchedulingStopID))
  368. .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name)
  369. .ToList();
  370. result.rows.ForEach(x =>
  371. {
  372. x.TeacherList = teacherList
  373. .Where(w => w.EducationSchedulingStopID == x.EducationSchedulingStopID).ToList();
  374. x.RecordStatusName = statusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name;
  375. });
  376. }
  377. else
  378. {
  379. var teacherList = teacherQuery
  380. .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name).ToList();
  381. result.rows.ForEach(x =>
  382. {
  383. x.TeacherList = teacherList
  384. .Where(w => w.EducationSchedulingStopID == x.EducationSchedulingStopID).ToList();
  385. x.RecordStatusName = statusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name;
  386. });
  387. }
  388. return result;
  389. }
  390. public List<EducationSchedulingStopView> GetEducationSchedulingStopApproveList(ConfiguretView configuretView, Guid? schoolyearID, Guid? coursematerialID, Guid? collegeID, Guid? userID,
  391. int? weekNum, int? weekDay, Guid? coursesTimeID, Guid? classroomID, Guid? applyUserID, DateTime? starDate, DateTime? endDate,int? recordStatus)
  392. {
  393. return this.GetEducationSchedulingStopApproveList(configuretView, schoolyearID, coursematerialID, collegeID, userID, weekNum, weekDay, coursesTimeID, classroomID, applyUserID, starDate, endDate, recordStatus,null,null).rows;
  394. }
  395. public void Delete(IList<Guid> educationSchedulingStopIDList)
  396. {
  397. var startStatus = this.GetStartStatus();
  398. var submitedAdjustmentList = this.EducationSchedulingStopDAL.EducationSchedulingStopRepository
  399. .GetList(x => educationSchedulingStopIDList.Contains(x.EducationSchedulingStopID) && x.RecordStatus != startStatus).ToList();
  400. if (submitedAdjustmentList.Count > 0)
  401. {
  402. throw new Exception("所选记录当中存在已经提交的记录,无法删除。");
  403. }
  404. var nullableStopIDList = educationSchedulingStopIDList.Select(x => (Guid?)x).ToList();
  405. this.UnitOfWork.Delete<ES_EducationSchedulingStopTeacher>(x => nullableStopIDList.Contains(x.EducationSchedulingStopID));
  406. this.UnitOfWork.Delete<ES_EducationSchedulingStop>(x => nullableStopIDList.Contains(x.EducationSchedulingStopID));
  407. }
  408. public void Submit(IList<Guid> educationSchedulingStopIDList, Guid userID)
  409. {
  410. var startStatus = this.GetStartStatus();
  411. var backpointStatusList = this.GetBackpointStatus();
  412. var adjustmentList = this.EducationSchedulingStopDAL.EducationSchedulingStopRepository
  413. .GetList(x => educationSchedulingStopIDList.Contains(x.EducationSchedulingStopID));
  414. if (adjustmentList.Any(x => x.RecordStatus != startStatus && !backpointStatusList.Contains(x.RecordStatus)))
  415. {
  416. throw new Exception("只能提交已提交和已退回的记录。");
  417. }
  418. var notSubmitList = adjustmentList.Where(x => x.RecordStatus == startStatus).Select(x => x.EducationSchedulingStopID).ToList();
  419. var submitedList = adjustmentList.Where(x => x.RecordStatus != startStatus).Select(x => x.EducationSchedulingStopID).ToList();
  420. if (notSubmitList.Count > 0)
  421. {
  422. this.StartUp(notSubmitList, userID);
  423. }
  424. if (submitedList.Count > 0)
  425. {
  426. var action = this.GetActionView(submitedList.First(), userID).FirstOrDefault();
  427. if (action != null)
  428. {
  429. this.Approve(submitedList, userID, action.ActionID);
  430. }
  431. }
  432. var nowTime = DateTime.Now;
  433. UnitOfWork.Update<ES_EducationSchedulingStop>((x => new ES_EducationSchedulingStop { ApplyUserID = userID, ApplyTime = nowTime }), (x => educationSchedulingStopIDList.Contains(x.EducationSchedulingStopID)));
  434. }
  435. public List<EducationSchedulingStopView> GetEducationSchedulingStopViewList(IList<Guid> schedulingStopIDList)
  436. {
  437. if (schedulingStopIDList.Count == 0)
  438. {
  439. throw new Exception("请选择需要查询的停课记录。");
  440. }
  441. var statusList = this.GetStatusViewList();
  442. Expression<Func<ES_EducationSchedulingStop, bool>> exp = (x => schedulingStopIDList.Contains(x.EducationSchedulingStopID));
  443. exp = exp.And(x => x.ES_EducationSchedulingStopTeacher.AsQueryable().Any(
  444. this.GetDataRageExpression<ES_EducationSchedulingStopTeacher>(w => w.UserID)));
  445. var query = this.EducationSchedulingStopDAL.GetEducationSchedulingStopViewQueryable(exp, (x => true), (x => true));
  446. var teacherQuery = this.EducationSchedulingStopDAL.GetEducationSchedulingStopTeacherViewQueryable(
  447. exp, (x => true), (x => true));
  448. var resultQuery = query.OrderByDescending(x => x.SchoolyearCode)
  449. .ThenBy(x => x.CourseName);
  450. var result = resultQuery.ToList();
  451. var teacherList = teacherQuery
  452. .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name).ToList();
  453. result.ForEach(x =>
  454. {
  455. x.TeacherList = teacherList
  456. .Where(w => w.EducationSchedulingStopID == x.EducationSchedulingStopID).ToList();
  457. x.RecordStatusName = statusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name;
  458. });
  459. return result;
  460. }
  461. public List<EducationSchedulingStopView> GetEducationSchedulingStopApproveList(IList<Guid> schedulingStopIDList)
  462. {
  463. if (schedulingStopIDList.Count == 0)
  464. {
  465. throw new Exception("请选择需要查询的停课记录。");
  466. }
  467. var statusList = this.GetStatusViewList();
  468. Expression<Func<ES_EducationSchedulingStop, bool>> exp = (x => schedulingStopIDList.Contains(x.EducationSchedulingStopID));
  469. exp = exp.And(x => x.ES_EducationSchedulingStopTeacher.AsQueryable().Any(
  470. this.GetDataRageExpression<ES_EducationSchedulingStopTeacher>(w => w.UserID))
  471. //&& appprovalStatusList.Contains(x.RecordStatus)
  472. );
  473. var query = this.EducationSchedulingStopDAL.GetEducationSchedulingStopViewQueryable(exp, (x => true), (x => true));
  474. var teacherQuery = this.EducationSchedulingStopDAL.GetEducationSchedulingStopTeacherViewQueryable(
  475. exp, (x => true), (x => true));
  476. var resultQuery = query.OrderByDescending(x => x.SchoolyearCode)
  477. .ThenBy(x => x.CourseName);
  478. var result = resultQuery.ToList();
  479. var teacherList = teacherQuery
  480. .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name).ToList();
  481. result.ForEach(x =>
  482. {
  483. x.TeacherList = teacherList
  484. .Where(w => w.EducationSchedulingStopID == x.EducationSchedulingStopID).ToList();
  485. x.RecordStatusName = statusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name;
  486. });
  487. return result;
  488. }
  489. }
  490. }