12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.ViewModel.ScoreManage;
- using EMIS.Entities;
- using System.Linq.Expressions;
- namespace EMIS.ExtensionLogic.DataLogic.ScoreManage
- {
- public class StudentScoreDAL : EMIS.DataLogic.ScoreManage.StudentScoreDAL
- {
- /// <summary>
- /// 已提交成绩
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public override IQueryable<StudentScoreView> GetStudentScoreViewQueryable(Expression<Func<ER_SubmitedScore, bool>> exp)
- {
- List<int?> examsStateList = examsStateSettingRepository.GetList(x => x.IsNormal == true).Select(x => x.ExamsStateID).ToList();
- var query = from x in submitedScoreRepository.GetList(exp)
- join u in userRepository.Entities on x.CreatorUserID equals u.UserID
- into user
- from a in user.DefaultIfEmpty()
- join ed in DictionaryItemRepository.GetList(x => x.DictionaryCode == "CF_ExamsState") 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
- {
- SubmitedScoreID = x.SubmitedScoreID,
- 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_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID,
- CollegeName = x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.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,
- CreatorUserCode = a.LoginID,
- CreatorUserName = a.Name,
- 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,
- //暂时按此种逻辑处理。。后续优化(廖兵良)
- //已经优化--20180517李晓林
- TotalScoreStr = x.TotalScore < 60 ? "重修" : (examsStateList.Any(w => w.Value == x.ExamsStateID) ? (Result.Name ?? ((double)Math.Round(x.TotalScore.Value, 1)).ToString()) : f.Name),
- ScoreCredit = x.ScoreCredit ?? 0,
- GradePoint = x.GradePoint,
- Remarks = x.Remark,
- StudentScoreRemark = x.Remark,
- CreateTime = x.CreateTime,
- CreateUserID = x.CreateUserID,
- TotalHours = x.TotalHours,
- Pingshi = x.ER_SubmitedScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Peacetime).FirstOrDefault().Score == null ? (decimal?)null : Math.Round(x.ER_SubmitedScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Peacetime).FirstOrDefault().Score ?? 0, 0),
- Jishu = x.ER_SubmitedScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Technique).FirstOrDefault().Score == null ? (decimal?)null : Math.Round(x.ER_SubmitedScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Technique).FirstOrDefault().Score ?? 0, 0),
- Lilun = x.ER_SubmitedScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Theoretical).FirstOrDefault().Score == null ? (decimal?)null : Math.Round(x.ER_SubmitedScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Theoretical).FirstOrDefault().Score ?? 0, 0),
- HandleModeID = x.HandleModeID,
- };
- return query;
- }
- }
- }
|