/// <summary>
        ///  根据楼-区-会议室查询会议室信息
        /// </summary>
        /// <param name="roomInformationSearchViewModel"></param>
        /// <returns></returns>
        public List <RoomInformationSearchMiddle> Room_Search(RoomInformationSearchViewModel roomInformationSearchViewModel)
        {
            var meetingroom_information = _IRoomInformationRepository.SearchRoomInformationWhere(roomInformationSearchViewModel);

            for (int i = 0; i < meetingroom_information.Count; i++)
            {
                TimeSpan GapTime         = new TimeSpan(0, 0, 00);
                var      RoomReservation = _IRoomInformationRepository.GetReservationByInformation(meetingroom_information[i].Id.ToString(), roomInformationSearchViewModel.ReservationDate);
                if (RoomReservation.Count > 0)
                {
                    for (int j = 0; j < RoomReservation.Count; j++)
                    {
                        string startdate  = RoomReservation[j].Meetingtime.ToString("HH:mm");
                        string endingdate = RoomReservation[j].Endingtime.ToString("HH:mm");
                        meetingroom_information[i].ReservationDate += startdate + "-" + endingdate + "  | ";
                        GapTime += (TimeSpan)(RoomReservation[j].Endingtime - RoomReservation[j].Meetingtime);
                    }
                    TimeSpan ralTime = new TimeSpan(15, 30, 00);

                    if (ralTime > GapTime)
                    {
                        meetingroom_information[i].RoomStatus = "1";//部分预定
                    }
                    if (ralTime <= GapTime)
                    {
                        meetingroom_information[i].RoomStatus = "2";//已经订满
                    }
                }
                else
                {
                    meetingroom_information[i].RoomStatus = "0";//全天空闲
                }
            }
            return(meetingroom_information);
        }
        /// <summary>
        /// 楼、区、会议室查询会议室信息
        /// </summary>
        /// <param name="bookSearchViewModel"></param>
        /// <returns></returns>
        public List <RoomInformationSearchMiddle> SearchRoomInformationWhere(RoomInformationSearchViewModel roomInformationSearchViewModel)
        {
            int SkipNum = roomInformationSearchViewModel.pageViewModel.CurrentPageNum * roomInformationSearchViewModel.pageViewModel.PageSize;

            var predicate = SearchRoominfo(roomInformationSearchViewModel);

            //var result = DbSet.Where(predicate).Include(a => a.DataBase_Type).OrderByDescending(a => a.CreateDate)
            //    .Skip(SkipNum)
            //    .Take(roomInformationSearchViewModel.pageViewModel.PageSize).ToList();
            var result = DbSet2.Where(D => D.Id.ToString().Contains(roomInformationSearchViewModel.FloorId)).Join(DbSet.Where(predicate).Include(c => c.DataBase_Type)
                                                                                                                  , a => a.Id.ToString(), D => D.DataBase_Type.Parentid, (a, D) => new RoomInformationSearchMiddle
            {
                Id                = D.Id,
                RoomNum           = D.RoomNum,
                RoomCapacity      = D.RoomCapacity,
                RoomDescription   = D.RoomDescription,
                RoomEquipmentCode = D.RoomEquipmentCode,
                RoomEquipmentName = D.RoomEquipmentName,
                Sort              = D.Sort,
                Status            = D.Status,
                IsDelete          = D.IsDelete,
                DataBase_TypeId   = D.DataBase_TypeId.ToString(),
                AreaName          = D.DataBase_Type.Name,
                FloorName         = a.Name,
            }).OrderByDescending(a => a.CreateDate)
                         .Skip(SkipNum)
                         .Take(roomInformationSearchViewModel.pageViewModel.PageSize).ToList();

            return(result);
        }
        public List <MeetingRoom_Information> SearchRoomInformationNum(RoomInformationSearchViewModel roomInformationSearchViewModel)
        {
            var predicate = SearchRoominfo(roomInformationSearchViewModel);

            var result = DbSet.Where(predicate).ToList();

            return(result);
        }
Example #4
0
        public ActionResult <MeetingRoom_Information> Manage_RoomSearchAll(RoomInformationSearchViewModel roomInformationSearchViewModel)
        {
            RoomInformationSearchResModel roomInformationSearchResModel = new RoomInformationSearchResModel();
            var Result = _RoomInformationService.Room_Search(roomInformationSearchViewModel);
            int count  = _RoomInformationService.Room_SearchNum(roomInformationSearchViewModel);

            roomInformationSearchResModel.Room_info                  = Result;
            roomInformationSearchResModel.TotalNum                   = count;
            roomInformationSearchResModel.isSuccess                  = true;
            roomInformationSearchResModel.baseViewModel.Message      = "查询成功";
            roomInformationSearchResModel.baseViewModel.ResponseCode = 200;
            _ILogger.Information("根据会议室信息,查询成功");
            return(Ok(roomInformationSearchResModel));
        }
        //根据条件查询会议室信息
        private Expression <Func <MeetingRoom_Information, bool> > SearchRoominfo(RoomInformationSearchViewModel roomInformationSearchViewModel)
        {
            var predicate = WhereExtension.True <MeetingRoom_Information>();//初始化where表达式

            predicate = predicate.And(a => a.IsDelete == "0");

            predicate = predicate.And(a => a.Id.ToString().Contains(roomInformationSearchViewModel.Id.ToString()));

            predicate = predicate.And(a => a.DataBase_TypeId.ToString().Contains(roomInformationSearchViewModel.AreaAll));

            predicate = predicate.And(a => a.DataBase_Type.Purview.Contains("(" + roomInformationSearchViewModel.departid + ")") || a.DataBase_Type.Purview.Contains("all"));

            return(predicate);
        }
        /// <summary>
        /// 查询会议室数量
        /// </summary>
        /// <param name="roomInformationSearchViewModel"></param>
        /// <returns></returns>
        public int Room_SearchNum(RoomInformationSearchViewModel roomInformationSearchViewModel)
        {
            List <MeetingRoom_Information> meetingroom_information = _IRoomInformationRepository.SearchRoomInformationNum(roomInformationSearchViewModel);
            List <MeetingRoom_Information> AreaSearchFloor         = new List <MeetingRoom_Information>();

            if ((roomInformationSearchViewModel.AreaAll == "" || roomInformationSearchViewModel.AreaAll == null) &&
                (roomInformationSearchViewModel.FloorId != "" && roomInformationSearchViewModel.FloorId != null))
            {
                List <DataBase_Type> floor_searchArea = _IDataBaseTypeRepository.SearchAreaByFloor(roomInformationSearchViewModel.FloorId);
                for (int i = 0; i < floor_searchArea.Count; i++)
                {
                    var dd = meetingroom_information.FindAll(a => a.DataBase_TypeId.ToString() == floor_searchArea[i].Id.ToString());

                    AreaSearchFloor = AreaSearchFloor.Union(dd).ToList();
                }
                return(AreaSearchFloor.Count);
            }
            else
            {
                return(meetingroom_information.Count);
            }
        }