コード例 #1
0
        private readonly List <TblDatSchoolTime> _classTimeList;      //班级上课时间段集合

        /// <summary>
        /// 描述:实例化一个班级上课时间课次调整生产者
        /// </summary>
        /// <param name="request">要调整的时间段信息</param>
        /// <param name="adjustLessonList">课次调整信息表信息</param>
        /// <param name="lessonList">要销毁的课次</param>
        /// <param name="classTimeList">班级上课时间段</param>
        public AdjustLessonClassTimeCreator(AdjustClassTimeRequest request, List <TblTimAdjustLesson> adjustLessonList, List <TblTimLesson> lessonList, List <TblDatSchoolTime> classTimeList)
        {
            _request             = request;
            _adjustLessonList    = adjustLessonList;
            _lessonList          = lessonList;
            _normalLessonList    = this.GetNormalLessonList();
            _replenishLessonList = this.GetRelenishLessonList();
            _classTimeList       = classTimeList;
        }
コード例 #2
0
        /// <summary>
        /// 描述:向课次调整信息表添加记录
        /// <para>作   者:瞿琦</para>
        /// <para>创建时间:2019-3-8</para>
        /// </summary>
        /// <param name="request">要保存的课次调整信息</param>
        /// <param name="timLessonList">要调整的课次列表</param>
        /// <param name="classTimeList">上课时间段集合</param>
        /// <param name="unitOfWork">事务</param>
        /// <returns>添加到数据库的课次调整表数据</returns>
        private List <TblTimAdjustLesson> AddAdjustLessonInfo(AdjustClassTimeRequest request, List <TblTimLesson> timLessonList, List <TblDatSchoolTime> classTimeList, UnitOfWork unitOfWork)
        {
            var adjustLessonList = new List <TblTimAdjustLesson>();
            var batchNo          = IdGenerator.NextId();

            foreach (var totalItem in timLessonList)
            {
                //开始上课时间
                var beginTime = request.NewClassBeginTime;
                //时间间隔
                var timeInterval      = 0;
                var studentLessonList = timLessonList.Where(x => x.ClassId == totalItem.ClassId && x.ClassDate == totalItem.ClassDate && x.StudentId == totalItem.StudentId);
                foreach (var studentLessonItem in studentLessonList)
                {
                    var dateBeginTime = DateTime.Parse($"{request.NewClassDate:yyyy-MM-dd} {beginTime}");
                    var classEndTime  = dateBeginTime.AddMinutes(classTimeList.FirstOrDefault().Duration);

                    var adjuseLessonEntity = new TblTimAdjustLesson
                    {
                        AdjustLessonId = IdGenerator.NextId(),
                        BatchNo        = batchNo,
                        BusinessType   = (int)LessonBusinessType.AdjustLessonClassTime,
                        ClassDate      = request.NewClassDate,                        //调整后的上课日期
                        ClassBeginTime = beginTime,                                   //调整后的上课时间
                        ClassEndTime   = classEndTime.ToShortTimeString().ToString(), //调整后的下课时间
                        ClassId        = studentLessonItem.ClassId,
                        ClassRoomId    = studentLessonItem.ClassRoomId,
                        FromLessonId   = studentLessonItem.LessonId,
                        FromTeacherId  = studentLessonItem.TeacherId,
                        SchoolTimeId   = 0, //此次业务是自定义时间段,为0
                        SchoolId       = studentLessonItem.SchoolId,
                        StudentId      = studentLessonItem.StudentId,
                        ToTeacherId    = studentLessonItem.TeacherId,
                        Status         = (int)TimAdjustLessonStatus.Normal,
                        Remark         = EnumName.GetDescription(typeof(LessonBusinessType), (int)LessonBusinessType.AdjustLessonClassTime),
                        CreateTime     = DateTime.Now
                    };
                    adjustLessonList.Add(adjuseLessonEntity);

                    if (classTimeList.Count > 1)
                    {
                        var lessonTime1 = DateTime.Parse($"{request.NewClassDate:yyyy-MM-dd} {classTimeList[0].EndTime}");
                        var lessonTime2 = DateTime.Parse($"{request.NewClassDate:yyyy-MM-dd} {classTimeList[1].BeginTime}");

                        timeInterval = (int)(lessonTime2 - lessonTime1).TotalMinutes;
                    }
                    beginTime = classEndTime.AddMinutes(timeInterval).ToShortTimeString().ToString();
                }
            }
            unitOfWork.GetCustomRepository <TblTimAdjustLessonRepository, TblTimAdjustLesson>().Add <TblTimAdjustLesson>(adjustLessonList);
            return(adjustLessonList);
        }
コード例 #3
0
        public void AdjustClassTime([FromBody] AdjustClassTimeRequest request)
        {
            var service = new AdjustLessonClassTimeService(base.SchoolId);

            service.Adjust(request);
        }