123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
- using EMIS.ViewModel.UniversityManage.ClassroomManage;
- using EMIS.DataLogic.Repositories;
- namespace EMIS.DataLogic.SchedulingManage.SchedulingSettings
- {
- public class ClassroomReserveDAL
- {
- public ClassroomReserveRepository ClassroomReserveRepository { get; set; }
- public ClassroomRepository ClassroomRepository { get; set; }
- public CollegeClassroomRepository CollegeClassroomRepository { get; set; }
- public UserRepository UserRepository { get; set; }
- public DictionaryItemRepository DictionaryItemRepository { get; set; }
- /// <summary>
- /// 查询教室预留信息ClassroomReserveView(根据教室预留信息、统计排课分配院系个数)
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<ClassroomReserveView> GetClassroomReserveViewQueryable(Expression<Func<ES_ClassroomReserve, bool>> exp)
- {
- var query = from re in ClassroomReserveRepository.GetList(exp)
- join cr in ClassroomRepository.Entities
- on re.ClassroomID equals cr.ClassroomID
- join cc in
- (
- from cc in CollegeClassroomRepository.Entities
- group cc by cc.ClassroomID into gcr
- select new
- {
- ClassroomID = gcr.Key,
- ScheduleCollegeCount = gcr.Count()
- }
- )
- on re.ClassroomID equals cc.ClassroomID into tempcc
- from colcr in tempcc.DefaultIfEmpty()
- join cus in UserRepository.Entities
- on re.CreateUserID equals cus.UserID into tempcus
- from recus in tempcus.DefaultIfEmpty()
- select new ClassroomReserveView
- {
- ClassroomReserveID = re.ClassroomReserveID,
- ClassroomID = cr.ClassroomID,
- ClassroomCode = cr.Code,
- ClassroomName = cr.Name,
- BuildingsInfoID = cr.BuildingsInfoID,
- BuildingsInfoCode = cr.CF_BuildingsInfo.Code,
- BuildingsInfoName = cr.CF_BuildingsInfo.Name,
- CampusID = cr.CF_BuildingsInfo.CampusID,
- CampusNo = cr.CF_BuildingsInfo.CF_Campus.No,
- CampusName = cr.CF_BuildingsInfo.CF_Campus.Name,
- CollegeID = cr.CollegeID,
- CollegeCode = cr.CF_College.No,
- CollegeName = cr.CF_College.Name,
- UnitCategoryID = cr.CF_College.CF_CollegeProfile.UnitCategoryID,
- CollegeCampusID = cr.CF_College.CampusID,
- CollegeCampusCode = cr.CF_College.CF_Campus.No,
- CollegeCampusName = cr.CF_College.CF_Campus.Name,
- CF_ClassroomType = cr.CF_ClassroomType,
- ClassroomTypeIDList = cr.CF_ClassroomType.Select(x => x.ClassroomType).ToList(),
- RoomUseID = cr.RoomUseID,
- Totalseating = cr.Totalseating,
- Effectiveseating = cr.Effectiveseating,
- IsConcurrentUse = cr.IsConcurrentUse ?? false,
- IsReserve = re.IsReserved == true ? true : false,
- IsAvailable = cr.IsAvailable ?? false,
- ScheduleCollegeCount = colcr.ScheduleCollegeCount == null ? 0 : colcr.ScheduleCollegeCount,
- RecordStatus = re.RecordStatus,
- CreateUserID = re.CreateUserID,
- CreateUserName = recus.Name,
- CreateTime = re.CreateTime,
- ModifyUserID = re.ModifyUserID,
- ModifyTime = re.ModifyTime
- };
- return query;
- }
- /// <summary>
- /// 查询未预留的教室信息ClassroomView
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<ClassroomView> GetClassroomViewNoReserveQueryable(Expression<Func<CF_Classroom, bool>> exp)
- {
- var query = from cr in ClassroomRepository.GetList(exp)
- join re in ClassroomReserveRepository.Entities
- on cr.ClassroomID equals re.ClassroomID into tempre
- from crre in tempre.DefaultIfEmpty()
- where crre.ClassroomReserveID == null
- select new ClassroomView
- {
- ClassroomID = cr.ClassroomID,
- Code = cr.Code,
- Name = cr.Name,
- BuildingsInfoID = cr.BuildingsInfoID,
- BuildingsInfoCode = cr.CF_BuildingsInfo.Code,
- BuildingsInfoName = cr.CF_BuildingsInfo.Name,
- CampusID = cr.CF_BuildingsInfo.CampusID,
- CampusCode = cr.CF_BuildingsInfo.CF_Campus.No,
- CampusName = cr.CF_BuildingsInfo.CF_Campus.Name,
- CollegeID = cr.CollegeID,
- CollegeCode = cr.CF_College.No,
- CollegeName = cr.CF_College.Name,
- UnitCategoryID = cr.CF_College.CF_CollegeProfile.UnitCategoryID,
- CollegeCampusID = cr.CF_College.CampusID,
- CollegeCampusCode = cr.CF_College.CF_Campus.No,
- CollegeCampusName = cr.CF_College.CF_Campus.Name,
- CF_ClassroomType = cr.CF_ClassroomType,
- ClassroomTypeIDList = cr.CF_ClassroomType.Select(x => x.ClassroomType).ToList(),
- LayoutTypeID = cr.LayoutTypeID,
- RoomUseID = cr.RoomUseID,
- FloorLevel = cr.FloorLevel,
- Acreage = cr.Acreage,
- RowCout = cr.RowCout,
- ColumnCount = cr.ColumnCount,
- Totalseating = cr.Totalseating,
- Effectiveseating = cr.Effectiveseating,
- Examinationseating = cr.Examinationseating,
- IsWrittenExam = cr.IsWrittenExam ?? false,
- IsMachinetest = cr.IsMachinetest ?? false,
- IsConcurrentUse = cr.IsConcurrentUse ?? false,
- IsAvailable = cr.IsAvailable ?? false,
- Remark = cr.Remark,
- RecordStatus = cr.RecordStatus,
- CreateUserID = cr.CreateUserID,
- CreateTime = cr.CreateTime,
- ModifyUserID = cr.ModifyUserID,
- ModifyTime = cr.ModifyTime
- };
- return query;
- }
- /// <summary>
- /// 查询教室类型信息ClassroomTypeView
- /// </summary>
- /// <returns></returns>
- public IQueryable<ClassroomTypeView> GetClassroomTypeViewQueryable()
- {
- var query = from cr in ClassroomRepository.Entities
- from crct in cr.CF_ClassroomType
- join dicct in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_ClassroomType).Name)
- on crct.ClassroomType equals dicct.Value
- select new ClassroomTypeView
- {
- ClassroomTypeID = crct.ClassroomTypeID,
- ClassroomID = cr.ClassroomID,
- ClassroomType = crct.ClassroomType,
- ClassroomTypeName = dicct.Name
- };
- return query;
- }
- /// <summary>
- /// 查询教室类型信息ClassroomTypeView(根据教室信息)
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<ClassroomTypeView> GetClassroomTypeViewQueryable(Expression<Func<CF_Classroom, bool>> exp)
- {
- var query = from cr in ClassroomRepository.GetList(exp)
- from crct in cr.CF_ClassroomType
- join dicct in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_ClassroomType).Name)
- on crct.ClassroomType equals dicct.Value
- select new ClassroomTypeView
- {
- ClassroomTypeID = crct.ClassroomTypeID,
- ClassroomID = cr.ClassroomID,
- ClassroomType = crct.ClassroomType,
- ClassroomTypeName = dicct.Name
- };
- return query;
- }
- }
- }
|