123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.ViewModel.Specialtyclass;
- using EMIS.DataLogic.Repositories;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.SystemView;
- using EMIS.ViewModel.Students;
- namespace EMIS.DataLogic.Common.Specialtyclass
- {
- public class FacultymajorDAL
- {
- public FacultymajorRepository FacultymajorRepository { get; set; }
- public CollegeRepository CollegeRepository { get; set; }
- public GrademajorRepository GrademajorRepository { get; set; }
- public ClassmajorRepository ClassmajorRepository { get; set; }
- public StudentRepository StudentRepository { get; set; }
- public UserRepository UserRepository { get; set; }
- public DictionaryItemRepository DictionaryItemRepository { get; set; }
- /// <summary>
- /// 查询对应的院系专业信息View
- /// </summary>
- /// <param name="expFacultymajor"></param>
- /// <returns></returns>
- public IQueryable<FacultymajorView> GetFacultymajorViewQueryable(Expression<Func<CF_Facultymajor, bool>> expFacultymajor)
- {
- var query = from fa in FacultymajorRepository.GetList(expFacultymajor)
- join dicst in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_Standard.ToString())
- on fa.StandardID equals dicst.Value into tempst
- from standard in tempst.DefaultIfEmpty()
- select new FacultymajorView
- {
- FacultymajorID = fa.FacultymajorID,
- Code = fa.Code,
- Name = fa.Name,
- Abbreviation = fa.Abbreviation,
- EnglishName = fa.EnglishName,
- NameCode = fa.Name + fa.Code,
- CampusID = fa.CF_College.CampusID,
- CampusNo = fa.CF_College.CF_Campus.No,
- CampusName = fa.CF_College.CF_Campus.Name,
- CollegeID = fa.CollegeID,
- CollegeCode = fa.CF_College.No,
- CollegeName = fa.CF_College.Name,
- StandardID = fa.StandardID,
- StandardName = standard.Name,
- EducationID = fa.EducationID,
- LearningformID = fa.LearningformID,
- LearnSystem = fa.LearnSystem,
- ScienceclassID = fa.ScienceclassID,
- LearningstyleID = fa.LearningstyleID,
- LearnPositionID = fa.LearnPositionID,
- TeacherIdentification = fa.TeacherIdentification,
- SetTime = fa.SetTime,
- Remark = fa.Remark,
- RecordStatus = fa.RecordStatus,
- CreateUserID = fa.CreateUserID,
- CreateTime = fa.CreateTime,
- ModifyUserID = fa.ModifyUserID,
- ModifyTime = fa.ModifyTime
- };
- return query;
- }
- /// <summary>
- /// 查询对应的院系专业信息View(统计对应的年级专业数、学生人数)
- /// </summary>
- /// <param name="expFacultymajor"></param>
- /// <param name="expStudent"></param>
- /// <returns></returns>
- public IQueryable<FacultymajorView> GetFacultymajorViewQueryable(Expression<Func<CF_Facultymajor, bool>> expFacultymajor,
- Expression<Func<CF_Student, bool>> expStudent)
- {
- var query = from fa in FacultymajorRepository.GetList(expFacultymajor)
- join dicst in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_Standard.ToString())
- on fa.StandardID equals dicst.Value into tempst
- from standard in tempst.DefaultIfEmpty()
- join gr in
- (
- from gr in GrademajorRepository.Entities
- group gr by gr.FacultymajorID into ggr
- select new
- {
- FacultymajorID = ggr.Key,
- GrademajorCount = ggr.Count()
- }
- )
- on fa.FacultymajorID equals gr.FacultymajorID into tempgr
- from grfa in tempgr.DefaultIfEmpty()
- join sc in
- (
- from sc in StudentRepository.GetList(expStudent)
- group sc by sc.CF_Classmajor.CF_Grademajor.FacultymajorID into gstu
- select new
- {
- FacultymajorID = gstu.Key,
- StudentCount = gstu.Count()
- }
- )
- on fa.FacultymajorID equals sc.FacultymajorID into tempstu
- from stufa in tempstu.DefaultIfEmpty()
- select new FacultymajorView
- {
- FacultymajorID = fa.FacultymajorID,
- Code = fa.Code,
- Name = fa.Name,
- Abbreviation = fa.Abbreviation,
- EnglishName = fa.EnglishName,
- NameCode = fa.Name + fa.Code,
- CampusID = fa.CF_College.CampusID,
- CampusNo = fa.CF_College.CF_Campus.No,
- CampusName = fa.CF_College.CF_Campus.Name,
- CollegeID = fa.CollegeID,
- CollegeCode = fa.CF_College.No,
- CollegeName = fa.CF_College.Name,
- StandardID = fa.StandardID,
- StandardName = standard.Name,
- EducationID = fa.EducationID,
- LearningformID = fa.LearningformID,
- LearnSystem = fa.LearnSystem,
- ScienceclassID = fa.ScienceclassID,
- LearningstyleID = fa.LearningstyleID,
- LearnPositionID = fa.LearnPositionID,
- TeacherIdentification = fa.TeacherIdentification,
- SetTime = fa.SetTime,
- GrademajorCount = grfa.GrademajorCount == null ? 0 : grfa.GrademajorCount,
- StudentCount = stufa.StudentCount == null ? 0 : stufa.StudentCount,
- Remark = fa.Remark,
- RecordStatus = fa.RecordStatus,
- CreateUserID = fa.CreateUserID,
- CreateTime = fa.CreateTime,
- ModifyUserID = fa.ModifyUserID,
- ModifyTime = fa.ModifyTime
- };
- return query;
- }
- /// <summary>
- /// 查询对应的年级专业信息View(根据院系专业信息,统计各年级专业对应的学生人数)
- /// </summary>
- /// <param name="expFacultymajor"></param>
- /// <param name="expStudent"></param>
- /// <returns></returns>
- public IQueryable<GrademajorView> GetGrademajorViwQueryable(Expression<Func<CF_Facultymajor, bool>> expFacultymajor,
- Expression<Func<CF_Student, bool>> expStudent)
- {
- var query = from fa in FacultymajorRepository.GetList(expFacultymajor)
- join gr in GrademajorRepository.Entities
- on fa.FacultymajorID equals gr.FacultymajorID
- join sc in
- (
- from sc in StudentRepository.GetList(expStudent)
- group sc by sc.CF_Classmajor.CF_Grademajor.GrademajorID into g
- select new
- {
- GrademajorID = g.Key,
- StudentCount = g.Count()
- }
- )
- on gr.GrademajorID equals sc.GrademajorID into dsc
- from esc in dsc.DefaultIfEmpty()
- select new GrademajorView
- {
- GrademajorID = gr.GrademajorID,
- Code = gr.Code,
- Name = gr.Name,
- Abbreviation = gr.Abbreviation,
- FacultymajorID = gr.CF_Facultymajor.FacultymajorID,
- FacultymajorCode = gr.CF_Facultymajor.Code,
- FacultymajorName = gr.CF_Facultymajor.Name,
- CampusID = gr.CF_Facultymajor.CF_College.CampusID,
- CampusNo = gr.CF_Facultymajor.CF_College.CF_Campus.No,
- CampusName = gr.CF_Facultymajor.CF_College.CF_Campus.Name,
- CollegeID = gr.CF_Facultymajor.CollegeID,
- CollegeCode = gr.CF_Facultymajor.CF_College.No,
- CollegeName = gr.CF_Facultymajor.CF_College.Name,
- SchoolyearID = gr.SchoolyearID,
- SchoolcodeID = gr.SchoolcodeID,
- StandardID = gr.CF_Facultymajor.StandardID,
- EducationID = gr.CF_Facultymajor.EducationID,
- LearningformID = gr.CF_Facultymajor.LearningformID,
- LearnSystem = gr.CF_Facultymajor.LearnSystem,
- GraduatingSemesterID = gr.GraduatingSemesterID,
- Value = gr.CF_Schoolyear.Value,
- GraduatingSemesterCode = gr.CF_Schoolyear.Code,
- Professional = gr.Professional,
- StudentCount = esc.StudentCount == null ? 0 : esc.StudentCount,
- SchoolAreaID = gr.SchoolAreaID,
- Remark = gr.Remark,
- RecordStatus = gr.RecordStatus,
- CreateUserID = gr.CreateUserID,
- CreateTime = gr.CreateTime,
- ModifyUserID = gr.ModifyUserID,
- ModifyTime = gr.ModifyTime
- };
- return query;
- }
- /// <summary>
- /// 查询院系专业所对应的学生信息BaseStudentView
- /// </summary>
- /// <param name="expFacultymajor"></param>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<BaseStudentView> GetBaseStudentViewQueryable(Expression<Func<CF_Facultymajor, bool>> expFacultymajor,
- Expression<Func<CF_Student, bool>> exp)
- {
- var query = from stu in StudentRepository.GetList(exp)
- 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.GetList(expFacultymajor)
- on gr.FacultymajorID equals fa.FacultymajorID
- join us in UserRepository.Entities
- on stu.UserID equals us.UserID
- select new BaseStudentView
- {
- UserID = stu.UserID,
- LoginID = us.LoginID,
- StudentNo = stu.StudentCardNo,
- UserName = us.Name,
- Sex = stu.Sex,
- IDNumber = stu.IDNumber,
- StudentStatus = stu.StudentStatus,
- InSchoolStatusID = stu.InSchoolStatusID,
- ClassmajorID = stu.ClassmajorID,
- ClassmajorCode = cl.No,
- ClassmajorName = cl.Name,
- ClassNum = cl.ClassNum == null ? 1 : cl.ClassNum,
- SchoolyearID = gr.SchoolyearID,
- GrademajorID = cl.GrademajorID,
- GrademajorCode = gr.Code,
- GrademajorName = gr.Name,
- FacultymajorID = gr.FacultymajorID,
- FacultymajorCode = fa.Code,
- FacultymajorName = fa.Name
- };
- return query;
- }
- /// <summary>
- /// 查询院系专业对应的学制(Distinct去重)
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<FacultymajorView> GetLearnSystemQueryable(Expression<Func<CF_Facultymajor, bool>> exp)
- {
- var query = from fa in FacultymajorRepository.GetList(exp)
- select new FacultymajorView
- {
- LearnSystem = fa.LearnSystem,
- };
- return query.Distinct();
- }
- /// <summary>
- /// 查询院系专业对应的专业信息(Distinct去重)
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<StandardView> GetStandardQueryable(Expression<Func<CF_Facultymajor, bool>> exp)
- {
- var query = from fa in FacultymajorRepository.GetList(exp)
- join dic in DictionaryItemRepository.Entities.Where(x => x.DictionaryCode == typeof(CF_Standard).Name)
- on fa.StandardID equals dic.Value
- select new StandardView
- {
- StandardID = fa.StandardID,
- StandardName = dic.Name
- };
- return query.Distinct();
- }
- }
- }
|