Example #1
0
        /// <summary>
        /// 获取学生补课周补课信息
        /// <para>作    者:HuangGaoLiang </para>
        /// <para>创建时间:2019-03-13</para>
        /// </summary>
        /// <param name="classId">班级编号</param>
        /// <param name="studentId">学生编号</param>
        /// <returns>返回学生补课周补课安排信息</returns>
        private List <ReplenishWeekClassTimeListResponse> GetTimAdjustLessonList(long classId, long studentId)
        {
            // 1、根据条件获取学生的补课周补课信息
            List <ViewTimAdjustLesson> timAdjustLessonList = new ViewTimAdjustLessonRepository().GetTimeLessonClassList(new List <long> {
                classId
            }).Where(m => m.StudentId == studentId).ToList();

            // 2、组合数据
            var list = (from t in timAdjustLessonList

                        join r in ClassRoomService.GetClassRoomListBySchoolId(this._schoolId) on t.ClassRoomId equals r.ClassRoomId into cr
                        from room in cr.DefaultIfEmpty()

                        select new ReplenishWeekClassTimeListResponse
            {
                AdjustLessonId = t.AdjustLessonId,
                Data = t.ClassDate,
                StartTime = t.ClassBeginTime,
                EndTime = t.ClassEndTime,
                ClassRoomId = room == null ? 0 : room.ClassRoomId,
                RoomNo = room == null ? "" : room.RoomNo
            }).ToList();

            return(list);
        }
        /// <summary>
        /// 正常考勤补签
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2019-03-12</para>
        /// </summary>
        /// <param name="lessonStudent">学生考勤</param>
        /// <exception cref="BussinessException">
        /// 异常ID:48 异常描述:未找到考勤信息
        /// 异常ID:49 异常描述:补签老师与上课老师不一致
        /// 异常ID:50 异常描述:当前状态不可补签
        /// </exception>
        private void UpdateStuAttend(ViewTimLessonStudent lessonStudent)
        {
            if (lessonStudent == null)
            {
                //未找到考勤信息
                throw new BussinessException(ModelType.Timetable, 48);
            }

            //校验是否绑定家校互联
            this.VerifyStudentBindWeiXin(lessonStudent.StudentId);

            if (!this._teacherId.Equals(lessonStudent.TeacherId, StringComparison.Ordinal))
            {
                //补签老师与上课老师不一致
                throw new BussinessException(ModelType.Timetable, 49);
            }
            if (lessonStudent.AttendStatus == (int)AttendStatus.Normal)
            {
                //当前状态不可补签
                throw new BussinessException(ModelType.Timetable, 50);
            }
            if (lessonStudent.AdjustType != (int)AdjustType.DEFAULT)
            {
                //当前状态不可补签
                throw new BussinessException(ModelType.Timetable, 50);
            }

            //如果是180分钟的课次会有两条课次信息 这里获取下面批量更新
            var lessonList = _viewLessonStudentRepository.Value
                             .GetLessonList(lessonStudent.SchoolId, lessonStudent.ClassId,
                                            lessonStudent.ClassDate, lessonStudent.StudentId);

            var stuLessonIdList = lessonList.Select(x => x.LessonStudentId);

            string replenishCode = Guid.NewGuid().ToString().Replace("-", "");

            //更新插班补课考勤课次
            _lessonStudentRepository.Value.UpdateStuAttend(stuLessonIdList,
                                                           AdjustType.SUPPLEMENTNOTCONFIRMED, AttendStatus.NotClockIn,
                                                           DateTime.Now, replenishCode);

            //微信通知

            //班级名称
            string className = CourseService.GetByCourseId(lessonStudent.CourseId)?.ClassCnName ?? string.Empty;

            //上课时间段
            var    classTimeList = lessonList.Select(x => x.ClassBeginTime + "-" + x.ClassEndTime);
            string classTime     = $"{lessonStudent.ClassDate.ToString("yyyy.MM.dd")} {string.Join("、", classTimeList)}";

            //教室
            var    roomService = new ClassRoomService(lessonStudent.ClassRoomId);
            string classRoom   = roomService.ClassRoomInfo?.RoomNo ?? string.Empty;

            //推送
            this.PushWeChatNotice(lessonStudent.StudentId, className, classRoom, classTime, replenishCode);
        }
Example #3
0
 /// <summary>
 /// 获取教室
 /// <para>作    者:zhiwei.Tang</para>
 /// <para>创建时间:2019-02-20</para>
 /// </summary>
 /// <returns>教室列表</returns>
 public List <ClassRoomMiniDataResponse> GetClassRoom()
 {
     return(ClassRoomService.GetClassRoomBySchoolId(_schoolId)
            .Select(x => new ClassRoomMiniDataResponse
     {
         ClassRoomId = x.ClassRoomId,
         RoomNo = x.RoomNo,
         IsDisable = x.IsDisabled
     }).Distinct(new AMS.Core.Compare <ClassRoomMiniDataResponse>((x, y) => (x != null && y != null && x.ClassRoomId == y.ClassRoomId)))
            .ToList());
 }
Example #4
0
        /// <summary>
        /// 待添加到审核中班级
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2019-02-19</para>
        /// </summary>
        /// <param name="input">待添加的班级信息</param>
        /// <param name="classRoomId">教室Id</param>
        /// <param name="schoolTimeId">上课时间段Id</param>
        /// <param name="createUserName">创建人</param>
        /// <returns>审核中的班级课表信息</returns>
        private static TblAutClass GetTblAutClass(ClassScheduleRequest input, long classRoomId, long schoolTimeId, string createUserName)
        {
            //教室信息
            var classRoom = new ClassRoomService(classRoomId).ClassRoomInfo;

            ValidateObject(classRoom);

            //上课时间信息
            var schoolTime = SchoolTimeService.GetBySchoolTimeId(schoolTimeId);

            ValidateObject(schoolTime);

            //根据学期编号获取学期信息
            TblDatTerm term = TermService.GetTermByTermId(schoolTime.TermId);

            ValidateObject(term);

            //获取课程
            TblDatRoomCourse roomCourse = new ClassRoomService(classRoomId).GetByCourseId(input.CourseId).Result;

            ValidateObject(roomCourse);

            //复制课表到审核中得到审核主表id
            long auditId = new TermCourseTimetableAuditService(schoolTime.TermId).VerifyGetAuditId(classRoom.SchoolId);

            TblAutClass autClass = new TblAutClass
            {
                AutClassId   = IdGenerator.NextId(),
                SchoolId     = classRoom.SchoolId,
                ClassId      = IdGenerator.NextId(),
                AuditId      = auditId,
                ClassNo      = input.ClassNo,
                TermId       = term.TermId,
                RoomCourseId = roomCourse.RoomCourseId,
                ClassRoomId  = classRoomId,
                CourseId     = roomCourse.CourseId,
                CourseLeveId = input.CourseLevelId,
                TeacherId    = input.TeacherId,
                CourseNum    = input.CourseNum,
                StudentsNum  = input.StudentsNum,
                CreateTime   = DateTime.Now,
                UpdateTime   = DateTime.Now,
                DataStatus   = 0
            };

            return(autClass);
        }
        /// <summary>
        /// 微信通知
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2019-03-15</para>
        /// </summary>
        private void PushWeChatNoticeStart(List <ViewStudentScanCodeAttend> stuAttends, DateTime attendTime)
        {
            List <long> cIds = stuAttends.Select(x => x.ClassId).Distinct().ToList();

            foreach (var item in cIds)
            {
                var    temp          = stuAttends.Where(x => x.ClassId == item).ToList();
                var    model         = temp.FirstOrDefault();
                var    classTimeList = temp.Select(x => x.ClassBeginTime + "-" + x.ClassEndTime);
                string classTime     = $"{model.ClassDate:yyyy.MM.dd} {string.Join("、", classTimeList)}"; //上课时间段
                var    classService  = new DefaultClassService(item);
                var    classInfo     = classService.TblDatClass;
                var    classRoom     = new ClassRoomService(classInfo.ClassRoomId).ClassRoomInfo.RoomNo; //教室门牌号

                var className = CourseService.GetByCourseId(classInfo.CourseId)?.ClassCnName;            //班级名称

                PushWeChatNotice(className, classTime, classRoom, attendTime);
            }
        }
Example #6
0
        /// <summary>
        /// 添加班级课程
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2018-09-10</para>
        /// </summary>
        /// <param name="schoolId">校区编号</param>
        /// <param name="request">教室分配及学位设置数据源</param>
        /// <returns></returns>
        public static async Task AddAsync(string schoolId, ClassRoomRequest request)
        {
            //1、添加教室
            long classRoomId = await ClassRoomService.AddClassRoomAsync(schoolId, request.RoomNo);

            //2、准备数据
            TblDatRoomCourse roomCourse = new TblDatRoomCourse
            {
                RoomCourseId     = IdGenerator.NextId(),
                ClassRoomId      = classRoomId,
                CourseId         = request.CourseId,
                CreateTime       = DateTime.Now,
                IsDisabled       = false,
                MaxStageStudents = request.MaxStageStudents,
                MaxWeekStage     = request.MaxWeekStage,
                UpdateTime       = DateTime.Now
            };

            //3.添加课程
            await AddClassCourseAsync(roomCourse);
        }
Example #7
0
        /// <summary>
        /// 获取的排课详情
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2018-11-06</para>
        /// </summary>
        /// <param name="enrollOrderItemId">报名课程订单Id</param>
        /// <returns>学生报名一个课程的排课详细信息</returns>
        public MakeLessonDetailResponse GetMakeLessonDetail(long enrollOrderItemId)
        {
            MakeLessonDetailResponse res = new MakeLessonDetailResponse
            {
                CourseInfos = new List <CourseInformation>()
            };

            TblOdrEnrollOrderItem enrollOrderItem = _enrollOrderItemRepository.Load(enrollOrderItemId);
            TblOdrEnrollOrder     enrollOrder     = _enrollOrderRepository.Load(enrollOrderItem.EnrollOrderId);

            TblDatCourse course = CourseService.GetByCourseId(enrollOrderItem.CourseId);

            res.RegisterInfo = new RegisterInformation()
            {
                ClassTimes    = enrollOrderItem.ClassTimes,
                ClassTimesUse = enrollOrderItem.ClassTimesUse,
                CourseName    = string.Empty,
                LevelName     = CourseLevelService.GetById(enrollOrderItem.CourseLevelId)?.LevelCnName ?? string.Empty,
                Year          = enrollOrderItem.Year,
                CourseType    = CourseType.Elective,
                TermTypeId    = enrollOrderItem.TermTypeId,
                TermTypeName  = TermTypeService.GetTermTypeName(enrollOrderItem.TermTypeId),
                EnrollDate    = enrollOrder.CreateTime
            };

            if (course != null)
            {
                res.RegisterInfo.CourseName = course.ShortName;
                res.RegisterInfo.CourseType = CourseType.Compulsory;
            }

            List <TblTimMakeLesson> makeLessons =
                _makeLessonRepository.GetUnconfirmedMakeLessonList(enrollOrderItem.EnrollOrderItemId);

            if (makeLessons.Any())
            {
                List <long> classIds = makeLessons.Select(x => x.ClassId).ToList();

                List <TblDatClass> classes = DefaultClassService.GetClassByClassIdAsync(classIds).Result;

                List <ViewRoomCourse> classRooms = ClassRoomService.GetClassRoomBySchoolId(enrollOrder.SchoolId);

                //老师
                var teacherList = TeachService.GetTeachers();

                foreach (var makeLesson in makeLessons)
                {
                    var classInfo        = classes.FirstOrDefault(x => x.ClassId == makeLesson.ClassId);
                    var classSchoolTimes = new DefaultClassService(classInfo.ClassId).ClassSchoolTimes;
                    //老师信息
                    var teacher = teacherList.FirstOrDefault(x => x.TeacherId == classInfo.TeacherId);

                    CourseInformation courseInformation = new CourseInformation
                    {
                        ClassId        = classInfo.ClassId,
                        Year           = enrollOrderItem.Year,
                        ClassNo        = classInfo.ClassNo,
                        ClassTimesUse  = makeLesson.ClassTimes,
                        CourseName     = course?.ShortName ?? string.Empty,
                        FirstClassTime = makeLesson.FirstClassTime,
                        RoomNo         = classRooms.FirstOrDefault(x => x.ClassRoomId == classInfo.ClassRoomId)?.RoomNo ?? string.Empty,
                        LevelName      = CourseLevelService.GetById(classInfo.CourseLeveId)?.LevelCnName ?? string.Empty,
                        TeacherName    = teacher?.TeacherName ?? string.Empty,
                        TermName       = TermService.GetTermByTermId(classInfo.TermId)?.TermName ?? string.Empty,
                        Week           = classSchoolTimes.Select(x => x.WeekDay)
                                         .Distinct()
                                         .OrderBy(x => x)
                                         .Select(x => WeekDayConvert.IntToString(x))
                                         .ToList(),
                        PeriodTime = new List <string>()
                    };

                    foreach (var item in classSchoolTimes)
                    {
                        string time = item.BeginTime + "-" + item.EndTime;
                        if (courseInformation.PeriodTime.Any(x => x == time))
                        {
                            continue;
                        }
                        courseInformation.PeriodTime.Add(time);
                    }

                    res.CourseInfos.Add(courseInformation);
                }
            }

            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);
        }
Example #9
0
        /// <summary>
        /// 添加补课周课次
        /// <para>作    者:Huang GaoLiang </para>
        /// <para>创建时间:2019-03-12 </para>
        /// </summary>
        ///  <param name="replenishWeekClassTime">安排补课参数信息</param>
        public void AddClassTime(ReplenishWeekClassTimeAddRequest replenishWeekClassTime)
        {
            lock (LocalThreadLock.GetLockKeyName(LockKeyNames.LOCK_AMSSCHOOLSTUDENT, this._schoolId, replenishWeekClassTime.StudentId.ToString()))
            {
                // 1、根据编辑编号查询原班级信息
                TblDatClass oldDatClass = new DefaultClassService(replenishWeekClassTime.ClassId).TblDatClass;

                // 2、获取学生缺课的课次信息
                List <ViewStudentTimeLess> studentTimeLessList = GetStudentMissClassList(replenishWeekClassTime);

                // 3、数据校验
                CheckDatClass(oldDatClass, replenishWeekClassTime.WeekClassTimeList.Count, studentTimeLessList.Count);

                // 获取补课日期中该老师所有的课次
                var classDates       = replenishWeekClassTime.WeekClassTimeList.Select(m => m.ClassDate).Distinct().ToList();
                var teacherClassList = new ViewTimAttendLessonRepository().GetClassDateTimAttendLessonList(this._schoolId, this._teacherId, classDates);

                this.ValidationLesson(replenishWeekClassTime.WeekClassTimeList, teacherClassList);


                // 4、获取所有补课周补课中的补课数据
                List <TblTimAdjustLesson> timAdjustLessonList = GetTimAdjustLessonList();

                // 用户补课周补课班级编号生成
                var classNo = string.Empty;
                classNo = oldDatClass.ClassNo.Substring(0, oldDatClass.ClassNo.IndexOf('-') + 1);

                // 5、根据上课教室编号,查询教室信息
                var roomIds = replenishWeekClassTime.WeekClassTimeList.Select(m => m.ClassRoomId).Distinct().ToList();
                List <TblDatClassRoom> datClassRooms = ClassRoomService.GetClassRoomListByIds(roomIds);

                List <TblTimAdjustLesson> adjustLessonList = new List <TblTimAdjustLesson>(); //业务调整表数据集合
                List <TblDatClass>        newClassList     = new List <TblDatClass>();        //补课周班级集合

                List <WeekClassTime> replenishWeekList = new List <WeekClassTime>();

                int index = 0;

                var batchNo = IdGenerator.NextId();
                foreach (var m in replenishWeekClassTime.WeekClassTimeList)
                {
                    var studentTimeLess = studentTimeLessList[index];
                    replenishWeekClassTime.EnrollOrderItemId = studentTimeLess.EnrollOrderItemId;
                    replenishWeekClassTime.CourseId          = studentTimeLess.CourseId;
                    replenishWeekClassTime.CourseLevelId     = studentTimeLess.CourseLevelId;
                    replenishWeekClassTime.TeacherId         = studentTimeLess.TeacherId;

                    // 补课周补课班级编号生成规则
                    var newClassNo = $"{classNo}{datClassRooms.FirstOrDefault(x => x.ClassRoomId == m.ClassRoomId).RoomNo }{WeekDayConvert.DayOfWeekToInt(m.ClassDate)}{GetTimeNumNo(m.ClassBeginTime, m.ClassEndTime, oldDatClass.ClassNo)}{WeekClassNo}";

                    SetDatClass(replenishWeekClassTime, oldDatClass, timAdjustLessonList, newClassNo, newClassList, adjustLessonList, m, replenishWeekList, studentTimeLess, batchNo);

                    WeekClassTime week = new WeekClassTime
                    {
                        ClassDate   = m.ClassDate,
                        ClassRoomId = m.ClassRoomId
                    };
                    replenishWeekList.Add(week);

                    index++;
                }

                using (var unitOfWork = new UnitOfWork())
                {
                    try
                    {
                        unitOfWork.BeginTransaction();

                        // 1、写入调整课次业务表
                        unitOfWork.GetCustomRepository <TblTimAdjustLessonRepository, TblTimAdjustLesson>().Add <TblTimAdjustLesson>(adjustLessonList);

                        // 2、创建补课周补课班级
                        unitOfWork.GetCustomRepository <TblDatClassRepository, TblDatClass>().Add(newClassList);

                        // 3、调用课次服务
                        var adjustLessonReplenishWeekCreator = new AdjustLessonReplenishWeekCreator(replenishWeekClassTime, adjustLessonList, studentTimeLessList, replenishWeekClassTime.StudentId, replenishWeekClassTime.TermId, this._schoolId, this._teacherId);

                        ReplenishLessonService replenishLessonService = new ReplenishLessonService(unitOfWork);
                        replenishLessonService.Create(adjustLessonReplenishWeekCreator);

                        unitOfWork.CommitTransaction();
                    }
                    catch (Exception ex)
                    {
                        unitOfWork.RollbackTransaction();
                        throw ex;
                    }
                }
            }
        }