123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using EMIS.Entities;
- using EMIS.ViewModel.UniversityManage.AdministrativeOrgan;
- using EMIS.ViewModel.UniversityManage.TeacherManage;
- using EMIS.DataLogic.Repositories;
- namespace EMIS.DataLogic.UniversityManage.AdministrativeOrgan
- {
- public class DepartmentDAL
- {
- public DepartmentRepository DepartmentRepository { get; set; }
- public DepartmentProfileRepository DepartmentProfileRepository { get; set; }
- public CollegeRepository CollegeRepository { get; set; }
- public CampusRepository CampusRepository { get; set; }
- public UniversityRepository UniversityRepository { get; set; }
- public StaffRepository StaffRepository { get; set; }
- public StaffProfileRepository StaffProfileRepository { get; set; }
- public UserRepository UserRepository { get; set; }
- /// <summary>
- /// 查询对应的部门信息View
- /// </summary>
- /// <param name="expDepartment"></param>
- /// <returns></returns>
- public IQueryable<DepartmentView> GetDepartmentViewQueryable(Expression<Func<CF_Department, bool>> expDepartment)
- {
- var query = from dep in DepartmentRepository.GetList(expDepartment)
- join c in UserRepository.Entities
- on dep.CF_DepartmentProfile.DirectorID equals c.UserID into gu
- from guic in gu.DefaultIfEmpty()
- join d in UserRepository.Entities
- on dep.CF_DepartmentProfile.DeputyDirectorID equals d.UserID into gude
- from gudeic in gude.DefaultIfEmpty()
- join sta in
- (
- from sta in StaffRepository.Entities
- group sta by sta.DepartmentID into stagr
- select new
- {
- DepartmentID = stagr.Key,
- StaffCount = stagr.Count()
- }
- )
- on dep.DepartmentID equals sta.DepartmentID into tempsta
- from stadep in tempsta.DefaultIfEmpty()
- select new DepartmentView
- {
- DepartmentID = dep.DepartmentID,
- No = dep.No,
- Name = dep.Name,
- SimpleName = dep.SimpleName,
- EnglishName = dep.EnglishName,
- CampusID = dep.CF_College.CampusID,
- CampusNo = dep.CF_College.CF_Campus.No,
- CampusName = dep.CF_College.CF_Campus.Name,
- CollegeID = dep.CollegeID,
- CollegeCode = dep.CF_College.No,
- CollegeName = dep.CF_College.Name,
- HierarchyID = dep.HierarchyID,
- DirectorID = dep.CF_DepartmentProfile.DirectorID,
- DirectorName = guic.Name,
- DeputyDirectorID = dep.CF_DepartmentProfile.DeputyDirectorID,
- DeputyDirectorName = gudeic.Name,
- FoundDate = dep.CF_DepartmentProfile.FoundDate,
- StaffCount = stadep.StaffCount == null ? 0 : stadep.StaffCount,
- Remark = dep.Remark,
- RecordStatus = dep.RecordStatus,
- CreateUserID = dep.CreateUserID,
- CreateTime = dep.CreateTime,
- ModifyUserID = dep.ModifyUserID,
- ModifyTime = dep.ModifyTime
- };
- return query;
- }
- /// <summary>
- /// 查询教研室对应的教师信息StaffView
- /// </summary>
- /// <param name="expDepartment"></param>
- /// <returns></returns>
- public IQueryable<StaffView> GetStaffViewQueryable(Expression<Func<CF_Department, bool>> expDepartment)
- {
- var query = from dep in DepartmentRepository.GetList(expDepartment)
- join sf in StaffRepository.Entities
- on dep.DepartmentID equals sf.DepartmentID
- join pr in StaffProfileRepository.Entities
- on sf.UserID equals pr.UserID into temppr
- from sfpr in temppr.DefaultIfEmpty()
- join col in CollegeRepository.Entities
- on sf.CollegeID equals col.CollegeID into tempcol
- from sfcol in tempcol.DefaultIfEmpty()
- join us in UserRepository.Entities
- on sf.UserID equals us.UserID
- select new StaffView
- {
- UserID = sf.UserID,
- StaffCode = us.LoginID,
- Name = us.Name,
- UsedName = sfpr.UsedName,
- CampusID = sfcol.CampusID,
- CampusCode = sfcol.CF_Campus.No,
- CampusName = sfcol.CF_Campus.Name,
- CollegeID = sf.CollegeID,
- CollegeNo = sfcol.No,
- CollegeName = sfcol.Name,
- DepartmentID = sf.DepartmentID,
- DepartmentCode = dep.No,
- DepartmentName = dep.Name,
- Nationality = sfpr.Nationality,
- Place = sfpr.Place,
- SexID = sf.SexID,
- BirthDate = sf.BirthDate,
- NationID = sf.NationID,
- PoliticsID = sf.PoliticsID,
- CertificatesType = sf.CertificatesType,
- CertificatesNum = sf.CertificatesNum,
- TeacherTypeID = sf.TeacherTypeID,
- IncumbencyState = sf.IncumbencyState,
- SituationID = sf.SituationID,
- TitleID = sf.TitleID,
- LiteracyLevelID = sf.LiteracyLevelID,
- LearnPositionID = sf.LearnPositionID,
- IsDualTeacher = sf.IsDualTeacher ?? false,
- PaymentLevelID = sf.PaymentLevelID,
- WorkDate = sf.WorkDate,
- ComeSchoolDate = sf.ComeSchoolDate,
- Email = sfpr.Email,
- ZIPCode = sfpr.ZIPCode,
- WeChatNum = sfpr.WeChatNum,
- QQ = sfpr.QQ,
- Telephone = sfpr.Telephone,
- OfficeTelephone = sfpr.OfficeTelephone,
- HousePhone = sfpr.HousePhone,
- Mobile = sfpr.Mobile,
- Speciality = sfpr.Speciality,
- HealthStateID = sfpr.HealthStateID,
- ReligionID = sfpr.ReligionID,
- Account = sfpr.Account,
- Residence = sfpr.Residence,
- HomeAddress = sfpr.HomeAddress,
- Address = sfpr.Address,
- NowAddress = sfpr.NowAddress,
- PhotoUrl = sf.PhotoUrl,
- PhotoHasValue = (sf.PhotoUrl == null || sf.PhotoUrl == "") ? false : true,
- Profile = sf.Profile,
- Remark = sf.Remark,
- RecordStatus = sf.RecordStatus,
- CreateUserID = sf.CreateUserID,
- CreateTime = sf.CreateTime,
- ModifyUserID = sf.ModifyUserID,
- ModifyTime = sf.ModifyTime
- };
- return query;
- }
- }
- }
|