예제 #1
0
        /// <summary>
        /// 删除
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2018-09-11</para>
        /// </summary>
        /// <exception cref="BussinessException">
        /// 异常ID:20,异常描述:课程已使用不可删除
        /// </exception>
        public async Task Remove()
        {
            //调用顺序过程:
            //1、校验是否可以删除 (校区排课总表已使用不可删除)
            var courseIsUseDat = await new TblDatClassRepository().CourseIsUseByRoomCourseId(_roomCourseId);

            if (courseIsUseDat)
            {
                throw new BussinessException((byte)ModelType.Datum, 20);
            }
            var courseIsUseAut = TermCourseTimetableAuditService.CourseIsUseByRoomCourseId(_roomCourseId);

            if (courseIsUseAut)
            {
                throw new BussinessException((byte)ModelType.Datum, 20);
            }
            //2、调用删除操作
            TblDatRoomCourse roomCourse = await _tblDatRoomCourseRepository.Value.LoadTask(_roomCourseId);

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

            await _tblDatRoomCourseRepository.Value.DeleteTask(roomCourse);
        }
예제 #2
0
        /// <summary>
        /// 数据校验
        /// <para>作     者:Huang GaoLiang  </para>
        /// <para>创建时间:2018-09-07  </para>
        /// </summary>
        /// <param name="schoolTimeId">上课时间段主键编号</param>
        /// <param name="termId">学期编号</param>
        /// <exception cref="AMS.Core.BussinessException">
        /// 异常ID:8,该时间段已排课,不可删除
        /// </exception>
        private static void CanDelete(long schoolTimeId, long termId)
        {
            // 1、查询已生效的数据
            TblTimClassTimeRepository cousClassRepository = new TblTimClassTimeRepository();
            TblTimClassTime           cousClass           = cousClassRepository.LoadList(m => m.SchoolTimeId == schoolTimeId).FirstOrDefault();

            // 如果查询的班级课表数据不存在
            if (cousClass != null)
            {
                throw new BussinessException((byte)ModelType.Datum, 8);
            }
            // 2、草稿中已被使用的也不能删除
            TermCourseTimetableAuditService auditService = new TermCourseTimetableAuditService(termId);

            if (auditService.IsAuditing || auditService.CanSubmitToAudit)
            {
                List <TblAutClassTime> autClassTimeList = new TermCourseTimetableAuditService(termId).GetAutClassTimeListById(schoolTimeId);

                // 如果查询的班级课表数据存在
                if (autClassTimeList.Any())
                {
                    throw new BussinessException((byte)ModelType.Datum, 8);
                }
            }
        }
        /// <summary>
        /// 根据类型类型,调取对应的服务
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public BaseAuditService CreateAuditService(AuditCallbackRequest dto)
        {
            var bussinessType        = int.Parse(dto.BussinessCode);
            BaseAuditService service = null;
            long             auditId = long.Parse(dto.ApplyNumber);

            switch (bussinessType)
            {
            case (int)AuditBusinessType.Term:       //学期审核服务
                service = TermAuditService.CreateByAutitId(auditId);
                break;

            case (int)AuditBusinessType.TermCourseTimetable:       //排课审核服务
                service = TermCourseTimetableAuditService.CreateByAutitId(auditId);
                break;

            case (int)AuditBusinessType.ScholarshipGive:
                service = CouponRuleAuditService.CreateByAutitId(auditId);
                break;

            default:
                break;
            }
            if (service == null)  //审核单据类型不存在
            {
                throw new BussinessException((byte)ModelType.Audit, 13);
            }

            if (service.TblAutAudit.BizType != bussinessType)  //审核单据类型不一致
            {
                throw new BussinessException((byte)ModelType.Audit, 14);
            }

            return(service);
        }
예제 #4
0
        /// <summary>
        /// 校验老师在同一时间段不同教室是否存在
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2019-02-20</para>
        /// </summary>
        /// <param name="schoolTimeId">时间段</param>
        /// <param name="notClassId">排除的班级Id</param>
        /// <param name="duration">时长</param>
        /// <param name="teacherId">老师Id</param>
        /// <param name="termId">学期Id</param>
        /// <exception cref="BussinessException">
        /// 异常ID:10,异常描述:老师上课时间冲突
        /// </exception>
        private static void VerifyTeacherOccupy(IEnumerable <long> inputSchoolTimeId, string teacherId, long termId)
        {
            //1.获取老师上课段
            TermCourseTimetableAuditService termCourseTimetableAuditService = new TermCourseTimetableAuditService(termId);

            List <long> teacherClassTimes = termCourseTimetableAuditService.GetAutClassTime(teacherId)
                                            .Select(x => x.SchoolTimeId)
                                            .ToList();

            if (!teacherClassTimes.Any())
            {
                return; //该老师未排课
            }

            //2.获取重叠的上课时间段
            var termSchoolTimes = new SchoolTimeService(termCourseTimetableAuditService._termId).TblDatSchoolTime.ToList();

            List <long> overlappingSchoolTime = OverlappingSchoolTime(termSchoolTimes, inputSchoolTimeId);

            //3.比较
            var intersectedList = teacherClassTimes.Intersect(overlappingSchoolTime);

            if (intersectedList.Any())
            {
                throw new BussinessException(ModelType.Timetable, 10);  //老师上课时间冲突
            }
        }
        /// <summary>
        /// 班级课表详情
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2018-11-06</para>
        /// </summary>
        /// <param name="classId">班级Id</param>
        /// <param name="termId">学期Id</param>
        /// <returns>课程表班级的详情信息</returns>
        public static ClassTimetableResponse GetClassTimetable(long classId, long termId)
        {
            TermCourseTimetableAuditService termCourseTimetableAuditService = new TermCourseTimetableAuditService(termId);

            if (termCourseTimetableAuditService.NoPass)
            {
                return(termCourseTimetableAuditService.GetNoPassClassTimetable(classId).Result);
            }

            return(new ClassCourseTimetableService(classId).GetClassTimetable());
        }
        /// <summary>
        /// 描述:根据学期获取老师及所属课程
        /// <para>作    者:瞿琦</para>
        /// <para>创建时间:2018.9.25</para>
        /// </summary>
        /// <returns>学期下老师及所属课程列表</returns>

        public List <ClassCourseSearchTeacherResponse> GetTermIdByTeacherList(long termId)
        {
            TblDatClassRepository tblDatClassService = new TblDatClassRepository();

            //获取所有的老师
            var teacherList = TeachService.GetTeachers();
            TermCourseTimetableAuditService auditService = new TermCourseTimetableAuditService(termId);

            //var termTeacherIdList = new List<string>();
            var termTeacherIdList = new List <CourseInfo>();
            var courseList        = new List <CourseInfo>();

            if (auditService.NoPass) //审核中
            {
                //根据学期Id查询审核中的班级信息
                TblAutClassRepository tblAutClassRepository = new TblAutClassRepository();
                var auditId = auditService.TblAutAudit.AuditId;  //获取审核中数据的审核Id
                courseList = tblAutClassRepository.GetByAuditId(auditId).Result.Select(x => new CourseInfo
                {
                    TeacherId = x.TeacherId,
                    CourseId  = x.CourseId
                }).ToList();
                termTeacherIdList = courseList.Distinct(new TeacherComparer()).ToList();
            }
            else  //已生效
            {
                //根据学期Id查询已生效的班级信息
                courseList = tblDatClassService.GetTermIdByClass(termId).Select(x => new CourseInfo
                {
                    TeacherId = x.TeacherId,
                    CourseId  = x.CourseId
                }).ToList();
                termTeacherIdList = courseList.Distinct(new TeacherComparer()).ToList();
            }

            var classTeachList = (from x1 in termTeacherIdList
                                  join x2 in teacherList on x1.TeacherId equals x2.TeacherId
                                  select new ClassCourseSearchTeacherResponse
            {
                TeacherNo = x2.TeacherId,
                TeacherName = x2.TeacherName
            }).ToList();

            //获取老师所属的课程
            foreach (var courseItem in classTeachList)
            {
                courseItem.TeacherByCourse = courseList.Where(x => x.TeacherId == courseItem.TeacherNo).Select(x => new ClassCourseResponse
                {
                    CourseId = x.CourseId
                }).Distinct(new CourseInfoComparer()).ToList();
            }

            return(classTeachList);
        }
예제 #7
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>作    者:瞿琦</para>
        /// <para>创建时间:2018-10-17</para>
        /// </summary>
        /// <param name="termId">学期id</param>
        /// <returns>审核中的课程列表</returns>

        public List <ClassCourseResponse> GetAuditClassCourse(long termId)
        {
            var auditCourseList = new List <ClassCourseResponse>();
            TermCourseTimetableAuditService termCourseTiemtableService = new TermCourseTimetableAuditService(termId);

            if (termCourseTiemtableService.IsAuditing)
            {
                //所有课程
                var courseList = new TblDatCourseRepository().LoadList(x => x.IsDisabled == false);
                var classList  = _tblAutClassRepository.Value.GetByAuditId(termCourseTiemtableService.TblAutAudit.AuditId).Result;

                auditCourseList = (from x1 in classList
                                   join x2 in courseList on x1.CourseId equals x2.CourseId
                                   select new ClassCourseResponse
                {
                    CourseId = x1.CourseId,
                    ClassCnName = x2.ClassCnName
                }).ToList();
            }

            return(auditCourseList);
        }
        /// <summary>
        /// 校验时间段是否可以连上
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2018-11-06</para>
        /// </summary>
        /// <param name="allClassTime">所有上课时间段</param>
        /// <param name="classRoomId">教室Id</param>
        /// <param name="schoolTimeId">上课时间段</param>
        /// <param name="termId">学期Id</param>
        /// <returns>课程表基础数据</returns>
        private static ClassTimetableSchoolTimeResult GetClassTimetableSchoolTimeResult(
            List <TblDatSchoolTime> allClassTime, long classRoomId, long schoolTimeId, long termId)
        {
            ClassTimetableSchoolTimeResult res = new ClassTimetableSchoolTimeResult()
            {
                Time2 = new List <string>(),
                WeekDaySchoolTimes = new List <ClassTimetableSchoolTimeResponse>(),
                CanClassJoin       = false
            };

            TermCourseTimetableAuditService termCourseTimetableAuditService = new TermCourseTimetableAuditService(termId);

            List <long> schoolTimeIds = allClassTime.Select(x => x.SchoolTimeId).Distinct().ToList();

            List <long> alreadySchoolTimeIds = null;//已上课时间段

            if (termCourseTimetableAuditService.NoPass)
            {
                alreadySchoolTimeIds = termCourseTimetableAuditService.GetAlreadyClassTime(classRoomId);
            }
            else
            {
                alreadySchoolTimeIds = GetAlreadyClassTime(termId, classRoomId);
            }

            //1.第一节上课时间
            TblDatSchoolTime firstClassTime = allClassTime.FirstOrDefault(x => x.SchoolTimeId == schoolTimeId);
            //2.第二节上课时间
            TblDatSchoolTime secondClassTime = null;

            //当天所有上课时间段
            var dayClassTimes = allClassTime
                                .Where(x => x.WeekDay == firstClassTime.WeekDay && x.Duration == firstClassTime.Duration)
                                .OrderBy(x => x.BeginTime)
                                .ToList();

            //第一个时间段索引
            int firstTimeIndex = dayClassTimes.IndexOf(firstClassTime);
            //第二个时间段索引
            int secondClassTimeIndex = firstTimeIndex + 1;

            //班级第二个时间段
            if (dayClassTimes.Count > secondClassTimeIndex)
            {
                secondClassTime = dayClassTimes[secondClassTimeIndex];
                if (!alreadySchoolTimeIds.Any(x => x == secondClassTime.SchoolTimeId))
                {
                    res.CanClassJoin = true;
                    res.Time2.Add(secondClassTime.BeginTime);
                    res.Time2.Add(secondClassTime.EndTime);
                }
            }

            //一周的上课时间
            for (int i = 1; i <= 7; i++)
            {
                ClassTimetableSchoolTimeResponse ctst = new ClassTimetableSchoolTimeResponse
                {
                    HasSchoolTime1 = false,
                    SchoolTimeId1  = 0,
                    HasSchoolTime2 = false,
                    SchoolTimeId2  = 0,
                    IsChecked      = false,
                    WeekDay        = i
                };

                //当天时间段
                var currentDayTime = allClassTime
                                     .Where(x => x.WeekDay == i && x.Duration == firstClassTime.Duration)
                                     .OrderBy(x => x.BeginTime)
                                     .ToList();

                //第一节
                TblDatSchoolTime first = currentDayTime.FirstOrDefault(x =>
                                                                       x.Duration == firstClassTime.Duration &&
                                                                       x.BeginTime == firstClassTime.BeginTime &&
                                                                       x.EndTime == firstClassTime.EndTime);

                //该天没有此时间段
                if (first == null)
                {
                    res.WeekDaySchoolTimes.Add(ctst);
                    continue;
                }

                //第一节课基本数据
                ctst.HasSchoolTime1 = true;
                ctst.SchoolTimeId1  = first.SchoolTimeId;
                if (first.SchoolTimeId == firstClassTime.SchoolTimeId)
                {
                    ctst.IsChecked = true;
                }

                //第一节课时间段段是否占用
                if (alreadySchoolTimeIds.Any(x => x == first.SchoolTimeId))
                {
                    ctst.HasSchoolTime1 = false;
                    ctst.SchoolTimeId1  = 0;
                    res.WeekDaySchoolTimes.Add(ctst);
                    continue;
                }

                //第二节 是否能够与下一个时间段连上
                if (secondClassTime != null)
                {
                    TblDatSchoolTime second = currentDayTime.FirstOrDefault(x =>
                                                                            x.Duration == secondClassTime.Duration &&
                                                                            x.BeginTime == secondClassTime.BeginTime &&
                                                                            x.EndTime == secondClassTime.EndTime);

                    if (second != null)
                    {
                        if (!alreadySchoolTimeIds.Any(x => x == second.SchoolTimeId))
                        {
                            ctst.HasSchoolTime2 = true;
                            ctst.SchoolTimeId2  = second.SchoolTimeId;
                        }
                    }
                }
                res.WeekDaySchoolTimes.Add(ctst);
            }

            return(res);
        }