/// <summary>
        /// 获取课程
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2018-11-06</para>
        /// </summary>
        /// <param name="schoolId">校区编号</param>
        /// <param name="classRoomId">教室Id</param>
        /// <param name="disableCourse">忽略课程已禁用的课程Id</param>
        /// <returns>课程列表</returns>
        internal static List <ClassTimetableCourseResponse> GetClassTimetableCourseResponse(string schoolId, long classRoomId, long?courseDisableId = null)
        {
            SchoolClassRoomService schoolClassRoomService = new SchoolClassRoomService(schoolId);
            //课程与课程等级
            var roomCourses = schoolClassRoomService.GetRoomCourses(classRoomId);

            List <long> disableCourseIds = schoolClassRoomService
                                           .RoomCourseList
                                           .Where(x => x.IsDisabled && x.ClassRoomId == classRoomId)
                                           .Select(x => x.CourseId)
                                           .ToList();

            if (courseDisableId.HasValue)
            {
                disableCourseIds = disableCourseIds.Where(x => x != courseDisableId.Value).ToList();
            }

            var res = roomCourses.Where(x => !disableCourseIds.Contains(x.CourseId)).Select(x => new ClassTimetableCourseResponse
            {
                CourseCnName = x.ClassCnName,
                CourseCode   = x.CourseCode,
                CourseId     = x.CourseId,
                ShortName    = x.ShortName,
                Levels       = x.CourseLevel.Select(m => new ClassTimetableCourseLevelResponse
                {
                    CourseLevelId = m.CourseLevelId,
                    LevelCnName   = m.LevelCnName,
                    LevelCode     = m.LevelCode
                }).ToList()
            }).ToList();

            return(res);
        }
Пример #2
0
        /// <summary>
        /// 获取教室查看课表
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2018-11-06</para>
        /// </summary>
        /// <returns>老师个人课表数据</returns>
        public async Task <List <TeacherCourseTimetableResponse> > GetCourseTimetable(string companyId)
        {
            List <TeacherCourseTimetableResponse> res = new List <TeacherCourseTimetableResponse>();

            //1.获取老师上课班级
            List <TblDatClass> classes = _classRepository.Value.GetClassByTermIdAsync(_termId)
                                         .Result
                                         .Where(x => x.TeacherId == _teacherId)
                                         .ToList();

            //2.获取班级上课时间
            List <TblTimClassTime> classTimes = await _classTimeRepository.Value.GetByClassId(classes.Select(x => x.ClassId));

            //3.获取基础数据
            //3.1 课程
            List <TblDatCourse> courses = CourseService.GetAllAsync().Result;

            //3.2 课程等级
            List <CourseLevelResponse> courseLevels = new CourseLevelService(companyId).GetList().Result;

            //3.3 获取教室
            TermCourseTimetableService termCourseService = new TermCourseTimetableService(_termId);
            List <TblDatClassRoom>     classRooms        = new SchoolClassRoomService(termCourseService.TblDatTerm.SchoolId).ClassRoomList;

            //3.4.获取上课时间段基础数据
            List <TblDatSchoolTime> schoolTimes = new SchoolTimeService(_termId).TblDatSchoolTime;

            int maxLength = 0;

            //4.整合数据
            for (int i = 1; i <= 7; i++)
            {
                TeacherCourseTimetableResponse classRoom = new TeacherCourseTimetableResponse
                {
                    Week       = WeekDayConvert.IntToString(i),
                    ClassTimes = new List <TeacherClassTime>()
                };

                var cts = (from a in classTimes                                                 //教室下的班级上课时间段
                           join b in classes on a.ClassId equals b.ClassId                      //教室下的班级
                           join c in schoolTimes on a.SchoolTimeId equals c.SchoolTimeId        //基础数据 学期下所有上课时间段
                           join d in courseLevels on b.CourseLeveId equals d.CourseLevelId      //基础数据 课程等级
                           join e in courses on b.CourseId equals e.CourseId                    //基础数据 课程
                           join f in classRooms on b.ClassRoomId equals f.ClassRoomId           //基础数据 教室
                           where c.WeekDay == i
                           select new TeacherClassTime
                {
                    BeginTime = c.BeginTime,
                    EndTime = c.EndTime,
                    CourseName = e.ShortName,
                    LevelCnName = d.LevelCnName,
                    RoomNo = f.RoomNo
                }).OrderBy(x => x.BeginTime);

                classRoom.ClassTimes.AddRange(cts);

                if (cts.Count() > maxLength)
                {
                    maxLength = cts.Count();
                }

                res.Add(classRoom);
            }

            //补齐
            foreach (var item in res)
            {
                if (item.ClassTimes.Count >= maxLength)
                {
                    continue;
                }

                while (item.ClassTimes.Count < maxLength)
                {
                    item.ClassTimes.Add(new TeacherClassTime());
                }
            }

            return(res);
        }
Пример #3
0
        /// <summary>
        /// 获取不同时间段的课表信息
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2018-09-21</para>
        /// </summary>
        /// <param name="duration">60分钟或90分钟</param>
        /// <returns>课表信息</returns>
        private TermCourseTimetableResponse GetTermCourseTimetable(TimeType duration)
        {
            TermCourseTimetableResponse res = new TermCourseTimetableResponse();

            var schTimeRes = this.GetTimetableSchoolTimeResponse(duration);

            res.SchoolTimes = schTimeRes.TimetableSchoolTimeResponses;        //上课时间表
            res.ClassRooms  = new List <TimetableClassRoomResponse>();        //教室信息

            //审核中所有班级
            var classes = _tblAutClassRepository.Value.GetByAuditId(base.TblAutAudit.AuditId).Result;

            //校区
            var schoolId = TermService.GetTermByTermId(_termId)?.SchoolId;

            //班级上课时间表
            var classTimes = new TblAutClassTimeRepository()
                             .GetBySchoolTimeId(schTimeRes.TblDatSchoolTimes.Select(x => x.SchoolTimeId), base.TblAutAudit.AuditId)
                             .Result;

            //获取老师用户信息
            var teachers = TeachService.GetTeachers();

            //所有的课程
            var courses = CourseService.GetAllAsync().Result;

            //课程等级
            var courseLv = CourseLevelService.GetCourseLevelList().Result;

            //获取校区教室
            var durationClassId = classTimes.Select(x => x.ClassId).ToList();
            SchoolClassRoomService    schoolClassRoomService = new SchoolClassRoomService(schoolId);
            List <RoomCourseResponse> roomCourseResponses    = schoolClassRoomService.RoomCourseList;

            List <long> classRoomIds = classes.Where(x => durationClassId.Contains(x.ClassId)).Select(x => x.ClassRoomId).ToList();

            classRoomIds.AddRange(roomCourseResponses.Where(x => !x.IsDisabled).Select(x => x.ClassRoomId));

            List <TblDatClassRoom> classRooms = schoolClassRoomService
                                                .ClassRoomList
                                                .Where(x => classRoomIds.Contains(x.ClassRoomId))
                                                .OrderBy(o => o.RoomNo, new NaturalStringComparer())
                                                .ToList();

            //渲染教室
            foreach (var classRoom in classRooms)
            {
                TimetableClassRoomResponse ttcrr = new TimetableClassRoomResponse
                {
                    ClassRoomId = classRoom.ClassRoomId,
                    RoomNo      = classRoom.RoomNo,
                    Classes     = new List <TimetableClassResponse>()
                };

                int lessonIndex = 0;

                int weekDay = -1;

                //教室对应的上课时间段的班级
                foreach (var schoolTime in schTimeRes.TblDatSchoolTimes)
                {
                    if (weekDay != schoolTime.WeekDay)
                    {
                        weekDay     = schoolTime.WeekDay;
                        lessonIndex = 0;
                    }

                    lessonIndex++;

                    TimetableClassResponse ttcr = new TimetableClassResponse
                    {
                        SchoolTimeId    = schoolTime.SchoolTimeId,
                        ClassId         = 0,
                        CourseId        = 0,
                        CourseName      = string.Empty,
                        CourseLeveId    = 0,
                        CourseLevelName = string.Empty,
                        TeacherId       = string.Empty,
                        TeacherName     = string.Empty,
                        WeekDay         = schoolTime.WeekDay,
                        LessonIndex     = lessonIndex
                    };

                    var classIds = (from a in classTimes
                                    join b in classes on a.ClassId equals b.ClassId
                                    where a.SchoolTimeId == schoolTime.SchoolTimeId && b.ClassRoomId == classRoom.ClassRoomId
                                    select a.ClassId).ToList();

                    if (classIds.Any())
                    {
                        var classInfo = classes.FirstOrDefault(x => x.ClassId == classIds.First());
                        ttcr.ClassId         = classInfo.ClassId;
                        ttcr.CourseId        = classInfo.CourseId;
                        ttcr.CourseName      = courses.FirstOrDefault(x => x.CourseId == classInfo.CourseId)?.ShortName;
                        ttcr.CourseLeveId    = classInfo.CourseLeveId;
                        ttcr.CourseLevelName = courseLv.FirstOrDefault(x => x.CourseLevelId == classInfo.CourseLeveId)?.LevelCnName;
                        ttcr.TeacherId       = classInfo.TeacherId;
                        ttcr.TeacherName     = teachers.FirstOrDefault(x => x.TeacherId == classInfo.TeacherId)?.TeacherName;
                    }

                    ttcrr.Classes.Add(ttcr);
                }

                res.ClassRooms.Add(ttcrr);
            }

            return(res);
        }