/// <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); }
/// <summary> /// 获取教室查看课表 /// <para>作 者:zhiwei.Tang</para> /// <para>创建时间:2018-11-06</para> /// </summary> /// <param name="termId">学期Id</param> /// <param name="companyId">公司编号</param> /// <returns>教室查看课表数据列表</returns> public async Task <List <ClassRoomCourseTimetableResponse> > GetCourseTimetable(long termId, string companyId) { List <ClassRoomCourseTimetableResponse> res = new List <ClassRoomCourseTimetableResponse>(); //1.获取教室下有哪些班级 List <TblDatClass> classes = _classRepository.Value.GetClassByTermIdAsync(termId) .Result .Where(x => x.ClassRoomId == _classRoomId) .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 获取老师 List <ClassTimetableTeacherResponse> teachers = TeachService.GetTeachers(); //3.4.获取上课时间段基础数据 List <TblDatSchoolTime> schoolTimes = new SchoolTimeService(termId).TblDatSchoolTime; int maxLength = 0; //4.整合数据 for (int i = 1; i <= 7; i++) { ClassRoomCourseTimetableResponse classRoom = new ClassRoomCourseTimetableResponse { Week = WeekDayConvert.IntToString(i), ClassTimes = new List <ClassRoomClassTime>() }; 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 teachers on b.TeacherId equals f.TeacherId //基础数据 老师信息 where c.WeekDay == i select new ClassRoomClassTime { BeginTime = c.BeginTime, EndTime = c.EndTime, CourseName = e.ShortName, LevelCnName = d.LevelCnName, TeacherName = f.TeacherName }).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 ClassRoomClassTime()); } } return(res); }
/// <summary> /// 微信通知 /// <para>作 者:zhiwei.Tang</para> /// <para>创建时间:2019-03-15</para> /// </summary> private void PushWeChatNotice() { var stuInfo = StudentService.GetStudentInfo(_request.StudentId); var inLesson = this._inLessonList.FirstOrDefault(); string pushClassTime = this._outLessonList .Select(x => DateTime.Parse(x.ClassDate.ToString("yyyy-MM-dd") + " " + x.ClassBeginTime)) .Min().ToString("yyyy.MM.dd HH:mm"); //first={0}家长,您好!因{1}于{2}请假,为了保证孩子的学习效果,我们特别为孩子安排了补课,具体时间如下: string title = string.Format( ClientConfigManager.HssConfig.WeChatTemplateTitle.MakeupNotice, stuInfo.StudentName, stuInfo.StudentName, pushClassTime); //keyword1=上课时间 var classTimeList = this._inLessonList.Select(x => x.ClassBeginTime + "-" + x.ClassEndTime); string classTime = $"{inLesson.ClassDate.ToString("yyyy.MM.dd")} {string.Join("、", classTimeList)}"; //keyword2=班级名称 string className = CourseService.GetByCourseId(inLesson.CourseId)?.ClassCnName ?? string.Empty; //keyword3=教室 string classRoom = new ClassRoomService(inLesson.ClassRoomId)?.ClassRoomInfo?.RoomNo ?? string.Empty; //keyword4=老师名称 string teacherName = TeachService.GetTeacher(inLesson.TeacherId)?.TeacherName ?? string.Empty; //remark=校区名称 string schoolName = OrgService.GetSchoolBySchoolId(_schoolId)?.SchoolName ?? string.Empty; WxNotifyProducerService wxNotifyProducerService = WxNotifyProducerService.Instance; WxNotifyInDto wxNotify = new WxNotifyInDto { Data = new List <WxNotifyItemInDto> { new WxNotifyItemInDto { DataKey = "first", Value = title }, new WxNotifyItemInDto { DataKey = "keyword1", Value = classTime }, new WxNotifyItemInDto { DataKey = "keyword2", Value = className }, new WxNotifyItemInDto { DataKey = "keyword3", Value = classRoom }, new WxNotifyItemInDto { DataKey = "keyword4", Value = teacherName }, new WxNotifyItemInDto { DataKey = "remark", Value = schoolName } }, ToUser = StudentService.GetWxOpenId(stuInfo), TemplateId = WeChatTemplateConstants.MakeupNotice, Url = string.Empty }; wxNotifyProducerService.Publish(wxNotify); }