Esempio n. 1
0
        /// <summary>
        /// 获取进出记录
        /// </summary>
        /// <param name="studentNo">用户学号</param>
        /// <param name="pageIndex">页编码</param>
        /// <param name="pageSize">每页数目</param>
        /// <returns></returns>
        public string GetEnterOutLog(string studentNo, int pageIndex, int pageSize)
        {
            AJM_HandleResult result = new AJM_HandleResult();

            try
            {
                if (string.IsNullOrEmpty(studentNo))
                {
                    result.Result = false;
                    result.Msg    = "学号不能为空!";
                    return(JSONSerializer.Serialize(result));
                }
                if (pageIndex < 0 || pageSize < 0)
                {
                    result.Result = false;
                    result.Msg    = "页数和每页显示数目必须大于等于0";
                    return(JSONSerializer.Serialize(result));
                }
                List <EnterOutLogInfo> enterOutLogInfos = SeatManageDateService.GetEnterOutLogsByPage(studentNo, pageIndex, pageSize);
                List <AJM_EnterOutLog> ajmEnterOutLogs  = new List <AJM_EnterOutLog>();
                for (int i = 0; i < enterOutLogInfos.Count; i++)
                {
                    AJM_EnterOutLog ajmEnterOutLog = new AJM_EnterOutLog();
                    ajmEnterOutLog = new AJM_EnterOutLog();
                    ajmEnterOutLog.EnterOutState = enterOutLogInfos[i].EnterOutState.ToString();
                    ajmEnterOutLog.EnterOutTime  = enterOutLogInfos[i].EnterOutTime.ToString("yyyy-MM-d HH:mm:ss");
                    ajmEnterOutLog.Id            = enterOutLogInfos[i].EnterOutLogID;
                    ajmEnterOutLog.Remark        = enterOutLogInfos[i].Remark;
                    ajmEnterOutLog.RoomName      = enterOutLogInfos[i].ReadingRoomName;
                    ajmEnterOutLog.RoomNo        = enterOutLogInfos[i].ReadingRoomNo;
                    ajmEnterOutLog.SeatNo        = enterOutLogInfos[i].SeatNo;
                    ajmEnterOutLog.SeatShortNo   = enterOutLogInfos[i].ShortSeatNo;
                    ajmEnterOutLogs.Add(ajmEnterOutLog);
                }
                if (ajmEnterOutLogs.Count < 1)
                {
                    result.Result = false;
                    result.Msg    = "暂时没有进出记录!";
                    return(JSONSerializer.Serialize(result));
                }
                result.Result = true;
                result.Msg    = JSONSerializer.Serialize(ajmEnterOutLogs);
                return(JSONSerializer.Serialize(result));
            }
            catch (Exception ex)
            {
                WriteLog.Write(string.Format("获取进出记录遇到异常:{0}", ex.Message));
                result.Result = false;
                result.Msg    = "获取进出记录执行异常!";
                return(JSONSerializer.Serialize(result));
            }
        }
        /// <summary>
        /// 获取用户当前的在座状态
        /// </summary>
        /// <param name="studentNo">学号</param>
        /// <returns></returns>
        public string GetUserNowState(string studentNo)
        {
            AJM_HandleResult result = new AJM_HandleResult();

            try
            {
                if (string.IsNullOrEmpty(studentNo))
                {
                    result.Result = false;
                    result.Msg    = "学号不能为空";
                    return(JSONSerializer.Serialize(result));
                }
                ReaderInfo readerInfo = seatManageDateService.GetReader(studentNo, true);

                if (readerInfo == null)
                {
                    result.Result = false;
                    result.Msg    = "未查询到该读者的当前状态";
                    return(JSONSerializer.Serialize(result));
                }
                AJM_ReaderStatus ajmReaderStatus = new AJM_ReaderStatus();

                if (readerInfo.EnterOutLog != null)
                {
                    AJM_EnterOutLog ajmEnterOutLog = new AJM_EnterOutLog
                    {
                        EnterOutTime  = readerInfo.EnterOutLog.EnterOutTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        EnterOutState = readerInfo.EnterOutLog.EnterOutState.ToString(),
                        Id            = readerInfo.EnterOutLog.EnterOutLogID,
                        Operator      = readerInfo.EnterOutLog.Flag.ToString(),
                        Remark        = readerInfo.EnterOutLog.Remark,
                        RoomName      = readerInfo.EnterOutLog.ReadingRoomName,
                        RoomNo        = readerInfo.EnterOutLog.ReadingRoomNo,
                        SeatNo        = readerInfo.EnterOutLog.SeatNo,
                        SeatShortNo   = readerInfo.EnterOutLog.ShortSeatNo
                    };
                    switch (readerInfo.EnterOutLog.EnterOutState)
                    {
                    case EnterOutLogType.None:
                    case EnterOutLogType.Leave:
                    case EnterOutLogType.BookingCancel:
                    case EnterOutLogType.WaitingCancel:
                    case EnterOutLogType.BespeakWaiting:
                        ajmReaderStatus.Status = ReaderStatus.Leave.ToString();
                        break;

                    case EnterOutLogType.BookingConfirmation:
                    case EnterOutLogType.CancelTime:
                    case EnterOutLogType.ComeBack:
                    case EnterOutLogType.ContinuedTime:
                    case EnterOutLogType.ReselectSeat:
                    case EnterOutLogType.SelectSeat:
                    case EnterOutLogType.Timing:
                    case EnterOutLogType.WaitingSuccess:
                        ajmReaderStatus.Status = ReaderStatus.Seating.ToString();
                        break;

                    case EnterOutLogType.ShortLeave:
                        ajmReaderStatus.Status = ReaderStatus.ShortLeave.ToString();
                        break;

                    case EnterOutLogType.Waiting:
                        ajmReaderStatus.Status = ReaderStatus.Waiting.ToString();
                        break;
                    }
                    ajmReaderStatus.AjmEnterOutLog = ajmEnterOutLog;
                }
                if (readerInfo.WaitSeatLog != null)
                {
                    AJM_WaitSeatLog ajmWaitSeatLog = new AJM_WaitSeatLog
                    {
                        RoomName     = readerInfo.WaitSeatLog.EnterOutLog.ReadingRoomName,
                        RoomNo       = readerInfo.WaitSeatLog.ReadingRoomNo,
                        SeatNo       = readerInfo.WaitSeatLog.SeatNo,
                        SeatShortNo  = readerInfo.WaitSeatLog.EnterOutLog.ShortSeatNo,
                        SeatWaitId   = readerInfo.WaitSeatLog.SeatWaitingID,
                        SeatWaitTime = readerInfo.WaitSeatLog.SeatWaitTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        StudentNo_A  = readerInfo.WaitSeatLog.CardNo,
                        StudentNo_B  = readerInfo.WaitSeatLog.CardNoB
                    };
                    ajmReaderStatus.AjmWaitSeatLogs = ajmWaitSeatLog;
                    ajmReaderStatus.Status          = ReaderStatus.Waiting.ToString();
                }
                if (readerInfo.BespeakLog.Count > 0)
                {
                    foreach (BespeakLogInfo model in readerInfo.BespeakLog)
                    {
                        if (model.BsepeakTime.Date == DateTime.Now.Date)
                        {
                            ajmReaderStatus.Status = ReaderStatus.Booking.ToString();
                        }
                        AJM_BespeakLog ajmBespeakLog = new AJM_BespeakLog
                        {
                            Id             = model.BsepeaklogID,
                            BookTime       = model.BsepeakTime.ToString("yyyy-MM-dd HH:mm:ss"),
                            IsValid        = true,
                            Remark         = model.Remark,
                            RoomName       = model.ReadingRoomName,
                            RoomNo         = model.ReadingRoomNo,
                            SeatNo         = model.SeatNo,
                            SeatShortNo    = model.ShortSeatNum,
                            SubmitDateTime = model.SubmitTime.ToString("yyyy-MM-dd HH:mm:ss")
                        };
                        ajmReaderStatus.AjmBespeakLogs.Add(ajmBespeakLog);
                    }
                }
                result.Result = true;
                result.Msg    = JSONSerializer.Serialize(ajmReaderStatus);
                return(JSONSerializer.Serialize(result));
            }
            catch (Exception ex)
            {
                WriteLog.Write(string.Format("获取读者当前状态发生异常:{0}", ex.Message));
                result.Result = false;
                result.Msg    = "获取用户状态执行异常!";
                return(JSONSerializer.Serialize(result));
            }
        }
        /// <summary>
        /// 获取登录读者详细信息
        /// </summary>
        /// <param name="studentNo"></param>
        /// <returns></returns>
        public string GetUserInfo_WeiXin(string studentNo)
        {
            AJM_HandleResult result = new AJM_HandleResult();

            try
            {
                if (string.IsNullOrEmpty(studentNo))
                {
                    result.Result = false;
                    result.Msg    = "学号不能为空!";
                    return(JSONSerializer.Serialize(result));
                }
                ReaderInfo readerInfo = seatManageDateService.GetReader(studentNo, true);
                if (readerInfo == null)
                {
                    result.Result = false;
                    result.Msg    = "未查询到该读者的当前状态";
                    return(JSONSerializer.Serialize(result));
                }
                AJM_WeiXinUserInfo ajmWeiXinUserInfo = new AJM_WeiXinUserInfo();
                ajmWeiXinUserInfo.StudentNo  = readerInfo.CardNo;
                ajmWeiXinUserInfo.Name       = readerInfo.Name;
                ajmWeiXinUserInfo.ReaderType = readerInfo.ReaderType;
                //预约网站设置
                ajmWeiXinUserInfo.AjmPecketBookSetting.UseBookComfirm     = readerInfo.PecketWebSetting.UseBookComfirm;
                ajmWeiXinUserInfo.AjmPecketBookSetting.UseBookNextDaySeat = readerInfo.PecketWebSetting.UseBookNextDaySeat;
                ajmWeiXinUserInfo.AjmPecketBookSetting.UseBookNowDaySeat  = readerInfo.PecketWebSetting.UseBookNowDaySeat;
                ajmWeiXinUserInfo.AjmPecketBookSetting.UseBookSeat        = readerInfo.PecketWebSetting.UseBookSeat;
                ajmWeiXinUserInfo.AjmPecketBookSetting.UseCanLeave        = readerInfo.PecketWebSetting.UseCanLeave;
                ajmWeiXinUserInfo.AjmPecketBookSetting.UseCancelBook      = readerInfo.PecketWebSetting.UseCancelBook;
                ajmWeiXinUserInfo.AjmPecketBookSetting.UseCancelWait      = readerInfo.PecketWebSetting.UseCancelWait;
                ajmWeiXinUserInfo.AjmPecketBookSetting.UseChangeSeat      = readerInfo.PecketWebSetting.UseChangeSeat;
                ajmWeiXinUserInfo.AjmPecketBookSetting.UseComeBack        = readerInfo.PecketWebSetting.UseComeBack;
                ajmWeiXinUserInfo.AjmPecketBookSetting.UseContinue        = readerInfo.PecketWebSetting.UseContinue;
                ajmWeiXinUserInfo.AjmPecketBookSetting.UseSelectSeat      = readerInfo.PecketWebSetting.UseSelectSeat;
                ajmWeiXinUserInfo.AjmPecketBookSetting.UseShortLeave      = readerInfo.PecketWebSetting.UseShortLeave;
                ajmWeiXinUserInfo.AjmPecketBookSetting.UseWaitSeat        = readerInfo.PecketWebSetting.UseWaitSeat;

                AJM_ReaderStatus ajmReaderStatus = new AJM_ReaderStatus();

                if (readerInfo.EnterOutLog != null)
                {
                    AJM_EnterOutLog ajmEnterOutLog = new AJM_EnterOutLog();
                    ajmEnterOutLog.EnterOutTime           = readerInfo.EnterOutLog.EnterOutTime.ToString("yyyy-MM-dd HH:mm:ss");
                    ajmEnterOutLog.EnterOutState          = readerInfo.EnterOutLog.EnterOutState.ToString();
                    ajmEnterOutLog.Id                     = readerInfo.EnterOutLog.EnterOutLogID;
                    ajmEnterOutLog.Operator               = readerInfo.EnterOutLog.Flag.ToString();
                    ajmEnterOutLog.Remark                 = readerInfo.EnterOutLog.Remark;
                    ajmEnterOutLog.RoomName               = readerInfo.EnterOutLog.ReadingRoomName;
                    ajmEnterOutLog.RoomNo                 = readerInfo.EnterOutLog.ReadingRoomNo;
                    ajmEnterOutLog.SeatNo                 = readerInfo.EnterOutLog.SeatNo;
                    ajmEnterOutLog.SeatShortNo            = readerInfo.EnterOutLog.ShortSeatNo;
                    ajmWeiXinUserInfo.AjmReadingRoomState = GetSingleRoomOpenState(ajmEnterOutLog.RoomNo);

                    switch (readerInfo.EnterOutLog.EnterOutState)
                    {
                    case EnumType.EnterOutLogType.None:
                    case EnumType.EnterOutLogType.Leave:
                    case EnumType.EnterOutLogType.BookingCancel:
                    case EnumType.EnterOutLogType.WaitingCancel:
                    case EnumType.EnterOutLogType.BespeakWaiting:
                        ajmReaderStatus.Status = EnumType.ReaderStatus.Leave.ToString();
                        break;

                    case EnumType.EnterOutLogType.BookingConfirmation:
                    case EnumType.EnterOutLogType.CancelTime:
                    case EnumType.EnterOutLogType.ComeBack:
                    case EnumType.EnterOutLogType.ContinuedTime:
                    case EnumType.EnterOutLogType.ReselectSeat:
                    case EnumType.EnterOutLogType.SelectSeat:
                    case EnumType.EnterOutLogType.Timing:
                    case EnumType.EnterOutLogType.WaitingSuccess:
                        ajmReaderStatus.Status = EnumType.ReaderStatus.Seating.ToString();
                        break;

                    case EnumType.EnterOutLogType.ShortLeave:
                        ajmReaderStatus.Status = EnumType.ReaderStatus.ShortLeave.ToString();
                        break;

                    case EnumType.EnterOutLogType.Waiting:
                        ajmReaderStatus.Status = EnumType.ReaderStatus.Waiting.ToString();
                        break;
                    }
                    ajmReaderStatus.AjmEnterOutLog = ajmEnterOutLog;
                }
                if (readerInfo.WaitSeatLog != null)
                {
                    AJM_WaitSeatLog ajmWaitSeatLog = new AJM_WaitSeatLog();
                    ajmWaitSeatLog.RoomName               = readerInfo.WaitSeatLog.EnterOutLog.ReadingRoomName;
                    ajmWaitSeatLog.RoomNo                 = readerInfo.WaitSeatLog.ReadingRoomNo;
                    ajmWaitSeatLog.SeatNo                 = readerInfo.WaitSeatLog.SeatNo;
                    ajmWaitSeatLog.SeatShortNo            = readerInfo.WaitSeatLog.EnterOutLog.ShortSeatNo;
                    ajmWaitSeatLog.SeatWaitId             = readerInfo.WaitSeatLog.SeatWaitingID;
                    ajmWaitSeatLog.SeatWaitTime           = readerInfo.WaitSeatLog.SeatWaitTime.ToString("yyyy-MM-dd HH:mm:ss");
                    ajmWaitSeatLog.StudentNo_A            = readerInfo.WaitSeatLog.CardNo;
                    ajmWaitSeatLog.StudentNo_B            = readerInfo.WaitSeatLog.CardNoB;
                    ajmWeiXinUserInfo.AjmReadingRoomState = GetSingleRoomOpenState(ajmWaitSeatLog.RoomNo);

                    ajmReaderStatus.AjmWaitSeatLogs = ajmWaitSeatLog;
                    ajmReaderStatus.Status          = EnumType.ReaderStatus.Waiting.ToString();
                }
                if (readerInfo.BespeakLog.Count > 0)
                {
                    foreach (BespeakLogInfo model in readerInfo.BespeakLog)
                    {
                        if (model.BsepeakTime.Date == DateTime.Now.Date)
                        {
                            ajmReaderStatus.Status = EnumType.ReaderStatus.Booking.ToString();
                        }
                        AJM_BespeakLog ajmBespeakLog = new AJM_BespeakLog
                        {
                            Id             = model.BsepeaklogID,
                            BookTime       = model.BsepeakTime.ToString("yyyy-MM-dd HH:mm:ss"),
                            IsValid        = true,
                            Remark         = model.Remark,
                            RoomName       = model.ReadingRoomName,
                            RoomNo         = model.ReadingRoomNo,
                            SeatNo         = model.SeatNo,
                            SeatShortNo    = model.ShortSeatNum,
                            SubmitDateTime = model.SubmitTime.ToString("yyyy-MM-dd HH:mm:ss")
                        };
                        ajmReaderStatus.AjmBespeakLogs.Add(ajmBespeakLog);
                    }
                }
                ajmWeiXinUserInfo.AjmReaderStatus = ajmReaderStatus;

                result.Result = true;
                result.Msg    = JSONSerializer.Serialize(ajmWeiXinUserInfo);
                return(JSONSerializer.Serialize(result));
            }
            catch (Exception ex)
            {
                WriteLog.Write(string.Format("获取登录读者详细信息遇到异常:{0}", ex.Message));
                result.Result = false;
                result.Msg    = "获取登录读者详细信息执行遇到异常!";
                return(JSONSerializer.Serialize(result));
            }
        }