Esempio n. 1
0
        ///// <summary>
        ///// 车道半小时内过的车
        ///// </summary>
        ///// <returns></returns>
        //public List<VehicleInOutModel> DriveWayHalfHourCarsRecord(string drivewayguid, string carNo)
        //{
        //    List<VehicleInOutModel> result = new List<VehicleInOutModel>();
        //    try
        //    {
        //        IDatabase db = FollowRedisHelper.GetDatabase(3); //通过车道的半小时数据的db
        //        IServer srv = FollowRedisHelper.GetCurrentServer();
        //        IEnumerable<RedisKey> allRecordKey = srv.Keys(3);

        //        //改之前的

        //        //    foreach (var RecordKey in allRecordKey)
        //        //{
        //        //    if (RecordKey.ToString().IndexOf(drivewayguid) > -1)
        //        //    {
        //        //        VehicleInOutModel content = m_serializer.Deserialize<VehicleInOutModel>(db.StringGet(RecordKey));
        //        //        if (content != null) result.Add(content);
        //        //    }
        //        //}

        //        //llp  改为可以兼容传输多个值
        //        string[] sArray = drivewayguid.Split(',');
        //        foreach (string i in sArray)
        //        {
        //            foreach (var RecordKey in allRecordKey)
        //            {
        //                if (RecordKey.ToString().IndexOf(i) > -1)
        //                {
        //                    VehicleInOutModel content = m_serializer.Deserialize<VehicleInOutModel>(db.StringGet(RecordKey));
        //                    if (content != null) result.Add(content);
        //                }
        //            }
        //        }
        //        if (result.Count > 0 && carNo != null)
        //        {
        //            result = result.FindAll(m => m.CarNo.Contains(carNo));
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        result = null;
        //    }

        //    return result.OrderByDescending(a => a.EventTime).ToList();//降序
        //}

        /// <summary>
        /// 获取某车的进场记录
        /// </summary>
        /// <param name="carno">车牌号码</param>
        /// <param name="parkingCode">停车场编号</param>
        /// <returns></returns>
        public VehicleInOutModel GetEntryRecord(string carno, string parkingCode)
        {
            VehicleInOutModel result = null;

            try
            {
                IDatabase db = RedisHelper.GetDatabase(GetDatabaseNumber(carno));

                VehicleEntryDetailModel content = m_serializer.Deserialize <VehicleEntryDetailModel>(db.HashGet(carno, parkingCode));
                if (content != null)
                {
                    result = new VehicleInOutModel()
                    {
                        Guid        = content.RecordGuid,
                        CarNo       = content.CarNo,
                        CarTypeGuid = content.CarTypeGuid,
                        EventTime   = content.BeginTime,
                        ImgUrl      = content.InImgUrl,
                        DriveWayMAC = content.DriveWayMAC,
                        Remark      = content.Description,
                        Entrance    = content.Entrance
                    };
                }
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
Esempio n. 2
0
 /// <summary>
 /// 分发入场数据
 /// </summary>
 /// <param name="entrymodel"></param>
 /// <param name="carType"></param>
 private static void DistributeEntryData(VehicleEntryDetailModel entrymodel, string carType, ILogger m_ilogger)
 {
     try
     {
         var instance = Distribute.GetInstance();
         VehicleEntryRequest entryReuqest = new VehicleEntryRequest()
         {
             CarNo          = entrymodel.CarNo,
             CardNo         = "",
             ParkingCode    = entrymodel.ParkingCode,
             ParkName       = entrymodel.ParkingName,
             CustomDate     = DateTime.Now,
             LineRecordCode = entrymodel.RecordGuid,
             OperatorName   = entrymodel.Entrance,
             IsBigParkCost  = true,
             WatchhouseCode = 0,
             SpecialCar     = 0,
             Entrance       = entrymodel.Entrance,
             InImgUrl       = entrymodel.InImgUrl,
             ParkingCard    = "",
             BeginTime      = entrymodel.BeginTime,
             CarType        = carType,
             CardType       = entrymodel.CarType == 0 ? 3 : (entrymodel.CarType == 3 ? 1 : entrymodel.CarType)
         };
         instance.DistributeEntryDataAsync(entryReuqest);
         m_ilogger.LogInfo(LoggerLogicEnum.Tools, entrymodel.RecordGuid, entrymodel.ParkingCode, entrymodel.CarNo, "Fujica.com.cn.MonitorServiceClient.EntryDataManager.DistributeEntryData", entrymodel.CarNo + "分发入场数据成功");
     }
     catch (Exception ex)
     {
         m_ilogger.LogFatal(LoggerLogicEnum.Tools, entrymodel.RecordGuid, entrymodel.ParkingCode, entrymodel.CarNo, "Fujica.com.cn.MonitorServiceClient.EntryDataManager.DistributeEntryData", entrymodel.CarNo + "分发入场数据异常", ex.ToString());
     }
 }
Esempio n. 3
0
 /// <summary>
 /// 分发出场数据
 /// </summary>
 /// <param name="entrymodel"></param>
 /// <param name="carType"></param>
 private static void DistributeExitData(VehicleExitDetailModel exitmodel, VehicleEntryDetailModel entrymodel, string carType, ILogger m_ilogger)
 {
     try
     {
         var instance = Distribute.GetInstance();
         VehicleOutRecordRequest exitReuqest = new VehicleOutRecordRequest()
         {
             CarNo          = entrymodel.CarNo,
             ParkingCode    = entrymodel.ParkingCode,
             CardNo         = "",
             LongStop       = (Int32)(exitmodel.LeaveTime - entrymodel.BeginTime).TotalMinutes,
             Entrance       = entrymodel.Entrance,
             Export         = exitmodel.Exit,
             CustomDate     = DateTime.Now,
             AppearanceDate = exitmodel.LeaveTime,
             Description    = exitmodel.Description,
             AdmissionDate  = entrymodel.BeginTime,
             ParkingCard    = "",
             InImgUrl       = entrymodel.InImgUrl,
             OutImgUrl      = exitmodel.OutImgUrl,
             LineRecordCode = entrymodel.RecordGuid,
             GroupCar       = 0,
             CarType        = carType,
             CardType       = entrymodel.CarType == 0 ? 3 : (entrymodel.CarType == 3 ? 1 : entrymodel.CarType)
         };
         instance.DistributeOutDataAsync(exitReuqest);
         m_ilogger.LogInfo(LoggerLogicEnum.Tools, entrymodel.RecordGuid, entrymodel.ParkingCode, entrymodel.CarNo, "Fujica.com.cn.MonitorServiceClient.ExitDataManager.DistributeExitData", entrymodel.CarNo + "分发出场数据成功");
     }
     catch (Exception ex)
     {
         m_ilogger.LogFatal(LoggerLogicEnum.Tools, entrymodel.RecordGuid, entrymodel.ParkingCode, entrymodel.CarNo, "Fujica.com.cn.MonitorServiceClient.ExitDataManager.DistributeExitData", entrymodel.CarNo + "分发出场数据异常", ex.ToString());
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 补发入场数据给主平台Fujica
        /// </summary>
        /// <param name="entrymodel">入场记录实体</param>
        /// <param name="carType">车类</param>
        /// <returns>true:补发成功  false:补发失败</returns>
        private static bool EntryDataToFujica(VehicleEntryDetailModel entrymodel, string carType)
        {
            RequestFujicaStandard requestFujica = new RequestFujicaStandard();
            //请求方法
            string servername = "/Park/ReVehicleEntryRecordV2";
            //请求参数
            Dictionary <string, object> dicParam = new Dictionary <string, object>();

            dicParam["InEquipmentCode"] = entrymodel.DriveWayMAC;    //入口设备机号
            dicParam["DiscernCamera"]   = entrymodel.EntranceCamera; //识别相机
            dicParam["ThroughType"]     = entrymodel.OpenType;       //通行方式
            dicParam["CarNo"]           = entrymodel.CarNo;          //车牌号
            dicParam["ParkingCode"]     = entrymodel.ParkingCode;    //停车场编码
            dicParam["ParkName"]        = entrymodel.ParkingName;    //停车场名称
            dicParam["CustomDate"]      = DateTime.Now;              //客户端时间
            dicParam["LineRecordCode"]  = entrymodel.RecordGuid;     //线下停车记录编号
            dicParam["OperatorName"]    = "入场服务程序";                  //操作员
            //暂时去掉,后期有可能用到,主平台那边是int类型
            //dicParam["WatchhouseCode"] = driveWayMAC;//出入口设备机号
            dicParam["Entrance"]        = entrymodel.Entrance;                                                              //入口名
            dicParam["InImgUrl"]        = entrymodel.InImgUrl;                                                              //入场车辆图片地址
            dicParam["BeginTime"]       = entrymodel.BeginTime;                                                             //车辆的入场时间
            dicParam["CarType"]         = carType;                                                                          //车类,对应车辆模板类型
            dicParam["CardType"]        = entrymodel.CarType == 0 ? 3 : (entrymodel.CarType == 3 ? 1 : entrymodel.CarType); //fujica停车卡类型 1月卡 2储值卡 3 临时卡
            dicParam["Remark"]          = entrymodel.Description;
            dicParam["ParkingOperator"] = entrymodel.Operator;

            //返回fujica api补发车辆入场记录 接口的结果
            return(requestFujica.RequestInterfaceV2(servername, dicParam));
        }
Esempio n. 5
0
        public static void Execute()
        {
            Task.Factory.StartNew(() =>
            {
                ILogger m_ilogger         = new Logger.Logger();
                ISerializer m_serializer  = new JsonSerializer(m_ilogger);
                RabbitMQPeeker m_rabbitMQ = new RabbitMQPeeker(m_ilogger, m_serializer);
                IDatabase db;

                //队列
                string queue = "";
                //路由key
                string routingKey = "";

                m_rabbitMQ.PeekMessageByRabbitMQ(queue, routingKey, (string content) =>
                {
                    //转换成Fujica缴费实体
                    IssuedRecord payModel = m_serializer.Deserialize <IssuedRecord>(content);
                    if (payModel != null)
                    {
                        //验证当前是否临时车
                        if (payModel.CardType == 3)
                        {
                            //验证当前车牌是否在场
                            string carNumber = payModel.CarNo;
                            int dbIndex      = GetDatabaseNumber(carNumber);
                            db = FollowRedisHelper.GetDatabase(dbIndex);
                            //去redis中查询车辆是否在场,返回在场实体
                            VehicleEntryDetailModel entryModel = m_serializer.Deserialize <VehicleEntryDetailModel>(db.HashGet(carNumber, payModel.ParkingCode));
                            //不为空,则代表车辆在场
                            if (entryModel != null)
                            {
                                //fujica缴费实体传过来的“停车记录编号”和本系统中的“当次停车唯一标识”的值相等,确认是同一条记录
                                if (payModel.OffLineOrderId == entryModel.RecordGuid)
                                {
                                    //查询当前车辆的计费模板,以获取缴费超时时间,计算最后出场时间
                                    db = FollowRedisHelper.GetDatabase(0);
                                    BillingTemplateModel billingModel = m_serializer.Deserialize <BillingTemplateModel>(db.HashGet("BillingTemplateList", entryModel.CarTypeGuid));
                                    int timeOut = TemplateDataTimeOut(billingModel, m_ilogger, m_serializer);

                                    //发送缴费数据到相机
                                    SendPayData.Execute(entryModel.ParkingCode, entryModel.RecordGuid, entryModel.CarNo, entryModel.BeginTime, payModel.FeeEndTime.AddMinutes(timeOut));
                                }
                            }
                        }
                    }

                    return(RabbitMQAction.ACCEPT);
                });
            });
        }
Esempio n. 6
0
        /// <summary>
        /// 补发出场数据给主平台Fujica
        /// </summary>
        /// <param name="exitmodel">出场记录实体</param>
        /// <param name="entrymodel">入场记录实体</param>
        /// <param name="carType">车类</param>
        /// <returns>true:补发成功  false:补发失败</returns>
        private static bool ExitDataToFujica(VehicleExitDetailModel exitmodel, VehicleEntryDetailModel entrymodel, string carType)
        {
            RequestFujicaStandard requestFujica = new RequestFujicaStandard();
            //请求方法
            string servername = "/Park/ReVehicleOutRecordV2";
            //请求参数
            Dictionary <string, object> dicParam = new Dictionary <string, object>();

            dicParam["InEquipmentCode"]  = entrymodel.DriveWayMAC;    //入口设备机号
            dicParam["OutEquipmentCode"] = exitmodel.DriveWayMAC;     //出口设备机号
            dicParam["InDiscernCamera"]  = entrymodel.EntranceCamera; //入口识别相机
            dicParam["OutDiscernCamera"] = exitmodel.ExitCamera;      //出口识别相机
            dicParam["InThroughType"]    = entrymodel.OpenType;       //入口通行方式
            dicParam["OutThroughType"]   = exitmodel.OpenType;        //出口通行方式
            dicParam["CarNo"]            = exitmodel.CarNo;           //车牌号
            dicParam["ParkingCode"]      = exitmodel.ParkingCode;     //停车场编码
            dicParam["LongStop"]         = (Int32)(exitmodel.LeaveTime - entrymodel.BeginTime).TotalMinutes;
            //LongStop  停驶时间(分钟)
            dicParam["Entrance"]           = entrymodel.Entrance;                                                              //入口名
            dicParam["Export"]             = exitmodel.Exit;                                                                   //出口名
            dicParam["CustomDate"]         = DateTime.Now;                                                                     //客户端时间
            dicParam["AppearanceDate"]     = exitmodel.LeaveTime;                                                              //出场时间
            dicParam["AdmissionDate"]      = entrymodel.BeginTime;                                                             //入场时间
            dicParam["InImgUrl"]           = entrymodel.InImgUrl;                                                              //入场车辆图片地址
            dicParam["OutImgUrl"]          = exitmodel.OutImgUrl;                                                              //出场车辆图片地址
            dicParam["LineRecordCode"]     = exitmodel.RecordGuid;                                                             //线下停车记录编号
            dicParam["CarType"]            = carType;                                                                          //车类
            dicParam["CardType"]           = entrymodel.CarType == 0 ? 3 : (entrymodel.CarType == 3 ? 1 : entrymodel.CarType); //fujica停车卡类型 1月卡 2储值卡 3 临时卡
            dicParam["Description"]        = exitmodel.Description;
            dicParam["InParkingOperator"]  = entrymodel.Operator;                                                              //入场值班人员
            dicParam["OutParkingOperator"] = exitmodel.Operator;                                                               //出场值班人员



            //返回fujica api补发车辆入场记录 接口的结果
            return(requestFujica.RequestInterfaceV2(servername, dicParam));
        }
Esempio n. 7
0
        public static ResponseCommon DataHandle(ILogger m_ilogger, ISerializer m_serializer)
        {
            ResponseCommon response = new ResponseCommon()
            {
                IsSuccess = false,
                MsgType   = MsgType.GroundSense
            };

            IDatabase db;

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

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

            //转换成 出口未缴费临时车辆 实体
            ExitTempCarPayModel exitTempCarModel = m_serializer.Deserialize <ExitTempCarPayModel>(redisContent);

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

            db = RedisHelper.GetDatabase(0);
            //根据相机MAC地址拿到车道的guid
            string drivewayguid = db.HashGet("DrivewayLinkMACList", exitTempCarModel.DriveWayMAC);
            //得到相对应的车道实体
            DrivewayModel drivewaymodel = m_serializer.Deserialize <DrivewayModel>(db.HashGet("DrivewayList", drivewayguid ?? ""));

            if (drivewaymodel == null)
            {
                response.MessageContent = "根据车道相机设备MAC地址,读取车道模型为空";
                return(response);
            }

            //验证当前车牌是否在场
            string carNumber = exitTempCarModel.CarNo;
            int    dbIndex   = Common.GetDatabaseNumber(carNumber);

            db = RedisHelper.GetDatabase(dbIndex);

            //去redis中查询车辆是否在场,返回在场实体
            VehicleEntryDetailModel entryModel = m_serializer.Deserialize <VehicleEntryDetailModel>(db.HashGet(carNumber, drivewaymodel.ParkCode));

            //为空,则代表车辆不在场
            if (entryModel == null)
            {
                response.MessageContent = "未找到当前车辆在场记录";
                return(response);
            }

            //相机 临时车实体传过来的“当次停车唯一标识”和redis在场数据中的“当次停车唯一标识”值相等,确认是同一条记录
            if (exitTempCarModel.Guid != entryModel.RecordGuid)
            {
                response.MessageContent = "当次停车唯一标识与redis数据不一致";
                return(response);
            }

            //拿到车类信息
            CarTypeModel cartypemodel = m_serializer.Deserialize <CarTypeModel>(db.HashGet("CarTypeList", entryModel.CarTypeGuid));

            if (cartypemodel == null)
            {
                response.MessageContent = "根据车类Guid,读取车类模型为空";
                return(response);
            }

            try
            {
                //去fujica拿到当前停车的费用
                string fujicaTempCarModel = GetFujicaTempCarByCarNo(entryModel.CarNo, entryModel.ParkingCode, m_serializer);
                if (string.IsNullOrEmpty(fujicaTempCarModel))
                {
                    response.MessageContent = "fujicaApi/GetTempCarPaymentInfoByCarNo未查询到停车信息";
                    return(response);
                }
                Dictionary <string, object> fujicaTempCarDic = m_serializer.Deserialize <Dictionary <string, object> >(fujicaTempCarModel);
                if (fujicaTempCarDic == null || fujicaTempCarDic["ParkingFee"] == null || fujicaTempCarDic["ActualAmount"] == null)
                {
                    response.MessageContent = "fujicaApi/GetTempCarPaymentInfoByCarNo返回结果解析失败" + fujicaTempCarModel;
                    return(response);
                }

                //fujica返回停车费用
                decimal amount = Convert.ToDecimal(fujicaTempCarDic["ParkingFee"]);
                //fujica返回应缴费用
                decimal actualAmount = Convert.ToDecimal(fujicaTempCarDic["ActualAmount"]);
                //再将数据组装后,上传到fujica的车道码压地感车辆上传接口
                bool uploadResult = UploadExitPayDataToFujica(entryModel.CarNo, entryModel.ParkingCode, amount, actualAmount, exitTempCarModel.LaneSenseDate, entryModel.RecordGuid, cartypemodel.Idx, entryModel.InImgUrl, entryModel.BeginTime, exitTempCarModel.DriveWayMAC, drivewaymodel.DrivewayName);
                if (uploadResult)
                {
                    response.IsSuccess      = true;
                    response.MessageContent = "车辆压地感数据上传Fujica成功";
                    return(response);
                }
                else
                {
                    response.MessageContent = "车辆压地感数据上传Fujica失败";
                    return(response);
                }
            }
            catch (Exception ex)
            {
                m_ilogger.LogFatal(LoggerLogicEnum.Tools, entryModel.RecordGuid, entryModel.ParkingCode, entryModel.CarNo, "Fujica.com.cn.MonitorServiceClient.Business.ExitPayDataManager.DataHandle", "未缴费临时车压地感上传fujica出现异常", ex.ToString());

                response.MessageContent = "车辆压地感数据发生异常:" + ex.ToString();
                return(response);
            }
        }
Esempio n. 8
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);
            }
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            ILogger        m_ilogger    = new Logger();
            ISerializer    m_serializer = new JsonSerializer(m_ilogger);
            RabbitMQPeeker m_rabbitMQ   = new RabbitMQPeeker(m_ilogger, m_serializer);
            IDatabase      db;

            Console.WriteLine(string.Format("出场数据处理工具运行中:"));
            //队列名与路由名一致
            m_rabbitMQ.PeekMessageByRabbitMQ("4GCameraExitDataQueue", "4GCameraExitDataQueue",
                                             (string content) => {
                Console.WriteLine(string.Format("收到出场数据:{0}", content));
                Console.WriteLine("");

                db = FollowRedisHelper.GetDatabase(0);
                VehicleOutRequest outmodel = m_serializer.Deserialize <VehicleOutRequest>(content);
                if (outmodel != null)
                {
                    //不为空说明是出场数据
                    string drivewayguid         = db.HashGet("DrivewayLinkMACList", outmodel.DriveWayMAC);
                    DrivewayModel drivewaymodel = m_serializer.Deserialize <DrivewayModel>(db.HashGet("DrivewayList", drivewayguid ?? ""));
                    if (drivewaymodel == null)
                    {
                        return(RabbitMQAction.REJECT);
                    }
                    CarTypeModel cartypemodel = m_serializer.Deserialize <CarTypeModel>(db.HashGet("CarTypeList", outmodel.CarTypeGuid));
                    if (cartypemodel == null)
                    {
                        return(RabbitMQAction.REJECT);
                    }
                    ParkLotModel parklotmodel = m_serializer.Deserialize <ParkLotModel>(db.HashGet("ParkLotList", drivewaymodel.ParkCode));
                    if (parklotmodel == null)
                    {
                        return(RabbitMQAction.REJECT);
                    }
                    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
                    };
                    //redis操作
                    try
                    {
                        db = FollowRedisHelper.GetDatabase(GetDatabaseNumber(exitmodel.CarNo));
                        //删除前先拿到实体内容
                        VehicleEntryDetailModel entrymodel = m_serializer.Deserialize <VehicleEntryDetailModel>(db.HashGet(exitmodel.CarNo, exitmodel.ParkingCode));

                        db.HashDelete(exitmodel.CarNo, exitmodel.ParkingCode);
                        //删除成功后在1号db移除该在场车牌,在2号db移除待广播的车牌(如果未广播的情况下)
                        //3号db缓存半小时该出场数据
                        //1号
                        db = FollowRedisHelper.GetDatabase(1);
                        db.HashDelete(exitmodel.ParkingCode, exitmodel.CarNo);
                        //2号
                        db = FollowRedisHelper.GetDatabase(2);
                        db.HashDelete(exitmodel.ParkingCode, exitmodel.CarNo);
                        //3号
                        db         = FollowRedisHelper.GetDatabase(3);
                        string key = string.Format("{0}_{1}", drivewaymodel.Guid, exitmodel.CarNo);
                        db.StringSet(key, content.Replace("OutTime", "EventTime"), TimeSpan.FromSeconds(0.5 * 3600));


                        //如果是临时车辆,并且入场实体不为空,则往主平台Fujica补发出场数据
                        if (cartypemodel.CarType == 0 && entrymodel != null)
                        {
                            ExitDataToFujica(exitmodel.CarNo, exitmodel.ParkingCode, entrymodel.Entrance, exitmodel.Exit, entrymodel.BeginTime, exitmodel.LeaveTime, entrymodel.InImgUrl, exitmodel.OutImgUrl, exitmodel.RecordGuid, cartypemodel.Idx);
                        }

                        return(RabbitMQAction.ACCEPT);
                    }
                    catch (Exception ex)
                    {
                        m_ilogger.LogFatal(LoggerLogicEnum.Tools, "", exitmodel.ParkingCode, "", "Fujica.com.cn.BroadcastService.JobsDetails.MonitorEnterData", "在redis移除停车数据异常", ex.ToString());
                        return(RabbitMQAction.RETRY);
                    }
                }
                return(RabbitMQAction.ACCEPT); //无效数据的时候直接返回成功
            });

            Console.WriteLine("程序逻辑不幸退出");
            Console.ReadKey();
        }
Esempio n. 11
0
        public static void Execute()
        {
            Task.Factory.StartNew(() => {
                //从mq获取进场数据
                ILogger m_ilogger = new Logger.Logger();
                ISerializer m_serializer = new JsonSerializer(m_ilogger);
                RabbitMQPeeker m_rabbitMQ = new RabbitMQPeeker(m_ilogger, m_serializer);
                IDatabase db;

                m_rabbitMQ.PeekMessageByRabbitMQ("4GCameraEntryDataQueue", "4GCameraEntryDataQueue",
                (string content) => {
                    db = FollowRedisHelper.GetDatabase(0);
                    VehicleInRequest inmodel = m_serializer.Deserialize<VehicleInRequest>(content);
                    if (inmodel != null)
                    {
                        //不为空说明是入场数据  
                        string drivewayguid = db.HashGet("DrivewayLinkMACList", inmodel.DriveWayMAC);
                        DrivewayModel drivewaymodel = m_serializer.Deserialize<DrivewayModel>(db.HashGet("DrivewayList", drivewayguid ?? ""));
                        if (drivewaymodel == null) return RabbitMQAction.REJECT;
                        CarTypeModel cartypemodel = m_serializer.Deserialize<CarTypeModel>(db.HashGet("CarTypeList", inmodel.CarTypeGuid));
                        if (cartypemodel == null) return RabbitMQAction.REJECT;
                        ParkLotModel parklotmodel = m_serializer.Deserialize<ParkLotModel>(db.HashGet("ParkLotList", cartypemodel.ParkCode));
                        if (parklotmodel == null) return RabbitMQAction.REJECT;
                        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 = cartypemodel.CarType,
                            CarTypeName = cartypemodel.CarTypeName,
                            Entrance = drivewaymodel.DrivewayName,
                            DriveWayMAC=inmodel.DriveWayMAC
                        };
                        //存到redis
                        try
                        {
                            db = FollowRedisHelper.GetDatabase(GetDatabaseNumber(entrymodel.CarNo));
                            db.HashSet(entrymodel.CarNo, entrymodel.ParkingCode, m_serializer.Serialize(entrymodel)); //存储入场数据
                            bool flag = db.HashExists(entrymodel.CarNo, entrymodel.ParkingCode);

                            //存储成功后在1号db存储在场车牌 在2号db存储待广播的车牌
                            ////3号db缓存半小时该进场数据
                            if (flag)
                            {
                                db = FollowRedisHelper.GetDatabase(1);
                                db.HashSet(entrymodel.ParkingCode, entrymodel.CarNo, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //存储车场在场车牌索引
                                flag = db.HashExists(entrymodel.ParkingCode, entrymodel.CarNo);
                            }
                            //存储成功后在2号db存储待广播的车牌
                            if (flag)
                            {
                                db = FollowRedisHelper.GetDatabase(2);
                                db.HashSet(entrymodel.ParkingCode, entrymodel.CarNo, content);
                                flag = db.HashExists(entrymodel.ParkingCode, entrymodel.CarNo);
                            }
                            //存储成功后在3号db存储入场车数据半小时
                            if (flag)
                            {
                                db = FollowRedisHelper.GetDatabase(3);
                                string key = string.Format("{0}_{1}", drivewaymodel.Guid, entrymodel.CarNo);
                                db.StringSet(key, content.Replace("InTime", "EventTime"), TimeSpan.FromSeconds(0.5 * 3600));
                                flag = db.KeyExists(key);
                            }

                            //如果是临时车辆,并且redis存储成功后
                            if (entrymodel.CarType == 0 && flag)
                            {
                                //再往主平台Fujica补发入场数据
                                EntryDataToFujica(entrymodel.CarNo, entrymodel.ParkingCode, entrymodel.ParkingName, entrymodel.RecordGuid, entrymodel.DriveWayMAC, entrymodel.Entrance, entrymodel.InImgUrl, entrymodel.BeginTime, cartypemodel.Idx);
                            }


                            if (!flag) return RabbitMQAction.RETRY;
                        }
                        catch (Exception ex)
                        {
                            m_ilogger.LogFatal(LoggerLogicEnum.Tools, "", entrymodel.ParkingCode, "", "Fujica.com.cn.EntryDataService.MonitorEnterData", "保存入场数据到redis异常", ex.ToString());
                            return RabbitMQAction.RETRY;
                        }
                    }
                    return RabbitMQAction.ACCEPT;
                });
            });
        }
Esempio n. 12
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();
            }
        }