/// <summary> /// 删除校验 /// <para>作 者:zhiwei.Tang</para> /// <para>创建时间:2018-09-15</para> /// </summary> /// <param name="courseId">课程编号</param> /// <exception cref="BussinessException"> /// 异常ID:3,异常描述:已授权给校区 /// 异常ID:3,异常描述:教室已使用该课程 /// 异常ID:3,异常描述:班级已使用该课程 /// </exception> private void RemoveVerify(long courseId) { //1.已授权给校区 bool schoolIsUse = SchoolCourseService.CourseIsUse(courseId); if (schoolIsUse) { throw new BussinessException(ModelType.Timetable, 3); } //2.教室已使用该课程 bool classRoomIsUse = ClassRoomCourseService.CourseIsUse(courseId); if (classRoomIsUse) { throw new BussinessException(ModelType.Timetable, 3); } //3.班级已使用该课程 bool classIsUse = new TblDatClassRepository().CourseIsUse(courseId).Result; if (classIsUse) { throw new BussinessException(ModelType.Timetable, 3); } }
/// <summary> /// 描述:获取排课列表的筛选条件数据 /// <para>作 者:瞿琦</para> /// <para>创建时间:2018.9.25</para> /// </summary> /// <param name="schoolId">校区Id</param> /// <param name="companyId">公司编号</param> /// <returns>校区年度下的学期数据</returns> /// <exception cref="AMS.Core.BussinessException"> ///异常ID:6, 异常描述:找不到授权校区 /// </exception> public ClassCourseSearchSchoolResponse GetSearchData(string schoolId, string companyId) { var searchResult = new ClassCourseSearchSchoolResponse(); //1、检查授权校区缓存是否存在 //2、授权自已拥有的授权校区(找平台) //获取授权校区 var currentSchoolRight = this.GetAuthorSchool(); var schoolInfo = currentSchoolRight.FirstOrDefault(x => x.SchoolId.Trim() == schoolId.Trim()); if (schoolInfo == null)//获取的校区不能为空 { throw new BussinessException(ModelType.Timetable, 6); } searchResult.SchoolId = schoolInfo.SchoolId; searchResult.SchoolName = schoolInfo.SchoolName; //3、加载所有学期及年份,并对数据进行处理 //3.1 实例化年度校区集合 var yearAndTermList = new List <ClassCourseearchYearResponse>(); TblDatTermRepository tblDatTermRepository = new TblDatTermRepository(); //3.2 获取有学期的年度 var yearList = tblDatTermRepository.GetShoolNoByTblDatTerm(schoolId).Select(x => x.Year).Distinct().OrderBy(x => x).ToList(); //3.3 根据校区+所有的年度获取所有年度的学期 var termList = tblDatTermRepository.GetTblDatTremList(schoolId, yearList); var schoolCourse = new SchoolCourseService(schoolId, companyId).GetCourseByType(null).Select(x => new ClassCourseResponse { CourseId = x.CourseId, ClassCnName = x.ClassCnName }).ToList(); foreach (var year in yearList) { // 3.4循环获取年度所属校区 var yearByTermList = termList.Where(x => x.SchoolId.Trim() == schoolId.Trim() && x.Year == year).Select(x => new ClassCourseSearchTermResponse { TermId = x.TermId, TermName = x.TermName, }).ToList(); foreach (var termItem in yearByTermList) { //学期下正式的所有班级 var termClassList = GetTermClassCourseInfo(termItem.TermId); //审核中的班级 var auditClassCourse = GetAuditClassCourse(termItem.TermId); schoolCourse.AddRange(termClassList); schoolCourse.AddRange(auditClassCourse); termItem.TermCourse = schoolCourse.Distinct(new CourseInfoComparer()).ToList(); } var model = new ClassCourseearchYearResponse() { Year = year, Terms = yearByTermList }; yearAndTermList.Add(model); } searchResult.Years = yearAndTermList; //5、将处理好的数据缓存到Redis //this.SetCache(result); return(searchResult); }