123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using EMIS.Entities;
- using EMIS.ViewModel.UniversityManage.ClassroomManage;
- using EMIS.DataLogic.Repositories;
- namespace EMIS.DataLogic.UniversityManage.ClassroomManage
- {
- public class BuildingsInfoDAL
- {
- public BuildingsInfoRepository BuildingsInfoRepository { get; set; }
- public ClassroomRepository ClassroomRepository { get; set; }
- public ClassroomReserveRepository ClassroomReserveRepository { get; set; }
- public CollegeClassroomRepository CollegeClassroomRepository { get; set; }
- public CampusRepository CampusRepository { get; set; }
- public CollegeRepository CollegeRepository { get; set; }
- /// <summary>
- /// 查询对应的建筑信息View(统计对应的教室数量)
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<BuildingsInfoView> GetBuildingsInfoViewQueryable(Expression<Func<CF_BuildingsInfo, bool>> exp)
- {
- var query = from a in BuildingsInfoRepository.GetList(exp)
- join cr in
- (
- from cr in ClassroomRepository.Entities
- group cr by cr.BuildingsInfoID into gcr
- select new
- {
- BuildingsInfoID = gcr.Key,
- ClassroomCount = gcr.Count()
- }
- )
- on a.BuildingsInfoID equals cr.BuildingsInfoID into tempcr
- from bicr in tempcr.DefaultIfEmpty()
- select new BuildingsInfoView
- {
- BuildingsInfoID = a.BuildingsInfoID,
- Code = a.Code,
- Name = a.Name,
- CampusID = a.CF_Campus.CampusID,
- CampusCode = a.CF_Campus.No,
- CampusName = a.CF_Campus.Name,
- CollegeID = a.CF_College.CollegeID,
- CollegeCode = a.CF_College.No,
- CollegeName = a.CF_College.Name,
- CollegeCampusID = a.CF_College.CampusID,
- CollegeCampusCode = a.CF_College.CF_Campus.No,
- CollegeCampusName = a.CF_College.CF_Campus.Name,
- BuildingsTypeID = a.BuildingsTypeID,
- BuildingsStatusID = a.BuildingsStatusID,
- BuildingsLevel = a.BuildingsLevel,
- BuildingsArea = a.BuildingsArea,
- UseArea = a.UseArea,
- Position = a.Position,
- IsSpecial = a.IsSpecial ?? false,
- ClassroomCount = bicr.ClassroomCount == null ? 0 : bicr.ClassroomCount,
- Remark = a.Remark,
- RecordStatus = a.RecordStatus,
- CreateUserID = a.CreateUserID,
- CreateTime = a.CreateTime,
- ModifyUserID = a.ModifyUserID,
- ModifyTime = a.ModifyTime
- };
- return query;
- }
- /// <summary>
- /// 查询教室信息View(根据建筑信息查询,关联排课中教室预留信息、统计排课分配的院系个数)
- /// </summary>
- /// <param name="expBuildingsInfo"></param>
- /// <returns></returns>
- public IQueryable<ClassroomView> GetClassroomViewQueryable(Expression<Func<CF_BuildingsInfo, bool>> expBuildingsInfo)
- {
- var query = from bi in BuildingsInfoRepository.GetList(expBuildingsInfo)
- join cr in ClassroomRepository.Entities
- on bi.BuildingsInfoID equals cr.BuildingsInfoID
- 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 = bi.BuildingsInfoID,
- BuildingsInfoCode = bi.Code,
- BuildingsInfoName = bi.Name,
- CampusID = bi.CampusID,
- CampusCode = bi.CF_Campus.No,
- CampusName = bi.CF_Campus.Name,
- CollegeID = cr.CollegeID,
- CollegeCode = cr.CF_College.No,
- CollegeName = cr.CF_College.Name,
- 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;
- }
- }
- }
|