Exemplo n.º 1
0
        /// <summary>
        /// 出场抓拍数据推送到客户端(实现移动岗亭功能)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static bool SendDataToClient(CaptureInOutModel model)
        {
            RequestFujicaMvcApi request = new RequestFujicaMvcApi();
            //请求方法
            string servername = "Capture/CaptureSend";
            //请求参数
            Dictionary <string, object> dicParam = new Dictionary <string, object>();

            dicParam["Guid"]        = model.Guid;        //编号
            dicParam["ParkCode"]    = model.ParkCode;    //停车场编码
            dicParam["DriveWayMAC"] = model.DriveWayMAC; //车道设备地址
            dicParam["CarNo"]       = model.CarNo;       //车牌号
            dicParam["EntryType"]   = model.EntryType;   //出入场类型
            dicParam["Entrance"]    = model.Entrance;    //入口地址
            dicParam["Exit"]        = model.Exit;        //出口地址
            dicParam["InImgUrl"]    = model.InImgUrl;    //入场图片地址
            dicParam["OutImgUrl"]   = model.OutImgUrl;   //出场图片地址
            dicParam["InTime"]      = model.InTime;      //车辆的入场时间
            dicParam["OutTime"]     = model.OutTime;     //车辆的出场时间
            dicParam["CarTypeName"] = model.CarTypeName; //车类
            dicParam["CarType"]     = model.CarType;     //车类
            dicParam["CarTypeGuid"] = model.CarTypeGuid;
            dicParam["Remark"]      = model.Remark;      //备注
            dicParam["ErrorCode"]   = model.ErrorCode;
            return(request.RequestInterfaceMvc(servername, dicParam));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 车道进出抓拍数据进出数据保存到redis中
        /// </summary>
        /// <param name="model">车道实体</param>
        /// <param name="m_serializer">序列化对象</param>
        /// <returns></returns>
        private static bool GateDataToRedis(CaptureInOutModel model, ISerializer m_serializer)
        {
            IDatabase db       = RedisHelper.GetDatabase(0);
            string    redisKey = $"GateDataList:{model.ParkCode}";

            db.HashSet(redisKey, model.DriveWayMAC, m_serializer.Serialize(model));
            db.KeyExpire(redisKey, DateTime.Now.AddDays(1).Date);
            return(db.HashExists(redisKey, model.DriveWayMAC));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取车道车辆进出抓拍数据
        /// </summary>
        /// <param name="parkingCode">车场编号</param>
        /// <param name="deviceMacAddress">车道mac地址</param>
        /// <returns></returns>
        public CaptureInOutModel GetGateData(string parkingCode, string deviceMacAddress)
        {
            CaptureInOutModel model = null;

            _gateDataRedisOperate.model = new CaptureInOutModel()
            {
                ParkCode = parkingCode, DriveWayMAC = deviceMacAddress
            };
            model = _gateDataRedisOperate.GetFromRedis();
            return(model);
        }
Exemplo n.º 4
0
        public IHttpActionResult CaptureSend(CaptureInOutModel model)
        {
            ResponseBaseCommon response = new ResponseBaseCommon()
            {
                IsSuccess      = false,
                MessageCode    = (int)ApiBaseErrorCode.API_FAIL,
                MessageContent = "请求失败"
            };
            List <string> laneIds = new List <string>()
            {
            };

            if (model.DriveWayMAC != null)
            {
                laneIds.Add(model.DriveWayMAC);
            }
            Clients.Groups(laneIds).broadcastMessage(model); //broadcastMessage
            response.IsSuccess      = true;
            response.MessageCode    = (int)ApiBaseErrorCode.API_SUCCESS;
            response.MessageContent = "请求成功";
            return(Ok(response));
        }
Exemplo n.º 5
0
        public static ResponseCommon DataHandle(ILogger m_ilogger, ISerializer m_serializer)
        {
            ResponseCommon response = new ResponseCommon()
            {
                IsSuccess = false,
                MsgType   = MsgType.GateCatch
            };

            IDatabase db;

            db = RedisHelper.GetDatabase(4);
            string redisContent = db.ListLeftPop(mq_ListKey);

            if (string.IsNullOrEmpty(redisContent))
            {
                response.MessageContent = "redis数据库读取值为空";
                return(response);
            }
            response.RedisContent = redisContent;

            GateCatchModel catchModel = m_serializer.Deserialize <GateCatchModel>(redisContent);

            if (catchModel == null)
            {
                response.MessageContent = "redis数据库读取值转换成实体失败:";
                return(response);
            }
            if (string.IsNullOrEmpty(catchModel.DeviceIdentify) ||
                string.IsNullOrEmpty(catchModel.ImgUrl)
                //|| string.IsNullOrEmpty(catchModel.CarNo)
                //|| string.IsNullOrEmpty(catchModel.CarTypeGuid)
                )
            {
                response.MessageContent = "redis数据转换成实体后必要参数缺失";
                return(response);
            }

            db = RedisHelper.GetDatabase(0);
            string        drivewayguid  = db.HashGet("DrivewayLinkMACList", catchModel.DeviceIdentify);
            DrivewayModel drivewaymodel = m_serializer.Deserialize <DrivewayModel>(db.HashGet("DrivewayList", drivewayguid ?? ""));

            if (drivewaymodel == null)
            {
                response.MessageContent = "根据车道相机设备MAC地址,读取车道模型为空";
                m_ilogger.LogError(LoggerLogicEnum.Tools, "", "", catchModel.CarNo, "Fujica.com.cn.MonitorServiceClient.GateCatchDataManager", "根据车道相机设备MAC地址,读取车道模型为空");
                return(response);
            }

            ParkLotModel parklotmodel = m_serializer.Deserialize <ParkLotModel>(db.HashGet("ParkLotList", drivewaymodel.ParkCode));

            if (parklotmodel == null)
            {
                response.MessageContent = "根据停车场编码,读取车场模型为空";
                m_ilogger.LogError(LoggerLogicEnum.Tools, "", "", catchModel.CarNo, "Fujica.com.cn.MonitorServiceClient.GateCatchDataManager", "根据停车场编码,读取车场模型为空");
                return(response);
            }

            //500错误为“非法开闸”
            if (catchModel.ErrorCode == 500)
            {
                //将非法开闸数据发送给Fujica Api存入“异常开闸记录”报表
                if (!AddOpenGateRecord(catchModel, drivewaymodel, m_ilogger))
                {
                    response.MessageContent = "遥控手动非法开闸记录发送Fujica Api失败";
                    m_ilogger.LogError(LoggerLogicEnum.Tools, "", parklotmodel.ParkCode, catchModel.CarNo, "Fujica.com.cn.MonitorServiceClient.GateCatchDataManager", "遥控手动非法开闸记录发送Fujica Api失败");
                    return(response);
                }
                else
                {
                    response.IsSuccess      = true;
                    response.MessageContent = "遥控手动非法开闸记录成功";
                    return(response);
                }
            }

            CarTypeModel cartypemodel = null;

            VehicleEntryDetailModel entrymodel = new VehicleEntryDetailModel(); //入场记录

            //无压地感车辆、无牌车数据
            if (catchModel.ErrorCode == 407 || catchModel.ErrorCode == 404)
            {
                cartypemodel = new CarTypeModel();
            }

            /// 13-无入场记录
            /// 14-临时车未缴费
            /// 400-黑名单
            /// 401-通行限制
            /// 402-月卡被锁
            /// 403-月卡过期
            /// 404-禁止无牌车
            /// 405-手动开闸
            /// 406-满车位
            /// 407-无压地感车辆
            /// 408是储值卡余额不足
            else
            {
                cartypemodel = m_serializer.Deserialize <CarTypeModel>(db.HashGet("CarTypeList", catchModel.CarTypeGuid));
                if (cartypemodel == null)
                {
                    response.MessageContent = "根据车类Guid,读取车类模型为空";
                    m_ilogger.LogError(LoggerLogicEnum.Tools, "", "", catchModel.CarNo, "Fujica.com.cn.MonitorServiceClient.EntryDataManager", "根据车类Guid,读取车类模型为空");
                    return(response);
                }
                if (catchModel.ErrorCode == 14 || catchModel.ErrorCode == 402 || catchModel.ErrorCode == 403 || catchModel.ErrorCode == 408 || catchModel.ErrorCode == 405)
                {
                    db = RedisHelper.GetDatabase(Common.GetDatabaseNumber(catchModel.CarNo));
                    //入场实体内容
                    entrymodel = m_serializer.Deserialize <VehicleEntryDetailModel>(db.HashGet(catchModel.CarNo, drivewaymodel.ParkCode));
                }
            }

            GateCatchDetailModel detailModel = new GateCatchDetailModel()
            {
                CarNo        = catchModel.CarNo,
                ParkingCode  = drivewaymodel.ParkCode,
                DrivewayName = drivewaymodel.DrivewayName,
                DriveWayMAC  = catchModel.DeviceIdentify,
                CarType      = cartypemodel.CarType,
                CarTypeGuid  = cartypemodel.Guid,
                CarTypeName  = cartypemodel.CarTypeName,
                ImgUrl       = catchModel.ImgUrl
            };

            //存到redis
            try
            {
                db = RedisHelper.GetDatabase(0);
                db.HashSet("GateCatchList", detailModel.DriveWayMAC, m_serializer.Serialize(detailModel)); //存储车道拦截数据
                bool flag = db.HashExists("GateCatchList", detailModel.DriveWayMAC);

                #region 移动岗亭数据推送
                CaptureInOutModel capturModel = new CaptureInOutModel();
                capturModel.Guid        = drivewaymodel.Guid;
                capturModel.ParkCode    = detailModel.ParkingCode;
                capturModel.Exit        = detailModel.DrivewayName;
                capturModel.DriveWayMAC = detailModel.DriveWayMAC;
                capturModel.CarNo       = detailModel.CarNo;
                if (drivewaymodel.Type == DrivewayType.In) //入场 异常数据
                {
                    capturModel.InImgUrl  = detailModel.ImgUrl;
                    capturModel.InTime    = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    capturModel.EntryType = "0";
                }
                else
                {
                    capturModel.OutImgUrl = detailModel.ImgUrl;
                    capturModel.OutTime   = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    capturModel.EntryType = "1";
                    if (catchModel.ErrorCode > 13 && (entrymodel.CarNo != null || entrymodel.CarNo != ""))//有入场记录
                    {
                        capturModel.InImgUrl = entrymodel.InImgUrl;
                        capturModel.Entrance = entrymodel.Entrance;
                        capturModel.InTime   = Convert.ToDateTime(entrymodel.BeginTime);
                    }
                }
                capturModel.CarType     = Convert.ToInt32(detailModel.CarType);
                capturModel.CarTypeName = detailModel.CarTypeName;
                capturModel.CarTypeGuid = detailModel.CarTypeGuid;
                capturModel.Remark      = "异常数据";
                capturModel.ErrorCode   = catchModel.ErrorCode.ToString();
                //推送到客户端(实现移动岗亭功能)
                SendDataToClient(capturModel);

                //存储一份在redis中
                GateDataToRedis(capturModel, m_serializer);
                #endregion

                if (!flag)
                {
                    response.MessageContent = "车道拦截数据添加redis失败";
                    return(response);
                }
                else
                {
                    response.IsSuccess      = true;
                    response.MessageContent = "车道拦截数据添加redis成功";
                    return(response);
                }
            }
            catch (Exception ex)
            {
                m_ilogger.LogFatal(LoggerLogicEnum.Tools, "", detailModel.ParkingCode, detailModel.CarNo, "Fujica.com.cn.MonitorServiceClient.Business.GateCatchDataManager.DataHandle", "保存车道拦截数据到redis异常", ex.ToString());

                response.MessageContent = "车道拦截数据数据发生异常:" + ex.ToString();
                return(response);
            }
        }
Exemplo n.º 6
0
        public static ResponseCommon DataHandle(ILogger m_ilogger, ISerializer m_serializer)
        {
            ResponseCommon response = new ResponseCommon()
            {
                IsSuccess = false,
                MsgType   = MsgType.OutParking
            };

            IDatabase db;

            db = RedisHelper.GetDatabase(4);
            string redisContent = db.ListLeftPop(mq_ListKey);

            if (string.IsNullOrEmpty(redisContent))
            {
                response.MessageContent = "redis数据库读取值为空";
                return(response);
            }
            response.RedisContent = redisContent;
            m_ilogger.LogInfo(LoggerLogicEnum.Tools, "", "", "", "Fujica.com.cn.MonitorServiceClient.ExitDataManager", "车辆出场数据接收成功.原始数据:" + redisContent);

            VehicleOutModel outmodel = m_serializer.Deserialize <VehicleOutModel>(redisContent);

            if (outmodel == null)
            {
                response.MessageContent = "redis数据库读取值转换成实体失败";
                return(response);
            }
            if (string.IsNullOrEmpty(outmodel.Guid) ||
                string.IsNullOrEmpty(outmodel.DriveWayMAC) ||
                string.IsNullOrEmpty(outmodel.CarNo)
                //|| string.IsNullOrEmpty(outmodel.ImgUrl)
                || outmodel.OutTime == DateTime.MinValue ||
                string.IsNullOrEmpty(outmodel.CarTypeGuid))
            {
                response.MessageContent = "redis数据转换成实体后必要参数缺失";
                return(response);
            }

            //不为空说明是出场数据
            db = RedisHelper.GetDatabase(0);
            string        drivewayguid  = db.HashGet("DrivewayLinkMACList", outmodel.DriveWayMAC);
            DrivewayModel drivewaymodel = m_serializer.Deserialize <DrivewayModel>(db.HashGet("DrivewayList", drivewayguid ?? ""));

            if (drivewaymodel == null)
            {
                response.MessageContent = "根据车道相机设备MAC地址,读取车道模型为空";
                m_ilogger.LogError(LoggerLogicEnum.Tools, outmodel.Guid, "", outmodel.CarNo, "Fujica.com.cn.MonitorServiceClient.ExitDataManager", "根据车道相机设备MAC地址,读取车道模型为空");
                return(response);
            }
            CarTypeModel cartypemodel = m_serializer.Deserialize <CarTypeModel>(db.HashGet("CarTypeList", outmodel.CarTypeGuid));

            if (cartypemodel == null)
            {
                response.MessageContent = "根据车类Guid,读取车类模型为空";
                m_ilogger.LogError(LoggerLogicEnum.Tools, outmodel.Guid, drivewaymodel.ParkCode, outmodel.CarNo, "Fujica.com.cn.MonitorServiceClient.ExitDataManager", "根据车类Guid,读取车类模型为空");
                return(response);
            }
            ParkLotModel parklotmodel = m_serializer.Deserialize <ParkLotModel>(db.HashGet("ParkLotList", drivewaymodel.ParkCode));

            if (parklotmodel == null)
            {
                response.MessageContent = "根据停车场编码,读取车场模型为空";
                m_ilogger.LogError(LoggerLogicEnum.Tools, outmodel.Guid, drivewaymodel.ParkCode, outmodel.CarNo, "Fujica.com.cn.MonitorServiceClient.ExitDataManager", "根据停车场编码,读取车场模型为空");
                return(response);
            }
            VehicleExitDetailModel exitmodel = new VehicleExitDetailModel()
            {
                RecordGuid  = outmodel.Guid,
                ParkingName = parklotmodel.ParkName,
                ParkingCode = parklotmodel.ParkCode,
                CarNo       = outmodel.CarNo,
                OutImgUrl   = outmodel.ImgUrl,
                LeaveTime   = outmodel.OutTime,
                Description = outmodel.Remark,
                Exit        = drivewaymodel.DrivewayName,
                ExitCamera  = drivewaymodel.DeviceName,
                DriveWayMAC = outmodel.DriveWayMAC,
                OpenType    = outmodel.OpenType,
                Operator    = outmodel.Operator
            };

            //redis操作
            try
            {
                db = RedisHelper.GetDatabase(Common.GetDatabaseNumber(exitmodel.CarNo));
                //删除前先拿到实体内容
                VehicleEntryDetailModel entrymodel = m_serializer.Deserialize <VehicleEntryDetailModel>(db.HashGet(exitmodel.CarNo, exitmodel.ParkingCode));

                if (entrymodel == null)
                {
                    response.MessageContent = "未找到入场记录";
                    return(response);
                }

                bool flag = db.HashDelete(exitmodel.CarNo, exitmodel.ParkingCode);

                //1号db移除该在场车牌
                if (flag)
                {
                    db = RedisHelper.GetDatabase(1);
                    string hashKey = entrymodel.ParkingCode + ":" + DateTime.Now.ToString("yyyyMM");
                    flag = db.SortedSetRemove(hashKey, entrymodel.CarNo);
                    //如果当月集合中不存在,则找最近的二个月的数据
                    if (!flag)
                    {
                        for (int i = 1; i < 3; i++)
                        {
                            hashKey = entrymodel.ParkingCode + ":" + DateTime.Now.AddMonths(-i).ToString("yyyyMM");
                            flag    = db.SortedSetRemove(hashKey, entrymodel.CarNo);
                            if (flag)
                            {
                                break;
                            }
                        }
                    }
                }
                //2号db移除存储入场数据(相机上传原样数据),出场再删掉(用于相机数据同步)
                if (flag)
                {
                    db = RedisHelper.GetDatabase(2);
                    string hashKey = entrymodel.ParkingCode + ":" + DateTime.Now.ToString("yyyyMM");
                    flag = db.HashDelete(hashKey, entrymodel.CarNo);
                    //如果当月集合中不存在,则找最近的二个月的数据
                    if (!flag)
                    {
                        for (int i = 1; i < 3; i++)
                        {
                            hashKey = entrymodel.ParkingCode + ":" + DateTime.Now.AddMonths(-i).ToString("yyyyMM");
                            flag    = db.HashDelete(hashKey, entrymodel.CarNo);
                            if (flag)
                            {
                                break;
                            }
                        }
                    }
                }

                if (flag)
                {
                    m_ilogger.LogInfo(LoggerLogicEnum.Tools, exitmodel.RecordGuid, exitmodel.ParkingCode, exitmodel.CarNo, "Fujica.com.cn.MonitorServiceClient.ExitDataManager", entrymodel.CarNo + "车辆出场数据删除redis数据成功");

                    //剩余车位数控制
                    db = RedisHelper.GetDatabase(0);
                    db.ListRightPush("SpaceNumberList:" + entrymodel.ParkingCode, 1);
                    //调用mq给相机发送当前车位数
                    int remainingNumber = Convert.ToInt32(db.ListLength("SpaceNumberList:" + entrymodel.ParkingCode));
                    SpaceNumberToCamera(remainingNumber, entrymodel.ParkingCode, m_ilogger, m_serializer);
                    //修改redis中停车场的剩余车位数
                    parklotmodel.RemainingSpace = (uint)remainingNumber;
                    db = RedisHelper.GetDatabase(0);
                    db.HashSet("ParkLotList", parklotmodel.ParkCode, m_serializer.Serialize(parklotmodel));
                    //修改mysql中停车场的剩余车位数
                    SaveSpaceNumberToDB(parklotmodel, m_ilogger, m_serializer);


                    #region 移动岗亭数据推送
                    CaptureInOutModel capturModel = new CaptureInOutModel()
                    {
                        Guid            = exitmodel.RecordGuid,
                        ParkCode        = exitmodel.ParkingCode,
                        Entrance        = entrymodel.Entrance,
                        Exit            = exitmodel.Exit,
                        DriveWayMAC     = exitmodel.DriveWayMAC,
                        RemainingNumber = remainingNumber.ToString(),
                        CarNo           = exitmodel.CarNo,
                        EntryType       = "1",
                        CarType         = Convert.ToInt32(entrymodel.CarType.ToString()),
                        CarTypeName     = entrymodel.CarTypeName,
                        CarTypeGuid     = entrymodel.CarTypeGuid,
                        InTime          = Convert.ToDateTime(entrymodel.BeginTime),
                        OutTime         = exitmodel.LeaveTime,
                        OutImgUrl       = exitmodel.OutImgUrl,
                        InImgUrl        = entrymodel.InImgUrl,
                        Remark          = exitmodel.Description,
                        ErrorCode       = "-1" //错误类型(异常时使用,正常数据默认是-1)
                    };

                    //推送到客户端(实现移动岗亭功能)
                    SendOutDataToClient(capturModel);

                    //存储一份在redis中
                    GateDataToRedis(capturModel, m_serializer);
                    #endregion

                    //往主平台Fujica补发出场数据
                    bool fujicaResult = ExitDataToFujica(exitmodel, entrymodel, cartypemodel.Idx);
                    if (fujicaResult)
                    {
                        //出场分发服务
                        DistributeExitData(exitmodel, entrymodel, cartypemodel.Idx, m_ilogger);

                        response.IsSuccess      = true;
                        response.MessageContent = entrymodel.CarNo + "车辆出场数据删除redis和补发fujica出场数据成功";
                        m_ilogger.LogInfo(LoggerLogicEnum.Tools, exitmodel.RecordGuid, exitmodel.ParkingCode, exitmodel.CarNo, "Fujica.com.cn.MonitorServiceClient.ExitDataManager", entrymodel.CarNo + "车辆出场数据删除redis和补发fujica出场数据成功");
                        return(response);
                    }
                    else
                    {
                        response.IsSuccess      = true;
                        response.MessageContent = entrymodel.CarNo + "车辆出场数据删除redis成功;补发fujica出场数据失败";
                        m_ilogger.LogError(LoggerLogicEnum.Tools, exitmodel.RecordGuid, exitmodel.ParkingCode, exitmodel.CarNo, "Fujica.com.cn.MonitorServiceClient.ExitDataManager", entrymodel.CarNo + "车辆出场数据删除redis成功;补发fujica出场数据失败");
                        return(response);
                    }
                }
                else
                {
                    response.MessageContent = entrymodel.CarNo + "车辆出场数据删除redis数据失败";
                    m_ilogger.LogError(LoggerLogicEnum.Tools, exitmodel.RecordGuid, exitmodel.ParkingCode, exitmodel.CarNo, "Fujica.com.cn.MonitorServiceClient.ExitDataManager", entrymodel.CarNo + "车辆出场数据删除redis数据失败");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                m_ilogger.LogFatal(LoggerLogicEnum.Tools, exitmodel.RecordGuid, exitmodel.ParkingCode, exitmodel.CarNo, "Fujica.com.cn.MonitorServiceClient.Business.ExitDataManager.DataHandle", "在redis移除停车数据异常", ex.ToString());

                response.MessageContent = "车辆出场数据发生异常:" + ex.ToString();
                return(response);
            }
        }
Exemplo n.º 7
0
        public static ResponseCommon DataHandle(ILogger m_ilogger, ISerializer m_serializer)
        {
            ResponseCommon response = new ResponseCommon()
            {
                IsSuccess = false,
                MsgType   = MsgType.InParking
            };

            IDatabase db;

            db = RedisHelper.GetDatabase(4);
            string redisContent = db.ListLeftPop(mq_ListKey);

            if (string.IsNullOrEmpty(redisContent))
            {
                response.MessageContent = "redis数据库读取值为空";
                return(response);
            }
            response.RedisContent = redisContent;
            m_ilogger.LogInfo(LoggerLogicEnum.Tools, "", "", "", "Fujica.com.cn.MonitorServiceClient.EntryDataManager", "车辆入场数据接收成功.原始数据:" + redisContent);

            VehicleInModel inmodel = m_serializer.Deserialize <VehicleInModel>(redisContent);

            if (inmodel == null)
            {
                response.MessageContent = "redis数据库读取值转换成实体失败:";
                return(response);
            }
            if (string.IsNullOrEmpty(inmodel.Guid) ||
                string.IsNullOrEmpty(inmodel.DriveWayMAC) ||
                string.IsNullOrEmpty(inmodel.CarNo)
                //|| string.IsNullOrEmpty(inmodel.ImgUrl)//补发入场车辆,没有照片
                || inmodel.InTime == DateTime.MinValue ||
                string.IsNullOrEmpty(inmodel.CarTypeGuid)
                //|| string.IsNullOrEmpty(inmodel.Remark)
                )
            {
                response.MessageContent = "redis数据转换成实体后必要参数缺失";
                return(response);
            }

            //不为空说明是入场数据
            db = RedisHelper.GetDatabase(0);
            string        drivewayguid  = db.HashGet("DrivewayLinkMACList", inmodel.DriveWayMAC);
            DrivewayModel drivewaymodel = m_serializer.Deserialize <DrivewayModel>(db.HashGet("DrivewayList", drivewayguid ?? ""));

            if (drivewaymodel == null)
            {
                response.MessageContent = "根据车道相机设备MAC地址,读取车道模型为空";
                m_ilogger.LogError(LoggerLogicEnum.Tools, inmodel.Guid, "", inmodel.CarNo, "Fujica.com.cn.MonitorServiceClient.EntryDataManager", "根据车道相机设备MAC地址,读取车道模型为空");
                return(response);
            }
            CarTypeModel cartypemodel = m_serializer.Deserialize <CarTypeModel>(db.HashGet("CarTypeList", inmodel.CarTypeGuid));

            if (cartypemodel == null)
            {
                response.MessageContent = "根据车类Guid,读取车类模型为空";
                m_ilogger.LogError(LoggerLogicEnum.Tools, inmodel.Guid, drivewaymodel.ParkCode, inmodel.CarNo, "Fujica.com.cn.MonitorServiceClient.EntryDataManager", "根据车类Guid,读取车类模型为空");
                return(response);
            }
            ParkLotModel parklotmodel = m_serializer.Deserialize <ParkLotModel>(db.HashGet("ParkLotList", cartypemodel.ParkCode));

            if (parklotmodel == null)
            {
                response.MessageContent = "根据停车场编码,读取车场模型为空";
                m_ilogger.LogError(LoggerLogicEnum.Tools, inmodel.Guid, drivewaymodel.ParkCode, inmodel.CarNo, "Fujica.com.cn.MonitorServiceClient.EntryDataManager", "根据停车场编码,读取车场模型为空");
                return(response);
            }
            VehicleEntryDetailModel entrymodel = new VehicleEntryDetailModel()
            {
                RecordGuid     = inmodel.Guid,
                ParkingName    = parklotmodel.ParkName,
                ParkingCode    = parklotmodel.ParkCode,
                CarNo          = inmodel.CarNo,
                InImgUrl       = inmodel.ImgUrl,
                BeginTime      = inmodel.InTime,
                CarTypeGuid    = inmodel.CarTypeGuid,
                Description    = inmodel.Remark,
                CarType        = (Int32)cartypemodel.CarType,
                CarTypeName    = cartypemodel.CarTypeName,
                Entrance       = drivewaymodel.DrivewayName,
                EntranceCamera = drivewaymodel.DeviceName,
                DriveWayMAC    = inmodel.DriveWayMAC,
                OpenType       = inmodel.OpenType,
                Operator       = inmodel.Operator
            };

            //存到redis
            try
            {
                db = RedisHelper.GetDatabase(Common.GetDatabaseNumber(entrymodel.CarNo));
                //查询车辆是否已在场内(是否重复入场)
                bool repeatEntry = db.HashExists(entrymodel.CarNo, entrymodel.ParkingCode);

                //散列储存车辆入场数据
                db.HashSet(entrymodel.CarNo, entrymodel.ParkingCode, m_serializer.Serialize(entrymodel));
                db.KeyExpire(entrymodel.CarNo, DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.AddMonths(3).AddSeconds(-1));//三个月自动过期或出场删除
                bool flag = db.HashExists(entrymodel.CarNo, entrymodel.ParkingCode);

                //在1号db存储在场车牌列表(用于后续业务的分页查询)
                if (flag)
                {
                    db = RedisHelper.GetDatabase(1);
                    string hashKey = entrymodel.ParkingCode + ":" + DateTime.Now.ToString("yyyyMM");
                    db.SortedSetAdd(hashKey, entrymodel.CarNo, Convert.ToDouble(inmodel.InTime.ToString("yyyyMMddHHmmss")));
                    flag = db.KeyExpire(hashKey, DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.AddMonths(3).AddSeconds(-1));//三个月自动过期或出场删除
                }

                //在2号db存储入场数据实体(相机上传原样数据),出场再删掉(用于相机数据同步)
                if (flag)
                {
                    db = RedisHelper.GetDatabase(2);
                    string hashKey = entrymodel.ParkingCode + ":" + DateTime.Now.ToString("yyyyMM");
                    db.HashSet(hashKey, entrymodel.CarNo, redisContent);
                    db.KeyExpire(hashKey, DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.AddMonths(3).AddSeconds(-1));//三个月自动过期或出场删除
                    flag = db.HashExists(hashKey, entrymodel.CarNo);
                }

                //redis存储成功后
                if (flag)
                {
                    m_ilogger.LogInfo(LoggerLogicEnum.Tools, entrymodel.RecordGuid, entrymodel.ParkingCode, entrymodel.CarNo, "Fujica.com.cn.MonitorServiceClient.EntryDataManager", entrymodel.CarNo + "车辆入场数据添加redis成功");

                    //当前车位数量
                    int remainingNumber = Convert.ToInt32(db.ListLength("SpaceNumberList:" + entrymodel.ParkingCode));
                    //如果不是重复入场,则进行车位数更新
                    if (!repeatEntry)
                    {
                        //剩余车位数控制
                        db = RedisHelper.GetDatabase(0);
                        db.ListLeftPop("SpaceNumberList:" + entrymodel.ParkingCode);
                        //调用mq给相机发送当前车位数
                        //最新车位数量
                        remainingNumber = Convert.ToInt32(db.ListLength("SpaceNumberList:" + entrymodel.ParkingCode));
                        SpaceNumberToCamera(remainingNumber, entrymodel.ParkingCode, m_ilogger, m_serializer);
                        //修改redis中停车场的剩余车位数
                        parklotmodel.RemainingSpace = (uint)remainingNumber;
                        db = RedisHelper.GetDatabase(0);
                        db.HashSet("ParkLotList", parklotmodel.ParkCode, m_serializer.Serialize(parklotmodel));
                        //修改mysql中停车场的剩余车位数
                        SaveSpaceNumberToDB(parklotmodel, m_ilogger, m_serializer);
                    }

                    #region 移动岗亭数据推送
                    CaptureInOutModel capturModel = new CaptureInOutModel()
                    {
                        Guid            = entrymodel.RecordGuid,
                        ParkCode        = entrymodel.ParkingCode,
                        Entrance        = entrymodel.Entrance,
                        DriveWayMAC     = entrymodel.DriveWayMAC,
                        RemainingNumber = remainingNumber.ToString(),
                        CarNo           = entrymodel.CarNo,
                        EntryType       = "0",
                        CarType         = entrymodel.CarType,
                        CarTypeName     = entrymodel.CarTypeName,
                        CarTypeGuid     = entrymodel.CarTypeGuid,
                        InTime          = Convert.ToDateTime(entrymodel.BeginTime),
                        InImgUrl        = entrymodel.InImgUrl,
                        Remark          = entrymodel.Description,
                        ErrorCode       = "-1" //错误类型(异常时使用,正常数据默认是-1)
                    };

                    //推送到客户端(实现移动岗亭功能)
                    SendInDataToClient(capturModel);

                    //存储一份在redis中
                    GateDataToRedis(capturModel, m_serializer);
                    #endregion

                    //再往主平台Fujica补发入场数据
                    bool fujicaResult = EntryDataToFujica(entrymodel, cartypemodel.Idx);
                    if (fujicaResult)
                    {
                        //入场分发服务
                        DistributeEntryData(entrymodel, cartypemodel.Idx, m_ilogger);

                        response.IsSuccess      = true;
                        response.MessageContent = entrymodel.CarNo + "车辆入场数据添加redis和补发fujica入场数据成功";
                        m_ilogger.LogInfo(LoggerLogicEnum.Tools, entrymodel.RecordGuid, entrymodel.ParkingCode, entrymodel.CarNo, "Fujica.com.cn.MonitorServiceClient.EntryDataManager", entrymodel.CarNo + "车辆入场数据添加redis和补发fujica入场数据成功");
                        return(response);
                    }
                    else
                    {
                        response.IsSuccess      = true;
                        response.MessageContent = entrymodel.CarNo + "车辆入场数据添加redis成功;补发fujica入场数据失败";
                        m_ilogger.LogError(LoggerLogicEnum.Tools, entrymodel.RecordGuid, entrymodel.ParkingCode, entrymodel.CarNo, "Fujica.com.cn.MonitorServiceClient.EntryDataManager", entrymodel.CarNo + "车辆入场数据添加redis成功;补发fujica入场数据失败");
                        return(response);
                    }
                }
                else
                {
                    response.MessageContent = entrymodel.CarNo + "车辆入场数据添加redis失败";
                    m_ilogger.LogError(LoggerLogicEnum.Tools, entrymodel.RecordGuid, entrymodel.ParkingCode, entrymodel.CarNo, "Fujica.com.cn.MonitorServiceClient.EntryDataManager", entrymodel.CarNo + "车辆入场数据添加redis失败");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                m_ilogger.LogFatal(LoggerLogicEnum.Tools, entrymodel.RecordGuid, entrymodel.ParkingCode, entrymodel.CarNo, "Fujica.com.cn.MonitorServiceClient.EntryDataManager", entrymodel.CarNo + "保存入场数据到redis异常", ex.ToString());

                response.MessageContent = entrymodel.CarNo + "车辆入场数据发生异常:" + ex.ToString();
                return(response);
            }
            finally
            {
                //GC.Collect();
            }
        }