/// <summary> /// 修改mysql中停车场的剩余车位数 /// </summary> /// <param name="model">停车场实体</param> /// <param name="m_ilogger"></param> /// <param name="m_serializer"></param> /// <returns></returns> private static bool SaveSpaceNumberToDB(ParkLotModel model, ILogger m_ilogger, ISerializer m_serializer) { try { string commandtext = @"UPDATE t_parklot SET entityContent=@entityContent WHERE projectGuid=@projectGuid and parkCode=@parkCode"; DbParameter projectGuid = dbhelper.factory.CreateParameter(); projectGuid.ParameterName = "@projectGuid"; projectGuid.Value = model.ProjectGuid; DbParameter parkCode = dbhelper.factory.CreateParameter(); parkCode.ParameterName = "@parkCode"; parkCode.Value = model.ParkCode; DbParameter entityContent = dbhelper.factory.CreateParameter(); entityContent.ParameterName = "@entityContent"; entityContent.Value = m_serializer.Serialize(model); DbParameter[] parameter = new DbParameter[] { projectGuid, parkCode, entityContent }; return(dbhelper.ExecuteNonQuery(commandtext, parameter) > 0 ? true : false); } catch (Exception ex) { m_ilogger.LogFatal(LoggerLogicEnum.Tools, "", model.ParkCode, "", "Fujica.com.cn.MonitorServiceClient.ExitDataManager.SaveSpaceNumberToDB", string.Format("保存停车场剩余车位数发生异常,入参:{0}", m_serializer.Serialize(model)), ex.ToString()); } return(false); }
/// <summary> /// 修改车场 /// </summary> /// <returns></returns> public bool ModifyParkLot(ParkLotModel model) { ParkLotModel dbModel = GetParkLot(model.ParkCode); if (dbModel != null && dbModel.ProjectGuid != model.ProjectGuid) { //不让修改其他项目的停车场 LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_EXISTS_PARKINGCODE.GetDesc(); return(false); } bool flag = _iParkLotContext.ModifyParkLot(model); if (!flag) { LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_SAVE_PARKLOT.GetDesc(); return(false); } //配置剩余车位数控制 SetRemainingSpace(new SpaceNumberModel() { ParkCode = model.ParkCode, RemainingSpace = model.RemainingSpace }); //添加城市区号 if (model.ParkCode.Length > 10) { string cityID = model.ParkCode.Substring(6, 4); AddCityCode(cityID); } return(true); }
public static bool Execute(string parkingCode, string guid, string carNo, DateTime beginTime, DateTime lastTime) { if (string.IsNullOrEmpty(guid) || string.IsNullOrEmpty(carNo) || beginTime == null || lastTime == null) { return(false); } ILogger m_ilogger = new Logger.Logger(); ISerializer m_serializer = new JsonSerializer(m_ilogger); RabbitMQSender m_rabbitMQ = new RabbitMQSender(m_ilogger, m_serializer); IDatabase db; db = FollowRedisHelper.GetDatabase(0); RedisValue parklotredis = db.HashGet("ParkLotList", parkingCode); if (parklotredis != RedisValue.Null) { ParkLotModel parklotmodel = m_serializer.Deserialize <ParkLotModel>(parklotredis); if (parklotmodel != null) { List <string> drivewaylist = parklotmodel.DrivewayList; //所有车道 if (drivewaylist != null) { //要广播的缴费数据 TempCardModel tempCarModel = new TempCardModel(); tempCarModel.Guid = guid; tempCarModel.CarNo = carNo; tempCarModel.BeginTime = beginTime; tempCarModel.LatestTime = lastTime; tempCarModel.HavePaid = true; foreach (var drivewayguid in drivewaylist) { DrivewayModel drivewaymodel = m_serializer.Deserialize <DrivewayModel>(db.HashGet("DrivewayList", drivewayguid)); //广播到所有出口车道 if (drivewaymodel.Type == DrivewayType.Out) { CommandEntity <TempCardModel> sendCommand = new CommandEntity <TempCardModel>() { command = BussineCommand.TempCar, idMsg = Convert.ToBase64String(Guid.NewGuid().ToByteArray()), message = tempCarModel }; if (m_rabbitMQ.SendMessageForRabbitMQ("发送缴费数据广播命令", m_serializer.Serialize(sendCommand), drivewaymodel.DeviceMacAddress, parkingCode)) { //广播成功 } } } } } } return(true); }
/// <summary> /// 添加车场 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AddParkLot(ParkLotModel model) { redisoperate.model = model; bool flag = databaseoperate.SaveToDataBase(model); if (flag) { flag = redisoperate.SaveToRedis(); } return(flag); }
/// <summary> /// 修改车场 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool ModifyParkLot(ParkLotModel model) { redisoperate.model = model; bool flag = databaseoperate.SaveToDataBase(model); if (flag) { redisoperate.SaveToRedis(); //此时不需要判断redis是否成功,因为修改时redis一定会返回false } return(flag); }
/// <summary> /// 注销车场 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool CancelParkLot(ParkLotModel model) { redisoperate.model = model; bool flag = databaseoperate.DeleteInDataBase(model); if (flag) { flag = redisoperate.DeleteInRedis(); //此时不需要判断redis是否成功,因为修改时redis一定会返回false } return(flag); }
public void Execute(IJobExecutionContext context) { Task.Factory.StartNew(() => { //从redis获取进场待广播数据进行广播 ILogger m_ilogger = new Logger.Logger(); ISerializer m_serializer = new JsonSerializer(m_ilogger); RabbitMQSender m_rabbitMQ = new RabbitMQSender(m_ilogger, m_serializer); IDatabase db = FollowRedisHelper.GetDatabase(2); IServer srv = FollowRedisHelper.GetCurrentServer(); IEnumerable <RedisKey> allParkingCode = srv.Keys(2); foreach (var parkingcode in allParkingCode) { HashEntry[] hashentryarray = db.HashGetAll(parkingcode); //所有实体 string[] allCarNo = db.HashKeys(parkingcode).ToStringArray(); //所有车牌 db = FollowRedisHelper.GetDatabase(0); RedisValue parklotredis = db.HashGet("ParkLotList", parkingcode.ToString()); if (parklotredis != RedisValue.Null) { ParkLotModel parklotmodel = m_serializer.Deserialize <ParkLotModel>(parklotredis); List <string> drivewaylist = parklotmodel.DrivewayList; //所有车道 if (drivewaylist != null) { foreach (var carno in allCarNo) { HashEntry hashenrty = hashentryarray.SingleOrDefault(o => o.Name == carno); string enterdata = hashenrty.Value; //要广播的入场数据 foreach (var drivewayguid in drivewaylist) { DrivewayModel drivewaymodel = m_serializer.Deserialize <DrivewayModel>(db.HashGet("DrivewayList", drivewayguid)); if (drivewaymodel.Type == DrivewayType.Out) { //广播到出口车道 string sendmsg = string.Format("{{\"command\":{0},\"idMsg\":\"{1}\",\"message\":{2}}}", 13, Convert.ToBase64String(Guid.NewGuid().ToByteArray()), enterdata); if (m_rabbitMQ.SendMessageForRabbitMQ("发送入场数据广播命令", sendmsg, drivewaymodel.DeviceMacAddress, parkingcode)) { //广播成功,移除缓存的数据 db = FollowRedisHelper.GetDatabase(2); db.HashDelete(parkingcode, carno); } } } } } } } }); }
/// <summary> /// 注销车场 /// </summary> /// <returns></returns> public bool CancelParkLot(ParkLotModel model) { bool flag = false; //删除角色授权车编 //删除所有车类和计费模板 List <CarTypeModel> carTypeList = AllCarType(model.ParkCode, model.ProjectGuid); if (carTypeList != null) { foreach (var item in carTypeList) { flag = DeleteCarType(item); if (!flag) { return(false); } } } //删除所有车道(业务层的车道删除方法里面,还包含一些其他的操作,比如下发mq、修改车场参数之类的。但此处的删除可以仅删除数据库数据,因为接下来立马会删除车场,所以不需要再执行相关业务动作,则直接调用context层的删除方法) List <DrivewayModel> drivewayList = AllDriveway(model.ParkCode); if (drivewayList != null) { foreach (var item in drivewayList) { flag = DeleteDriveway(item); if (!flag) { return(false); } //flag = _iDrivewayContext.DeleteDriveway(item); //if (!flag) //{ // LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_DELETE_DRIVEWAY.GetDesc(); // return false; //} } } //删除车场 flag = _iParkLotContext.CancelParkLot(model); if (!flag) { LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_DELETE_PARKLOT.GetDesc(); } return(flag); }
/// <summary> /// 车场整体业务方法访问权限 /// 验证车场编码和项目编码 /// </summary> /// <param name="parkingCode">停车场编码</param> /// <param name="projectGuid">项目编码</param> /// <param name="contentParkLot">out 车场模型</param> /// <returns></returns> public bool ParkLotAccessPermission(string parkingCode, string projectGuid, out ParkLotModel contentParkLot) { //验证当前车场是否存在 contentParkLot = _iParkLotContext.GetParkLot(parkingCode); if (contentParkLot == null) { LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_NOTEXISTS_PARKLOT.GetDesc(); return(false); } //验证当前车场与项目id是否匹配 if (projectGuid != contentParkLot.ProjectGuid) { LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_PARAM_ERROR_PROJECTGUID.GetDesc(); return(false); } return(true); }
/// <summary> /// 删除车道 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool DeleteDriveway(DrivewayModel model) { bool flag = _iDrivewayContext.DeleteDriveway(model); if (!flag) { //数据库不成功就不要往下执行了 LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_DELETE_DRIVEWAY.GetDesc(); return(false); } //修改车场信息中车道列表 ParkLotModel content = _iParkLotContext.GetParkLot(model.ParkCode); if (content != null) { if (content.DrivewayList != null) { if (content.DrivewayList.Remove(model.Guid)) { flag = _iParkLotContext.ModifyParkLot(content); if (!flag) { return(false); } } } } //获得入口相机数量 int entrywayCount = GetCameraCount(model.ParkCode, DrivewayType.In); //删除相机 bool mqReturn = SendDriveWayType(model, entrywayCount, BussineCommand.CameraDelete); if (!mqReturn) { LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_MQ_SEND_ERROR.GetDesc(); return(false); } else { return(true); } }
/// <summary> /// 根据停车场编码获取停车场 /// </summary> /// <param name="parkingCode">停车场编码</param> /// <returns>停车场实体</returns> public ParkLotModel GetParkLot(string parkingCode) { ParkLotModel model = null; redisoperate.model = new ParkLotModel() { ParkCode = parkingCode }; model = redisoperate.GetFromRedis(); //从数据库读 if (model == null) { model = databaseoperate.GetFromDataBase(parkingCode); //缓存到redis if (model != null) { redisoperate.model = model; redisoperate.SaveToRedis(); } } return(model); }
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(); }
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); } }
public bool AddDriveway(DrivewayModel model) { ParkLotModel contentParkLot = GetParkLot(model.ParkCode); //验证当前设备mac地址是否已存在 DrivewayModel content = _iDrivewayContext.GetDrivewayByMacAddress(model.DeviceMacAddress); if (content != null) { LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_EXISTS_MACADDRESS_DRIVEWAY.GetDesc(); return(false); } //添加车道 bool flag = _iDrivewayContext.AddDriveway(model); if (!flag) { LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_SAVE_DRIVEWAY.GetDesc(); return(false); } //修改车场信息中车道列表 if (contentParkLot.DrivewayList == null) { contentParkLot.DrivewayList = new List <string>(); } contentParkLot.DrivewayList.Add(model.Guid); flag = _iParkLotContext.ModifyParkLot(contentParkLot); if (!flag) { return(false); } //初始化语音指令 VoiceCommandModel voiceCommandModel = new VoiceCommandModel() { ProjectGuid = model.ProjectGuid, ParkCode = model.ParkCode, DrivewayGuid = model.Guid, DeviceMacAddress = model.DeviceMacAddress, CommandList = null }; //语音指令返回值不影响车道保存结果 _voiceCommandManager.InitVoiceCommand(voiceCommandModel); int entrywayCount = GetCameraCount(model.ParkCode, DrivewayType.In); //初始化相机 bool mqReturn = SendDriveWayType(model, entrywayCount, BussineCommand.CameraInfo); if (!mqReturn) { LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_MQ_SEND_ERROR.GetDesc(); return(false); } else { return(true); } }
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); } }
/// <summary> /// 添加车场 /// </summary> /// <returns></returns> public bool AddNewParkLot(ParkLotModel model, string roleGuid) { ParkLotModel dbModel = GetParkLot(model.ParkCode); if (dbModel != null) { //相同的停车场编码已经存在,则不让继续添加 LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_EXISTS_PARKINGCODE.GetDesc(); return(false); } bool flag = _iParkLotContext.AddParkLot(model); if (!flag) { //redis执行不成功,直接返回false LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_SAVE_PARKLOT.GetDesc(); return(false); } //配置剩余车位数控制 SetRemainingSpace(new SpaceNumberModel() { ParkCode = model.ParkCode, RemainingSpace = model.RemainingSpace }); //添加车场后,需要默认添加多条车类(时租车、储值车、月租车、贵宾车) List <CarTypeModel> carTypeList = InitNewCarTypeAll(model.ProjectGuid, model.ParkCode); //给时租车、储值车车类添加默认计费模板(按小时算费) if (carTypeList != null) { foreach (var item in carTypeList.Where(m => m.CarType == CarTypeEnum.TempCar || m.CarType == CarTypeEnum.ValueCar)) { AddNewBillingTemplate(new BillingTemplateModel() { ProjectGuid = model.ProjectGuid, ParkCode = model.ParkCode, CarTypeGuid = item.Guid, ChargeMode = 1, TemplateJson = "{\"MonetaryUnit\":\"1\",\"FreeMinutes\":\"30\",\"LeaveTimeout\":\"15\",\"DayAmountTopLimit\":\"255\",\"AmountTopLimit\":\"65535\",\"h1\":\"1\",\"h2\":\"2\",\"h3\":\"3\",\"h4\":\"4\",\"h5\":\"5\",\"h6\":\"6\",\"h7\":\"7\",\"h8\":\"8\",\"h9\":\"9\",\"h10\":\"10\",\"h11\":\"10\",\"h12\":\"10\",\"h13\":\"10\",\"h14\":\"10\",\"h15\":\"10\",\"h16\":\"10\",\"h17\":\"10\",\"h18\":\"10\",\"h19\":\"10\",\"h20\":\"10\",\"h21\":\"10\",\"h22\":\"10\",\"h23\":\"10\",\"h24\":\"10\"}" }); } } //将默认的车类发送给相机 SendTempCarTypeOfPlateColor(model.ProjectGuid, model.ParkCode); //添加车场后,给当前角色增加授权车场列表 if (!string.IsNullOrEmpty(roleGuid)) { //添加新车编 _roleManager.ModifyRoleAddParkingCode(roleGuid, model.ParkCode); } //发送创建新车场的命令 SendNewParkLotToCameras(model.ParkCode); //添加城市区号 if (model.ParkCode.Length > 10) { string cityID = model.ParkCode.Substring(6, 4); AddCityCode(cityID); } //返回值以添加车场方法返回值为准 return(flag); }
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; }); }); }
/// <summary> /// 车场整体业务方法访问权限 /// 验证车场编码和项目编码 /// </summary> /// <param name="parkingCode">停车场编码</param> /// <param name="projectGuid">项目编码</param> /// <returns></returns> public bool ParkLotAccessPermission(string parkingCode, string projectGuid) { ParkLotModel parkLotModel = null; return(ParkLotAccessPermission(parkingCode, projectGuid, out parkLotModel)); }
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(); } }