public async Task <IActionResult> Index() { var model = new GetScoresViewModel(); TeacherItemDto teacher = await GetTeacher(); model.Input.StudentId = null; model.Input.TeacherId = teacher.Id; if (!teacher.StudyGroups.IsNullOrEmpty()) { ViewBag.StudyGroups = new SelectList(teacher.StudyGroups, "Id", "Name"); model.Input.StudyGroupId = teacher.StudyGroups.First().Id; } if (model.Input.StudyGroupId.HasValue) { var resultGetStudents = await _studentService.GetStudents( new GetStudentsInput { StudyGroupId = model.Input.StudyGroupId }); if (resultGetStudents.IsSuccessed) { model.Students = resultGetStudents.Value.Items.ToList(); } } var dateTime = DateTime.Now; model.Input.DateString = $"01." + $"{(dateTime.Month < 10 ? "0" + dateTime.Month.ToString() : dateTime.Month.ToString())}." + $"{dateTime.Year}"; var daysInMonth = DateTime.DaysInMonth(model.Input.Date.Value.Year, model.Input.Date.Value.Month); var days = new List <DayItemDto>(); for (int i = 0; i < daysInMonth; i++) { var dayItem = new DayItemDto { DayInMonth = i + 1, DateTime = new DateTime(model.Input.Date.Value.Year, model.Input.Date.Value.Month, i + 1) }; dayItem.DateString = $"{(dayItem.DateTime.Day < 10 ? "0" + dayItem.DateTime.Day.ToString() : dayItem.DateTime.Day.ToString())}." + $"{(dayItem.DateTime.Month < 10 ? "0" + dayItem.DateTime.Month.ToString() : dayItem.DateTime.Month.ToString())}." + $"{dayItem.DateTime.Year}"; days.Add(dayItem); } model.Days = days; if (teacher.AcademicSubject != null) { model.AcademicSubject = teacher.AcademicSubject; } var result = await _scoreService.GetScores(model.Input); if (result.IsSuccessed) { model.Value = result.Value; } return(View(model)); }
public ActionResult StudentCourseArrange(string studentId = "", string yearMonth = "") { ViewBag.ActiveMenu = "ArrangeCourse"; var categorys = _categoryAppService.GetAllCategorys(); ViewBag.ClassType = categorys.Where(c => c.CategoryType == "ClassType").ToList().CreateSelect("CategoryName", "Id", ""); ViewBag.CourseType = categorys.Where(c => c.CategoryType == "CourseType").ToList().CreateSelect("CategoryName", "Id", ""); ViewBag.CourseAddressType = categorys.Where(c => c.CategoryType == "CourseAddressType").ToList().CreateSelect("CategoryName", "Id", ""); var courseArrangeData = new ListResultDto <StudentCourseArrangeListDto>(); var now = DateTime.Now; yearMonth = string.IsNullOrEmpty(yearMonth) ? string.Format("{0}-{1}", now.Year, now.Month) : yearMonth; if (!string.IsNullOrEmpty(yearMonth)) { string[] yearMonthArr = yearMonth.Split('-'); int year = Convert.ToInt32(yearMonthArr[0]); int month = Convert.ToInt32(yearMonthArr[1]); ViewBag.YearMonth = new DateTime(year, month, 01, 00, 00, 00); if (!string.IsNullOrEmpty(studentId)) { courseArrangeData = _studentCourseArrangeAppService.GetArranages(new StudentCourseArrangeInput() { StudentId = studentId, BeginTime = new DateTime(year, month, 01, 00, 00, 00), EndTime = new DateTime(year, month + 1, 01, 00, 00, 00) }); } else { courseArrangeData = _studentCourseArrangeAppService.GetArranages(new StudentCourseArrangeInput() { BeginTime = new DateTime(year, month, 01, 00, 00, 00), EndTime = new DateTime(year, month + 1, 01, 00, 00, 00) }); } } var students = _studentAppService.GetStudents().Items; ViewBag.Students = students; string stuName = string.Empty; if (!string.IsNullOrEmpty(studentId)) { var stu = students.Where(t => t.Id == studentId).FirstOrDefault(); if (stu != null) { stuName = stu.CnName; } } ViewBag.StudentName = stuName; ViewBag.CourseArranges = courseArrangeData; return(View("~/Views/CourseArrange/StudentCourseArrange/StudentCourseArrange.cshtml")); }
public async Task <IActionResult> Index() { var returnUrl = NormalizeReturnUrl(null); var model = new GetStudentsViewModel { ReturnUrl = returnUrl }; model.Input.StudyGroupId = null; var resultGetStudyGroups = await _studyGroupService.GetStudyGroups(new GetStudyGroupsInput()); if (resultGetStudyGroups.IsSuccessed) { ViewBag.StudyGroups = new SelectList(resultGetStudyGroups.Value.Items, "Id", "Name"); } var result = await _studentService.GetStudents(model.Input); if (result.IsSuccessed) { model.Value = result.Value; } return(View(model)); }
private void SetOtherExtendData(IEnumerable <SignInListDto> list) { if (list != null && list.Any()) { // var categoryData = _categorysAppService.GetCategorysPageListBy(new CategorysInput { }); var students = _studentAppService.GetStudents(); StudentListDto studentModel = new StudentListDto(); foreach (var item in list) { if (!string.IsNullOrEmpty(item.ClassType) && categoryData.Any(c => c.Id == item.ClassType)) { item.ClassTypeName = categoryData.FirstOrDefault(c => c.Id == item.ClassType).CategoryName; } if (!string.IsNullOrEmpty(item.Type) && categoryData.Any(c => c.Id == item.Type)) { item.TypeName = categoryData.FirstOrDefault(c => c.Id == item.Type).CategoryName; } if (!string.IsNullOrEmpty(item.CourseType) && categoryData.Any(c => c.Id == item.CourseType)) { item.CourseTypeName = categoryData.FirstOrDefault(c => c.Id == item.CourseType).CategoryName; } if (!string.IsNullOrEmpty(item.UnNormalType) && categoryData.Any(c => c.Id == item.UnNormalType)) { item.UnNormalTypeName = categoryData.FirstOrDefault(c => c.Id == item.UnNormalType).CategoryName; } if (!string.IsNullOrEmpty(item.CourseAddressType) && categoryData.Any(c => c.Id == item.CourseAddressType)) { item.CourseAddressTypeName = categoryData.FirstOrDefault(c => c.Id == item.CourseAddressType).CategoryName; } var studentIds = item.StudentId.Split(','); string stuName = string.Empty; foreach (var stu in studentIds) { studentModel = students.Items.FirstOrDefault(s => s.Id == stu); if (studentModel != null && !string.IsNullOrEmpty(studentModel.Id)) { stuName += students.Items.FirstOrDefault(s => s.Id == stu).CnName + ","; } } item.StudentName = stuName.TrimEnd(','); } } }
public async Task <Result <ListResultDto <ScoreItemDto> > > GetScores(GetScoresInput input) { var query = _academicSubjectScoreRepository.GetAll(); var scores = await query.ToListAsync(); if (input.StudentId.HasValue) { scores = scores.Where(score => score.StudentId == input.StudentId.Value).ToList(); } if (input.TeacherId.HasValue) { scores = scores.Where(score => score.TeacherId == input.TeacherId.Value).ToList(); } if (input.Date.HasValue) { scores = scores.Where(score => score.Date.Month == input.Date.Value.Month && score.Date.Year == input.Date.Value.Year).ToList(); } if (input.StudyGroupId.HasValue) { var resultGetStudents = await _studentService.GetStudents(new GetStudentsInput { StudyGroupId = input.StudyGroupId }); if (resultGetStudents.IsSuccessed) { var students = resultGetStudents.Value; scores = (from score in scores from student in students.Items where score.StudentId == student.Id select score).ToList(); } } var scoreDtos = new List <ScoreItemDto>(); foreach (var score in scores) { var scoreDto = await MapEntityToEntityDto(score); scoreDtos.Add(scoreDto); } return(Result <ListResultDto <ScoreItemDto> > .Success(new ListResultDto <ScoreItemDto>(scoreDtos))); }
private void SetOtherExtendData(IEnumerable <TeacherCourseArrangeListDto> list) { if (list != null && list.Any()) { var students = _studentAppService.GetStudents(); StudentListDto studentModel = new StudentListDto(); foreach (var item in list) { var studentIds = item.StudentId.Split(','); string stuName = string.Empty; foreach (var stu in studentIds) { studentModel = students.Items.FirstOrDefault(s => s.Id == stu); if (studentModel != null && !string.IsNullOrEmpty(studentModel.Id)) { stuName += students.Items.FirstOrDefault(s => s.Id == stu).CnName + ","; } } item.StudentName = stuName.TrimEnd(','); } } }
public async Task <IActionResult> Index() { var model = new GetRatingViewModel(); var student = await GetStudent(); if (student.StudyGroup != null) { var resultGetStudents = await _studentService.GetStudents(new GetStudentsInput { StudyGroupId = student.StudyGroup.Id }); if (resultGetStudents.IsSuccessed) { foreach (var stud in resultGetStudents.Value.Items) { var studentRating = new StudentRatingViewModel(); studentRating.Student = stud; var resultGetScores = await _scoreService.GetScores(new GetScoresInput() { StudentId = stud.Id }); if (resultGetScores.IsSuccessed) { var scores = resultGetScores.Value.Items; float ratingScore = 0; foreach (var score in scores) { ratingScore += score.Score; } studentRating.Score = ratingScore / scores.Count; model.StudentRatings.Add(studentRating); } } } model.StudentRatings = model.StudentRatings.OrderByDescending(rating => rating.Score).ToList(); } return(View(model)); }
/// <summary> /// 统计各个学生当前月需要上课多少个小时 以及续学学生 /// </summary> /// <param name="input"></param> /// <param name="result"></param> /// <param name="vm"></param> private void CountUpStudentCourses(ClassHourStatisticsInput input, IReadOnlyList <ClassHourStatisticsOutput> result, PayCalculationViewModel vm) { var result2DealAbsentFee = from p in result where p.BeginTime > input.BeginTime && p.EndTime <= input.EndTime select p; var allGroupHours = from p in result2DealAbsentFee group p by p.StudentId into g select new PayCalculation2StuViewModel { TotalDuration = g.Sum(r => r.Duration), StudentId = g.Key }; var allGroupAbsentHours = from p in result2DealAbsentFee where p.UnNormalType == CourseManagerConsts.StudentNoCourseReasonType //学生请假 group p by p.StudentId into g select new PayCalculation2StuViewModel { TotalDuration = g.Sum(r => r.Duration), StudentId = g.Key }; var absentHoursFee = new Dictionary <string, PayCalculation2StuViewModel>(); var renewFee = new List <string>();//续学记录 var stus = _cacheManager.GetCache("ControllerCache").Get("AllStudents", () => _studentAppService.GetStudents().Items); // var stus = _studentAppService.GetStudents().Items; foreach (var item in allGroupHours) { foreach (var absent in allGroupAbsentHours) { if (absent.StudentId == item.StudentId) { var realDutaion = item.TotalDuration - absent.TotalDuration; var ruleBasicDuration = item.TotalDuration * 0.8M; //合同规定的基数 //续学 if (realDutaion >= CourseManagerConsts.RenewHours * 60) // { renewFee.Add(stus.SingleOrDefault(s => s.Id == item.StudentId).CnName); } //学生请假次数太多 if (ruleBasicDuration > realDutaion) { absentHoursFee.Add( stus.SingleOrDefault(s => s.Id == item.StudentId).CnName, new PayCalculation2StuViewModel { StudentId = item.StudentId, TotalDuration = decimal.Round(ruleBasicDuration.Value / 60, 1), RealDuration = decimal.Round(realDutaion.Value / 60, 1), Balance = decimal.Round((ruleBasicDuration.Value - realDutaion.Value) / 60, 1) * CourseManagerConsts.One2OneClassFees * 0.8M } ); } } } } vm.StudentAbsentFees = 0.0M; vm.StudentAbsentFeeDes = string.Empty; foreach (KeyValuePair <string, PayCalculation2StuViewModel> kvp in absentHoursFee) { var model = kvp.Value; vm.StudentAbsentFees += model.Balance; vm.StudentAbsentFeeDes += string.Format("学生{0}应上至少{1}h 实上{2}h ,需按照课时费80%付费{3}\r\n", kvp.Key, model.TotalDuration, model.RealDuration, model.Balance);//因请假未到到80%应上课时 } vm.RenewNum = renewFee.Count; vm.RenewFee = vm.RenewNum > 0 ? vm.RenewNum * CourseManagerConsts.RenewBonus : 0; }