AdultEducationMissionClassServices.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.EducationManage;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.ViewModel.EducationManagement;
  8. using EMIS.ViewModel;
  9. using EMIS.Entities;
  10. using EMIS.ViewModel.EducationManage;
  11. using EMIS.ViewModel.CacheManage;
  12. using System.Linq.Expressions;
  13. using Bowin.Common.Linq;
  14. using EMIS.DataLogic.Common.CalendarManage;
  15. using EMIS.ViewModel.UniversityManage.ClassroomManage;
  16. using EMIS.DataLogic.EducationSchedule;
  17. using EMIS.CommonLogic.Students;
  18. using EMIS.DataLogic.Common.Students;
  19. using EMIS.DataLogic.UniversityManage.TeacherManage;
  20. using EMIS.ViewModel.UniversityManage.TeacherManage;
  21. using EMIS.DataLogic;
  22. namespace EMIS.CommonLogic.EducationManage
  23. {
  24. public partial class AdultEducationMissionClassServices : BaseServices, IAdultEducationMissionClassServices
  25. {
  26. public AdultEducationMissionClassDAL educationMissionClassDAL { get; set; }
  27. public ClassroomScheduleDAL ClassroomScheduleDAL { get; set; }
  28. public SchoolYearDAL schoolYearDAL { get; set; }
  29. public IStudentsServices studentServices { get; set; }
  30. public Lazy<StudentsDAL> StudentsDAL { get; set; }
  31. public Lazy<StaffDAL> staffDAL { get; set; }
  32. public CoursesTimeDAL coursesTimeDAL { get; set; }
  33. #region 查询任务班
  34. /// <summary>
  35. /// 查询教学任务班
  36. /// </summary>
  37. /// <param name="configuretView">查询条件</param>
  38. /// <param name="schoolyearID">学年学期ID</param>
  39. /// <param name="courseCode">课程代码</param>
  40. /// <param name="courseName">课程名称</param>
  41. /// <param name="name">排课班级</param>
  42. /// <param name="pageIndex">页数</param>
  43. /// <param name="pageSize">显示数</param>
  44. /// <returns></returns>
  45. public Bowin.Common.Linq.Entity.IGridResultSet<EducationMissionClassView> GetEducationMissionClassViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? schoolyearID, int? standardID, Guid? coursematerialID,
  46. int? approvalStatus, int? teachingModeID, Guid? classmajorID, int? gradeYearID, Guid? CoursesTimeID, int? learningformID, int? education, string LearnSystem, int pageIndex, int pageSize)
  47. {
  48. bool hasClassmajorFilter = false;
  49. Expression<Func<EM_EducationMissionClass, bool>> exp = (x => true);
  50. Expression<Func<CF_Classmajor, bool>> classmajorFilter = x => true;
  51. if (campusID.HasValue)
  52. {
  53. exp = exp.And(x => x.EM_EducationMission.CF_College.CampusID == campusID);
  54. }
  55. if (collegeID.HasValue)
  56. {
  57. exp = exp.And(x => x.EM_EducationMission.CollegeID == collegeID);
  58. }
  59. if (CoursesTimeID.HasValue)
  60. {
  61. exp = exp.And(x => x.EM_CoursesTime.Any(c => c.CoursesTimeID == CoursesTimeID));
  62. }
  63. if (standardID.HasValue)
  64. {
  65. hasClassmajorFilter = true;
  66. classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  67. }
  68. if (learningformID.HasValue)
  69. {
  70. hasClassmajorFilter = true;
  71. classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID);
  72. }
  73. if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
  74. {
  75. hasClassmajorFilter = true;
  76. var LearnSystems = Convert.ToDecimal(LearnSystem);
  77. classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
  78. }
  79. if (education.HasValue)
  80. {
  81. hasClassmajorFilter = true;
  82. classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.EducationID == education.Value);
  83. }
  84. if (gradeYearID.HasValue)
  85. {
  86. hasClassmajorFilter = true;
  87. classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.GradeID == gradeYearID);
  88. }
  89. if (classmajorID.HasValue)
  90. {
  91. hasClassmajorFilter = true;
  92. classmajorFilter = classmajorFilter.And(x => x.ClassmajorID == classmajorID);
  93. }
  94. //if (hasClassmajorFilter)
  95. //{
  96. // exp = exp.And(w => w.CF_Classmajor.AsQueryable().Any(classmajorFilter));
  97. //}
  98. if (schoolyearID.HasValue)
  99. {
  100. exp = exp.And(x => x.EM_EducationMission.SchoolyearID == schoolyearID);
  101. }
  102. if (coursematerialID.HasValue)
  103. {
  104. exp = exp.And(x => x.CoursematerialID == coursematerialID);
  105. }
  106. if (approvalStatus.HasValue)
  107. {
  108. exp = exp.And(x => x.RecordStatus == approvalStatus);
  109. }
  110. if (teachingModeID.HasValue)
  111. {
  112. exp = exp.And(x => x.TeachingModeID == teachingModeID);
  113. }
  114. var query = educationMissionClassDAL.GetEducationMissionClassViewQueryble(exp, classmajorFilter).Distinct();
  115. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  116. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  117. var resultQuery = this.GetQueryByDataRangeByCollege(query, (x => x.ClassmajorCollegeID)).OrderByDescending(x => x.SchoolyearCode)
  118. .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeYearID)
  119. .ThenBy(x => x.StandardID).ThenBy(x => x.CourseName).ThenBy(x => x.OrderNo).ThenBy(x => x.Name);
  120. var result = resultQuery.ToGridResultSet<EducationMissionClassView>(pageIndex, pageSize);
  121. var educationMissionClassID = result.rows.Select(x => x.EducationMissionClassID).ToList();
  122. var missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).Distinct().ToList();
  123. result.rows.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID)));
  124. return result;
  125. }
  126. public List<EducationMissionImportClassView> GetEducationMissionClassViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? schoolyearID, int? standardID, Guid? coursematerialID, int? approvalStatus, int? teachingModeID, Guid? classmajorID, int? gradeYearID, int? learningformID, int? education, string LearnSystem)
  127. {
  128. bool hasClassmajorFilter = false;
  129. Expression<Func<EM_EducationMissionClass, bool>> exp = (x => true);
  130. Expression<Func<CF_Classmajor, bool>> classmajorFilter = x => true;
  131. if (campusID.HasValue)
  132. {
  133. exp = exp.And(x => x.EM_EducationMission.CF_College.CampusID == campusID);
  134. }
  135. if (collegeID.HasValue)
  136. {
  137. exp = exp.And(x => x.EM_EducationMission.CF_Department.CollegeID == collegeID);
  138. }
  139. if (standardID.HasValue)
  140. {
  141. hasClassmajorFilter = true;
  142. classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  143. }
  144. if (learningformID.HasValue)
  145. {
  146. hasClassmajorFilter = true;
  147. classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID);
  148. }
  149. if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
  150. {
  151. hasClassmajorFilter = true;
  152. var LearnSystems = Convert.ToDecimal(LearnSystem);
  153. classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
  154. }
  155. if (education.HasValue)
  156. {
  157. hasClassmajorFilter = true;
  158. classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.EducationID == education.Value);
  159. }
  160. if (gradeYearID.HasValue)
  161. {
  162. hasClassmajorFilter = true;
  163. classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.GradeID == gradeYearID);
  164. }
  165. if (classmajorID.HasValue)
  166. {
  167. hasClassmajorFilter = true;
  168. classmajorFilter = classmajorFilter.And(x => x.ClassmajorID == classmajorID);
  169. }
  170. //if (hasClassmajorFilter)
  171. //{
  172. // exp = exp.And(w => w.CF_Classmajor.AsQueryable().Any(classmajorFilter));
  173. //}
  174. if (schoolyearID.HasValue)
  175. {
  176. exp = exp.And(x => x.EM_EducationMission.SchoolyearID == schoolyearID);
  177. }
  178. if (coursematerialID.HasValue)
  179. {
  180. exp = exp.And(x => x.CoursematerialID == coursematerialID);
  181. }
  182. if (approvalStatus.HasValue)
  183. {
  184. exp = exp.And(x => x.RecordStatus == approvalStatus);
  185. }
  186. if (teachingModeID.HasValue)
  187. {
  188. exp = exp.And(x => x.TeachingModeID == teachingModeID);
  189. }
  190. var query = educationMissionClassDAL.GetEducationMissionClassViewQueryble(exp, classmajorFilter);
  191. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  192. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  193. var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolyearCode)
  194. .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeYearID)
  195. .ThenBy(x => x.StandardID).ThenBy(x => x.CourseName).ThenBy(x => x.OrderNo).ThenBy(x => x.Name)
  196. .ToList();
  197. var educationMissionClassID = result.Select(x => x.EducationMissionClassID).ToList();
  198. var missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).ToList();
  199. result.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID)));
  200. return result;
  201. }
  202. #endregion
  203. /// <summary>
  204. /// 获取任务班信息
  205. /// </summary>
  206. /// <param name="educationMissionClassID"></param>
  207. /// <returns></returns>
  208. public EducationMissionImportClassView GetEducationMissionClassView(Guid? educationMissionClassID)
  209. {
  210. return educationMissionClassDAL.GetEducationMissionClassViewQueryble(x => x.EducationMissionClassID == educationMissionClassID,w=>true).FirstOrDefault();
  211. }
  212. /// <summary>
  213. /// 获取任务班信息
  214. /// </summary>
  215. /// <param name="educationMissionClassID"></param>
  216. /// <returns></returns>
  217. public Entities.EM_EducationMissionClass GetEducationMissionClass(Guid? educationMissionClassID)
  218. {
  219. return educationMissionClassDAL.educationMissionClassRepository.GetSingle(x => x.EducationMissionClassID == educationMissionClassID,
  220. (x => x.EM_EducationMission),
  221. (x => x.CF_Classmajor),
  222. (x => x.EM_CoursesTime),
  223. (x => x.EM_MissionClassTeacher),
  224. (x => x.EM_EducationMissionClassSettings),
  225. (x => x.EM_CourseProcess),
  226. (x => x.EM_CourseProcess.Select(y => y.EM_CourseProcessTeacher)),
  227. (x => x.EM_EducationSchedulingClass),
  228. (x => x.EM_EducationMissionClassTeachingSetting), (x => x.CF_Classroom));
  229. }
  230. public void BatchModifyCoursesTime(List<Guid?> educationMissionClassIDs, Guid? CourseTimeID, int? ClassroomTypeID)
  231. {
  232. try
  233. {
  234. foreach (var id in educationMissionClassIDs)
  235. {
  236. EM_EducationMissionClass educationMissionClass = GetEducationMissionClass(id);
  237. educationMissionClass.ClassroomTypeID = ClassroomTypeID;
  238. List<EM_CoursesTime> coursesTime = coursesTimeDAL.coursesTimeRepository.Entities.Where(x => x.CoursesTimeID == CourseTimeID).ToList();
  239. educationMissionClass.EM_CoursesTime = new HashSet<EM_CoursesTime>();
  240. //educationMissionClass.EM_CoursesTime = new HashSet<EM_CoursesTime>();
  241. foreach (var time in coursesTime)
  242. {
  243. EM_CoursesTime c = time;
  244. educationMissionClass.EM_CoursesTime.Add(c);
  245. }
  246. SetModifyStatus(educationMissionClass);
  247. }
  248. UnitOfWork.Commit();
  249. }
  250. catch
  251. {
  252. }
  253. }
  254. /// <summary>
  255. /// 更新教学任务班表 处理状态
  256. /// </summary>
  257. /// <param name="educationMissionClassIDs"></param>
  258. public void EducationMissionClassUpdate(List<Guid?> educationMissionClassIDs)
  259. {
  260. try
  261. {
  262. string massge = string.Empty;
  263. var educationMissionClassList = educationMissionClassDAL.educationMissionClassRepository
  264. .GetList(x => educationMissionClassIDs.Contains(x.EducationMissionClassID),
  265. (x => x.CF_Classmajor),
  266. (x => x.EM_EducationMission),
  267. (x => x.EM_EducationMissionClassTeachingSetting),
  268. (x => x.EM_EducationMissionClassSettings),
  269. (x => x.EM_EducationSchedulingClass),
  270. (x => x.EM_EducationSchedulingClass.Select(w => w.CF_Student)),
  271. (x => x.EM_MissionClassTeacher),
  272. (x => x.EM_CourseProcess),
  273. (x => x.EM_CoursesTime),
  274. (x => x.EM_CourseProcess.Select(y => y.EM_CourseProcessTeacher))).ToList();
  275. var educationMissionIDList = educationMissionClassList.Select(x => x.EducationMissionID).Distinct();
  276. foreach (var educationMissionClass in educationMissionClassList)
  277. {
  278. if (educationMissionClass.RecordStatus != (int)EMIS.ViewModel.EM_EducationMissionClassStatus.NotSubmitted)
  279. massge += educationMissionClass.Name + "任务班,已提交,不能重复提交。";
  280. if (educationMissionClass.EM_CoursesTime.Count == 0)
  281. massge += educationMissionClass.Name + "任务班,未设置课时类别。";
  282. //if (educationMissionClass.EM_EducationMissionClassSettings.Count == 0)
  283. // massge += educationMissionClass.Name + "任务班,未设置授课周次。";
  284. if (educationMissionClass.ClassroomTypeID == null)
  285. massge += educationMissionClass.Name + "任务班,未设置教室类型。";
  286. var courseProcessList = educationMissionClassDAL.GetRelatedCourseProcess(x => x.EducationMissionClassID == educationMissionClass.EducationMissionClassID)
  287. .ToList();
  288. var hours = courseProcessList.Select(x => x.Times).Sum();
  289. //总学时
  290. int? totalHours = (educationMissionClass.EM_EducationMissionClassTeachingSetting.TheoryCourse ?? 0)
  291. + (educationMissionClass.EM_EducationMissionClassTeachingSetting.Practicehours ?? 0);
  292. //TODO:兵良说:排课学时要小于等于总学时 2016年10月17日18:48:49
  293. if (hours > totalHours)
  294. {
  295. massge += educationMissionClass.Name + "任务班,课程进度设置错误,请检查并重新设置后提交。";
  296. }
  297. if (!string.IsNullOrEmpty(massge))
  298. massge += ",";
  299. }
  300. //20161110 MM姐提的要求, 先提交数据检测是否问题,有问题把所有问题反馈回页面让客户进行修改,再重新提交
  301. if (!string.IsNullOrEmpty(massge))
  302. throw new Exception(massge.TrimEnd(','));
  303. foreach (var educationMissionClass in educationMissionClassList)
  304. {
  305. educationMissionClass.RecordStatus = (int)EMIS.ViewModel.EM_EducationMissionClassStatus.Submitted;
  306. }
  307. UnitOfWork.Commit();
  308. }
  309. catch (Exception)
  310. {
  311. throw;
  312. }
  313. }
  314. }
  315. }