using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using EMIS.Entities; using EMIS.ViewModel.EvaluationManage.StudentEvaluation; using EMIS.ViewModel.EducationManage.EducationArrange; using EMIS.DataLogic.Repositories; namespace EMIS.DataLogic.EvaluationManage.StudentEvaluation { public class EvaluationStudentSettingDAL { public EvaluationStudentSettingRepository EvaluationStudentSettingRepository { get; set; } public EducationMissionRepository EducationMissionRepository { get; set; } public EducationMissionClassRepository EducationMissionClassRepository { get; set; } public ClassmajorRepository ClassmajorRepository { get; set; } public GrademajorRepository GrademajorRepository { get; set; } public FacultymajorRepository FacultymajorRepository { get; set; } public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; } public StudentRepository StudentRepository { get; set; } public MissionClassTeacherRepository MissionClassTeacherRepository { get; set; } public SchoolyearRepository SchoolyearRepository { get; set; } public DepartmentRepository DepartmentRepository { get; set; } public CollegeRepository CollegeRepository { get; set; } public CampusRepository CampusRepository { get; set; } public CoursematerialRepository CoursematerialRepository { get; set; } public EvaluationTableRepository EvaluationTableRepository { get; set; } public EvaluationParticipateTypeRepository EvaluationParticipateTypeRepository { get; set; } public EvaluationIntTypeRepository EvaluationIntTypeRepository { get; set; } public StaffRepository StaffRepository { get; set; } public UserRepository UserRepository { get; set; } public EvaluationStudentRepository EvaluationStudentRepository { get; set; } /// /// 查询对应的学评设定信息EvaluationStudentSettingView /// /// /// public IQueryable GetEvaluationStudentSettingViewQueryable(Expression> expEvaluationStudentSetting) { var query = from evstust in EvaluationStudentSettingRepository.GetList(expEvaluationStudentSetting) join educl in EducationMissionClassRepository.Entities on evstust.EducationMissionClassID equals educl.EducationMissionClassID join edu in EducationMissionRepository.Entities on educl.EducationMissionID equals edu.EducationMissionID join sy in SchoolyearRepository.Entities on edu.SchoolyearID equals sy.SchoolyearID join dep in DepartmentRepository.Entities on edu.DepartmentID equals dep.DepartmentID join col in CollegeRepository.Entities on edu.CollegeID equals col.CollegeID join cam in CampusRepository.Entities on col.CampusID equals cam.CampusID join cou in CoursematerialRepository.Entities on educl.CoursematerialID equals cou.CoursematerialID join evtb in EvaluationTableRepository.Entities on evstust.EvaluationTableID equals evtb.EvaluationTableID join evpt in EvaluationParticipateTypeRepository.Entities on evtb.EvaluationParticipateTypeID equals evpt.EvaluationParticipateTypeID join evtp in EvaluationIntTypeRepository.Entities on evtb.EvaluationIntTypeID equals evtp.EvaluationIntTypeID join sf in StaffRepository.Entities on evstust.UserID equals sf.UserID join us in UserRepository.Entities on sf.UserID equals us.UserID select new EvaluationStudentSettingView { EvaluationStudentSettingID = evstust.EvaluationStudentSettingID, EducationMissionClassID = evstust.EducationMissionClassID, EducationMissionID = educl.EducationMissionID, SchoolyearID = edu.SchoolyearID, SchoolyearValue = sy.Value, SchoolyearCode = sy.Code, MissionName = edu.ClassName, MissionClassName = educl.Name, CollegeID = edu.CollegeID, CollegeNo = col.No, CollegeName = col.Name, CampusID = col.CampusID, CampusNo = cam.No, CampusName = cam.Name, CoursematerialID = educl.CoursematerialID, CourseCode = cou.CourseCode, CourseName = cou.CourseName, CourseStructureID = educl.CourseStructureID, CourseCategoryID = educl.CourseCategoryID, CourseTypeID = educl.CourseTypeID, CourseQualityID = educl.CourseQualityID, Credit = educl.EM_EducationMissionClassTeachingSetting.Credit ?? 0, DepartmentID = edu.DepartmentID, DepartmentNo = dep.No, DepartmentName = dep.Name, HandleModeID = educl.HandleModeID, TeachingModeID = educl.TeachingModeID, MissionClassStatus = educl.RecordStatus, EvaluationTableID = evstust.EvaluationTableID, EvaluationTableCode = evtb.Code, EvaluationTableName = evtb.Name, EvaluationParticipateTypeID = evtb.EvaluationParticipateTypeID, ParticipateTypeID = evpt.ParticipateTypeID, EvaluationTypeID = evtb.EvaluationIntTypeID, EvaluationTypeCode = evtp.Code, EvaluationTypeName = evtp.Name, UserID = evstust.UserID, StaffCode = us.LoginID, StaffName = us.Name, TitleID = sf.TitleID, TeachingMethodID = evstust.TeachingMethodID, ParticipateCount = evstust.CF_Student.Count(), NoParticipateCount = evstust.CF_Student.Count() - evstust.EM_EvaluationStudent.Count(), ValidityParticipateCount = evstust.EM_EvaluationStudent.Where(x => x.IsValidity == true).Count(), ValidityParticipateRate = evstust.CF_Student.Count() == 0 ? 0 : Math.Round((decimal)((decimal?)evstust.EM_EvaluationStudent.Where(x => x.IsValidity == true).Count() * (decimal?)1.00 / (decimal?)evstust.CF_Student.Count() * (decimal?)100.0), 1), OpenState = evstust.OpenState.Value, Remark = evstust.Remark, RecordStatus = evstust.RecordStatus, CreateUserID = evstust.CreateUserID, CreateTime = evstust.CreateTime, ModifyUserID = evstust.ModifyUserID, ModifyTime = evstust.ModifyTime }; return query; } /// /// 查询对应的学评设定信息EvaluationStudentSettingView /// /// /// /// /// public IQueryable GetEvaluationStudentSettingViewQueryable(Expression> expEvaluationStudentSetting, Expression> expEducationMissionClass, Expression> expEducationMission) { var query = from evstust in EvaluationStudentSettingRepository.GetList(expEvaluationStudentSetting) join educl in EducationMissionClassRepository.GetList(expEducationMissionClass) on evstust.EducationMissionClassID equals educl.EducationMissionClassID join edu in EducationMissionRepository.GetList(expEducationMission) on educl.EducationMissionID equals edu.EducationMissionID join sy in SchoolyearRepository.Entities on edu.SchoolyearID equals sy.SchoolyearID join dep in DepartmentRepository.Entities on edu.DepartmentID equals dep.DepartmentID join col in CollegeRepository.Entities on edu.CollegeID equals col.CollegeID join cam in CampusRepository.Entities on col.CampusID equals cam.CampusID join cou in CoursematerialRepository.Entities on educl.CoursematerialID equals cou.CoursematerialID join evtb in EvaluationTableRepository.Entities on evstust.EvaluationTableID equals evtb.EvaluationTableID join evpt in EvaluationParticipateTypeRepository.Entities on evtb.EvaluationParticipateTypeID equals evpt.EvaluationParticipateTypeID join evtp in EvaluationIntTypeRepository.Entities on evtb.EvaluationIntTypeID equals evtp.EvaluationIntTypeID join sf in StaffRepository.Entities on evstust.UserID equals sf.UserID join us in UserRepository.Entities on sf.UserID equals us.UserID select new EvaluationStudentSettingView { EvaluationStudentSettingID = evstust.EvaluationStudentSettingID, EducationMissionClassID = evstust.EducationMissionClassID, EducationMissionID = educl.EducationMissionID, SchoolyearID = edu.SchoolyearID, SchoolyearValue = sy.Value, SchoolyearCode = sy.Code, MissionName = edu.ClassName, MissionClassName = educl.Name, CollegeID = edu.CollegeID, CollegeNo = col.No, CollegeName = col.Name, CampusID = col.CampusID, CampusNo = cam.No, CampusName = cam.Name, CoursematerialID = educl.CoursematerialID, CourseCode = cou.CourseCode, CourseName = cou.CourseName, CourseStructureID = educl.CourseStructureID, CourseCategoryID = educl.CourseCategoryID, CourseTypeID = educl.CourseTypeID, CourseQualityID = educl.CourseQualityID, Credit = educl.EM_EducationMissionClassTeachingSetting.Credit ?? 0, DepartmentID = edu.DepartmentID, DepartmentNo = dep.No, DepartmentName = dep.Name, HandleModeID = educl.HandleModeID, TeachingModeID = educl.TeachingModeID, MissionClassStatus = educl.RecordStatus, EvaluationTableID = evstust.EvaluationTableID, EvaluationTableCode = evtb.Code, EvaluationTableName = evtb.Name, EvaluationParticipateTypeID = evtb.EvaluationParticipateTypeID, ParticipateTypeID = evpt.ParticipateTypeID, EvaluationTypeID = evtb.EvaluationIntTypeID, EvaluationTypeCode = evtp.Code, EvaluationTypeName = evtp.Name, UserID = evstust.UserID, StaffCode = us.LoginID, StaffName = us.Name, TitleID = sf.TitleID, TeachingMethodID = evstust.TeachingMethodID, ParticipateCount = evstust.CF_Student.Count(), NoParticipateCount = evstust.CF_Student.Count() - evstust.EM_EvaluationStudent.Count(), ValidityParticipateCount = evstust.EM_EvaluationStudent.Where(x => x.IsValidity == true).Count(), ValidityParticipateRate = evstust.CF_Student.Count() == 0 ? 0 : Math.Round((decimal)((decimal?)evstust.EM_EvaluationStudent.Where(x => x.IsValidity == true).Count() * (decimal?)1.00 / (decimal?)evstust.CF_Student.Count() * (decimal?)100.0), 1), OpenState = evstust.OpenState.Value, Remark = evstust.Remark, RecordStatus = evstust.RecordStatus, CreateUserID = evstust.CreateUserID, CreateTime = evstust.CreateTime, ModifyUserID = evstust.ModifyUserID, ModifyTime = evstust.ModifyTime }; return query; } /// /// 查询学评设定中对应的学生名单信息CF_Student /// /// /// public IQueryable GetEvaluationStudentSettingStudentQueryable(Expression> exp) { var query = from evstust in EvaluationStudentSettingRepository.GetList(exp) from stu in evstust.CF_Student select stu; return query; } /// /// 查询教学任务班中对应的学生名单信息CF_Student /// /// /// public IQueryable GetEducationMissionClassStudentQueryable(Expression> exp) { var query = from educl in EducationMissionClassRepository.GetList(exp) join edusccl in EducationSchedulingClassRepository.Entities on educl.EducationMissionClassID equals edusccl.EducationMissionClassID from stu in edusccl.CF_Student select stu; return query; } /// /// 查询对应的评价任务教师信息EvaluationMissionStaffView /// /// /// public IQueryable GetEvaluationMissionStaffViewQueryable(Expression> exp) { var query = from edu in EducationMissionRepository.Entities join educl in EducationMissionClassRepository.GetList(exp) on edu.EducationMissionID equals educl.EducationMissionID join mctea in MissionClassTeacherRepository.Entities on educl.EducationMissionClassID equals mctea.MissionClassID join sy in SchoolyearRepository.Entities on edu.SchoolyearID equals sy.SchoolyearID join sf in StaffRepository.Entities on mctea.UserID equals sf.UserID join dep in DepartmentRepository.Entities on edu.DepartmentID equals dep.DepartmentID join col in CollegeRepository.Entities on dep.CollegeID equals col.CollegeID join cam in CampusRepository.Entities on col.CampusID equals cam.CampusID select new EvaluationMissionStaffView { SchoolyearID = edu.SchoolyearID, SchoolyearValue = sy.Value, UserID = mctea.UserID, CoursematerialID = educl.CoursematerialID, DepartmentID = edu.DepartmentID, CollegeID = dep.CollegeID, CampusID = col.CampusID }; return query; } /// /// 查询对应的学评任务教师信息EvaluationMissionStaffView /// /// /// public IQueryable GetEvaluationStudentMissionStaffViewQueryable(Expression> exp) { var query = from evstust in EvaluationStudentSettingRepository.Entities join educl in EducationMissionClassRepository.GetList(exp) on evstust.EducationMissionClassID equals educl.EducationMissionClassID join edu in EducationMissionRepository.Entities on educl.EducationMissionID equals edu.EducationMissionID join sy in SchoolyearRepository.Entities on edu.SchoolyearID equals sy.SchoolyearID join sf in StaffRepository.Entities on evstust.UserID equals sf.UserID join dep in DepartmentRepository.Entities on edu.DepartmentID equals dep.DepartmentID join col in CollegeRepository.Entities on dep.CollegeID equals col.CollegeID join cam in CampusRepository.Entities on col.CampusID equals cam.CampusID select new EvaluationMissionStaffView { SchoolyearID = edu.SchoolyearID, SchoolyearValue = sy.Value, UserID = evstust.UserID, CoursematerialID = educl.CoursematerialID, DepartmentID = edu.DepartmentID, CollegeID = dep.CollegeID, CampusID = col.CampusID }; return query; } /// /// 查询对应的教学任务班信息EducationMissionClassView /// /// /// public IQueryable GetEducationMissionClassViewQueryable(Expression> exp) { var query = from educl in EducationMissionClassRepository.GetList(exp) join edu in EducationMissionRepository.Entities on educl.EducationMissionID equals edu.EducationMissionID join mctea in MissionClassTeacherRepository.Entities on educl.EducationMissionClassID equals mctea.MissionClassID join sf in StaffRepository.Entities on mctea.UserID equals sf.UserID select new EducationMissionClassView { EducationMissionClassID = educl.EducationMissionClassID, EducationMissionID = educl.EducationMissionID, SchoolyearID = edu.SchoolyearID, MissionName = edu.ClassName, MissionClassName = educl.Name, CollegeID = edu.CollegeID, CoursematerialID = educl.CoursematerialID, CourseStructureID = educl.CourseStructureID, CourseCategoryID = educl.CourseCategoryID, CourseTypeID = educl.CourseTypeID, CourseQualityID = educl.CourseQualityID, DepartmentID = edu.DepartmentID, HandleModeID = educl.HandleModeID, TeachingModeID = educl.TeachingModeID, UserID = mctea.UserID, TitleID = sf.TitleID, TeachingMethodID = mctea.TeachType, MissionClassStatus = educl.RecordStatus, Remark = educl.Remark, RecordStatus = educl.RecordStatus, CreateUserID = educl.CreateUserID, CreateTime = educl.CreateTime, ModifyUserID = educl.ModifyUserID, ModifyTime = educl.ModifyTime }; return query; } /// /// 查询教学任务班中未新增学生评价信息EducationMissionClassView /// /// /// /// public IQueryable GetEducationMissionClassViewNoAddQueryable(Expression> expEducationMission, Expression> expEducationMissionClass) { var query = from educl in EducationMissionClassRepository.GetList(expEducationMissionClass) join edu in EducationMissionRepository.GetList(expEducationMission) on educl.EducationMissionID equals edu.EducationMissionID join sy in SchoolyearRepository.Entities on edu.SchoolyearID equals sy.SchoolyearID join dep in DepartmentRepository.Entities on edu.DepartmentID equals dep.DepartmentID join col in CollegeRepository.Entities on edu.CollegeID equals col.CollegeID join cam in CampusRepository.Entities on col.CampusID equals cam.CampusID join cou in CoursematerialRepository.Entities on educl.CoursematerialID equals cou.CoursematerialID join mctea in MissionClassTeacherRepository.Entities on educl.EducationMissionClassID equals mctea.MissionClassID join sf in StaffRepository.Entities on mctea.UserID equals sf.UserID join us in UserRepository.Entities on sf.UserID equals us.UserID from escl in ( from edusccl in EducationSchedulingClassRepository.Entities group edusccl by edusccl.EducationMissionClassID into gescl select new { EducationMissionClassID = gescl.Key, StudentCount = gescl.Sum(x => x.CF_Student.Count()) } ).Where(x => x.EducationMissionClassID == educl.EducationMissionClassID).DefaultIfEmpty() join est in EvaluationStudentSettingRepository.Entities on new { EducationMissionClassID = educl.EducationMissionClassID, mctea.UserID } equals new { EducationMissionClassID = est.EducationMissionClassID.Value, est.UserID } into tempest from evstust in tempest.DefaultIfEmpty() where evstust.EvaluationStudentSettingID == null select new EducationMissionClassView { EducationMissionClassID = educl.EducationMissionClassID, EducationMissionID = educl.EducationMissionID, SchoolyearID = edu.SchoolyearID, SchoolyearValue = sy.Value, SchoolyearCode = sy.Code, MissionName = edu.ClassName, MissionClassName = educl.Name, CollegeID = edu.CollegeID, CollegeNo = col.No, CollegeName = col.Name, CampusID = col.CampusID, CampusNo = cam.No, CampusName = cam.Name, CoursematerialID = educl.CoursematerialID, CourseCode = cou.CourseCode, CourseName = cou.CourseName, CourseStructureID = educl.CourseStructureID, CourseCategoryID = educl.CourseCategoryID, CourseTypeID = educl.CourseTypeID, CourseQualityID = educl.CourseQualityID, Credit = educl.EM_EducationMissionClassTeachingSetting.Credit ?? 0, DepartmentID = edu.DepartmentID, DepartmentNo = dep.No, DepartmentName = dep.Name, HandleModeID = educl.HandleModeID, TeachingModeID = educl.TeachingModeID, UserID = mctea.UserID, StaffCode = us.LoginID, StaffName = us.Name, TitleID = sf.TitleID, TeachingMethodID = mctea.TeachType, MissionClassStatus = educl.RecordStatus, StudentCount = escl.EducationMissionClassID == null ? 0 : escl.StudentCount, Remark = educl.Remark, RecordStatus = educl.RecordStatus, CreateUserID = educl.CreateUserID, CreateTime = educl.CreateTime, ModifyUserID = educl.ModifyUserID, ModifyTime = educl.ModifyTime }; return query; } /// /// 查询学评设定中对应的学生名单信息EvaluationStudentSettingDetailView /// /// /// /// public IQueryable GetEvaluationStudentSettingDetailViewQueryable(Expression> expEvaluationStudentSetting, Expression> expEducationMissionClass, Expression> expEducationMission, Expression> expStudent) { var query = from evstust in EvaluationStudentSettingRepository.GetList(expEvaluationStudentSetting) join educl in EducationMissionClassRepository.GetList(expEducationMissionClass) on evstust.EducationMissionClassID equals educl.EducationMissionClassID join edu in EducationMissionRepository.GetList(expEducationMission) on educl.EducationMissionID equals edu.EducationMissionID from stu in evstust.CF_Student.AsQueryable().Where(expStudent) join sy in SchoolyearRepository.Entities on edu.SchoolyearID equals sy.SchoolyearID join cou in CoursematerialRepository.Entities on educl.CoursematerialID equals cou.CoursematerialID from dep in DepartmentRepository.Entities.Where(x => x.DepartmentID == edu.DepartmentID) join evtb in EvaluationTableRepository.Entities on evstust.EvaluationTableID equals evtb.EvaluationTableID join evpt in EvaluationParticipateTypeRepository.Entities on evtb.EvaluationParticipateTypeID equals evpt.EvaluationParticipateTypeID join evtp in EvaluationIntTypeRepository.Entities on evtb.EvaluationIntTypeID equals evtp.EvaluationIntTypeID join sf in StaffRepository.Entities on evstust.UserID equals sf.UserID from cl in ClassmajorRepository.Entities.Where(x => x.ClassmajorID == stu.ClassmajorID) from gr in GrademajorRepository.Entities.Where(x => x.GrademajorID == cl.GrademajorID) from fa in FacultymajorRepository.Entities.Where(x => x.FacultymajorID == gr.FacultymajorID) from col in CollegeRepository.Entities.Where(x => x.CollegeID == fa.CollegeID) from cam in CampusRepository.Entities.Where(x => x.CampusID == col.CampusID) from sfus in UserRepository.Entities.Where(x => x.UserID == sf.UserID) from stuus in UserRepository.Entities.Where(x => x.UserID == stu.UserID) from evstu in evstust.EM_EvaluationStudent.Where(x => x.UserID == stu.UserID).DefaultIfEmpty() select new EvaluationStudentSettingDetailView { EvaluationStudentSettingID = evstust.EvaluationStudentSettingID, UserID = stu.UserID, StudentNo = stuus.LoginID, Name = stuus.Name, SexID = stu.SexID, BirthDate = stu.BirthDate, NationID = stu.NationID, PoliticsID = stu.PoliticsID, InSchoolStatusID = stu.InSchoolStatusID, StudentStatus = stu.StudentStatus, StandardID = fa.StandardID, EducationID = fa.EducationID, LearningformID = fa.LearningformID, LearnSystem = fa.LearnSystem, ClassmajorID = stu.ClassmajorID, ClassmajorNo = cl.No, ClassmajorName = cl.Name, ClassNum = cl.ClassNum, GradeID = gr.GradeID, GrademajorID = cl.GrademajorID, GrademajorCode = gr.Code, GrademajorName = gr.Name, FacultymajorID = gr.FacultymajorID, FacultymajorCode = fa.Code, FacultymajorName = fa.Name, CollegeID = fa.CollegeID, CollegeNo = col.No, CollegeName = col.Name, CampusID = col.CampusID, CampusNo = cam.No, CampusName = cam.Name, EducationMissionClassID = evstust.EducationMissionClassID, EducationMissionID = educl.EducationMissionID, SchoolyearID = edu.SchoolyearID, SchoolyearValue = sy.Value, SchoolyearCode = sy.Code, MissionName = edu.ClassName, MissionClassName = educl.Name, CoursematerialID = educl.CoursematerialID, CourseCode = cou.CourseCode, CourseName = cou.CourseName, CourseStructureID = educl.CourseStructureID, CourseCategoryID = educl.CourseCategoryID, CourseTypeID = educl.CourseTypeID, CourseQualityID = educl.CourseQualityID, Credit = educl.EM_EducationMissionClassTeachingSetting.Credit ?? 0, DepartmentID = edu.DepartmentID, DepartmentNo = dep.No, DepartmentName = dep.Name, HandleModeID = educl.HandleModeID, TeachingModeID = educl.TeachingModeID, MissionClassStatus = educl.RecordStatus, EvaluationTableID = evstust.EvaluationTableID, EvaluationTableCode = evtb.Code, EvaluationTableName = evtb.Name, EvaluationParticipateTypeID = evtb.EvaluationParticipateTypeID, ParticipateTypeID = evpt.ParticipateTypeID, EvaluationTypeID = evtb.EvaluationIntTypeID, EvaluationTypeCode = evtp.Code, EvaluationTypeName = evtp.Name, StaffUserID = evstust.UserID, StaffCode = sfus.LoginID, StaffName = sfus.Name, TitleID = sf.TitleID, TeachingMethodID = evstust.TeachingMethodID, OpenState = evstust.OpenState.Value, IsEvaluation = evstu.EvaluationStudentID == null ? false : true }; return query; } } }