Example #1
0
        /// <summary>
        /// 描述:审核终审通过
        /// <para>作    者:瞿琦</para>
        /// <para>创建时间:2018.9.19</para>
        /// </summary>
        /// <returns>无</returns>
        public override void ProcessAuditSuccess()
        {
            TermService termService = new TermService(this._schoolId, this._year);
            var         query       = _tblAutTermRepository.LoadList(x => x.AuditId == this.TblAutAudit.AuditId);

            //1先删除原来的数据
            termService.Remove();

            //2增加审核后的数据
            var datTermModel = query.Select(x => new TblDatTerm
            {
                TermId      = x.TermId,
                TermName    = x.TermName,
                TermTypeId  = x.TermTypeId,
                SchoolId    = x.SchoolId,
                Year        = x.Year,
                BeginDate   = x.BeginDate,
                EndDate     = x.EndDate,
                Classes60   = x.Classes60,
                Classes90   = x.Classes90,
                Classes180  = x.Classes180,
                TuitionFee  = x.TuitionFee,
                MaterialFee = x.MaterialFee,
                CreateTime  = x.CreateTime,
                UpdateTime  = DateTime.Now
            }).ToList();

            termService.ResetTermList(datTermModel);

            //3同步报名时的学习计划数据
            StudyPlanService.AsyncSchoolTermType(this._schoolId).Wait();
        }
Example #2
0
        /// <summary>
        /// 获取写生课的课次信息
        /// <para>作    者:郭伟佳</para>
        /// <para>创建时间:2018-11-10</para>
        /// </summary>
        /// <returns>课程信息列表</returns>
        /// <exception cref="AMS.Core.BussinessException">
        /// 异常ID:
        /// 1. 未找到数据
        /// </exception>
        public List <LessonCreatorInfo> GetLessonCreatorInfo()
        {
            List <LessonCreatorInfo> result = new List <LessonCreatorInfo>();

            // 1.获取学期信息
            var termInfo = TermService.GetTermByTermId(_entity.TermId);

            if (termInfo == null)
            {
                throw new BussinessException(ModelType.Default, 1);
            }
            // 2.添加课程信息
            foreach (var item in _data)
            {
                LessonCreatorInfo lesson = new LessonCreatorInfo
                {
                    BusinessId        = _entity.LifeClassId,
                    BusinessType      = base.BusinessType,
                    ClassId           = item.ClassId,
                    ClassDate         = _entity.ClassBeginTime.Value,
                    ClassBeginTime    = _entity.ClassBeginTime.Value.ToString("yyyy.MM.dd HH:mm"),
                    ClassEndTime      = _entity.ClassEndTime.Value.ToString("yyyy.MM.dd HH:mm"),
                    EnrollOrderItemId = item.EnrollOrderItemId,
                    SchoolId          = _entity.SchoolId,
                    StudentId         = item.StudentId,
                    TeacherId         = _entity.TeacherId,
                    TermId            = _entity.TermId,
                    LessonCount       = _entity.UseLessonCount,
                    LessonType        = LessonType.SketchCourse
                };
                result.Add(lesson);
            }

            return(result);
        }
Example #3
0
        /// <summary>
        /// 获取学期排课表
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2018-09-21</para>
        /// </summary>
        /// <returns>学期排课表数据</returns>
        private TermTimetableResponse GetTermCourseTimetable()
        {
            TermTimetableResponse res = new TermTimetableResponse
            {
                CourseTimetableSixty  = this.GetTermCourseTimetable(TimeType.Sixty),
                CourseTimetableNinety = this.GetTermCourseTimetable(TimeType.Ninety),

                TermTimetableAuditResponse = new TermTimetableAuditResponse
                {
                    AuditStatus = (AuditStatus)base.TblAutAudit.AuditStatus,
                    Auditime    = base.TblAutAudit.AuditDate.ToString("yyyy-MM-dd HH:mm"),
                    AuditName   = base.TblAutAudit.AuditUserName,
                    Remark      = GetAuditRemark()
                }
            };

            TblDatTerm term = TermService.GetTermByTermId(_termId);

            res.TermBeginDate = term.BeginDate.ToString("yyyy-MM-dd");
            res.TermEndDate   = term.EndDate.ToString("yyyy-MM-dd");

            //如果被退回,退回原因应从DataExt中取
            if (res.TermTimetableAuditResponse.AuditStatus == AuditStatus.Return)
            {
                res.TermTimetableAuditResponse.IsFirstSubmitUser = base.IsFlowSubmitUser;
                res.TermTimetableAuditResponse.CreateUserName    = base.TblAutAudit.CreateUserName;
                res.TermTimetableAuditResponse.Remark            = base.TblAutAudit.DataExt;
            }
            return(res);
        }
Example #4
0
        /// <summary>
        /// 根据班级信息查询班级详情信息
        /// <para>作     者:Huang GaoLiang </para>
        /// <para>创建时间:2018-11-02</para>
        /// </summary>
        /// <param name="classInfo">班级查询信息</param>
        /// <returns>返回班级详情信息</returns>
        public static ClassDetailResponse GetClassDetail(ClassInfo classInfo)
        {
            // 获取当前学期下该编辑编码下的班级信息
            TblDatClassRepository repository = new TblDatClassRepository();
            List <long>           termIds    = TermService.GetTermByTermTypeId(classInfo.Year, classInfo.TermTypeId, classInfo.SchoolId).Select(t => t.TermId).ToList(); //获取学期类型下的所有学期

            // 根据学期编号、班级编号、校区编号获取班级信息
            TblDatClass datClass = repository.GetByClassNo(termIds, classInfo.classNo, classInfo.SchoolId);

            if (datClass == null)
            {
                return(null);
            }
            return(GetClassInfo(datClass, classInfo.CompanyId));
        }
Example #5
0
        /// <summary>
        /// 获取班级信息
        /// <para>作     者:Huang GaoLiang </para>
        /// <para>创建时间:2018-11-02</para>
        /// </summary>
        /// <param name="datClass">班级信息</param>
        /// <param name="companyId">公司编号</param>
        /// <returns>返回班级详细信息</returns>
        /// <exception cref="BussinessException">
        /// 异常ID:7,数据异常
        /// </exception>
        private static ClassDetailResponse GetClassInfo(TblDatClass datClass, string companyId)
        {
            ClassDetailResponse dto = new ClassDetailResponse
            {
                ClassId      = datClass.ClassId,
                ClassNo      = datClass.ClassNo,
                RoomCourseId = datClass.RoomCourseId,
                ClassRoomId  = datClass.ClassRoomId,
                CourseId     = datClass.CourseId,
                CourseLeveId = datClass.CourseLeveId,
                TermId       = datClass.TermId,
                CourseNum    = datClass.CourseNum,
                StudentsNum  = datClass.StudentsNum,
                SurplusNum   = datClass.StudentsNum,
            };

            if (dto == null)
            {
                throw new BussinessException((byte)ModelType.SignUp, 7);
            }

            //1、课程名称,课程等级
            CourseResponse course = new CourseService(companyId).GetCourseDetailsAsync(dto.CourseId).Result;

            if (course != null)
            {
                dto.CourseName     = course.CourseCnName;
                dto.CourseLeveName = course.CourseLevels.FirstOrDefault(m => m.CourseLevelId == dto.CourseLeveId)
                                     ?.CourseLevelName;
            }

            dto.TeachName = TeachService.GetTeacher(datClass.TeacherId)?.TeacherName;
            dto.TermName  = TermService.GetTermByTermId(dto.TermId)?.TermName;

            //2、门牌号
            dto.ClassRoomName = new ClassRoomService(dto.ClassRoomId).ClassRoomInfo?.RoomNo;

            //、计算出剩余学位数
            dto.SurplusNum = dto.StudentsNum - MakeLessonService.GetClassScheduleNum(dto.ClassId);

            //3、获取上课时间段数据
            dto.SchoolTimeList = GetDatSchoolTimeInfo(dto.ClassId);

            dto.ClassTime = GetSchoolTime(datClass.ClassId);

            return(dto);
        }
Example #6
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);
        }
Example #7
0
        /// <summary>
        /// 根据学期类型Id加年度获取学期
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2018-11-09</para>
        /// </summary>
        /// <returns>学期列表</returns>
        public List <TermMiniDataResponse> GetTermByTermTypeAndYear(long termTypeId, int year)
        {
            TermService service = new TermService(_schoolId, year);

            List <TermDetailResponse> responses = service.GetTermList();

            List <TermMiniDataResponse> res = responses
                                              .Where(x => x.TermTypeId == termTypeId)
                                              .Select(x => new TermMiniDataResponse
            {
                TermId   = x.TermId,
                TermName = x.TermName,
                Year     = x.Year
            })
                                              .ToList();

            return(res);
        }
Example #8
0
        /// <summary>
        /// 获取排课基础数据
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2019-02-19</para>
        /// </summary>
        /// <param name="classId">班级Id</param>
        /// <remarks>排课基础数据</remarks>
        private CourseBasicData GetCourseBasicData(IEnumerable <long> classId)
        {
            CourseBasicData courseBasicData = new CourseBasicData
            {
                Classs = DefaultClassService.GetClassByClassIdAsync(classId).Result //班级
            };

            //学期
            courseBasicData.Terms = TermService.GetTermByTermId(courseBasicData.Classs.Select(x => x.TermId));

            //所有课程
            courseBasicData.Courses = CourseService.GetAllAsync().Result;

            //所有课程等级
            courseBasicData.CourseLvs = CourseLevelService.GetAll();

            //老师
            courseBasicData.Teachers = TeachService.GetTeachers();

            return(courseBasicData);
        }
Example #9
0
        /// <summary>
        /// 取消之前,先进行检查数据
        /// <para>作    者:郭伟佳</para>
        /// <para>创建时间:2018-11-10</para>
        /// </summary>
        /// <param name="lifeClassInfo">写生课信息</param>
        /// <param name="lessonIdList">课程Id列表</param>
        /// <exception cref="AMS.Core.BussinessException">
        /// 异常ID:
        /// 13. 系统不存在该写生课信息
        /// 14. 该学期已结束,不可取消
        /// 34. 写生课已取消
        /// </exception>
        private void CheckDataBeforeCancel(TblTimLifeClass lifeClassInfo, List <long> lessonIdList)
        {
            //检查写生课排课是否存在
            if (lifeClassInfo == null)
            {
                throw new BussinessException(ModelType.Timetable, 13);
            }
            //检查学生写生课是否已取消,如已取消,不可再取消
            var lifeLessonList = _timLessonRepository.Value.GetByLessonIdTask(lessonIdList).Result;

            if (lifeLessonList.Any(a => a.Status == (int)LessonUltimateStatus.Invalid))
            {
                throw new BussinessException(ModelType.Timetable, 34);
            }
            //学期的结束日期小于当前日期,则不允许取消
            var termInfo = TermService.GetTermByTermId(lifeClassInfo.TermId);

            if (termInfo != null && termInfo.EndDate < DateTime.Now)
            {
                throw new BussinessException(ModelType.Timetable, 14);
            }
        }
Example #10
0
        /// <summary>
        /// 获取插班补上本学期已上课程数
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2018-11-07</para>
        /// </summary>
        /// <param name="firstTime">首次上课时间</param>
        /// <returns>插班补上本学期已上课程数</returns>
        /// <exception cref="BussinessException">
        /// 异常ID:1 异常描述:学期信息为空
        /// </exception>
        public int GetTransferLessonByFirstTime(DateTime?firstTime)
        {
            int transferLesson = 0;

            //1.获取学期信息
            var termInfo = TermService.GetTermByTermId(TblDatClass.TermId);

            if (termInfo == null)
            {
                throw new BussinessException(ModelType.Default, 1);
            }

            if (!firstTime.HasValue)
            {
                firstTime = termInfo.BeginDate;
            }

            //时间不在学期的开始、结束范围类则没有插班补课
            if (firstTime < termInfo.BeginDate || firstTime > termInfo.EndDate)
            {
                return(transferLesson);
            }

            //2.获取停课日
            List <SchoolHolidayResponse> schoolHoliday = TermService.GetSchoolHoliday(termInfo);

            while (termInfo.BeginDate < firstTime)
            {
                //今天
                DateTime today = termInfo.BeginDate;

                termInfo.BeginDate = termInfo.BeginDate.AddDays(1);

                bool isClosed = SchoolHolidayService.TodayIsSuspendClasses(schoolHoliday, today);
                if (isClosed)
                {
                    continue;
                }

                int weekDay = WeekDayConvert.DayOfWeekToInt(today);

                var todayClassTimes = ClassSchoolTimes
                                      .Where(x => x.WeekDay == weekDay)
                                      .OrderBy(x => x.BeginTime)
                                      .ToList();
                if (todayClassTimes.Count == 0)
                {
                    continue;
                }

                var firstClassTime = todayClassTimes.FirstOrDefault();

                if (todayClassTimes.Count == 1)
                {
                    switch ((TimeType)firstClassTime.Duration)
                    {
                    case TimeType.Sixty when termInfo.Classes60 <= transferLesson:
                        return(transferLesson);

                    case TimeType.Ninety when termInfo.Classes60 <= transferLesson:
                        return(transferLesson);
                    }
                }
                else
                {
                    if (termInfo.Classes180 <= transferLesson)
                    {
                        return(transferLesson);
                    }
                }

                transferLesson += todayClassTimes.Count;
            }

            return(transferLesson);
        }
Example #11
0
        /// <summary>
        /// 根据首次上课时间获取排课最大课次
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2018-11-05</para>
        /// </summary>
        /// <param name="firstTime">首次上课时间</param>
        /// <returns>获取排课最大课次</returns>
        /// <exception cref="BussinessException">
        /// 异常ID:1 异常描述:学期信息为空
        /// </exception>
        public int GetMaximumLessonByFirstTime(DateTime firstTime)
        {
            int maximumLesson = 0;

            //1.获取学期信息
            var termInfo = TermService.GetTermByTermId(TblDatClass.TermId);

            if (termInfo == null)
            {
                throw new BussinessException(ModelType.Default, 1);
            }

            //获取停课日
            List <SchoolHolidayResponse> schoolHoliday = TermService.GetSchoolHoliday(termInfo);

            //首次上课时间大于学期结束时间则没有课次
            if (firstTime > termInfo.EndDate)
            {
                return(maximumLesson);
            }

            //首次上课时间小于学期开始时间则以学期开始时间为准
            if (firstTime < termInfo.BeginDate)
            {
                firstTime = termInfo.BeginDate;
            }

            bool     isStandard180 = this.IsStandard180(ClassSchoolTimes);                 //180分钟
            TimeType duration      = (TimeType)ClassSchoolTimes.FirstOrDefault().Duration; //时长

            while (firstTime <= termInfo.EndDate)
            {
                //判断停课日
                bool isClosed = SchoolHolidayService.TodayIsSuspendClasses(schoolHoliday, firstTime);
                if (isClosed)
                {
                    firstTime = firstTime.AddDays(1);
                    continue;
                }

                //执行60分钟标准
                if (duration == TimeType.Sixty && maximumLesson == termInfo.Classes60)
                {
                    return(maximumLesson);
                }
                //执行90分钟标准
                else if (duration == TimeType.Ninety && !isStandard180 && maximumLesson == termInfo.Classes90)
                {
                    return(maximumLesson);
                }
                //执行180分钟标准
                else if (duration == TimeType.Ninety && isStandard180 && maximumLesson >= termInfo.Classes180)
                {
                    //180分钟标准由90分钟标准构成
                    //180分钟标准设置可能会是奇数
                    //最大课次排课超过标准,则按标准执行
                    if (maximumLesson > termInfo.Classes180)
                    {
                        return(termInfo.Classes180);
                    }
                    break;
                }

                int weekDay = WeekDayConvert.DayOfWeekToInt(firstTime);

                int lessonCount = ClassSchoolTimes.Count(x => x.WeekDay == weekDay);

                maximumLesson += lessonCount;

                firstTime = firstTime.AddDays(1);
            }

            return(maximumLesson);
        }
Example #12
0
        /// <summary>
        /// 获取排课课次信息列表
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2019-02-19</para>
        /// </summary>
        /// <returns>课次信息列表</returns>
        public List <LessonCreatorInfo> GetLessonCreatorInfo()
        {
            List <LessonCreatorInfo> res = new List <LessonCreatorInfo>();

            //校验排课信息是否为空
            ValidateObject(_makeLesson);

            if (_makeLesson.IsConfirm)
            {
                throw new BussinessException(ModelType.SignUp, 9);
            }

            //1.获取学期信息
            var termInfo = TermService.GetTermByTermId(_classService.TblDatClass.TermId);

            ValidateObject(termInfo);

            //订单明细
            TblOdrEnrollOrderItem orderItem =
                _enrollOrderItemRepository.Load(_makeLesson.EnrollOrderItemId);
            //订单
            TblOdrEnrollOrder order =
                _enrollOrderRepository.Load(orderItem.EnrollOrderId);

            //2.获取停课日
            List <SchoolHolidayResponse> schoolHoliday = TermService.GetSchoolHoliday(termInfo);

            //上课时间
            DateTime classDate = _makeLesson.FirstClassTime;

            //首次上课日期大于学期结束日期则没有课次
            if (classDate > termInfo.EndDate)
            {
                return(res);
            }

            //首次上课日期未到学期开始时间取学期设置开始日期
            if (classDate < termInfo.BeginDate)
            {
                classDate = termInfo.BeginDate;
            }

            bool     isStandard180 = this.IsStandard180(_classService.ClassSchoolTimes);                 //180分钟
            TimeType duration      = (TimeType)_classService.ClassSchoolTimes.FirstOrDefault().Duration; //时长

            int standard180     = termInfo.Classes180;                                                   //设置180分钟标准
            int makeLessonTotal = _makeLesson.ClassTimes;                                                //设置排课总数

            if (isStandard180)
            {
                //180分钟设置的标准是否是奇数
                bool class180IsOddNumber = Convert.ToBoolean(termInfo.Classes180 % 2);
                standard180 = class180IsOddNumber ? termInfo.Classes180 - 1 : termInfo.Classes180;

                //排课是否是奇数
                bool makeIsOddNumber = Convert.ToBoolean(_makeLesson.ClassTimes % 2);
                //报名课次数量 考虑180分钟排2个课次的完整性
                makeLessonTotal = makeIsOddNumber ? _makeLesson.ClassTimes - 1 : _makeLesson.ClassTimes;
            }

            //上课日期大于学期结束日期停止排课
            while (classDate <= termInfo.EndDate)
            {
                //当天是否停课
                bool isClosed = SchoolHolidayService.TodayIsSuspendClasses(schoolHoliday, classDate);

                if (isClosed)
                {
                    classDate = classDate.AddDays(1);
                    continue;
                }

                int week = WeekDayConvert.DayOfWeekToInt(classDate);

                List <TblDatSchoolTime> classTimes = _classService.ClassSchoolTimes
                                                     .Where(x => x.WeekDay == week)
                                                     .OrderBy(x => x.BeginTime)
                                                     .ToList();

                //处理上课时间发生变化
                var changeTimes = _viewChangeClassTimeDates
                                  .Where(x => x.OldClassDate == classDate)
                                  .OrderBy(x => x.NewClassBeginTime)
                                  .ToList();

                if (!classTimes.Any() && !changeTimes.Any())
                {
                    classDate = classDate.AddDays(1);
                    continue;
                }

                //180分钟课程
                if (duration == TimeType.Ninety && isStandard180 == true)
                {
                    if (!changeTimes.Any())
                    {
                        var ct1 = classTimes[0];
                        var ct2 = classTimes[1];

                        res.Add(this.GetCreatorInfo(classDate, ct1.BeginTime, ct1.EndTime, termInfo.SchoolId, order.StudentId, termInfo.TermId));
                        res.Add(this.GetCreatorInfo(classDate, ct2.BeginTime, ct2.EndTime, termInfo.SchoolId, order.StudentId, termInfo.TermId));
                    }
                    else
                    {
                        var ct1 = changeTimes[0];
                        var ct2 = changeTimes[1];

                        res.Add(this.GetCreatorInfo(ct1.NewClassDate, ct1.NewClassBeginTime, ct1.NewClassEndTime, termInfo.SchoolId, order.StudentId, termInfo.TermId));
                        res.Add(this.GetCreatorInfo(ct2.NewClassDate, ct2.NewClassBeginTime, ct2.NewClassEndTime, termInfo.SchoolId, order.StudentId, termInfo.TermId));
                    }

                    _lessonCount += 2;
                }
                else
                {
                    if (!changeTimes.Any())
                    {
                        var ct1 = classTimes[0];
                        res.Add(this.GetCreatorInfo(classDate, ct1.BeginTime, ct1.EndTime, termInfo.SchoolId, order.StudentId, termInfo.TermId));
                    }
                    else
                    {
                        var ct1 = changeTimes[0];
                        res.Add(this.GetCreatorInfo(ct1.NewClassDate, ct1.NewClassBeginTime, ct1.NewClassEndTime, termInfo.SchoolId, order.StudentId, termInfo.TermId));
                    }

                    _lessonCount += 1;
                }

                //上课时间大于学期结束时间停止排课或者预计排课课次等于实际排课课次停止排课
                if (this._lessonCount == makeLessonTotal)
                {
                    return(res);
                }
                //执行60分钟标准
                else if (duration == TimeType.Sixty && this._lessonCount == termInfo.Classes60)
                {
                    return(res);
                }
                //执行90分钟标准
                else if (duration == TimeType.Ninety && isStandard180 == false && this._lessonCount == termInfo.Classes90)
                {
                    return(res);
                }
                //执行180分钟标准
                else if (duration == TimeType.Ninety && isStandard180 == true && this._lessonCount == standard180)
                {
                    return(res);
                }

                classDate = classDate.AddDays(1);
            }

            return(res);
        }
Example #13
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>作    者:瞿琦</para>
        /// <para>创建时间:2018-11-7</para>
        /// </summary>
        /// <exception cref="AMS.Core.BussinessException">
        /// 异常Id:1,异常描述:未找到数据
        /// 异常Id:71,异常描述:转入班级时间段和课次信息调整时间段不一致
        /// </exception>
        /// <returns>可转入课次信息列表</returns>
        public List <LessonCreatorInfo> GetLessonCreatorInfo()
        {
            var result = new List <LessonCreatorInfo>();
            //获取转入班级信息
            var classService = new DefaultClassService(base._entity.InClassId);
            var firstTime    = base._entity.InDate;
            //1.获取学期信息
            var termInfo = TermService.GetTermByTermId(classService.TblDatClass.TermId);

            if (termInfo == null)
            {
                throw new BussinessException(ModelType.Default, 1);
            }
            //2.获取停课日
            var schoolHoliday = TermService.GetSchoolHoliday(termInfo);

            //首次上课时间大于学期结束时间则没有课次
            if (firstTime > termInfo.EndDate)
            {
                return(result);
            }
            //首次上课时间小于学期开始时间,则首次上课时间等于学期开始时间
            if (firstTime < termInfo.BeginDate)
            {
                firstTime = termInfo.BeginDate;
            }

            while (firstTime <= termInfo.EndDate)
            {
                //上课时间大于学期结束时间或者预计排课课次等于实际排课课次,则停止排课
                if (firstTime > termInfo.EndDate || _entity.ClassTimes == _actualLesson)
                {
                    break;
                }

                var isClosed = SchoolHolidayService.TodayIsSuspendClasses(schoolHoliday, firstTime);
                //当前时间是否是停课日,如果是则加1
                if (isClosed)
                {
                    firstTime = firstTime.AddDays(1);
                    continue;
                }
                //星期转换
                var week = WeekDayConvert.DayOfWeekToInt(firstTime);
                //获取与当前时间匹配的班级上课时间
                var schoolTimes = classService.ClassSchoolTimes.Where(x => x.WeekDay == week).OrderBy(x => x.BeginTime).ToList();

                //获取班级是否有课程信息调整(上课日期和上课时间段 修改)
                var classDateChangeList = _viewChangeClassTimeDates.Where(x => x.OldClassDate == firstTime).OrderBy(x => x.NewClassBeginTime).ToList();
                if (classDateChangeList.Count > 0 && classDateChangeList.Count != schoolTimes.Count)  //如果班级设置的上课时间段和课程调整的时间段不一致则抛出异常
                {
                    throw new BussinessException(ModelType.Timetable, 71);
                }
                var lessonCount = 0;
                foreach (var time in schoolTimes)
                {
                    var lesson = new LessonCreatorInfo
                    {
                        BusinessId        = base._entity.ChangeClassId,
                        BusinessType      = base.BusinessType,
                        ClassId           = base._entity.InClassId,
                        ClassDate         = firstTime,
                        ClassBeginTime    = time.BeginTime,
                        ClassEndTime      = time.EndTime,
                        ClassRoomId       = classService.TblDatClass.ClassRoomId,
                        CourseId          = classService.TblDatClass.CourseId,
                        CourseLevelId     = classService.TblDatClass.CourseLeveId,
                        EnrollOrderItemId = _enrollOrderItemId,
                        SchoolId          = termInfo.SchoolId,
                        StudentId         = base._entity.StudentId,
                        TeacherId         = classService.TblDatClass.TeacherId,
                        TermId            = termInfo.TermId
                    };
                    //获取是否有老师调课
                    var teacherLessonChangeInfo = _viewClassTeacherDates.FirstOrDefault(x => x.ClassId == lesson.ClassId && x.ClassDate == lesson.ClassDate);
                    if (teacherLessonChangeInfo != null && teacherLessonChangeInfo.TeacherId.Trim() != lesson.TeacherId.Trim())
                    {
                        lesson.TeacherId = teacherLessonChangeInfo.TeacherId;
                    }
                    //获取班级是否有修改上课日期和上课时间段,并赋值
                    if (classDateChangeList.Any())
                    {
                        lesson.ClassDate      = classDateChangeList[lessonCount].NewClassDate;
                        lesson.ClassBeginTime = classDateChangeList[lessonCount].NewClassBeginTime;
                        lesson.ClassEndTime   = classDateChangeList[lessonCount].NewClassEndTime;
                    }
                    result.Add(lesson);
                    lessonCount++;
                    //实际排课课次+1
                    _actualLesson++;
                }
                firstTime = firstTime.AddDays(1);
            }
            return(result);
        }
Example #15
0
 /// <summary>
 /// 获取年份数据
 /// <para>作    者:zhiwei.Tang</para>
 /// <para>创建时间:2018-11-07</para>
 /// </summary>
 /// <returns>年份列表</returns>
 public List <int> GetYears()
 {
     return(TermService.GetPredictYears(_schoolId));
 }
Example #16
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);
        }