예제 #1
0
        /// <summary>
        /// 对写生排课进行数据校验
        /// <para>作    者:郭伟佳</para>
        /// <para>创建时间:2018-11-20</para>
        /// </summary>
        /// <param name="request">学期班级学生实体请求对象</param>
        /// <param name="lifeClassInfo">写生课对象</param>
        /// <param name="lessonClassList">课次基础信息表</param>
        /// <exception cref="AMS.Core.BussinessException">
        /// 异常ID:
        /// 13. 系统不存在该写生课信息
        /// 28. 系统不存在该报名订单课程明细信息
        /// 29. 请选择学生进行写生排课
        /// </exception>
        private void CheckDataBeforeMake(List <TimeLessonClassRequest> request, TblTimLifeClass lifeClassInfo, List <ViewTimeLessonClass> lessonClassList)
        {
            //获取写生课信息
            if (lifeClassInfo == null)
            {
                throw new BussinessException(ModelType.Timetable, 13);
            }
            if (request == null || request.Count == 0)
            {
                throw new BussinessException(ModelType.Timetable, 29);
            }

            //获取报名订单课程明细信息
            var enrollOrderItemInfoList = EnrollOrderService.GetEnrollOrderItemByItemId(lessonClassList.Select(a => a.EnrollOrderItemId).Distinct());

            //检查课次基础信息是否存在
            var classEnrollOrderItemList = lessonClassList.Where(a => request.Any(b => b.TermId == a.TermId && b.ClassId == a.ClassId)).GroupBy(g => new { g.EnrollOrderItemId, g.StudentId, g.ClassId })
                                           .Select(s => new { s.Key.ClassId, s.Key.EnrollOrderItemId, s.Key.StudentId });

            //如果学生不存在课次基础信息,则直接抛出异常信息
            if (!enrollOrderItemInfoList.Exists(a => classEnrollOrderItemList.Any(b => b.EnrollOrderItemId == a.EnrollOrderItemId) && a.Status == (int)OrderItemStatus.Enroll))
            {
                throw new BussinessException(ModelType.Timetable, 28);
            }
        }
예제 #2
0
        /// <summary>
        /// 学生写生排课
        /// <para>作    者:郭伟佳</para>
        /// <para>创建时间:2019-01-05</para>
        /// </summary>
        /// <param name="request">学期班级学生请求参数</param>
        /// <param name="lifeClassInfo">写生课信息</param>
        /// <param name="lessonClassList">报班明细信息</param>
        /// <returns>写生排课结果</returns>
        private LifeClassResultResponse MakeLessonForStudent(List <TimeLessonClassRequest> request, TblTimLifeClass lifeClassInfo, List <ViewTimeLessonClass> lessonClassList)
        {
            LifeClassResultResponse resultResponse = new LifeClassResultResponse();

            foreach (var studentId in lessonClassList.Select(a => a.StudentId).Distinct())
            {
                lock (LocalThreadLock.GetLockKeyName(LockKeyNames.LOCK_AMSSCHOOLSTUDENT, _schoolId, studentId.ToString()))
                {
                    //1.获取学生对应的课次信息
                    var studentLessonList = lessonClassList.Where(a => a.StudentId == studentId);

                    //2.获取报名订单课程明细信息
                    var studentEnrollItemList = EnrollOrderService.GetEnrollOrderItemByItemId(studentLessonList.Select(a => a.EnrollOrderItemId).Distinct());

                    //3.获取需要生成的写生课明细、一个学生多个班级列表和课次不够的学生列表
                    var result = GetLifeClassLesson(request, lifeClassInfo, studentLessonList, studentEnrollItemList);
                    resultResponse.LackTimeList.AddRange(result.Item1);                   //获取课次不够的学生列表
                    List <LifeClassLessonMakeRequest> lifeClassLessonList = result.Item2; //获取写生课明细
                    resultResponse.StudentClassList.AddRange(result.Item3);               //获取一个学生多个班级列表

                    //4.进行写生排课
                    MakeLifeClass(lifeClassInfo, lifeClassLessonList);
                }
            }
            return(resultResponse);
        }
예제 #3
0
        /// <summary>
        /// 写生排课(选择学生班级)
        /// <para>作    者:郭伟佳</para>
        /// <para>创建时间:2019-01-03</para>
        /// </summary>
        /// <param name="lifeClassSelectList">学生班级课程对象</param>
        /// <returns>学生课次不够的信息列表</returns>
        internal List <LifeClassLackTimesListResponse> SelectClassToMake(List <LifeClassSelectClassRequest> lifeClassSelectList)
        {
            lock (LocalThreadLock.GetLockKeyName(LockKeyNames.LOCK_LIFE_CLASS, _lifeClassId.ToString()))
            {
                List <LifeClassLackTimesListResponse> result = new List <LifeClassLackTimesListResponse>();

                //1.获取写生课信息
                TblTimLifeClass lifeClassInfo = _repository.Value.GetLifeClassInfo(_lifeClassId);

                foreach (var studentId in lifeClassSelectList.Select(a => a.StudentId).Distinct())
                {
                    lock (LocalThreadLock.GetLockKeyName(LockKeyNames.LOCK_AMSSCHOOLSTUDENT, _schoolId, studentId.ToString()))
                    {
                        //2.获取学生对应的班级课程信息
                        var studentLifeList = lifeClassSelectList.Where(a => a.StudentId == studentId);

                        //3.获取报名订单课程明细信息
                        var enrollOrderItemInfoList = EnrollOrderService.GetEnrollOrderItemByItemId(studentLifeList.Select(a => a.EnrollOrderItemId).Distinct());

                        //4.获取课次不够扣的报名订单课程明细信息
                        var enrollNotEnoughTimeList = enrollOrderItemInfoList.Where(a => a.Status == (int)OrderItemStatus.Enroll && a.ClassTimes - a.ClassTimesUse < lifeClassInfo.UseLessonCount);

                        //5.获取课次不够的学生列表
                        result.AddRange(GetNoEnoughTimeList(lifeClassInfo, studentLifeList, enrollNotEnoughTimeList));

                        //6.过滤课次不够的写生排课
                        var lifeClassList = studentLifeList.Where(a => !enrollNotEnoughTimeList.Any(b => b.EnrollOrderItemId == a.EnrollOrderItemId))
                                            .Select(a => new LifeClassLessonMakeRequest()
                        {
                            StudentId         = a.StudentId,
                            ClassId           = a.ClassId,
                            EnrollOrderItemId = a.EnrollOrderItemId
                        }).ToList();

                        //7.写生排课
                        MakeLifeClass(lifeClassInfo, lifeClassList);
                    }
                }
                return(result);
            }
        }