123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.UniversityManage.ClassroomManage;
- using EMIS.DataLogic.Repositories;
- namespace EMIS.DataLogic.UniversityManage.ClassroomManage
- {
- public class ClassroomDAL
- {
- public ClassroomRepository ClassroomRepository { get; set; }
- public ClassroomTypeRepository ClassroomTypeRepository { get; set; }
- public BuildingsInfoRepository BuildingsInfoRepository { get; set; }
- public CollegeRepository CollegeRepository { get; set; }
- public ClassroomReserveRepository ClassroomReserveRepository { get; set; }
- public CollegeClassroomRepository CollegeClassroomRepository { get; set; }
- public DictionaryItemRepository DictionaryItemRepository { get; set; }
- public ClassroomTypeRepository classroomTypeRepository { get; set; }
- /// <summary>
- /// 查询教室信息View(关联排课中教室预留信息、统计排课分配的院系个数)
- /// </summary>
- /// <param name="expClassroom"></param>
- /// <returns></returns>
- public IQueryable<ClassroomView> GetClassroomViewQueryable(Expression<Func<CF_Classroom, bool>> expClassroom)
- {
- var query = from cr in ClassroomRepository.GetList(expClassroom)
- join re in ClassroomReserveRepository.Entities
- on cr.ClassroomID equals re.ClassroomID into tempre
- from crre in tempre.DefaultIfEmpty()
- join cc in
- (
- from cc in CollegeClassroomRepository.Entities
- group cc by cc.ClassroomID into gcr
- select new
- {
- ClassroomID = gcr.Key,
- ScheduleCollegeCount = gcr.Count()
- }
- )
- on cr.ClassroomID equals cc.ClassroomID into tempcc
- from colcr in tempcc.DefaultIfEmpty()
- 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,
- IsReserve = crre.IsReserved == true ? true : false,
- IsAvailable = cr.IsAvailable ?? false,
- ScheduleCollegeCount = colcr.ScheduleCollegeCount == null ? 0 : colcr.ScheduleCollegeCount,
- Remark = cr.Remark,
- RecordStatus = cr.RecordStatus,
- CreateUserID = cr.CreateUserID,
- CreateTime = cr.CreateTime,
- ModifyUserID = cr.ModifyUserID,
- ModifyTime = cr.ModifyTime
- };
- return query;
- }
- /// <summary>
- /// 查询教室信息对应的排课分配院系所信息(根据教室信息)
- /// </summary>
- /// <param name="expClassroom"></param>
- /// <returns></returns>
- public IQueryable<ClassroomView> GetClassroomCollegeViewQueryable(Expression<Func<CF_Classroom, bool>> expClassroom)
- {
- var query = from cr in ClassroomRepository.GetList(expClassroom)
- join re in ClassroomReserveRepository.Entities
- on cr.ClassroomID equals re.ClassroomID into tempre
- from crre in tempre.DefaultIfEmpty()
- join colcr in CollegeClassroomRepository.Entities
- on cr.ClassroomID equals colcr.ClassroomID
- join col in CollegeRepository.Entities
- on colcr.CollegeID equals col.CollegeID
- 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 = colcr.CollegeID,
- CollegeCode = col.No,
- CollegeName = col.Name,
- UnitCategoryID = col.CF_CollegeProfile.UnitCategoryID,
- CollegeCampusID = col.CampusID,
- CollegeCampusCode = col.CF_Campus.No,
- CollegeCampusName = col.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,
- IsReserve = crre.IsReserved == true ? true : 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>
- /// 查询对应的教室类型信息(根据教室信息ID)
- /// </summary>
- /// <param name="classroomID"></param>
- /// <returns></returns>
- public List<int> GetClassroomModeTypeQueryble(Guid? classroomID)
- {
- var query = from a in ClassroomTypeRepository.Entities.Where(x => x.ClassroomID == classroomID)
- join b in DictionaryItemRepository.Entities
- on new { ClassroomType = a.ClassroomType, DictionaryCode = DictionaryItem.CF_ClassroomType.ToString() }
- equals new { ClassroomType = b.Value, DictionaryCode = b.DictionaryCode }
- select b.Value.Value;
- return query.ToList();
- }
- }
- }
|