Ejemplo n.º 1
0
        /// <summary>
        /// 描述:获取可预见的年份
        /// <para>作    者:瞿琦</para>
        /// <para>创建时间:2018-11-7</para>
        /// </summary>
        /// <param name="schoolId">校区Id</param>
        /// <returns>年度列表</returns>

        public static List <int> GetPredictYears(string schoolId)
        {
            TblDatTermRepository tblDatTermRepository = new TblDatTermRepository();
            //根据校区获取学期列表
            var yearList  = tblDatTermRepository.GetShoolNoByTblDatTerm(schoolId).Select(x => x.Year).OrderByDescending(x => x).ToList();
            var yearArray = new List <int>();
            int stratYear = yearList.LastOrDefault();

            if (!yearList.Any())  //如果当前校区没有学期
            {
                stratYear = DateTime.Now.Year;
            }
            else
            {
                if (stratYear > DateTime.Now.Year)
                {
                    stratYear = DateTime.Now.Year;
                }
            }

            for (int i = stratYear; i <= DateTime.Now.Year + 5; i++)
            {
                yearArray.Add(i);
            }

            return(yearArray);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 描述:根据日期获取时间段集合
        /// <para>作者:瞿琦</para>
        /// <para>创建时间:2019-3-14</para>
        /// </summary>
        /// <param name="schoolId">校区Id</param>
        /// <param name="day">日期</param>
        /// <returns>时间段集合</returns>
        public static List <SchoolDayTimeListResponse> GetDayTimeList(string schoolId, DateTime day)
        {
            //获取今天属于星期几
            int dayInt = WeekDayConvert.DayOfWeekToInt(day);
            //获取日期所属学期
            var termList          = new TblDatTermRepository().GetDateByTermList(day);
            var schoolTimeList    = new TblDatSchoolTimeRepository().GetSchoolOrTermBySchoolTimeList(schoolId, termList.Select(x => x.TermId));
            var daySchoolTimeList = schoolTimeList.Where(x => x.WeekDay == dayInt).Select(x => new SchoolDayTimeListResponse
            {
                BeginTime = x.BeginTime,
                EndTime   = x.EndTime
            }).Distinct(new Compare <SchoolDayTimeListResponse>((x, y) => (x != null && y != null && x.BeginTime == y.BeginTime && x.EndTime == y.EndTime)))
                                    .ToList();

            return(daySchoolTimeList);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据校区编号获取可预见的年份
        /// <para>作     者:Huang GaoLiang   </para>
        /// <para>创建时间:2018-09-07  </para>
        /// </summary>
        /// <param name="schoolId">校区编号</param>
        /// <returns>返回年度编号集合</returns>
        /// <exception cref="AMS.Core.BussinessException">
        /// 异常ID:9,校区编号为空
        /// </exception>
        public static List <int> GetPredictYears(string schoolId)
        {
            // 如果校区编号为空
            if (string.IsNullOrWhiteSpace(schoolId))
            {
                throw new BussinessException((byte)ModelType.Datum, 9);
            }
            //获取当前校区授权学期下的年份
            TblDatTermRepository termRepository = new TblDatTermRepository();
            List <int>           yearList       = termRepository.GetShoolNoByTblDatTerm(schoolId)
                                                  .OrderByDescending(m => m.CreateTime)
                                                  .Select(m => m.Year)
                                                  .Distinct()
                                                  .ToList();

            return(PredictYear.Get(yearList));
        }
        /// <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);
        }