using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; using EMIS.Entities; using EMIS.DataLogic.Repositories; using EMIS.ViewModel; using EMIS.ViewModel.GraduationManage.GraduateCardManage; using EMIS.ViewModel.ScoreManage; namespace EMIS.DataLogic.GraduationManage.GraduateCardManage { public class GraduateCardApplyDAL { public GraduateCardApplyRepository GraduateCardApplyRepository { get; set; } public GraduateCardApplyAttachmentRepository GraduateCardApplyAttachmentRepository { get; set; } public SchoolyearRepository SchoolyearRepository { get; set; } public StudentRepository StudentRepository { get; set; } public ClassmajorRepository ClassmajorRepository { get; set; } public GrademajorRepository GrademajorRepository { get; set; } public FacultymajorRepository FacultymajorRepository { get; set; } public EducationTypeSettingRepository EducationTypeSettingRepository { get; set; } public DepartmentRepository DepartmentRepository { get; set; } public CollegeRepository CollegeRepository { get; set; } public CampusRepository CampusRepository { get; set; } public ExecutablePlanRepository ExecutablePlanRepository { get; set; } public ExecutablePlanProfileRepository ExecutablePlanProfileRepository { get; set; } public ExecutablePlanTeachingSettingRepository ExecutablePlanTeachingSettingRepository { get; set; } public CoursematerialRepository CoursematerialRepository { get; set; } public CourseTypeSelectCourseTypeRepository CourseTypeSelectCourseTypeRepository { get; set; } public FinallyScoreRepository FinallyScoreRepository { get; set; } public UserRepository UserRepository { get; set; } /// /// 查询对应的去向申请信息View(根据对应的去向申请信息) /// /// /// public IQueryable GetGraduateCardApplyViewQueryable(Expression> exp) { var query = from gc in GraduateCardApplyRepository.GetList(exp) join gcsy in SchoolyearRepository.Entities on gc.GraduatingSemesterID equals gcsy.SchoolyearID join stu in StudentRepository.Entities on gc.UserID equals stu.UserID join cl in ClassmajorRepository.Entities on stu.ClassmajorID equals cl.ClassmajorID join gr in GrademajorRepository.Entities on cl.GrademajorID equals gr.GrademajorID join fa in FacultymajorRepository.Entities on gr.FacultymajorID equals fa.FacultymajorID join ets in EducationTypeSettingRepository.Entities on fa.EducationID equals ets.EducationID join col in CollegeRepository.Entities on fa.CollegeID equals col.CollegeID join cam in CampusRepository.Entities on col.CampusID equals cam.CampusID join us in UserRepository.Entities on stu.UserID equals us.UserID join assistant in UserRepository.Entities on cl.UserID equals assistant.UserID into tempassistant from usassistant in tempassistant.DefaultIfEmpty() join sye in SchoolyearRepository.Entities on new { SchoolyearID = gr.GradeID.Value, SchoolcodeID = gr.SemesterID.Value } equals new { SchoolyearID = sye.Years, SchoolcodeID = sye.SchoolcodeID } into tempsyenter from syenter in tempsyenter.DefaultIfEmpty() select new GraduateCardApplyView { GraduateCardApplyID = gc.GraduateCardApplyID, UserID = gc.UserID, StudentNo = us.LoginID, UserName = us.Name, ExamineeNum = stu.CF_Recruitstudents.ExamineeNum, IDNumber = stu.IDNumber, SexID = stu.SexID, BirthDate = stu.BirthDate, NationID = stu.NationID, PoliticsID = stu.PoliticsID, EntranceDate = stu.CF_Recruitstudents.EntranceDate, ZIPCode = stu.CF_StudentContact.ZIPCode, Telephone = stu.CF_StudentContact.Telephone, Mobile = stu.CF_StudentContact.Mobile, Address = stu.CF_StudentContact.Address, InSchoolStatusID = stu.InSchoolStatusID, StudentStatusID = stu.StudentStatus, ClassID = stu.ClassmajorID, ClassNo = cl.No, ClassName = cl.Name, GrademajorID = cl.GrademajorID, GrademajorCode = gr.Code, GrademajorName = gr.Name, FacultymajorID = fa.FacultymajorID, FacultymajorNo = fa.Code, FacultymajorName = fa.Name, CollegeID = fa.CollegeID, CollegeNo = col.No, CollegeName = col.Name, CampusID = col.CampusID, CampusNo = cam.No, CampusName = cam.Name, SchoolyearID = gr.GradeID, EnteringSchoolYearID = syenter.SchoolyearID, EnteringSchoolYearCode = syenter.Code, StandardID = fa.StandardID, EducationID = fa.EducationID, EducationTypeID = ets.EducationTypeID, LearningformID = fa.LearningformID, LearnSystem = fa.LearnSystem, GraduationTypeID = gc.GraduationTypeID, GraduatingSemesterID = gc.GraduatingSemesterID, GraduatingSemesterCode = gcsy.Code, GraduatingSemesterValue = gcsy.Value, GraduationYear = gcsy.Years, NeedCardResult = gc.NeedCardResult, ApprovalStatus = gc.ApprovalStatus, RecordStatus = gc.RecordStatus, Remark = gc.Remark, CreateUserID = gc.CreateUserID, CreateTime = gc.CreateTime, ModifyUserID = gc.ModifyUserID, ModifyTime = gc.ModifyTime }; return query; } /// /// 查询对应的去向申请信息View(根据对应的去向申请信息、学生信息,统计对应的最终成绩) /// /// /// /// public IQueryable GetGraduateCardApplyViewQueryable(Expression> expGraduateCardApply, Expression> expStudent) { var query = from gc in GraduateCardApplyRepository.GetList(expGraduateCardApply) join gcsy in SchoolyearRepository.Entities on gc.GraduatingSemesterID equals gcsy.SchoolyearID join stu in StudentRepository.GetList(expStudent) on gc.UserID equals stu.UserID join cl in ClassmajorRepository.Entities on stu.ClassmajorID equals cl.ClassmajorID join gr in GrademajorRepository.Entities on cl.GrademajorID equals gr.GrademajorID join fa in FacultymajorRepository.Entities on gr.FacultymajorID equals fa.FacultymajorID join ets in EducationTypeSettingRepository.Entities on fa.EducationID equals ets.EducationID join col in CollegeRepository.Entities on fa.CollegeID equals col.CollegeID join cam in CampusRepository.Entities on col.CampusID equals cam.CampusID join us in UserRepository.Entities on stu.UserID equals us.UserID join assistant in UserRepository.Entities on cl.UserID equals assistant.UserID into tempassistant from usassistant in tempassistant.DefaultIfEmpty() join sye in SchoolyearRepository.Entities on new { SchoolyearID = gr.GradeID.Value, SchoolcodeID = gr.SemesterID.Value } equals new { SchoolyearID = sye.Years, SchoolcodeID = sye.SchoolcodeID } into tempsyenter from syenter in tempsyenter.DefaultIfEmpty() join fsgr in ( //学生最终成绩(已修门数) from fs in FinallyScoreRepository.Entities group fs by fs.UserID into g select new { UserID = g.Key, FinallyScoreCount = g.Count() } ) on stu.UserID equals fsgr.UserID into tempfsgr from gcfsgr in tempfsgr.DefaultIfEmpty() select new GraduateCardApplyView { GraduateCardApplyID = gc.GraduateCardApplyID, UserID = gc.UserID, StudentNo = us.LoginID, UserName = us.Name, ExamineeNum = stu.CF_Recruitstudents.ExamineeNum, IDNumber = stu.IDNumber, SexID = stu.SexID, BirthDate = stu.BirthDate, NationID = stu.NationID, PoliticsID = stu.PoliticsID, EntranceDate = stu.CF_Recruitstudents.EntranceDate, ZIPCode = stu.CF_StudentContact.ZIPCode, Telephone = stu.CF_StudentContact.Telephone, Mobile = stu.CF_StudentContact.Mobile, Address = stu.CF_StudentContact.Address, InSchoolStatusID = stu.InSchoolStatusID, StudentStatusID = stu.StudentStatus, ClassID = stu.ClassmajorID, ClassNo = cl.No, ClassName = cl.Name, GrademajorID = cl.GrademajorID, GrademajorCode = gr.Code, GrademajorName = gr.Name, FacultymajorID = fa.FacultymajorID, FacultymajorNo = fa.Code, FacultymajorName = fa.Name, CollegeID = fa.CollegeID, CollegeNo = col.No, CollegeName = col.Name, CampusID = col.CampusID, CampusNo = cam.No, CampusName = cam.Name, SchoolyearID = gr.GradeID, EnteringSchoolYearID = syenter.SchoolyearID, EnteringSchoolYearCode = syenter.Code, StandardID = fa.StandardID, EducationID = fa.EducationID, EducationTypeID = ets.EducationTypeID, LearningformID = fa.LearningformID, LearnSystem = fa.LearnSystem, GraduationTypeID = gc.GraduationTypeID, GraduatingSemesterID = gc.GraduatingSemesterID, GraduatingSemesterCode = gcsy.Code, GraduatingSemesterValue = gcsy.Value, GraduationYear = gcsy.Years, FinallyScoreCount = gcfsgr.FinallyScoreCount == null ? 0 : gcfsgr.FinallyScoreCount, NeedCardResult = gc.NeedCardResult, ApprovalStatus = gc.ApprovalStatus, RecordStatus = gc.RecordStatus, Remark = gc.Remark, CreateUserID = gc.CreateUserID, CreateTime = gc.CreateTime, ModifyUserID = gc.ModifyUserID, ModifyTime = gc.ModifyTime }; return query; } /// /// 查询对应的毕业学生信息View(根据相应的学生信息、学年学期信息、去向申请信息、毕业学期ID) /// 注:需排除相应的去向申请信息(待审核、已通过) /// 注:计算对应的毕业年限(通过当前设置的毕业学期Value与学生年级专业对应的毕业学期Value进行计算) /// /// /// /// /// /// public IQueryable GetGraduationStudentViewQueryable(Expression> expStudent, Expression> expSchoolyear, Expression> expGraduateCardApply, Guid? graduatingSemesterID) { var query = from stu in StudentRepository.GetList(expStudent) join us in UserRepository.Entities on stu.UserID equals us.UserID join cl in ClassmajorRepository.Entities on stu.ClassmajorID equals cl.ClassmajorID join gr in GrademajorRepository.Entities on cl.GrademajorID equals gr.GrademajorID join grsy in SchoolyearRepository.GetList(expSchoolyear) on gr.GraduateSchoolyearID equals grsy.SchoolyearID join fa in FacultymajorRepository.Entities on gr.FacultymajorID equals fa.FacultymajorID join ets in EducationTypeSettingRepository.Entities on fa.EducationID equals ets.EducationID join col in CollegeRepository.Entities on fa.CollegeID equals col.CollegeID join cam in CampusRepository.Entities on col.CampusID equals cam.CampusID join assistant in UserRepository.Entities on cl.UserID equals assistant.UserID into tempassistant from usassistant in tempassistant.DefaultIfEmpty() join stsy in SchoolyearRepository.Entities on graduatingSemesterID equals stsy.SchoolyearID into tempstsy from grstsy in tempstsy.DefaultIfEmpty() join gc in GraduateCardApplyRepository.GetList(expGraduateCardApply) on stu.UserID equals gc.UserID into tempga from stugc in tempga.DefaultIfEmpty() where stugc.GraduateCardApplyID == null select new GraduateCardApplyView { UserID = stu.UserID, StudentNo = us.LoginID, UserName = us.Name, SexID = stu.SexID, InSchoolStatusID = stu.InSchoolStatusID, StudentStatusID = stu.StudentStatus, ClassID = stu.ClassmajorID, ClassNo = cl.No, ClassName = cl.Name, GrademajorID = cl.GrademajorID, GrademajorCode = gr.Code, GrademajorName = gr.Name, FacultymajorID = gr.FacultymajorID, FacultymajorNo = fa.Code, FacultymajorName = fa.Name, CollegeID = fa.CollegeID, CollegeNo = col.No, CollegeName = col.Name, CampusID = col.CampusID, CampusNo = cam.No, CampusName = cam.Name, SchoolyearID = gr.GradeID, StandardID = fa.StandardID, EducationID = fa.EducationID, EducationTypeID = ets.EducationTypeID, LearningformID = fa.LearningformID, LearnSystem = fa.LearnSystem, GraduatingSemesterID = gr.GraduateSchoolyearID, GraduatingSemesterCode = grsy.Code, GraduatingSemesterValue = grsy.Value, GraduationYear = grsy.Years, GraduationAgeLimitValue = grstsy.Value == null ? 0 : Math.Round(((decimal)(grstsy.Value - grsy.Value) / 2), 1) }; return query; } /// /// 查询对应的未新增毕业学生信息View(根据相应的学生信息、学年学期信息、去向申请信息、毕业学期ID) /// 注:需排除相应的去向申请信息(待审核、已通过) /// 注:需排除相应的去向申请信息(业务主键) /// 注:计算对应的毕业年限(通过当前设置的毕业学期Value与学生年级专业对应的毕业学期Value进行计算) /// /// /// /// /// /// public IQueryable GetGraduationStudentNoAddViewQueryable(Expression> expStudent, Expression> expSchoolyear, Expression> expGraduateCardApply, Guid? graduatingSemesterID) { var query = from stu in this.GetGraduationStudentViewQueryable(expStudent, expSchoolyear, expGraduateCardApply, graduatingSemesterID) join gc in GraduateCardApplyRepository.Entities on new { UserID = stu.UserID, GraduatingSemesterID = graduatingSemesterID } equals new { UserID = gc.UserID, GraduatingSemesterID = gc.GraduatingSemesterID } into tempgc from stugc in tempgc.DefaultIfEmpty() where stugc.GraduateCardApplyID == null select stu; return query; } /// /// 查询去向申请对应的最终成绩信息(根据动向申请信息并且匹配执行计划) /// 注:以学生最终成绩为准匹配对应的执行计划(左连) /// 注:由于存在在不同的学年学期参加补考的情况,匹配学生最终成绩时,采用开学学期ID匹配 /// 注:匹配暂时不考虑总学时TotalHours /// /// /// public IQueryable GetFinallyScoreViewQueryable(Expression> exp) { var query = from gc in GraduateCardApplyRepository.GetList(exp) join stu in StudentRepository.Entities on gc.UserID equals stu.UserID join cl in ClassmajorRepository.Entities on stu.ClassmajorID equals cl.ClassmajorID join gr in GrademajorRepository.Entities on cl.GrademajorID equals gr.GrademajorID join fa in FacultymajorRepository.Entities on gr.FacultymajorID equals fa.FacultymajorID join col in CollegeRepository.Entities on fa.CollegeID equals col.CollegeID join fs in FinallyScoreRepository.Entities on stu.UserID equals fs.UserID join sy in SchoolyearRepository.Entities on fs.SchoolyearID equals sy.SchoolyearID join cou in CoursematerialRepository.Entities on fs.CoursematerialID equals cou.CoursematerialID join us in UserRepository.Entities on stu.UserID equals us.UserID join cd in DepartmentRepository.Entities on fs.DepartmentID equals cd.DepartmentID into tempcd from coudep in tempcd.DefaultIfEmpty() join ue in UserRepository.Entities on fs.CreatorUserID equals ue.UserID into tempue from usentry in tempue.DefaultIfEmpty() join ct in CourseTypeSelectCourseTypeRepository.Entities on fs.CourseTypeID equals ct.CourseTypeID into tempct from fsct in tempct.DefaultIfEmpty() join ep in ( from gc in GraduateCardApplyRepository.GetList(exp) join stu in StudentRepository.Entities on gc.UserID equals stu.UserID join cl in ClassmajorRepository.Entities on stu.ClassmajorID equals cl.ClassmajorID join gr in GrademajorRepository.Entities on cl.GrademajorID equals gr.GrademajorID join ep in ExecutablePlanRepository.Entities on gr.GrademajorID equals ep.GrademajorID join epsy in SchoolyearRepository.Entities on ep.SchoolyearID equals epsy.SchoolyearID join pf in ExecutablePlanProfileRepository.Entities on ep.ExecutablePlanID equals pf.ExecutablePlanID into temppf from eppro in temppf.DefaultIfEmpty() join st in ExecutablePlanTeachingSettingRepository.Entities on ep.ExecutablePlanID equals st.ExecutablePlanID into tempst from epst in tempst.DefaultIfEmpty() select new { ExecutablePlanID = ep.ExecutablePlanID, SpecialtyPlanID = ep.SpecialtyPlanID, GrademajorID = ep.GrademajorID, UserID = gc.UserID, DepartmentID = ep.DepartmentID, CoursematerialID = ep.CoursematerialID, CourseTypeID = ep.CourseTypeID, Credit = epst.Credit, TheoryCourse = epst.TheoryCourse, Practicehours = epst.Practicehours, Trialhours = epst.Trialhours, Totalhours = (epst.TheoryCourse ?? 0) + (epst.Practicehours ?? 0), SchoolyearID = ep.SchoolyearID, SchoolyearCode = epsy.Code, SchoolyearNumID = (epsy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1)) / 2 + 1, SchoolcodeID = epsy.SchoolcodeID, StarttermID = (epsy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1) + 1), IsSpecialtycore = eppro.IsSpecialtycore == null ? false : eppro.IsSpecialtycore.Value, IsCooperation = eppro.IsCooperation == null ? false : eppro.IsCooperation.Value, IsRequired = eppro.IsRequired == null ? false : eppro.IsRequired.Value, IsElective = eppro.IsElective == null ? false : eppro.IsElective.Value, IsNetworkCourse = eppro.IsNetworkCourse == null ? false : eppro.IsNetworkCourse.Value, IsMainCourse = eppro.IsMainCourse == null ? false : eppro.IsMainCourse.Value, ResultTypeID = ep.ResultTypeID, RecordStatus = ep.RecordStatus } ) on new { UserID = gc.UserID, StarttermID = fs.StarttermID, CoursematerialID = fs.CoursematerialID, CourseTypeID = fs.CourseTypeID, Credit = fs.Credit } equals new { UserID = ep.UserID, StarttermID = ep.StarttermID, CoursematerialID = ep.CoursematerialID, CourseTypeID = ep.CourseTypeID, Credit = ep.Credit } into tempep from fsep in tempep.DefaultIfEmpty() select new FinallyScoreView { FinallyScoreID = fs.FinallyScoreID, SchoolyearID = fs.SchoolyearID, SchoolyearCode = sy.Code, UserID = fs.UserID, LoginID = us.LoginID, UserName = us.Name, ClassmajorID = stu.ClassmajorID, ClassmajorNo = cl.No, ClassmajorName = cl.Name, CollegeID = fa.CollegeID, CollegeNo = col.No, CollegeName = col.Name, SchoolyearNumID = fs.SchoolyearNumID, StarttermID = fs.StarttermID, ClassName = fs.ClassName, CoursematerialID = fs.CoursematerialID, CourseCode = cou.CourseCode, CourseName = cou.CourseName, DepartmentID = fs.DepartmentID, DepartmentNo = coudep.No, DepartmentName = coudep.Name, CourseTypeID = fs.CourseTypeID, IsMainCourse = fsep.IsMainCourse == null ? false : fsep.IsMainCourse, CourseSelectTypeID = (fsct.IsFreeSelectionCourse ?? false) ? (int)EMIS.ViewModel.CF_CourseSelectType.FreeSelectionCourse : ((fsct.IsOptionalCourse ?? false) ? (int)EMIS.ViewModel.CF_CourseSelectType.OptionalCourse : (int)EMIS.ViewModel.CF_CourseSelectType.Required), CourseTypeColour = fsct.CourseTypeColour == null ? "white" : fsct.CourseTypeColour, Credit = fs.Credit ?? 0, TotalHours = fs.TotalHours ?? 0, IsExecutablePlan = fsep.ExecutablePlanID == null ? false : true, ExecutablePlanStatus = fsep.RecordStatus, ExaminationType = fs.ExaminationType, ExaminationModeID = fs.ExaminationModeID, HandleModeID = fs.HandleModeID, ExamsDatetime = fs.ExamsDatetime, CreatorUserID = fs.CreatorUserID, CreatorUserNo = usentry.LoginID, CreatorUserName = usentry.Name, EntryDeadlineTime = fs.EntryDeadlineTime, ResultTypeID = fs.ResultTypeID, ExamsCategoryID = fs.ExamsCategoryID, ExamsStateID = fs.ExamsStateID, TotalScore = fs.TotalScore, ScoreCredit = fs.ScoreCredit ?? 0, GradePoint = fs.GradePoint ?? 0, Remarks = fs.Remark, RecordStatus = fs.RecordStatus, CreateUserID = fs.CreateUserID, CreateTime = fs.CreateTime, ModifyUserID = fs.ModifyUserID, ModifyTime = fs.ModifyTime }; return query; } /// /// 查询对应的附件文件明细信息FileUploadView(根据去向申请信息) /// /// /// public IQueryable GetGraduateCardApplyAttachmentQueryable(Expression> exp) { var tableName = typeof(ER_GraduateCardApplyAttachment).Name; var query = from gc in GraduateCardApplyRepository.GetList(exp) from gcat in GraduateCardApplyAttachmentRepository.Entities .Where(x => x.GraduateCardApplyID == gc.GraduateCardApplyID) select new FileUploadView { FileID = gcat.GraduateCardApplyAttachmentID, FormID = gc.GraduateCardApplyID, FileName = gcat.Name, FileUrl = gcat.Url, TableName = tableName, RecordStatus = gcat.RecordStatus, CreateUserID = gcat.CreateUserID, CreateTime = gcat.CreateTime, ModifyUserID = gcat.ModifyUserID, ModifyTime = gcat.ModifyTime }; return query; } } }