public async Task <MessageModel <PageModel <Teacher> > > Get(int page = 1, string key = "") { if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key)) { key = ""; } else { page = 1; } int intPageSize = 50; var data = await _iTeacherRepository.QueryPage(a => (a.IsDeleted == false && (a.Name != null && a.Name.Contains(key))) && (a.gradeId == GID || (GID == -9999 && true)), page, intPageSize, " Id asc "); var cctList = await _iCCTRepository.Query(d => d.IsDeleted == false); var gradeList = await _iGradeRepository.Query(d => d.IsDeleted == false); var clazzList = await _iClazzRepository.Query(d => d.IsDeleted == false); var coureseList = await _iCourseRepository.Query(d => d.IsDeleted == false); foreach (var item in cctList) { item.grade = gradeList.Where(d => d.Id == item.gradeid).FirstOrDefault(); item.clazz = clazzList.Where(d => d.Id == item.clazzid).FirstOrDefault(); item.course = coureseList.Where(d => d.Id == item.courseid).FirstOrDefault(); } foreach (var item in data.data) { item.cct = cctList.Where(d => d.teacherid == item.Id).ToList(); item.gradeId = (item.cct.FirstOrDefault()?.gradeid).ObjToInt(); item.courseId = (item.cct.FirstOrDefault()?.courseid).ObjToInt(); item.clazzIds = item.cct.Select(d => d.clazzid).ToArray(); } return(new MessageModel <PageModel <Teacher> >() { msg = "获取成功", success = data.dataCount >= 0, response = data }); }
public async Task <MessageModel <PageModel <FSN> > > Get(int GradeId, string AcademicYearSchoolTerm, string ExamName, int fsn, int ClazzId, int page = 1) { int intPageSize = 100; if (!(GradeId > 0 && !string.IsNullOrEmpty(AcademicYearSchoolTerm) && !string.IsNullOrEmpty(ExamName))) { return(new MessageModel <PageModel <FSN> >()); } var exScoreList = await _iExScoreRepository.Query(d => d.IsDeleted == false); var gradeList = await _iGradeRepository.Query(d => d.IsDeleted == false && d.Id == GradeId); var clazzList = await _iClazzRepository.Query(d => d.IsDeleted == false && d.GradeId == GradeId); var courseList = await _iCourseRepository.Query(d => d.IsDeleted == false); var examList = await _iExamRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var studentsList = await _iStudentsRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var cctList = await _iCCTRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var teachersList = await _iTeacherRepository.Query(d => d.IsDeleted == false && d.gradeId == GradeId); foreach (var item in examList) { item.grade = gradeList.Where(d => d.Id == item.gradeid).FirstOrDefault(); item.course = courseList.Where(d => d.Id == item.courseid).FirstOrDefault(); } foreach (var exscore in exScoreList) { exscore.exam = examList.Where(d => d.Id == exscore.examid).FirstOrDefault(); var teacherid = cctList.Where(d => d.clazzid == exscore.clazzid && d.gradeid == exscore.exam.gradeid && d.courseid == exscore.exam.courseid).FirstOrDefault()?.teacherid; exscore.Teacher = teachersList.Where(d => d.Id == teacherid.ObjToInt()).FirstOrDefault()?.Name; exscore.clazz = clazzList.Where(d => d.Id == exscore.clazzid).FirstOrDefault(); exscore.student = studentsList.Where(d => d.Id == exscore.studentid).FirstOrDefault(); } exScoreList = exScoreList.Where(d => (d.exam != null && d.exam.grade != null && d.exam.grade.Id == GID || (GID == -9999 && true))).ToList(); if (GradeId > 0) { exScoreList = exScoreList.Where(d => d.exam != null && d.exam.grade != null && d.exam.gradeid == GradeId).ToList(); } if (!string.IsNullOrEmpty(AcademicYearSchoolTerm)) { exScoreList = exScoreList.Where(d => d.exam != null && d.exam.grade != null && AcademicYearSchoolTerm == (d.exam.AcademicYear + d.exam.SchoolTerm)).ToList(); } if (!string.IsNullOrEmpty(ExamName)) { exScoreList = exScoreList.Where(d => d.exam != null && d.exam.grade != null && d.exam.ExamName == ExamName).ToList(); } List <FSN> FSNs = new List <FSN>(); foreach (var item in studentsList) { var clazzModel = clazzList.Where(d => d.Id == item.clazzid).FirstOrDefault(); var exscoreStudentList = exScoreList.Where(d => d.studentid == item.Id).ToList(); FSN fSN = new FSN() { StudentNo = item.StudentNo, StudentName = item.Name, Clazz = clazzModel.ClassNo, ClazzId = clazzModel.Id, SubjectA = item.SubjectA, SubjectB = item.SubjectB, Chinese = exscoreStudentList.Where(d => d.exam.course.Name == "语文").FirstOrDefault().score, Meth = exscoreStudentList.Where(d => d.exam.course.Name == "数学").FirstOrDefault().score, English = exscoreStudentList.Where(d => d.exam.course.Name == "英语").FirstOrDefault().score, Physics = exscoreStudentList.Where(d => d.exam.course.Name == "物理").FirstOrDefault().score, Chemistry = exscoreStudentList.Where(d => d.exam.course.Name == "化学").FirstOrDefault().score, Politics = exscoreStudentList.Where(d => d.exam.course.Name == "政治").FirstOrDefault().score, History = exscoreStudentList.Where(d => d.exam.course.Name == "历史").FirstOrDefault().score, Biology = exscoreStudentList.Where(d => d.exam.course.Name == "生物").FirstOrDefault().score, Geography = exscoreStudentList.Where(d => d.exam.course.Name == "地理").FirstOrDefault().score, }; fSN.T = fSN.Chinese + fSN.Chinese + fSN.Chinese; if (fSN.SubjectA == "物理") { fSN.F = fSN.T + fSN.Physics; } else if (fSN.SubjectA == "历史") { fSN.F = fSN.T + fSN.History; } fSN.S += fSN.F; switch (fSN.SubjectB) { case "1": fSN.S = fSN.Chemistry + fSN.Biology; break; case "2": fSN.S = fSN.Chemistry + fSN.Politics; break; case "3": fSN.S = fSN.Chemistry + fSN.Geography; break; case "4": fSN.S = fSN.Politics + fSN.Biology; break; case "5": fSN.S = fSN.Geography + fSN.Biology; break; case "6": fSN.S = fSN.Politics + fSN.Geography; break; case "7": fSN.S = fSN.Politics + fSN.Geography; break; case "8": fSN.S = fSN.Politics + fSN.Chemistry; break; case "9": fSN.S = fSN.Politics + fSN.Biology; break; case "10": fSN.S = fSN.Geography + fSN.Chemistry; break; case "11": fSN.S = fSN.Geography + fSN.Biology; break; case "12": fSN.S = fSN.Chemistry + fSN.Biology; break; default: break; } fSN.N = fSN.Chinese + fSN.Meth + fSN.English + fSN.Physics + fSN.Chemistry + fSN.Biology + fSN.Politics + fSN.History + fSN.Geography; FSNs.Add(fSN); } { FSNs = FSNs.OrderByDescending(d => d.Chinese).ToList(); for (int i = 0; i < FSNs.Count; i++) { FSNs[i].ChineseSort = i + 1; } FSNs = FSNs.OrderByDescending(d => d.Meth).ToList(); for (int i = 0; i < FSNs.Count; i++) { FSNs[i].MethSort = i + 1; } FSNs = FSNs.OrderByDescending(d => d.English).ToList(); for (int i = 0; i < FSNs.Count; i++) { FSNs[i].EnglishSort = i + 1; } FSNs = FSNs.OrderByDescending(d => d.Physics).ToList(); for (int i = 0; i < FSNs.Count; i++) { FSNs[i].PhysicsSort = i + 1; } FSNs = FSNs.OrderByDescending(d => d.Chemistry).ToList(); for (int i = 0; i < FSNs.Count; i++) { FSNs[i].ChemistrySort = i + 1; } FSNs = FSNs.OrderByDescending(d => d.Politics).ToList(); for (int i = 0; i < FSNs.Count; i++) { FSNs[i].PoliticsSort = i + 1; } FSNs = FSNs.OrderByDescending(d => d.History).ToList(); for (int i = 0; i < FSNs.Count; i++) { FSNs[i].HistorySort = i + 1; } FSNs = FSNs.OrderByDescending(d => d.Biology).ToList(); for (int i = 0; i < FSNs.Count; i++) { FSNs[i].BiologySort = i + 1; } FSNs = FSNs.OrderByDescending(d => d.Geography).ToList(); for (int i = 0; i < FSNs.Count; i++) { FSNs[i].GeographySort = i + 1; } FSNs = FSNs.OrderByDescending(d => d.T).ToList(); for (int i = 0; i < FSNs.Count; i++) { FSNs[i].TSort = i + 1; } FSNs = FSNs.OrderByDescending(d => d.F).ToList(); for (int i = 0; i < FSNs.Count; i++) { FSNs[i].FSort = i + 1; } FSNs = FSNs.OrderByDescending(d => d.S).ToList(); for (int i = 0; i < FSNs.Count; i++) { FSNs[i].SSort = i + 1; } FSNs = FSNs.OrderByDescending(d => d.N).ToList(); for (int i = 0; i < FSNs.Count; i++) { FSNs[i].NSort = i + 1; } } if (ClazzId > 0) { FSNs = FSNs.Where(d => d.ClazzId == ClazzId).ToList(); } var totalCount = FSNs.Count; int pageCount = (Math.Ceiling(totalCount.ObjToDecimal() / intPageSize.ObjToDecimal())).ObjToInt(); var exScores = FSNs.Skip((page - 1) * intPageSize).Take(intPageSize).ToList(); PageModel <FSN> data = new PageModel <FSN>() { data = exScores, dataCount = totalCount, page = page, pageCount = pageCount, PageSize = intPageSize }; return(new MessageModel <PageModel <FSN> >() { msg = "获取成功", success = data.dataCount >= 0, response = data }); }
public async Task <MessageModel <PageModel <FSNStudent> > > Get(int GradeId, string AcademicYearSchoolTerm, string ExamName, int FSNStudent, int ClazzId, int page = 1) { int intPageSize = 100; if (!(GradeId > 0 && ClazzId > 0 && !string.IsNullOrEmpty(AcademicYearSchoolTerm) && !string.IsNullOrEmpty(ExamName))) { return(new MessageModel <PageModel <FSNStudent> >()); } var exScoreList = await _iExScoreRepository.Query(d => d.IsDeleted == false); var gradeList = await _iGradeRepository.Query(d => d.IsDeleted == false && d.Id == GradeId); var clazzList = await _iClazzRepository.Query(d => d.IsDeleted == false && d.GradeId == GradeId); var courseList = await _iCourseRepository.Query(d => d.IsDeleted == false); var examList = await _iExamRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var studentsList = await _iStudentsRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var cctList = await _iCCTRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var teachersList = await _iTeacherRepository.Query(d => d.IsDeleted == false && d.gradeId == GradeId); foreach (var item in examList) { item.grade = gradeList.Where(d => d.Id == item.gradeid).FirstOrDefault(); item.course = courseList.Where(d => d.Id == item.courseid).FirstOrDefault(); } foreach (var exscore in exScoreList) { exscore.exam = examList.Where(d => d.Id == exscore.examid).FirstOrDefault(); var teacherid = cctList.Where(d => d.clazzid == exscore.clazzid && d.gradeid == exscore.exam.gradeid && d.courseid == exscore.exam.courseid).FirstOrDefault()?.teacherid; exscore.Teacher = teachersList.Where(d => d.Id == teacherid.ObjToInt()).FirstOrDefault()?.Name; exscore.clazz = clazzList.Where(d => d.Id == exscore.clazzid).FirstOrDefault(); exscore.student = studentsList.Where(d => d.Id == exscore.studentid).FirstOrDefault(); } if (GradeId > 0) { exScoreList = exScoreList.Where(d => d.exam != null && d.exam.grade != null && d.exam.gradeid == GradeId).ToList(); } if (!string.IsNullOrEmpty(AcademicYearSchoolTerm)) { exScoreList = exScoreList.Where(d => d.exam != null && d.exam.grade != null && AcademicYearSchoolTerm == (d.exam.AcademicYear + d.exam.SchoolTerm)).ToList(); } if (!string.IsNullOrEmpty(ExamName)) { exScoreList = exScoreList.Where(d => d.exam != null && d.exam.grade != null && d.exam.ExamName == ExamName).ToList(); } List <FSNStudent> FSNStudents = new List <FSNStudent>(); foreach (var item in studentsList) { var clazzModel = clazzList.Where(d => d.Id == item.clazzid).FirstOrDefault(); var exscoreStudentList = exScoreList.Where(d => d.studentid == item.Id).ToList(); FSNStudent FSNStudentModel = new FSNStudent() { StudentNo = item.StudentNo, StudentName = item.Name, Clazz = clazzModel.ClassNo, ClazzId = clazzModel.Id, SubjectA = item.SubjectA, SubjectB = item.SubjectB, Chinese = (exscoreStudentList.Where(d => d.exam.course.Name == "语文").FirstOrDefault()?.score).ObjToInt(), Meth = (exscoreStudentList.Where(d => d.exam.course.Name == "数学").FirstOrDefault()?.score).ObjToInt(), English = (exscoreStudentList.Where(d => d.exam.course.Name == "英语").FirstOrDefault()?.score).ObjToInt(), Physics = (exscoreStudentList.Where(d => d.exam.course.Name == "物理").FirstOrDefault()?.score).ObjToInt(), Chemistry = (exscoreStudentList.Where(d => d.exam.course.Name == "化学").FirstOrDefault()?.score).ObjToInt(), Politics = (exscoreStudentList.Where(d => d.exam.course.Name == "政治").FirstOrDefault()?.score).ObjToInt(), History = (exscoreStudentList.Where(d => d.exam.course.Name == "历史").FirstOrDefault()?.score).ObjToInt(), Biology = (exscoreStudentList.Where(d => d.exam.course.Name == "生物").FirstOrDefault()?.score).ObjToInt(), Geography = (exscoreStudentList.Where(d => d.exam.course.Name == "地理").FirstOrDefault()?.score).ObjToInt(), }; FSNStudentModel.T = FSNStudentModel.Chinese + FSNStudentModel.Chinese + FSNStudentModel.Chinese; if (FSNStudentModel.SubjectA == "物理") { FSNStudentModel.F = FSNStudentModel.T + FSNStudentModel.Physics; } else if (FSNStudentModel.SubjectA == "历史") { FSNStudentModel.F = FSNStudentModel.T + FSNStudentModel.History; } FSNStudentModel.S += FSNStudentModel.F; switch (FSNStudentModel.SubjectB) { case "1": FSNStudentModel.S = FSNStudentModel.Chemistry + FSNStudentModel.Biology; break; case "2": FSNStudentModel.S = FSNStudentModel.Chemistry + FSNStudentModel.Politics; break; case "3": FSNStudentModel.S = FSNStudentModel.Chemistry + FSNStudentModel.Geography; break; case "4": FSNStudentModel.S = FSNStudentModel.Politics + FSNStudentModel.Biology; break; case "5": FSNStudentModel.S = FSNStudentModel.Geography + FSNStudentModel.Biology; break; case "6": FSNStudentModel.S = FSNStudentModel.Politics + FSNStudentModel.Geography; break; case "7": FSNStudentModel.S = FSNStudentModel.Politics + FSNStudentModel.Geography; break; case "8": FSNStudentModel.S = FSNStudentModel.Politics + FSNStudentModel.Chemistry; break; case "9": FSNStudentModel.S = FSNStudentModel.Politics + FSNStudentModel.Biology; break; case "10": FSNStudentModel.S = FSNStudentModel.Geography + FSNStudentModel.Chemistry; break; case "11": FSNStudentModel.S = FSNStudentModel.Geography + FSNStudentModel.Biology; break; case "12": FSNStudentModel.S = FSNStudentModel.Chemistry + FSNStudentModel.Biology; break; default: break; } FSNStudentModel.N = FSNStudentModel.Chinese + FSNStudentModel.Meth + FSNStudentModel.English + FSNStudentModel.Physics + FSNStudentModel.Chemistry + FSNStudentModel.Biology + FSNStudentModel.Politics + FSNStudentModel.History + FSNStudentModel.Geography; FSNStudents.Add(FSNStudentModel); } if (ClazzId > 0) { FSNStudents = FSNStudents.Where(d => d.ClazzId == ClazzId).ToList(); } var totalCount = FSNStudents.Count; int pageCount = (Math.Ceiling(totalCount.ObjToDecimal() / intPageSize.ObjToDecimal())).ObjToInt(); var exScores = FSNStudents.Skip((page - 1) * intPageSize).Take(intPageSize).ToList(); PageModel <FSNStudent> data = new PageModel <FSNStudent>() { data = exScores, dataCount = totalCount, page = page, pageCount = pageCount, PageSize = intPageSize }; return(new MessageModel <PageModel <FSNStudent> >() { msg = "获取成功", success = data.dataCount >= 0, response = data }); }
public async Task <MessageModel <PageModel <Objective> > > Get(int GradeId, string AcademicYearSchoolTerm, string ExamName, int CourseId, int ClazzId, int page = 1) { int intPageSize = 100; if (!(GradeId > 0 && CourseId > 0 && !string.IsNullOrEmpty(AcademicYearSchoolTerm) && !string.IsNullOrEmpty(ExamName))) { return(new MessageModel <PageModel <Objective> >()); } var gradeList = await _iGradeRepository.Query(d => d.IsDeleted == false && d.Id == GradeId); var clazzList = await _iClazzRepository.Query(d => d.IsDeleted == false && d.GradeId == GradeId); var courseList = await _iCourseRepository.Query(d => d.IsDeleted == false); var examList = await _iExamRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var studentsList = await _iStudentsRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var cctList = await _iCCTRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var teachersList = await _iTeacherRepository.Query(d => d.IsDeleted == false && d.gradeId == GradeId); var examDetailList = await _iExamDetailRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId && d.EDType == "客观题"); var examDetailScoreList = await _iExamDetailScoreRepository.Query(d => d.IsDeleted == false); foreach (var item in examList) { item.grade = gradeList.Where(d => d.Id == item.gradeid).FirstOrDefault(); item.course = courseList.Where(d => d.Id == item.courseid).FirstOrDefault(); } foreach (var item in examDetailList) { item.exam = examList.Where(d => d.Id == item.examid).FirstOrDefault(); } //题目 examDetailList = examDetailList.Where(d => AcademicYearSchoolTerm == (d.exam.AcademicYear + d.exam.SchoolTerm) && d.exam.ExamName == ExamName && d.exam.gradeid == GradeId && d.exam.courseid == CourseId && d.courseid == CourseId).ToList(); // 如果选中班级,则是部分学生 if (ClazzId > 0) { studentsList = studentsList.Where(d => d.gradeid == GradeId && d.clazzid == ClazzId).ToList(); } var lookStudentIds = studentsList.Select(d => d.Id).ToList(); var studentCount = examDetailScoreList.Where(d => lookStudentIds.Contains(d.studentid)).Select(d => d.studentid).GroupBy(x => new { x }).Select(x => x.First()).Count(); List <Objective> objectives = new List <Objective>(); foreach (var item in examDetailList) { var examDetailScoreCurrent = examDetailScoreList.Where(d => d.ExamDetailId == item.Id & lookStudentIds.Contains(d.studentid)); Objective objective = new Objective() { Name = item.Name, Answer = item.Answer, A = examDetailScoreCurrent.Where(d => d.StudentAnswer == "A").Count(), B = examDetailScoreCurrent.Where(d => d.StudentAnswer == "B").Count(), C = examDetailScoreCurrent.Where(d => d.StudentAnswer == "C").Count(), D = examDetailScoreCurrent.Where(d => d.StudentAnswer == "D").Count(), AB = examDetailScoreCurrent.Where(d => d.StudentAnswer == "AB").Count(), ABC = examDetailScoreCurrent.Where(d => d.StudentAnswer == "ABC").Count(), ABCD = examDetailScoreCurrent.Where(d => d.StudentAnswer == "ABCD").Count(), AC = examDetailScoreCurrent.Where(d => d.StudentAnswer == "AC").Count(), ACD = examDetailScoreCurrent.Where(d => d.StudentAnswer == "ACD").Count(), AD = examDetailScoreCurrent.Where(d => d.StudentAnswer == "AD").Count(), BC = examDetailScoreCurrent.Where(d => d.StudentAnswer == "BC").Count(), BCD = examDetailScoreCurrent.Where(d => d.StudentAnswer == "BCD").Count(), BD = examDetailScoreCurrent.Where(d => d.StudentAnswer == "BD").Count(), CD = examDetailScoreCurrent.Where(d => d.StudentAnswer == "CD").Count(), NoWrite = 0, ReadCardCount = studentCount, TotalScore = item.Score * studentCount, StudentTotalScore = examDetailScoreCurrent.Select(d => d.StudentScore).Sum(), }; objective.NoWrite = studentCount - (objective.A + objective.B + objective.C + objective.D + objective.AB + objective.ABC + objective.ABCD + objective.AC + objective.ACD + objective.AD + objective.BC + objective.BCD + objective.BD + objective.CD); objective.TotalScoreRate = (((objective.StudentTotalScore / objective.TotalScore).ToString("#0.00")).ObjToDecimal()) * 100; objectives.Add(objective); } var totalCount = objectives.Count; int pageCount = (Math.Ceiling(totalCount.ObjToDecimal() / intPageSize.ObjToDecimal())).ObjToInt(); var exScores = objectives.Skip((page - 1) * intPageSize).Take(intPageSize).ToList(); PageModel <Objective> data = new PageModel <Objective>() { data = exScores, dataCount = totalCount, page = page, pageCount = pageCount, PageSize = intPageSize }; return(new MessageModel <PageModel <Objective> >() { msg = "获取成功", success = data.dataCount >= 0, response = data }); }
public async Task <MessageModel <ObjectiveStudent> > Get(int GradeId, string AcademicYearSchoolTerm, string ExamName, int CourseId, int ClazzId, int page = 1) { int intPageSize = 100; if (!(GradeId > 0 && CourseId > 0 && ClazzId > 0 && !string.IsNullOrEmpty(AcademicYearSchoolTerm) && !string.IsNullOrEmpty(ExamName))) { return(new MessageModel <ObjectiveStudent>()); } var gradeList = await _iGradeRepository.Query(d => d.IsDeleted == false && d.Id == GradeId); var clazzList = await _iClazzRepository.Query(d => d.IsDeleted == false && d.GradeId == GradeId); var courseList = await _iCourseRepository.Query(d => d.IsDeleted == false); var examList = await _iExamRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var studentsList = await _iStudentsRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var cctList = await _iCCTRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var teachersList = await _iTeacherRepository.Query(d => d.IsDeleted == false && d.gradeId == GradeId); //题目 var examDetailList = await _iExamDetailRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId && d.EDType == "客观题"); var examDetailScoreList = await _iExamDetailScoreRepository.Query(d => d.IsDeleted == false); foreach (var item in examList) { item.grade = gradeList.Where(d => d.Id == item.gradeid).FirstOrDefault(); item.course = courseList.Where(d => d.Id == item.courseid).FirstOrDefault(); } foreach (var item in examDetailList) { item.exam = examList.Where(d => d.Id == item.examid).FirstOrDefault(); } //题目 examDetailList = examDetailList.Where(d => AcademicYearSchoolTerm == (d.exam.AcademicYear + d.exam.SchoolTerm) && d.exam.ExamName == ExamName && d.exam.gradeid == GradeId && d.exam.courseid == CourseId && d.courseid == CourseId).ToList(); // 如果选中班级,则是部分学生 studentsList = studentsList.Where(d => d.gradeid == GradeId && d.clazzid == ClazzId).ToList(); StringBuilder jsonBuilder = new StringBuilder(); StringBuilder jsonBuilderHeader = new StringBuilder(); jsonBuilder.Append("["); jsonBuilderHeader.Append("["); jsonBuilderHeader.Append("{\"prop\": \"学号\", \"label\": \"学号\"},"); jsonBuilderHeader.Append("{\"prop\": \"姓名\", \"label\": \"姓名\"},"); jsonBuilderHeader.Append("{\"prop\": \"班级\", \"label\": \"班级\"},"); foreach (var item in studentsList) { var clazzModel = clazzList.Where(d => d.Id == item.clazzid).FirstOrDefault(); jsonBuilder.Append("{"); jsonBuilder.Append("\""); jsonBuilder.Append("学号"); jsonBuilder.Append("\":\""); jsonBuilder.Append(item.StudentNo.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); jsonBuilder.Append("\""); jsonBuilder.Append("姓名"); jsonBuilder.Append("\":\""); jsonBuilder.Append(item.Name.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); jsonBuilder.Append("\""); jsonBuilder.Append("班级"); jsonBuilder.Append("\":\""); jsonBuilder.Append(clazzModel.ClassNo.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); for (int j = 0; j < examDetailList.Count; j++) { var examDetailScore = examDetailScoreList.Where(d => d.ExamDetailId == examDetailList[j].Id && d.studentid == item.Id).FirstOrDefault(); jsonBuilder.Append("\""); jsonBuilder.Append(examDetailList[j].Name); jsonBuilder.Append("\":\""); jsonBuilder.Append(examDetailScore.StudentAnswer.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); } jsonBuilder.Remove(jsonBuilder.Length - 1, 1); jsonBuilder.Append("},"); } for (int j = 0; j < examDetailList.Count; j++) { jsonBuilderHeader.Append("{\"prop\": \"" + examDetailList[j].Name + "\", \"label\": \"" + examDetailList[j].Name + "\"},"); } jsonBuilder.Remove(jsonBuilder.Length - 1, 1); jsonBuilderHeader.Remove(jsonBuilderHeader.Length - 1, 1); jsonBuilder.Append("]"); jsonBuilderHeader.Append("]"); ObjectiveStudent objectiveStudent = new ObjectiveStudent() { Header = jsonBuilderHeader.ObjToString(), Content = jsonBuilder.ObjToString() }; return(new MessageModel <ObjectiveStudent>() { msg = "获取成功", success = true, response = objectiveStudent }); }
public async Task <MessageModel <PageModel <CourseScoreDistribute> > > Get(int GradeId, string AcademicYearSchoolTerm, string ExamName, int CourseId, int page = 1) { int intPageSize = 100; var exScoreList = await _iExScoreRepository.Query(d => d.IsDeleted == false); var gradeList = await _iGradeRepository.Query(d => d.IsDeleted == false && d.Id == GradeId); var clazzList = await _iClazzRepository.Query(d => d.IsDeleted == false && d.GradeId == GradeId); var courseList = await _iCourseRepository.Query(d => d.IsDeleted == false); var examList = await _iExamRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var studentsList = await _iStudentsRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var cctList = await _iCCTRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var teachersList = await _iTeacherRepository.Query(d => d.IsDeleted == false && d.gradeId == GradeId); foreach (var item in examList) { item.grade = gradeList.Where(d => d.Id == item.gradeid).FirstOrDefault(); item.course = courseList.Where(d => d.Id == item.courseid).FirstOrDefault(); } foreach (var exscore in exScoreList) { exscore.exam = examList.Where(d => d.Id == exscore.examid).FirstOrDefault(); var teacherid = cctList.Where(d => d.clazzid == exscore.clazzid && d.gradeid == exscore.exam.gradeid && d.courseid == exscore.exam.courseid).FirstOrDefault()?.teacherid; exscore.Teacher = teachersList.Where(d => d.Id == teacherid.ObjToInt()).FirstOrDefault()?.Name; exscore.clazz = clazzList.Where(d => d.Id == exscore.clazzid).FirstOrDefault(); exscore.student = studentsList.Where(d => d.Id == exscore.studentid).FirstOrDefault(); } exScoreList = exScoreList.Where(d => (d.exam != null && d.exam.grade != null && d.exam.grade.Id == GID || (GID == -9999 && true))).ToList(); if (GradeId > 0) { exScoreList = exScoreList.Where(d => d.exam != null && d.exam.grade != null && d.exam.gradeid == GradeId).ToList(); } if (!string.IsNullOrEmpty(AcademicYearSchoolTerm)) { exScoreList = exScoreList.Where(d => d.exam != null && d.exam.grade != null && AcademicYearSchoolTerm == (d.exam.AcademicYear + d.exam.SchoolTerm)).ToList(); } if (!string.IsNullOrEmpty(ExamName)) { exScoreList = exScoreList.Where(d => d.exam != null && d.exam.grade != null && d.exam.ExamName == ExamName).ToList(); } if (CourseId > 0) { exScoreList = exScoreList.Where(d => d.exam != null && d.exam.grade != null && d.courseid == CourseId).ToList(); } var clazzGroups = exScoreList.Select(d => new { d.clazzid, d.exam.gradeid }).ToList(); clazzGroups = clazzGroups.GroupBy(x => new { x.clazzid, x.gradeid }).Select(x => x.First()).ToList(); List <CourseScoreDistribute> courseScoreDistributes = new List <CourseScoreDistribute>(); foreach (var item in clazzGroups) { var exscore = exScoreList.Where(d => d.clazzid == item.clazzid && d.exam.gradeid == item.gradeid).ToList(); var examStuCount = (exscore.GroupBy(x => new { x.studentid }).Select(x => x.First()).Count()); var scores = exscore.Select(d => d.score).ToList(); CourseScoreDistribute courseScoreDistribute = new CourseScoreDistribute() { Clazz = exscore.FirstOrDefault().clazz.ClassNo, Teacher = exscore.FirstOrDefault().Teacher, ExamStuCount = examStuCount.ObjToString(), C140_150 = (exscore.Where(d => d.score >= 140 && d.score <= 150).Count()), C130_139 = (exscore.Where(d => d.score >= 130 && d.score < 140).Count()), C120_129 = (exscore.Where(d => d.score >= 120 && d.score < 130).Count()), C110_119 = (exscore.Where(d => d.score >= 110 && d.score < 120).Count()), C100_109 = (exscore.Where(d => d.score >= 100 && d.score < 110).Count()), C90_99 = (exscore.Where(d => d.score >= 90 && d.score < 100).Count()), C80_89 = (exscore.Where(d => d.score >= 80 && d.score < 90).Count()), C70_79 = (exscore.Where(d => d.score >= 70 && d.score < 80).Count()), C60_69 = (exscore.Where(d => d.score >= 60 && d.score < 70).Count()), C50_59 = (exscore.Where(d => d.score >= 50 && d.score < 60).Count()), C40_49 = (exscore.Where(d => d.score >= 40 && d.score < 50).Count()), C40_0 = (exscore.Where(d => d.score >= 0 && d.score < 40).Count()), C_Good = ((exscore.Where(d => d.score >= 120).Count())), C_Pass = ((exscore.Where(d => d.score >= 90).Count())), C_Good_Rate = ((((decimal)(exscore.Where(d => d.score >= 120).Count()) / (decimal)examStuCount).ToString("#0.00")).ObjToDecimal()) * 100, C_Pass_Rate = ((((decimal)(exscore.Where(d => d.score >= 90).Count()) / (decimal)examStuCount).ToString("#0.00")).ObjToDecimal()) * 100, C_Max = (scores.Max()), C_Min = (scores.Min()), C_Avg = (scores.Average().ToString("#0.00")).ObjToInt(), }; courseScoreDistributes.Add(courseScoreDistribute); } var totalCount = courseScoreDistributes.Count; int pageCount = (Math.Ceiling(totalCount.ObjToDecimal() / intPageSize.ObjToDecimal())).ObjToInt(); var exScores = courseScoreDistributes.Skip((page - 1) * intPageSize).Take(intPageSize).ToList(); PageModel <CourseScoreDistribute> data = new PageModel <CourseScoreDistribute>() { data = courseScoreDistributes, dataCount = courseScoreDistributes.Count, page = page, pageCount = pageCount, PageSize = intPageSize }; return(new MessageModel <PageModel <CourseScoreDistribute> >() { msg = "获取成功", success = data.dataCount >= 0, response = data }); }
public async Task <MessageModel <ObjectiveStudent> > Get(int GradeId, string AcademicYearSchoolTerm, string ExamName, int CourseId, int ClazzId, int page = 1) { int intPageSize = 100; if (!(GradeId > 0 && CourseId > 0 && ClazzId > 0 && !string.IsNullOrEmpty(AcademicYearSchoolTerm) && !string.IsNullOrEmpty(ExamName))) { return(new MessageModel <ObjectiveStudent>()); } var exScoreList = await _iExScoreRepository.Query(d => d.IsDeleted == false); var gradeList = await _iGradeRepository.Query(d => d.IsDeleted == false && d.Id == GradeId); var clazzList = await _iClazzRepository.Query(d => d.IsDeleted == false && d.GradeId == GradeId); var courseList = await _iCourseRepository.Query(d => d.IsDeleted == false); var examList = await _iExamRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var studentsList = await _iStudentsRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var cctList = await _iCCTRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var teachersList = await _iTeacherRepository.Query(d => d.IsDeleted == false && d.gradeId == GradeId); //题目 var examDetailList = await _iExamDetailRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var examDetailScoreList = await _iExamDetailScoreRepository.Query(d => d.IsDeleted == false); foreach (var item in examList) { item.grade = gradeList.Where(d => d.Id == item.gradeid).FirstOrDefault(); item.course = courseList.Where(d => d.Id == item.courseid).FirstOrDefault(); } foreach (var exscore in exScoreList) { exscore.exam = examList.Where(d => d.Id == exscore.examid).FirstOrDefault(); var teacherid = cctList.Where(d => d.clazzid == exscore.clazzid && d.gradeid == exscore.exam.gradeid && d.courseid == exscore.exam.courseid).FirstOrDefault()?.teacherid; exscore.Teacher = teachersList.Where(d => d.Id == teacherid.ObjToInt()).FirstOrDefault()?.Name; exscore.clazz = clazzList.Where(d => d.Id == exscore.clazzid).FirstOrDefault(); exscore.student = studentsList.Where(d => d.Id == exscore.studentid).FirstOrDefault(); } // 统计 全年级的 某次考试 全部科目的 全部成绩 var examSortAllCourse = exScoreList.Where(d => d.clazzid == ClazzId && AcademicYearSchoolTerm == (d.exam.AcademicYear + d.exam.SchoolTerm) && d.exam.ExamName == ExamName && d.exam.gradeid == GradeId).ToList(); // 统计 全年级的 某次考试 某门科目中 的全部成绩 var exscoreGrade = examSortAllCourse.Where(d => d.courseid == CourseId).ToList(); List <SingleCourseStudent> totalGradeSingleCourseStudents = new List <SingleCourseStudent>(); foreach (var item in exscoreGrade) { SingleCourseStudent SingleCourseStudent = new SingleCourseStudent() { StudentNo = item.student.StudentNo, StudentName = item.student.Name, TotalScore = item.score.ObjToDecimal(), SubjectiveScore = item.SubjectiveScore.ObjToDecimal(), ObjectiveScore = item.ObjectiveScore.ObjToDecimal(), Clazz = item.clazz.ClassNo, Clazzid = item.clazz.Id, }; totalGradeSingleCourseStudents.Add(SingleCourseStudent); } // 如果选中班级,则是部分学生 studentsList = studentsList.Where(d => d.gradeid == GradeId && d.clazzid == ClazzId).ToList(); StringBuilder jsonBuilder = new StringBuilder(); StringBuilder jsonBuilderHeader = new StringBuilder(); jsonBuilder.Append("["); jsonBuilderHeader.Append("["); jsonBuilderHeader.Append("{\"prop\": \"学号\", \"label\": \"学号\"},"); jsonBuilderHeader.Append("{\"prop\": \"姓名\", \"label\": \"姓名\"},"); jsonBuilderHeader.Append("{\"prop\": \"班级\", \"label\": \"班级\"},"); jsonBuilderHeader.Append("{\"prop\": \"主观分数\", \"label\": \"主观分数\"},"); jsonBuilderHeader.Append("{\"prop\": \"客观分数\", \"label\": \"客观分数\"},"); jsonBuilderHeader.Append("{\"prop\": \"总分数\", \"label\": \"总分数\"},"); foreach (var item in studentsList) { var clazzModel = clazzList.Where(d => d.Id == item.clazzid).FirstOrDefault(); var examdetailscoreModel = totalGradeSingleCourseStudents.Where(d => d.StudentNo == item.StudentNo).FirstOrDefault(); jsonBuilder.Append("{"); jsonBuilder.Append("\""); jsonBuilder.Append("学号"); jsonBuilder.Append("\":\""); jsonBuilder.Append(item.StudentNo.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); jsonBuilder.Append("\""); jsonBuilder.Append("姓名"); jsonBuilder.Append("\":\""); jsonBuilder.Append(item.Name.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); jsonBuilder.Append("\""); jsonBuilder.Append("班级"); jsonBuilder.Append("\":\""); jsonBuilder.Append(clazzModel.ClassNo.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); jsonBuilder.Append("\""); jsonBuilder.Append("主观分数"); jsonBuilder.Append("\":\""); jsonBuilder.Append(examdetailscoreModel.SubjectiveScore.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); jsonBuilder.Append("\""); jsonBuilder.Append("客观分数"); jsonBuilder.Append("\":\""); jsonBuilder.Append(examdetailscoreModel.ObjectiveScore.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); jsonBuilder.Append("\""); jsonBuilder.Append("总分数"); jsonBuilder.Append("\":\""); jsonBuilder.Append(examdetailscoreModel.TotalScore.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); for (int j = 0; j < examDetailList.Count; j++) { var examDetailScore = examDetailScoreList.Where(d => d.ExamDetailId == examDetailList[j].Id && d.studentid == item.Id).FirstOrDefault(); jsonBuilder.Append("\""); jsonBuilder.Append(examDetailList[j].Name); jsonBuilder.Append("\":\""); jsonBuilder.Append(examDetailScore.StudentScore.ObjToString().Replace("\"", "\\\"")); jsonBuilder.Append("\","); } jsonBuilder.Remove(jsonBuilder.Length - 1, 1); jsonBuilder.Append("},"); } for (int j = 0; j < examDetailList.Count; j++) { jsonBuilderHeader.Append("{\"prop\": \"" + examDetailList[j].Name + "\", \"label\": \"" + examDetailList[j].Name + "\"},"); } jsonBuilder.Remove(jsonBuilder.Length - 1, 1); jsonBuilderHeader.Remove(jsonBuilderHeader.Length - 1, 1); jsonBuilder.Append("]"); jsonBuilderHeader.Append("]"); ObjectiveStudent objectiveStudent = new ObjectiveStudent() { Header = jsonBuilderHeader.ObjToString(), Content = jsonBuilder.ObjToString() }; return(new MessageModel <ObjectiveStudent>() { msg = "获取成功", success = true, response = objectiveStudent }); }
public async Task <MessageModel <PageModel <SingleCourse> > > Get(int GradeId, string AcademicYearSchoolTerm, string ExamName, int CourseId, int ClazzId, int page = 1) { int intPageSize = 100; if (!(GradeId > 0 && CourseId > 0 && !string.IsNullOrEmpty(AcademicYearSchoolTerm) && !string.IsNullOrEmpty(ExamName))) { return(new MessageModel <PageModel <SingleCourse> >()); } var exScoreList = await _iExScoreRepository.Query(d => d.IsDeleted == false); var gradeList = await _iGradeRepository.Query(d => d.IsDeleted == false && d.Id == GradeId); var clazzList = await _iClazzRepository.Query(d => d.IsDeleted == false && d.GradeId == GradeId); var courseList = await _iCourseRepository.Query(d => d.IsDeleted == false); var examList = await _iExamRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var studentsList = await _iStudentsRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var cctList = await _iCCTRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var teachersList = await _iTeacherRepository.Query(d => d.IsDeleted == false && d.gradeId == GradeId); var leaveCourseIds = courseList.Where(d => d.Name == "化学" || d.Name == "生物" || d.Name == "政治" || d.Name == "地理").Select(d => d.Id).ToList(); foreach (var item in examList) { item.grade = gradeList.Where(d => d.Id == item.gradeid).FirstOrDefault(); item.course = courseList.Where(d => d.Id == item.courseid).FirstOrDefault(); } foreach (var exscore in exScoreList) { try { exscore.exam = examList.Where(d => d.Id == exscore.examid).FirstOrDefault(); var teacherid = cctList.Where(d => d.clazzid == exscore.clazzid && d.gradeid == exscore.exam.gradeid && d.courseid == exscore.exam.courseid).FirstOrDefault()?.teacherid; exscore.Teacher = teachersList.Where(d => d.Id == teacherid.ObjToInt()).FirstOrDefault()?.Name; exscore.clazz = clazzList.Where(d => d.Id == exscore.clazzid).FirstOrDefault(); exscore.student = studentsList.Where(d => d.Id == exscore.studentid).FirstOrDefault(); } catch (Exception ex) { } } exScoreList = exScoreList.Where(d => (d.exam != null && d.exam.grade != null && d.exam.grade.Id == GID || (GID == -9999 && true))).ToList(); // 统计 全年级的 某次考试 全部科目的 全部成绩 var examSortAllCourse = exScoreList.Where(d => AcademicYearSchoolTerm == (d.exam?.AcademicYear + d.exam?.SchoolTerm) && d.exam?.ExamName == ExamName && d.exam?.gradeid == GradeId).ToList(); // 统计 全年级的 某次考试 某门科目中 的全部成绩 var exscoreGrade = examSortAllCourse.Where(d => d.courseid == CourseId).ToList(); List <SingleCourse> totalGradeSingleCourses = new List <SingleCourse>(); foreach (var item in exscoreGrade) { var studentAllCourseScore = (examSortAllCourse.Where(d => d.studentid == item.studentid).ToList()).Select(d => d.score).ToList(); SingleCourse SingleCourse = new SingleCourse() { StudentNo = item.student.StudentNo, StudentName = item.student.Name, TotalScore = item.score.ObjToDecimal(), SubjectiveScore = item.SubjectiveScore.ObjToDecimal(), ObjectiveScore = item.ObjectiveScore.ObjToDecimal(), Clazz = item.clazz.ClassNo, Clazzid = item.clazz.Id, courseid = item.courseid, TotalNineScore = (studentAllCourseScore.Sum()).ObjToDecimal(), TotalNineScoreSort = item.BaseSort.ObjToInt(), }; totalGradeSingleCourses.Add(SingleCourse); } //totalGradeSingleCourses = totalGradeSingleCourses.OrderByDescending(d => d.TotalNineScore).ToList(); //for (int i = 0; i < totalGradeSingleCourses.Count; i++) //{ // var item = totalGradeSingleCourses[i]; // item.TotalNineScoreSort = (i + 1); //} totalGradeSingleCourses = totalGradeSingleCourses.OrderByDescending(d => d.TotalScore).ToList(); List <decimal> scoreLeaveA = new List <decimal>(); List <decimal> scoreLeaveB = new List <decimal>(); List <decimal> scoreLeaveC = new List <decimal>(); List <decimal> scoreLeaveD = new List <decimal>(); List <decimal> scoreLeaveE = new List <decimal>(); decimal leaveIndex = 0; foreach (var item in totalGradeSingleCourses) { leaveIndex++; item.GradeSort = leaveIndex.ObjToInt(); if (leaveCourseIds.Contains(item.courseid)) { if (scoreLeaveA.Contains(item.TotalScore)) { item.Leave = "A"; } else if (scoreLeaveB.Contains(item.TotalScore)) { item.Leave = "B"; } else if (scoreLeaveC.Contains(item.TotalScore)) { item.Leave = "C"; } else if (scoreLeaveD.Contains(item.TotalScore)) { item.Leave = "D"; } else if (scoreLeaveE.Contains(item.TotalScore)) { item.Leave = "E"; } else { var totalStudent = totalGradeSingleCourses.Count.ObjToDecimal(); if (leaveIndex / totalStudent <= (decimal)0.17) { item.Leave = "A"; scoreLeaveA.Add(item.TotalScore); } else if (leaveIndex / totalStudent <= (decimal)0.50) { item.Leave = "B"; scoreLeaveB.Add(item.TotalScore); } else if (leaveIndex / totalStudent <= (decimal)0.83) { item.Leave = "C"; scoreLeaveC.Add(item.TotalScore); } else if (leaveIndex / totalStudent <= (decimal)0.98) { item.Leave = "D"; scoreLeaveD.Add(item.TotalScore); } else { item.Leave = "E"; scoreLeaveE.Add(item.TotalScore); } } } } // ↓↓↓四科参考分↓↓↓ var aMaxStudent = GetStudentMax(totalGradeSingleCourses, "A"); var aMinStudent = GetStudentMin(totalGradeSingleCourses, "A"); var aMaxLeave = 100; var aMinLeave = 83; var bMaxStudent = GetStudentMax(totalGradeSingleCourses, "B"); var bMinStudent = GetStudentMin(totalGradeSingleCourses, "B"); var bMaxLeave = 82; var bMinLeave = 71; var cMaxStudent = GetStudentMax(totalGradeSingleCourses, "C"); var cMinStudent = GetStudentMin(totalGradeSingleCourses, "C"); var cMaxLeave = 70; var cMinLeave = 59; var dMaxStudent = GetStudentMax(totalGradeSingleCourses, "D"); var dMinStudent = GetStudentMin(totalGradeSingleCourses, "D"); var dMaxLeave = 58; var dMinLeave = 41; var eMaxStudent = GetStudentMax(totalGradeSingleCourses, "E"); var eMinStudent = GetStudentMin(totalGradeSingleCourses, "E"); var eMaxLeave = 40; var eMinLeave = 30; for (int i = 0; i < totalGradeSingleCourses.Count; i++) { var item = totalGradeSingleCourses[i]; if (leaveCourseIds.Contains(item.courseid)) { if (item.Leave == "A") { item.ReferenceLeaveScore = (aMaxLeave - aMinLeave) / (aMaxStudent - aMinStudent) * (item.TotalScore - aMinStudent) + aMinLeave; } else if (item.Leave == "B") { item.ReferenceLeaveScore = (bMaxLeave - bMinLeave) / (bMaxStudent - bMinStudent) * (item.TotalScore - bMinStudent) + bMinLeave; } else if (item.Leave == "C") { item.ReferenceLeaveScore = (cMaxLeave - cMinLeave) / (cMaxStudent - cMinStudent) * (item.TotalScore - cMinStudent) + cMinLeave; } else if (item.Leave == "D") { item.ReferenceLeaveScore = (dMaxLeave - dMinLeave) / (dMaxStudent - dMinStudent) * (item.TotalScore - dMinStudent) + dMinLeave; } else if (item.Leave == "E") { item.ReferenceLeaveScore = (eMaxLeave - eMinLeave) / (eMaxStudent - eMinStudent) * (item.TotalScore - eMinStudent) + eMinLeave; } else { item.ReferenceLeaveScore = 0; } } item.ReferenceLeaveScore = Math.Round(item.ReferenceLeaveScore, 1, MidpointRounding.AwayFromZero); } // ↑↑↑四科参考分↑↑↑ var clazzids = clazzList.Where(d => d.GradeId == GradeId).GroupBy(x => new { x.Id }).Select(s => s.First()).ToList(); List <SingleCourse> dataSC = new List <SingleCourse>(); foreach (var item in clazzids) { var totalGradeSingleCoursesClazz = totalGradeSingleCourses.Where(d => d.Clazzid == item.Id).ToList(); totalGradeSingleCoursesClazz = totalGradeSingleCoursesClazz.OrderByDescending(d => d.TotalScore).ToList(); for (int i = 0; i < totalGradeSingleCoursesClazz.Count; i++) { var itemClazz = totalGradeSingleCoursesClazz[i]; itemClazz.ClazzSort = (i + 1); } dataSC.AddRange(totalGradeSingleCoursesClazz); } if (ClazzId > 0) { dataSC = dataSC.Where(d => d.Clazzid == ClazzId).ToList(); } var totalCount = dataSC.Count; int pageCount = (Math.Ceiling(totalCount.ObjToDecimal() / intPageSize.ObjToDecimal())).ObjToInt(); var exScores = dataSC.Skip((page - 1) * intPageSize).Take(intPageSize).ToList(); PageModel <SingleCourse> data = new PageModel <SingleCourse>() { data = exScores, dataCount = totalCount, page = page, pageCount = pageCount, PageSize = intPageSize }; return(new MessageModel <PageModel <SingleCourse> >() { msg = "获取成功", success = data.dataCount >= 0, response = data }); }
public async Task <MessageModel <List <PositivePointTotal> > > Get(int GradeId, string AcademicYearSchoolTerm, string ExamName, int CourseId, int ClazzId, int page = 1) { int intPageSize = 100; if (!(GradeId > 0 && CourseId > 0 && !string.IsNullOrEmpty(AcademicYearSchoolTerm) && !string.IsNullOrEmpty(ExamName))) { return(new MessageModel <List <PositivePointTotal> >()); } var exScoreList = await _iExScoreRepository.Query(d => d.IsDeleted == false); var gradeList = await _iGradeRepository.Query(d => d.IsDeleted == false && d.Id == GradeId); var clazzList = await _iClazzRepository.Query(d => d.IsDeleted == false && d.GradeId == GradeId); var courseList = await _iCourseRepository.Query(d => d.IsDeleted == false); var examList = await _iExamRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var studentsList = await _iStudentsRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var cctList = await _iCCTRepository.Query(d => d.IsDeleted == false && d.gradeid == GradeId); var teachersList = await _iTeacherRepository.Query(d => d.IsDeleted == false && d.gradeId == GradeId); foreach (var item in examList) { item.grade = gradeList.Where(d => d.Id == item.gradeid).FirstOrDefault(); item.course = courseList.Where(d => d.Id == item.courseid).FirstOrDefault(); } foreach (var exscore in exScoreList) { try { exscore.exam = examList.Where(d => d.Id == exscore.examid).FirstOrDefault(); var teacherid = cctList.Where(d => d.clazzid == exscore.clazzid && d.gradeid == exscore.exam.gradeid && d.courseid == exscore.exam.courseid).FirstOrDefault()?.teacherid; exscore.Teacher = teachersList.Where(d => d.Id == teacherid.ObjToInt()).FirstOrDefault()?.Name; exscore.clazz = clazzList.Where(d => d.Id == exscore.clazzid).FirstOrDefault(); exscore.student = studentsList.Where(d => d.Id == exscore.studentid).FirstOrDefault(); } catch (Exception ex) { } } exScoreList = exScoreList.Where(d => (d.exam != null && d.exam.grade != null && d.exam.grade.Id == GID || (GID == -9999 && true))).ToList(); // 统计 全年级的 某次考试 全部科目的 全部成绩 var examSortAllCourse = exScoreList.Where(d => AcademicYearSchoolTerm == (d.exam?.AcademicYear + d.exam?.SchoolTerm) && d.exam?.ExamName == ExamName && d.exam?.gradeid == GradeId).ToList(); // 统计 全年级的 某次考试 某门科目中 的全部成绩 var exscoreGrade = examSortAllCourse.Where(d => d.courseid == CourseId).ToList(); List <PositivePoint> totalGradePositivePoints = new List <PositivePoint>(); foreach (var item in exscoreGrade) { PositivePoint PositivePoint = new PositivePoint() { StudentNo = item.student.StudentNo, StudentName = item.student.Name, BaseSort = item.BaseSort.ObjToInt(), Score = item.score.ObjToDecimal(), Clazz = item.clazz.ClassNo, Teacher = item.Teacher, Clazzid = item.clazz.Id, }; totalGradePositivePoints.Add(PositivePoint); } // 基础名次排序 —— 求出来 基础名次ok,序号,本次基础 totalGradePositivePoints = totalGradePositivePoints.OrderBy(d => d.BaseSort).ToList(); List <int> baseSortArr = new List <int>(); var j = 1; var clazzCount = clazzList.Count; var totalStudentCount = studentsList.Count; var examStudentCount = totalGradePositivePoints.Count; for (int i = 1; i <= totalGradePositivePoints.Count; i++) { var item = totalGradePositivePoints[i - 1]; item.Xuhao = i; if (!baseSortArr.Contains(item.BaseSort)) { j = i; baseSortArr.Add(item.BaseSort); } item.BaseSortOK = j; item.ThisBase = (examStudentCount - (i - 1)) * 0.01 * clazzCount * 100 / (0.01 * ((examStudentCount + 1) / 2) * examStudentCount); } // 基础名次OK排名 —— 求出来 本次基础ok totalGradePositivePoints = totalGradePositivePoints.OrderBy(d => d.BaseSortOK).ToList(); for (int i = 1; i <= totalGradePositivePoints.Count; i++) { var item = totalGradePositivePoints[i - 1]; var avgList = totalGradePositivePoints.Where(d => d.BaseSortOK == item.BaseSortOK).Select(d => d.ThisBase).ToList(); item.ThisBaseOk = avgList.Sum() / avgList.Count; } // 根据分数排序 —— 得到年级排序ok,序号,本次考试 totalGradePositivePoints = totalGradePositivePoints.OrderByDescending(d => d.Score).ToList(); List <decimal> scoreArr = new List <decimal>(); for (int i = 1; i <= totalGradePositivePoints.Count; i++) { var item = totalGradePositivePoints[i - 1]; item.Xuhao = i; if (!scoreArr.Contains(item.Score)) { j = i; scoreArr.Add(item.Score); } item.GradeSortOk = j; item.ThisExam = (examStudentCount - (i - 1)) * 0.01 * clazzCount * 100 / (0.01 * ((examStudentCount + 1) / 2) * examStudentCount); } // 年级重排OK排名 —— 求出来 本次考试ok totalGradePositivePoints = totalGradePositivePoints.OrderBy(d => d.GradeSortOk).ToList(); for (int i = 1; i <= totalGradePositivePoints.Count; i++) { var item = totalGradePositivePoints[i - 1]; var avgList = totalGradePositivePoints.Where(d => d.GradeSortOk == item.GradeSortOk).Select(d => d.ThisExam).ToList(); item.ThisExamOk = avgList.Sum() / avgList.Count; } var clazzids = clazzList.Where(d => d.GradeId == GradeId).GroupBy(x => new { x.Id }).Select(s => s.First()).ToList(); // ↑↑↑↑每个考生正负分完成↑↑↑↑↑↑ List <PositivePointTotal> positivePointTotals = new List <PositivePointTotal>(); foreach (var item in clazzids) { var totalGradePositivePointsClazz = totalGradePositivePoints.Where(d => d.Clazzid == item.Id).ToList(); PositivePointTotal positivePointTotal = new PositivePointTotal() { Clazz = item.ClassNo, Teacher = totalGradePositivePointsClazz.FirstOrDefault()?.Teacher, TotalStudentCount = studentsList.Where(d => d.clazzid == item.Id).Count(), ExamStudentCount = totalGradePositivePointsClazz.Count, ThisBaseOk = totalGradePositivePointsClazz.Select(d => d.ThisBaseOk).Sum(), ThisExamOk = totalGradePositivePointsClazz.Select(d => d.ThisExamOk).Sum(), }; positivePointTotal.NoExamStudentCount = positivePointTotal.TotalStudentCount - positivePointTotal.ExamStudentCount; positivePointTotal.RankBase = positivePointTotal.ThisExamOk - positivePointTotal.ThisBaseOk; positivePointTotal.ThisBaseOk = Math.Round(positivePointTotal.ThisBaseOk, 2, MidpointRounding.AwayFromZero); positivePointTotal.ThisExamOk = Math.Round(positivePointTotal.ThisExamOk, 2, MidpointRounding.AwayFromZero); positivePointTotal.ThisOk = positivePointTotal.ThisExamOk; positivePointTotal.RankBase = Math.Round(positivePointTotal.RankBase, 2, MidpointRounding.AwayFromZero); positivePointTotals.Add(positivePointTotal); } return(new MessageModel <List <PositivePointTotal> >() { msg = "获取成功", success = positivePointTotals.Count >= 0, response = positivePointTotals }); }