Ejemplo n.º 1
0
        private void txt_MoneyOrTime_TextChanged(object sender, TextChangedEventArgs e)
        {
            delayAction.Debounce(500, SynchronizationContext, async() =>
            {
                if (!chargerViewModel.LocalMoneyOrTime.HasValue)
                {
                    return;
                }
                if (chargerViewModel.LocalMoneyOrTime.HasValue && chargerViewModel.LocalMoneyOrTime == 0)
                {
                    return;
                }
                //计算金额
                if (Tsh_Time.IsChecked.HasValue && Tsh_Time.IsChecked.Value)
                {
                    var money = FareRule?.CalculateFees(DateTime.Now, DateTime.Now.AddMinutes((double)chargerViewModel.LocalMoneyOrTime.Value), 0, true) ?? 0;

                    chargerViewModel.Pay -= money;
                }
                else if (Tsh_Money.IsChecked.HasValue && Tsh_Money.IsChecked.Value)
                {
                    chargerViewModel.Pay -= chargerViewModel.LocalMoneyOrTime.Value;
                }

                //更新显示屏
                await _ledManager.SpeakAndShowText(Deviceable, CarOutModel, OutEnum.CalculationFee);

                //调用平台接口
            });
        }
Ejemplo n.º 2
0
        public void Init(bool isRestFare = false)
        {
            if (CarOutModel != null)
            {
                CarOutModel.CarDiscount = _vehicleFlow.GetCarDiscount(CarOutModel.ParkId, CarOutModel.CarInRecord?.CarNumber);
                if (CarOutModel.CarInRecord.IsMonthTempIn)
                {
                    SyncDoAction(() => txt_CarType.Text = "月租车(车位满以临时车入场)");
                }
                else
                {
                    var id      = CarOutModel.CarInRecord.CarPort?.CarPortTypeId;
                    var carPort = _repositoryCarTypes.GetAll().FirstOrDefault(x => x.Id == (id ?? 0));
                    if (isRestFare)
                    {
                        var outTime = DateTime.Now;
                        if (carPort == null || carPort.Category == CarType.Month)
                        {
                            FareRule = _repositoryFareRule.GetAll().FirstOrDefault(x => x.CarTypeId == _parkBoxOptions.TempCarTypeId);
                            FareRule.TimeRangeList = _repositoryRangeTime.GetAllIncluding(x => x.FareRule).Where(x => x.FareRuleId == FareRule.Id).ToList();
                            CarOutModel.Receivable = FareRule.CalculateFees(CarOutModel.CarInRecord.InTime, outTime, 0);
                        }
                        else
                        {
                            FareRule = _repositoryFareRule.GetAll().FirstOrDefault(x => x.CarTypeId == carPort.Id);
                            FareRule.TimeRangeList = _repositoryRangeTime.GetAllIncluding(x => x.FareRule).Where(x => x.FareRuleId == FareRule.Id).ToList();
                        }
                        if (CarOutModel.CarInRecord.IsMonthTempIn && CarOutModel.CarInRecord.TempConvertMonthTime.HasValue)
                        {
                            outTime = CarOutModel.CarInRecord.TempConvertMonthTime.Value;

                            CarOutModel.Receivable = FareRule.CalculateFees(CarOutModel.CarInRecord.InTime, outTime, 0);
                        }
                    }
                    if (carPort == null || carPort.Id == _parkBoxOptions.TempCarTypeId)
                    {
                        SyncDoAction(() => txt_CarType.Text = "临时车");
                    }
                    else
                    {
                        SyncDoAction(() => txt_CarType.Text = carPort?.CustomName);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public async void DoMessage(DeviceInfoDto deviceInfoDto)
        {
            ManualResetEvent manualResetEvent = new ManualResetEvent(false);

            using (var unitOfWork = _unitOfWork.Begin())
            {
                DateTime photoTime = DateTime.Now;
                var      result    = deviceInfoDto.Controlable.Camerable.GetPlateNumber();
                string   carNumber = result.Item1;
                //Task.Run(async () =>
                // {
                await parkBoxOptions.SetInfosDic?[deviceInfoDto.EntranceDto.Id]?.SetImage(await result.Item2);
                //});
                if (deviceInfoDto.EntranceDto.EntranceType == Enum.EntranceType.In)
                {
                    //禁止非机动车入场
                    if (!parkBoxOptions.NonmotorVehicleIn && result.Item4 == CarTypeEnum.NonMotorVehicle)
                    {
                        Logger.Info("非机动车辆禁止进入" + result.Item1);
                        return;
                    }
                    var backList = await _repositoryBlackList.FirstOrDefaultAsync(x => x.CarNumber == carNumber);

                    if (backList != null)
                    {
                        Logger.Info(result.Item1 + " 存在于黑名单 禁止进入");
                    }

                    var permission = _carNumberPermission.CheckCarNumberPermission(carNumber, deviceInfoDto.EntranceDto.Id);
                    var carInModel = new Parks.ParkBox.CarInModel()
                    {
                        CarNumber = carNumber,
                        Img       = null,
                        InOutType = Enum.InOutTypeEnum.Photo,
                        InTime    = DateTime.Now,
                        Entrance  = deviceInfoDto.EntranceDto
                    };
                    if (permission.IsCarIn.HasValue && !permission.IsCarIn.Value)
                    {
                        Logger.Debug(carNumber + "no permission" + permission.ToString());

                        return;
                    }
                    else if (permission.IsCarIn == null)
                    {
                        var cancle = MessageBox.Show("当前车辆无权进入是否放行?", "提示", MessageBoxButton.OKCancel);
                        if (cancle == MessageBoxResult.Cancel)
                        {
                            return;
                        }
                    }
                    //入场时检查是否有场内记录
                    var isCarIn = _vehicleFlow.IsCarIn(deviceInfoDto.EntranceDto.ParkLevel.Park.Id, carNumber);
                    if (isCarIn.IsCarIn)
                    {
                        var carOutModel = new CarOutModel()
                        {
                            CarInRecord = isCarIn.CarInRecord,
                            InOutType   = Enum.InOutTypeEnum.Photo,
                            OutTime     = DateTime.Now,
                            Receivable  = 0,
                            ParkId      = deviceInfoDto.EntranceDto.ParkLevel.Park.Id,
                            Remark      = "有场内纪录,再次入场"
                        };
                        _vehicleFlow.CarErrorOut(isCarIn.CarInRecord, carOutModel);
                    }
                    var carIn = _vehicleFlow.CarIn(carInModel, permission);
                    if (carIn != null)
                    {
                        await deviceInfoDto.Controlable?.Camerable?.OpenRod();

                        //await deviceInfoDto.Controlable.Camerable.OpenRod(); //抬杆
                        await _ledManager.SpeakAndShowText(deviceInfoDto, carInModel, permission); //播报语音

                        await parkBoxOptions.SetInfosDic?[deviceInfoDto.EntranceDto.Id]?.SetInfo(carIn);
                    }
                    else
                    {
                        MessageBox.Show("入场失败");
                        return;
                    }
                }
                else
                {
                    /*
                     * 出场逻辑中 无场内车辆的记录也弹出
                     */


                    var isCarIn = _vehicleFlow.IsCarIn(deviceInfoDto.EntranceDto.ParkLevel.Park.Id, carNumber);
                    if (isCarIn.IsCarIn)
                    {
                        var user = _carNumberPermission.GetUser(deviceInfoDto.EntranceDto.ParkLevel.Park.Id, carNumber);
                        if (user != null)
                        {
                            var typeId  = user.CarPorts.FirstOrDefault()?.CarPortTypeId;
                            var carType = _repositoryCarType.GetAll().FirstOrDefault(x => x.Id == (typeId.HasValue ? typeId.Value : parkBoxOptions.TempCarTypeId));
                            //月租车正常出场
                            if (carType.Category == CarType.Month)
                            {
                                if (!isCarIn.CarInRecord.IsMonthTempIn)
                                {
                                    var outRcode = _vehicleFlow.CarOut(isCarIn.CarInRecord, new Parks.ParkBox.CarOutModel()
                                    {
                                        Pay = 0, InOutType = Enum.InOutTypeEnum.Artificial, OutTime = DateTime.Now
                                    });
                                    if (outRcode != null)
                                    {
                                        await parkBoxOptions.SetInfosDic?[deviceInfoDto.EntranceDto.Id]?.SetInfo(outRcode);
                                    }
                                    else
                                    {
                                        MessageBox.Show("出场失败!", "提示");
                                    }
                                }
                                else
                                {  //月租车收费
                                    DateTime outTime = DateTime.Now;

                                    FareRule fareRule  = _repositoryFareRule.GetAll().FirstOrDefault(x => x.CarTypeId == parkBoxOptions.TempCarTypeId);
                                    var      rangTimes = _repositoryRangeTime.GetAllIncluding(x => x.FareRule).Where(x => x.FareRuleId == fareRule.Id).ToList();
                                    fareRule.TimeRangeList = rangTimes;

                                    if (isCarIn.CarInRecord.TempConvertMonthTime.HasValue)
                                    {
                                        outTime = isCarIn.CarInRecord.TempConvertMonthTime.Value;
                                    }
                                    var receivable  = fareRule.CalculateFees(isCarIn.CarInRecord.InTime, outTime, 0);
                                    var carOutModel = new CarOutModel()
                                    {
                                        CarInRecord = isCarIn.CarInRecord,
                                        InOutType   = Enum.InOutTypeEnum.Artificial,
                                        OutTime     = DateTime.Now,
                                        Receivable  = receivable,
                                        ParkId      = deviceInfoDto.EntranceDto.ParkLevel.Park.Id
                                    };
                                    if (parkBoxOptions.IsZeroMoneyOut && receivable == 0) //收费为0 直接放行
                                    {
                                        var outRcode = _vehicleFlow.CarOut(isCarIn.CarInRecord, carOutModel);
                                        if (outRcode != null)
                                        {
                                            await parkBoxOptions.SetInfosDic?[deviceInfoDto.EntranceDto.Id]?.SetInfo(outRcode);

                                            await deviceInfoDto.Controlable?.Camerable?.OpenRod();

                                            await _ledManager.SpeakAndShowText(deviceInfoDto, carOutModel, OutEnum.SuccessfulPayment); //播报语音
                                        }
                                        else
                                        {
                                            MessageBox.Show("出场失败!", "提示");
                                        }
                                        return;
                                    }


                                    await _ledManager.SpeakAndShowText(deviceInfoDto, carOutModel, OutEnum.CalculationFee); //播报语音

                                    var tollWindow = await GetChargerWindow(_ledManager, carOutModel, fareRule, receivable, _repositoryCarType, parkBoxOptions, _repositoryCarPort, _vehicleFlow, deviceInfoDto, _repositoryFareRule, _repositoryRangeTime, manualResetEvent);

                                    tollWindow.Init();
                                    tollWindow.Show();
                                    WaitHandle.WaitAll(new WaitHandle[] { manualResetEvent });
                                    var isFree = tollWindow.IsClose;
                                    if (isFree.HasValue && isFree.Value)
                                    {
                                        await deviceInfoDto.Controlable?.Camerable?.OpenRod();

                                        await parkBoxOptions.SetInfosDic?[deviceInfoDto.EntranceDto.Id]?.SetInfo(tollWindow.CarOutRecord);
                                        await _ledManager.SpeakAndShowText(deviceInfoDto, carOutModel, OutEnum.SuccessfulPayment); //播报语音
                                    }
                                }
                            }
                            else
                            {
                                //其他车类型
                                DateTime outTime = DateTime.Now;

                                FareRule fareRule  = _repositoryFareRule.GetAll().FirstOrDefault(x => x.CarTypeId == carType.Id);
                                var      rangTimes = _repositoryRangeTime.GetAllIncluding(x => x.FareRule).Where(x => x.FareRuleId == fareRule.Id).ToList();
                                fareRule.TimeRangeList = rangTimes;

                                var receivable  = fareRule?.CalculateFees(isCarIn.CarInRecord.InTime, outTime, 0) ?? 0;
                                var carOutModel = new CarOutModel()
                                {
                                    CarInRecord = isCarIn.CarInRecord,
                                    InOutType   = Enum.InOutTypeEnum.Artificial,
                                    OutTime     = outTime,
                                    Receivable  = receivable,
                                    ParkId      = deviceInfoDto.EntranceDto.ParkLevel.Park.Id
                                };

                                if (parkBoxOptions.IsZeroMoneyOut && receivable == 0) //收费为0 直接放行
                                {
                                    var outRcode = _vehicleFlow.CarOut(isCarIn.CarInRecord, carOutModel);
                                    if (outRcode != null)
                                    {
                                        await deviceInfoDto.Controlable?.Camerable?.OpenRod();

                                        await parkBoxOptions.SetInfosDic?[deviceInfoDto.EntranceDto.Id]?.SetInfo(outRcode);
                                        await _ledManager.SpeakAndShowText(deviceInfoDto, carOutModel, OutEnum.SuccessfulPayment); //播报语音
                                    }
                                    else
                                    {
                                        MessageBox.Show("出场失败!", "提示");
                                    }
                                    return;
                                }

                                await _ledManager.SpeakAndShowText(deviceInfoDto, carOutModel, OutEnum.CalculationFee); //播报语音

                                var tollWindow = await GetChargerWindow(_ledManager, carOutModel, fareRule, receivable, _repositoryCarType, parkBoxOptions, _repositoryCarPort, _vehicleFlow, deviceInfoDto, _repositoryFareRule, _repositoryRangeTime, manualResetEvent);

                                tollWindow.Init();
                                tollWindow.Show();
                                WaitHandle.WaitAll(new WaitHandle[] { manualResetEvent });
                                var isFree = tollWindow.IsClose;
                                if (isFree.HasValue && isFree.Value)
                                {
                                    await deviceInfoDto.Controlable?.Camerable?.OpenRod();

                                    await parkBoxOptions.SetInfosDic?[deviceInfoDto.EntranceDto.Id]?.SetInfo(tollWindow.CarOutRecord);


                                    await _ledManager.SpeakAndShowText(deviceInfoDto, carOutModel, OutEnum.SuccessfulPayment); //播报语音
                                }
                            }
                        }
                        else
                        {  //临时车
                            DateTime outTime = DateTime.Now;

                            FareRule fareRule = _repositoryFareRule.GetAll().FirstOrDefault(x => x.CarTypeId == parkBoxOptions.TempCarTypeId);

                            var rangTimes = _repositoryRangeTime.GetAllIncluding(x => x.FareRule).Where(x => x.FareRuleId == fareRule.Id).ToList();
                            fareRule.TimeRangeList = rangTimes;

                            var receivable = fareRule?.CalculateFees(isCarIn.CarInRecord.InTime, outTime, 0) ?? 0;

                            var carOutModel = new CarOutModel()
                            {
                                CarInRecord = isCarIn.CarInRecord,
                                InOutType   = Enum.InOutTypeEnum.Artificial,
                                OutTime     = outTime,
                                Receivable  = receivable,
                                ParkId      = deviceInfoDto.EntranceDto.ParkLevel.Park.Id
                            };

                            if (parkBoxOptions.IsZeroMoneyOut && receivable == 0) //收费为0 直接放行
                            {
                                var outRcode = _vehicleFlow.CarOut(isCarIn.CarInRecord, carOutModel);
                                if (outRcode != null)
                                {
                                    await deviceInfoDto.Controlable?.Camerable?.OpenRod();

                                    await parkBoxOptions.SetInfosDic?[deviceInfoDto.EntranceDto.Id]?.SetInfo(outRcode);
                                    await _ledManager.SpeakAndShowText(deviceInfoDto, carOutModel, OutEnum.SuccessfulPayment); //播报语音
                                }
                                else
                                {
                                    MessageBox.Show("出场失败!", "提示");
                                }
                                return;
                            }

                            await _ledManager.SpeakAndShowText(deviceInfoDto, carOutModel, OutEnum.CalculationFee); //播报语音

                            var tollWindow = await GetChargerWindow(_ledManager, carOutModel, fareRule, receivable, _repositoryCarType, parkBoxOptions, _repositoryCarPort, _vehicleFlow, deviceInfoDto, _repositoryFareRule, _repositoryRangeTime, manualResetEvent);

                            tollWindow.Init();
                            tollWindow.Show();
                            var isFree = tollWindow.IsClose;
                            if (isFree.HasValue && isFree.Value)
                            {
                                await deviceInfoDto.Controlable?.Camerable?.OpenRod();

                                await parkBoxOptions.SetInfosDic?[deviceInfoDto.EntranceDto.Id]?.SetInfo(tollWindow.CarOutRecord);
                                await _ledManager.SpeakAndShowText(deviceInfoDto, carOutModel, OutEnum.SuccessfulPayment); //播报语音
                            }
                        }
                    }
                    else
                    {
                        Logger.Info(carNumber + " 无场内记录");
                        //无在场记录如果为月租车直接放行  否则弹出收费框
                        var user = _carNumberPermission.GetUser(deviceInfoDto.EntranceDto.ParkLevel.Park.Id, carNumber);
                        if (user != null)
                        {
                            var model = new Parks.ParkBox.CarOutModel()
                            {
                                Pay = 0, InOutType = Enum.InOutTypeEnum.Artificial, OutTime = DateTime.Now, ParkId = deviceInfoDto.EntranceDto.ParkLevel.Park.Id
                            };
                            var outRcode = _vehicleFlow.CarOut(carNumber, user, model);
                            if (outRcode != null)
                            {
                                await deviceInfoDto.Controlable?.Camerable?.OpenRod();

                                await parkBoxOptions.SetInfosDic?[deviceInfoDto.EntranceDto.Id]?.SetInfo(outRcode);


                                await _ledManager.SpeakAndShowText(deviceInfoDto, model, OutEnum.SuccessfulPayment); //播报语音
                            }
                            else
                            {
                                MessageBox.Show("出场失败!", "提示");
                            }
                            return;
                        }
                        else
                        {
                            FareRule fareRule  = _repositoryFareRule.GetAll().FirstOrDefault(x => x.CarTypeId == parkBoxOptions.TempCarTypeId);
                            var      rangTimes = _repositoryRangeTime.GetAllIncluding(x => x.FareRule).Where(x => x.FareRuleId == fareRule.Id).ToList();
                            fareRule.TimeRangeList = rangTimes;

                            ///弹出收费框
                            var tollWindow = await GetChargerWindow(_ledManager, carNumber, fareRule, InOutTypeEnum.Photo, _repositoryCarType, parkBoxOptions, _repositoryCarPort, _vehicleFlow, deviceInfoDto, _repositoryFareRule, _repositoryRangeTime, manualResetEvent);

                            tollWindow.Init();
                            tollWindow.Show();
                            WaitHandle.WaitAll(new WaitHandle[] { manualResetEvent });
                            var isFree = tollWindow.IsClose;
                            if (isFree.HasValue && isFree.Value)
                            {
                                await deviceInfoDto.Controlable?.Camerable?.OpenRod();

                                await parkBoxOptions.SetInfosDic?[deviceInfoDto.EntranceDto.Id]?.SetInfo(tollWindow.CarOutRecord);


                                await _ledManager.SpeakAndShowText(deviceInfoDto, tollWindow.CarOutModel, OutEnum.SuccessfulPayment); //播报语音
                            }
                            return;
                        }
                    }
                }


                await unitOfWork.CompleteAsync();
            }
        }
Ejemplo n.º 4
0
        private async void btn_Out_Click(object sender, RoutedEventArgs e)
        {
            #region   移到接口实现  接口实现中无法调用收费界面
            if (_outEntranceDto == null)
            {
                await this.ShowMessageAsync("提示", "未找到出入口信息");

                return;
            }
            var carNumber = txt_OutCarNumber.Text;
            if (carNumber.IsNullOrEmpty())
            {
                await this.ShowMessageAsync("提示", "车牌号不允许为空!");

                return;
            }
            using (var unitOfWork = UnitOfWorkManager.Begin())
            {
                var isCarIn = _vehicleFlow.IsCarIn(_outEntranceDto.ParkLevel.Park.Id, carNumber);
                if (isCarIn.IsCarIn)
                {
                    var user = _carNumberPermission.GetUser(_outEntranceDto.ParkLevel.Park.Id, carNumber);
                    if (user != null)
                    {
                        var typeId  = user.CarPorts.FirstOrDefault()?.CarPortTypeId;
                        var carType = _repositoryCarType.GetAll().FirstOrDefault(x => x.Id == (typeId.HasValue ? typeId.Value : parkBoxOptions.TempCarTypeId));
                        //月租车正常出场
                        if (carType.Category == CarType.Month)
                        {
                            if (!isCarIn.CarInRecord.IsMonthTempIn)
                            {
                                var outRcode = _vehicleFlow.CarOut(isCarIn.CarInRecord, new Parks.ParkBox.CarOutModel()
                                {
                                    Pay = 0, InOutType = Enum.InOutTypeEnum.Artificial, OutTime = DateTime.Now
                                });
                                if (outRcode != null)
                                {
                                    parkEntrances[_outEntranceDto.Id]?.SetInfo(outRcode);
                                }
                                else
                                {
                                    await this.ShowMessageAsync("提示", "出场失败!");
                                }
                            }
                            else
                            {  //月租车收费
                                DateTime outTime = DateTime.Now;

                                FareRule fareRule  = _repositoryFareRule.GetAll().FirstOrDefault(x => x.CarTypeId == parkBoxOptions.TempCarTypeId);
                                var      rangTimes = _repositoryRangeTime.GetAllIncluding(x => x.FareRule).Where(x => x.FareRuleId == fareRule.Id).ToList();
                                fareRule.TimeRangeList = rangTimes;

                                if (isCarIn.CarInRecord.TempConvertMonthTime.HasValue)
                                {
                                    outTime = isCarIn.CarInRecord.TempConvertMonthTime.Value;
                                }
                                var receivable  = fareRule.CalculateFees(isCarIn.CarInRecord.InTime, outTime, 0);
                                var carOutModel = new CarOutModel()
                                {
                                    CarInRecord = isCarIn.CarInRecord,
                                    InOutType   = Enum.InOutTypeEnum.Artificial,
                                    OutTime     = DateTime.Now,
                                    Receivable  = receivable,
                                    ParkId      = _outEntranceDto.ParkLevel.Park.Id
                                };
                                if (parkBoxOptions.IsZeroMoneyOut && receivable == 0) //收费为0 直接放行
                                {
                                    var outRcode = _vehicleFlow.CarOut(isCarIn.CarInRecord, carOutModel);
                                    if (outRcode != null)
                                    {
                                        await parkEntrances[_outEntranceDto.Id]?.SetInfo(outRcode);

                                        await parkEntrances[_outEntranceDto.Id]?.OpenRod();
                                        await _ledManager.SpeakAndShowText((parkEntrances[_inEntranceDto.Id] as ParkEntranceInfo)?.GetDeviceInfo(), carOutModel, OutEnum.SuccessfulPayment); //播报语音
                                    }
                                    else
                                    {
                                        await this.ShowMessageAsync("提示", "出场失败!");
                                    }
                                    return;
                                }


                                await _ledManager.SpeakAndShowText((parkEntrances[_inEntranceDto.Id] as ParkEntranceInfo)?.GetDeviceInfo(), carOutModel, OutEnum.CalculationFee); //播报语音

                                var tollWindow = new ChargerWindow(_ledManager, carOutModel, fareRule, receivable, _repositoryCarType, parkBoxOptions, _repositoryCarPort, _vehicleFlow, (parkEntrances[_inEntranceDto.Id] as ParkEntranceInfo)?.GetDeviceInfo(), _repositoryFareRule, _repositoryRangeTime, null);
                                tollWindow.Init();
                                var isFree = tollWindow.ShowDialog();
                                if (isFree.HasValue && isFree.Value)
                                {
                                    await parkEntrances[_outEntranceDto.Id]?.OpenRod();
                                    await parkEntrances[_outEntranceDto.Id]?.SetInfo(tollWindow.CarOutRecord);
                                    await _ledManager.SpeakAndShowText((parkEntrances[_inEntranceDto.Id] as ParkEntranceInfo)?.GetDeviceInfo(), carOutModel, OutEnum.SuccessfulPayment); //播报语音
                                }
                            }
                        }
                        else
                        {
                            //其他车类型
                            DateTime outTime = DateTime.Now;

                            FareRule fareRule  = _repositoryFareRule.GetAll().FirstOrDefault(x => x.CarTypeId == carType.Id);
                            var      rangTimes = _repositoryRangeTime.GetAllIncluding(x => x.FareRule).Where(x => x.FareRuleId == fareRule.Id).ToList();
                            fareRule.TimeRangeList = rangTimes;

                            var receivable  = fareRule?.CalculateFees(isCarIn.CarInRecord.InTime, outTime, 0) ?? 0;
                            var carOutModel = new CarOutModel()
                            {
                                CarInRecord = isCarIn.CarInRecord,
                                InOutType   = Enum.InOutTypeEnum.Artificial,
                                OutTime     = outTime,
                                Receivable  = receivable,
                                ParkId      = _outEntranceDto.ParkLevel.Park.Id
                            };

                            if (parkBoxOptions.IsZeroMoneyOut && receivable == 0) //收费为0 直接放行
                            {
                                var outRcode = _vehicleFlow.CarOut(isCarIn.CarInRecord, carOutModel);
                                if (outRcode != null)
                                {
                                    await parkEntrances[_outEntranceDto.Id]?.SetInfo(outRcode);

                                    await parkEntrances[_outEntranceDto.Id]?.OpenRod();
                                    await _ledManager.SpeakAndShowText((parkEntrances[_outEntranceDto.Id] as ParkEntranceInfo)?.GetDeviceInfo(), carOutModel, OutEnum.SuccessfulPayment); //播报语音
                                }
                                else
                                {
                                    await this.ShowMessageAsync("提示", "出场失败!");
                                }
                                return;
                            }

                            await _ledManager.SpeakAndShowText((parkEntrances[_outEntranceDto.Id] as ParkEntranceInfo)?.GetDeviceInfo(), carOutModel, OutEnum.CalculationFee); //播报语音

                            var tollWindow = new ChargerWindow(_ledManager, carOutModel, fareRule, receivable, _repositoryCarType, parkBoxOptions, _repositoryCarPort, _vehicleFlow, (parkEntrances[_outEntranceDto.Id] as ParkEntranceInfo)?.GetDeviceInfo(), _repositoryFareRule, _repositoryRangeTime, null);
                            tollWindow.Init();
                            var isFree = tollWindow.ShowDialog();
                            if (isFree.HasValue && isFree.Value)
                            {
                                await parkEntrances[_outEntranceDto.Id]?.OpenRod();
                                await parkEntrances[_outEntranceDto.Id]?.SetInfo(tollWindow.CarOutRecord);


                                await _ledManager.SpeakAndShowText((parkEntrances[_outEntranceDto.Id] as ParkEntranceInfo)?.GetDeviceInfo(), carOutModel, OutEnum.SuccessfulPayment); //播报语音
                            }
                        }
                    }
                    else
                    {  //临时车
                        DateTime outTime = DateTime.Now;

                        FareRule fareRule = _repositoryFareRule.GetAll().FirstOrDefault(x => x.CarTypeId == parkBoxOptions.TempCarTypeId);

                        var rangTimes = _repositoryRangeTime.GetAllIncluding(x => x.FareRule).Where(x => x.FareRuleId == fareRule.Id).ToList();
                        fareRule.TimeRangeList = rangTimes;

                        var receivable = fareRule?.CalculateFees(isCarIn.CarInRecord.InTime, outTime, 0) ?? 0;

                        var carOutModel = new CarOutModel()
                        {
                            CarInRecord = isCarIn.CarInRecord,
                            InOutType   = Enum.InOutTypeEnum.Artificial,
                            OutTime     = outTime,
                            Receivable  = receivable,
                            ParkId      = _outEntranceDto.ParkLevel.Park.Id
                        };

                        if (parkBoxOptions.IsZeroMoneyOut && receivable == 0) //收费为0 直接放行
                        {
                            var outRcode = _vehicleFlow.CarOut(isCarIn.CarInRecord, carOutModel);
                            if (outRcode != null)
                            {
                                await parkEntrances[_outEntranceDto.Id]?.SetInfo(outRcode);

                                await parkEntrances[_outEntranceDto.Id]?.OpenRod();
                                await _ledManager.SpeakAndShowText((parkEntrances[_outEntranceDto.Id] as ParkEntranceInfo)?.GetDeviceInfo(), carOutModel, OutEnum.SuccessfulPayment); //播报语音
                            }
                            else
                            {
                                await this.ShowMessageAsync("提示", "出场失败!");
                            }
                            return;
                        }

                        await _ledManager.SpeakAndShowText((parkEntrances[_outEntranceDto.Id] as ParkEntranceInfo)?.GetDeviceInfo(), carOutModel, OutEnum.CalculationFee); //播报语音

                        var tollWindow = new ChargerWindow(_ledManager, carOutModel, fareRule, receivable, _repositoryCarType, parkBoxOptions, _repositoryCarPort, _vehicleFlow, (parkEntrances[_outEntranceDto.Id] as ParkEntranceInfo)?.GetDeviceInfo(), _repositoryFareRule, _repositoryRangeTime, null);
                        tollWindow.Init();
                        var isFree = tollWindow.ShowDialog();
                        if (isFree.HasValue && isFree.Value)
                        {
                            await parkEntrances[_outEntranceDto.Id]?.OpenRod();
                            await parkEntrances[_outEntranceDto.Id]?.SetInfo(tollWindow.CarOutRecord);


                            await _ledManager.SpeakAndShowText((parkEntrances[_inEntranceDto.Id] as ParkEntranceInfo)?.GetDeviceInfo(), carOutModel, OutEnum.SuccessfulPayment); //播报语音
                        }
                    }
                }
                else
                {
                    Logger.Info(carNumber + " 无场内记录");
                    //无在场记录如果为月租车直接放行  否则弹出收费框
                    var user = _carNumberPermission.GetUser(_outEntranceDto.ParkLevel.Park.Id, carNumber);
                    if (user != null)
                    {
                        var model = new Parks.ParkBox.CarOutModel()
                        {
                            Pay = 0, InOutType = Enum.InOutTypeEnum.Artificial, OutTime = DateTime.Now, ParkId = _outEntranceDto.ParkLevel.Park.Id
                        };
                        var outRcode = _vehicleFlow.CarOut(carNumber, user, model);
                        if (outRcode != null)
                        {
                            await parkEntrances[_outEntranceDto.Id]?.OpenRod();
                            await parkEntrances[_outEntranceDto.Id]?.SetInfo(outRcode);


                            await _ledManager.SpeakAndShowText((parkEntrances[_outEntranceDto.Id] as ParkEntranceInfo)?.GetDeviceInfo(), model, OutEnum.SuccessfulPayment); //播报语音
                        }
                        else
                        {
                            await this.ShowMessageAsync("提示", "出场失败!");
                        }
                        return;
                    }
                    else
                    {
                        FareRule fareRule  = _repositoryFareRule.GetAll().FirstOrDefault(x => x.CarTypeId == parkBoxOptions.TempCarTypeId);
                        var      rangTimes = _repositoryRangeTime.GetAllIncluding(x => x.FareRule).Where(x => x.FareRuleId == fareRule.Id).ToList();
                        fareRule.TimeRangeList = rangTimes;

                        ///弹出收费框
                        var tollWindow = new ChargerWindow(_ledManager, carNumber, fareRule, InOutTypeEnum.Artificial, _repositoryCarType, parkBoxOptions, _repositoryCarPort, _vehicleFlow, (parkEntrances[_inEntranceDto.Id] as ParkEntranceInfo)?.GetDeviceInfo(), _repositoryFareRule, _repositoryRangeTime, null);
                        tollWindow.Init();

                        var isFree = tollWindow.ShowDialog();
                        if (isFree.HasValue && isFree.Value)
                        {
                            await parkEntrances[_outEntranceDto.Id]?.OpenRod();
                            await parkEntrances[_outEntranceDto.Id]?.SetInfo(tollWindow.CarOutRecord);


                            await _ledManager.SpeakAndShowText((parkEntrances[_outEntranceDto.Id] as ParkEntranceInfo)?.GetDeviceInfo(), tollWindow.CarOutModel, OutEnum.SuccessfulPayment); //播报语音
                        }
                        return;
                    }
                }
                #endregion

                unitOfWork.Complete();
            }
        }