示例#1
0
        /// <summary>
        /// 创建补课周补课
        /// <para>作    者:Huang GaoLiang </para>
        /// <para>创建时间:2019-03-12 </para>
        /// </summary>
        /// <param name="weekClassId">班级主键编号</param>
        /// <param name="replenishWeekClassTime"></param>
        /// <param name="oldDatClass">常规课班级信息</param>
        /// <param name="classNo">补课周班级生成规则</param>
        /// <param name="datClassList">补课周补课班级</param>
        /// <param name="m">补课周补课信息</param>
        /// <param name="studentTimeLessList">学生考勤数据</param>
        /// <param name="batchNo">批次号</param>
        private void CreateDatClass(long weekClassId, ReplenishWeekClassTimeAddRequest replenishWeekClassTime, TblDatClass oldDatClass, string classNo, List <TblDatClass> datClassList, WeekClassTime m, ViewStudentTimeLess studentTimeLessList, long batchNo)
        {
            replenishWeekClassTime.NewClassId = weekClassId;

            if (!datClassList.Any(c => c.ClassId == weekClassId))
            {
                TblDatClass weekClass = new TblDatClass
                {
                    ClassId      = weekClassId,
                    SchoolId     = this._schoolId,
                    ClassNo      = classNo,
                    TermId       = oldDatClass.TermId,
                    RoomCourseId = oldDatClass.RoomCourseId,
                    ClassRoomId  = m.ClassRoomId,
                    CourseId     = oldDatClass.CourseId,
                    CourseLeveId = oldDatClass.CourseLeveId,
                    TeacherId    = oldDatClass.TeacherId,
                    CourseNum    = oldDatClass.CourseNum,
                    StudentsNum  = oldDatClass.StudentsNum,
                    ClassType    = (int)ClassType.ReplenishWeek,
                    CreateTime   = DateTime.Now,
                    UpdateTime   = DateTime.Now
                };
                datClassList.Add(weekClass);
            }
        }
示例#2
0
        /// <summary>
        /// 生成补课周补课班级信息
        /// <para>作    者:Huang GaoLiang </para>
        /// <para>创建时间:2019-03-12 </para>
        /// </summary>
        /// <param name="replenishWeekClassTime"></param>
        /// <param name="oldDatClass">常规课班级信息</param>
        /// <param name="timAdjustLessonList">补课周补课集合</param>
        /// <param name="classNo">补课周班级生成规则</param>
        /// <param name="newClassList">新班级集合</param>
        /// <param name="adjustLessonList">业务调整数据集合</param>
        /// <param name="m">补课周补课信息</param>
        /// <param name="replenishWeekList">即将生成补课周的信息</param>
        /// <param name="studentTimeLessList">学生考勤数据</param>
        /// <param name="batchNo">批次号</param>
        private void SetDatClass(ReplenishWeekClassTimeAddRequest replenishWeekClassTime, TblDatClass oldDatClass, List <TblTimAdjustLesson> timAdjustLessonList, string classNo, List <TblDatClass> newClassList, List <TblTimAdjustLesson> adjustLessonList, WeekClassTime m, List <WeekClassTime> replenishWeekList, ViewStudentTimeLess studentTimeLessList, long batchNo)
        {
            // 检查该班级是否存在(上课日期/上课时间/下课时间/教室)
            var adjustLesson = timAdjustLessonList.FirstOrDefault(j => j.ClassDate == m.ClassDate &&
                                                                  j.ClassBeginTime == m.ClassBeginTime &&
                                                                  j.ClassEndTime == m.ClassEndTime &&
                                                                  j.ClassRoomId == m.ClassRoomId);

            // 如果补课周补课班级不存在,则需要生成一个补课周补课班级
            long weekClassId = 0;

            // 如果不是连着上的,则判断补课周班级存不存在
            if (!oldDatClass.ClassNo.Contains(HundredEight) && null == adjustLesson)
            {
                weekClassId = IdGenerator.NextId();
            }
            // 如果是连着上的
            else if (oldDatClass.ClassNo.Contains(HundredEight))
            {
                adjustLesson = timAdjustLessonList.FirstOrDefault(j => j.ClassDate == m.ClassDate && j.ClassRoomId == m.ClassRoomId);
                if (adjustLesson == null && adjustLessonList.Any())
                {
                    weekClassId = adjustLessonList.FirstOrDefault().ClassId;
                }
                else
                {
                    weekClassId = IdGenerator.NextId();
                }
            }
            else
            {
                weekClassId = adjustLesson.ClassId;
                replenishWeekClassTime.NewClassId = adjustLesson.ClassId;
            }

            CreateDatClass(weekClassId, replenishWeekClassTime, oldDatClass, classNo, newClassList, m, studentTimeLessList, batchNo);

            var adjust = new TblTimAdjustLesson
            {
                AdjustLessonId = IdGenerator.NextId(),
                BatchNo        = batchNo,
                BusinessType   = (int)LessonBusinessType.AdjustLessonReplenishWeek,
                ClassBeginTime = m.ClassBeginTime,
                ClassDate      = m.ClassDate,
                ClassEndTime   = m.ClassEndTime,
                ClassId        = weekClassId,
                ClassRoomId    = m.ClassRoomId,
                FromLessonId   = studentTimeLessList.LessonId,
                FromTeacherId  = studentTimeLessList.TeacherId,
                ToTeacherId    = studentTimeLessList.TeacherId,
                Remark         = LessonProcessConstants.WeekRemark,
                SchoolId       = this._schoolId,
                SchoolTimeId   = 0,//补课周补课,无需添加上课时间段编号
                StudentId      = replenishWeekClassTime.StudentId,
                Status         = (int)TimAdjustLessonStatus.Normal,
                CreateTime     = DateTime.Now
            };

            adjustLessonList.Add(adjust);
        }
示例#3
0
        private List <ViewStudentTimeLess> _studentTimeLessList;          //学生缺课信息集合

        /// <summary>
        /// 补课周补课构造函数
        /// </summary>
        /// <param name="replenishLessonList">添加补课周补课集合</param>
        /// <param name="adjustLessonList">课次调整业务信息</param>
        /// <param name="studentTimeLessList">学生缺课信息集合</param>
        /// <param name="studentId">学生编号</param>
        /// <param name="termId">学期编号</param>
        /// <param name="schoolId">校区编号</param>
        /// <param name="teacherId">教师编号</param>
        public AdjustLessonReplenishWeekCreator(ReplenishWeekClassTimeAddRequest replenishLessonList, List <TblTimAdjustLesson> adjustLessonList, List <ViewStudentTimeLess> studentTimeLessList, long studentId, long termId, string schoolId, string teacherId)
        {
            this._studentId = studentId;
            this._termId    = termId;
            this._schoolId  = schoolId;
            this._teacherId = teacherId;
            this._replenishWeekClassTime = replenishLessonList;
            this._adjustLessonList       = adjustLessonList;
            this._studentTimeLessList    = studentTimeLessList;
        }
示例#4
0
        /// <summary>
        /// 获取学生缺课的课次信息
        /// <para>作    者:Huang GaoLiang </para>
        /// <para>创建时间:2019-03-12 </para>
        /// </summary>
        /// <param name="replenishWeekClassTime">学生缺课查询条件</param>
        /// <returns>返回学生缺课信息</returns>
        private List <ViewStudentTimeLess> GetStudentMissClassList(ReplenishWeekClassTimeAddRequest replenishWeekClassTime)
        {
            StudentLessonInDto search = new StudentLessonInDto
            {
                StudentId = replenishWeekClassTime.StudentId,
                ClassId   = replenishWeekClassTime.ClassId,
                SchoolId  = this._schoolId,
                TeacherId = this._teacherId,
                TermId    = replenishWeekClassTime.TermId,
                CourseId  = replenishWeekClassTime.CourseId
            };
            List <ViewStudentTimeLess> studentTimeLessList = new ViewStudentTimeLessRepository().GetStudentTimeLessList(search);

            return(studentTimeLessList);
        }
 public void Post([FromBody] ReplenishWeekClassTimeAddRequest request)
 {
     new ReplenishWeekService(base.SchoolId, base.CurrentUser.UserId, base.CurrentUser.UserName).AddClassTime(request);
 }
示例#6
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;
                    }
                }
            }
        }