123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.ViewModel.ScoreManage;
- using System.Linq.Expressions;
- using Bowin.Common.Linq;
- using EMIS.Entities;
- using EMIS.ViewModel;
- namespace EMIS.ExtensionLogic.DataLogic.ScoreManage
- {
- public class SpecialityScoreSumDAL : EMIS.DataLogic.ScoreManage.SpecialityScoreSumDAL
- {
- /// <summary>
- ///
- /// </summary>
- /// <param name="collegeID"></param>
- /// <param name="years"></param>
- /// <param name="schoolyearNumID"></param>
- /// <param name="schoolcodeID"></param>
- /// <param name="classmajorID"></param>
- /// <returns></returns>
- public override IQueryable<StudentScoreView> GetStudentScoreViewQueryable(Guid? collegeID, int? years, int? schoolyearNumID, int? schoolcodeID, Guid? classmajorID)
- {
- List<int?> examsStateList = examsStateSettingRepository.GetList(x => x.IsNormal == true).Select(x => x.ExamsStateID).ToList();
- Expression<Func<ER_FinallyScore, bool>> exp = (x => true);
- if (collegeID.HasValue)
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
- if (years.HasValue)
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == years);
- if (schoolyearNumID.HasValue)
- exp = exp.And(x => x.SchoolyearNumID == schoolyearNumID);
- if (schoolcodeID.HasValue)
- exp = exp.And(x => (x.CF_Student.CF_Classmajor.CF_Grademajor.SemesterID + (x.StarttermID - 1)) % 2 == schoolcodeID % 2);
- if (classmajorID.HasValue)
- exp = exp.And(x => x.CF_Student.ClassmajorID == classmajorID);
- var query = from x in finallyScoreRepository.GetList(exp, (x => x.CF_Student), (x => x.CF_Student.Sys_User), (x => x.CF_Schoolyear), (x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor), (x => x.CF_Student.CF_Classmajor))
- join ed in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_ExamsState).Name) on x.ExamsStateID equals ed.Value
- into ged
- from f in ged.DefaultIfEmpty()
- join d in DictionaryItemRepository.GetList(x => x.DictionaryCode == "CF_ResultType") on x.ResultTypeID equals d.Value
- join rd in ResultTypeDetailRepository.GetList(x => true) on d.Value equals rd.ResultTypeID
- into ResultTypeDetail
- from Result in ResultTypeDetail.DefaultIfEmpty()
- where (Result.ResultTypeDetailID != null &&
- ((x.TotalScore <= Result.MaxScore && Result.MinScore <= x.TotalScore && (Result.MaxScoreOperator == "<=" && Result.MinScoreOperator == "<="))
- || (x.TotalScore <= Result.MaxScore && Result.MinScore < x.TotalScore && (Result.MaxScoreOperator == "<=" && Result.MinScoreOperator == "<"))
- || (x.TotalScore < Result.MaxScore && Result.MinScore < x.TotalScore && (Result.MaxScoreOperator == "<" && Result.MinScoreOperator == "<"))
- || (x.TotalScore < Result.MaxScore && Result.MinScore <= x.TotalScore && (Result.MaxScoreOperator == "<" && Result.MinScoreOperator == "<="))
- ))
- || (Result.ResultTypeDetailID == null)
- select new StudentScoreView
- {
- SchoolyearID = x.SchoolyearID,
- SchoolyearCode = x.CF_Schoolyear.Code,
- SchoolyearNumID = x.SchoolyearNumID,
- ClassName = x.ClassName,
- GrademajorID = x.CF_Student.CF_Classmajor.CF_Grademajor.GrademajorID,
- GrademajorCode = x.CF_Student.CF_Classmajor.CF_Grademajor.Code,
- GrademajorName = x.CF_Student.CF_Classmajor.CF_Grademajor.Name,
- ClassmajorID = x.CF_Student.CF_Classmajor.ClassmajorID,
- ClassmajorCode = x.CF_Student.CF_Classmajor.No,
- ClassmajorName = x.CF_Student.CF_Classmajor.Name,
- CollegeID = x.CF_Department.CollegeID,
- CollegeName = x.CF_Department.CF_College.Name,
- DepartmentID = x.DepartmentID,
- DepartmentName = x.CF_Department.Name,
- CoursematerialID = x.EM_Coursematerial.CoursematerialID,
- CourseCode = x.EM_Coursematerial.CourseCode,
- CourseName = x.EM_Coursematerial.CourseName,
- CourseTypeID = x.CourseTypeID,
- ExamsCategoryID = x.ExamsCategoryID,
- ExaminationModeID = x.ExaminationModeID,
- Credit = x.Credit ?? 0,
- ExamsDatetime = x.ExamsDatetime,
- ResultTypeID = x.ResultTypeID,
- CreatorUserID = x.CreatorUserID,
- EntryDeadlineTime = x.EntryDeadlineTime,
- ExaminationType = x.ExaminationType,
- StarttermID = x.StarttermID,
- UserID = x.UserID,
- LoginID = x.CF_Student.Sys_User.LoginID,
- UserName = x.CF_Student.Sys_User.Name,
- ExamsStateID = x.ExamsStateID,
- TotalScore = x.TotalScore,
- TotalScoreStr = x.TotalScore < 60 ? "重修" : (examsStateList.Any(w => w.Value == x.ExamsStateID) ? (Result.Name ?? ((double)x.TotalScore).ToString()) : f.Name),
- ScoreCredit = x.ScoreCredit ?? 0,
- GradePoint = x.GradePoint,
- Remarks = x.Remark,
- StudentScoreRemark = x.Remark,
- CreateTime = x.CreateTime,
- CreateUserID = x.CreateUserID,
- Pingshi = Math.Round(x.ER_FinallyScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Peacetime).FirstOrDefault().Score ?? 0, 0),
- Jishu = Math.Round(x.ER_FinallyScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Technique).FirstOrDefault().Score ?? 0, 0),
- Lilun = Math.Round(x.ER_FinallyScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Theoretical).FirstOrDefault().Score ?? 0, 0)
- };
- return query.OrderByDescending(x => x.SchoolyearCode);
- }
- }
- }
|