|
|
|
@ -29,13 +29,14 @@ public class SwapDoneState : IState
|
|
|
|
|
public StateResult Handle(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
//更新换电订单
|
|
|
|
|
|
|
|
|
|
machine.SwapOrder!.SwapResult = machine.SwapStatus;
|
|
|
|
|
machine.SwapOrder.SwapEndTime = DateTime.Now;
|
|
|
|
|
machine.SwapOrder.FailReason = machine.SwapFailReason;
|
|
|
|
|
_CommonMgr.UpdateSwapOrder(machine);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//修改预约单
|
|
|
|
|
////修改预约单
|
|
|
|
|
if (machine.SwapOrderBatteryInfo!.swapAmtOrder != null)
|
|
|
|
|
{
|
|
|
|
|
machine.SwapOrderBatteryInfo.swapAmtOrder.Status =
|
|
|
|
@ -48,7 +49,7 @@ public class SwapDoneState : IState
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
//新增换电成功上报云平台数据
|
|
|
|
|
// _CommonMgr.InsertCloudReportForSwapSuccess(machine);
|
|
|
|
|
// _CommonMgr.InsertCloudReportForSwapSuccess(machine);
|
|
|
|
|
//换电成功关于bininfo表的更新
|
|
|
|
|
_CommonMgr.UpdateBinInfoForSwapSuccess(machine);
|
|
|
|
|
|
|
|
|
@ -66,27 +67,33 @@ public class SwapDoneState : IState
|
|
|
|
|
|
|
|
|
|
////云平台没有匹配的失败状态
|
|
|
|
|
////车辆上锁 ,提示请驶离
|
|
|
|
|
//InvokeStatus lockCar = LockCar(machine);
|
|
|
|
|
InvokeStatus lockCar = LockCar(machine);
|
|
|
|
|
|
|
|
|
|
//if (lockCar != InvokeStatus.Done)
|
|
|
|
|
//{
|
|
|
|
|
// return SwappingStateMachine.ReturnWithInvokeErr(lockCar, ExceptionReason.None);
|
|
|
|
|
//}
|
|
|
|
|
if (lockCar != InvokeStatus.Done)
|
|
|
|
|
{
|
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(lockCar, ExceptionReason.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoCarLeave.GetLed());
|
|
|
|
|
|
|
|
|
|
var adjustCarByRadar = AdjustCarByRadar(machine);
|
|
|
|
|
machine.Reset();
|
|
|
|
|
if (InvokeStatus.Done != adjustCarByRadar)
|
|
|
|
|
{
|
|
|
|
|
return SwappingStateMachine.ReturnWithInvokeErr(adjustCarByRadar, ExceptionReason.None);
|
|
|
|
|
}
|
|
|
|
|
//出口雷达监测
|
|
|
|
|
//InvokeStatus existRadar = ExistRadar(machine);
|
|
|
|
|
//if (existRadar != InvokeStatus.Done)
|
|
|
|
|
//{
|
|
|
|
|
// return SwappingStateMachine.ReturnWithInvokeErr(existRadar, ExceptionReason.None);
|
|
|
|
|
//}
|
|
|
|
|
////关闭雷达
|
|
|
|
|
//var closeRadar = ControlRadar(machine, 0);
|
|
|
|
|
//if (InvokeStatus.Done != closeRadar)
|
|
|
|
|
//{
|
|
|
|
|
// return SwappingStateMachine.ReturnWithInvokeErr(closeRadar, ExceptionReason.None);
|
|
|
|
|
//}
|
|
|
|
|
// InvokeStatus existRadar = ExistRadar(machine);
|
|
|
|
|
//if (existRadar != InvokeStatus.Done)
|
|
|
|
|
//{
|
|
|
|
|
// return SwappingStateMachine.ReturnWithInvokeErr(existRadar, ExceptionReason.None);
|
|
|
|
|
//}
|
|
|
|
|
////关闭雷达
|
|
|
|
|
//var closeRadar = ControlRadar(machine, 0);
|
|
|
|
|
//if (InvokeStatus.Done != closeRadar)
|
|
|
|
|
//{
|
|
|
|
|
// return SwappingStateMachine.ReturnWithInvokeErr(closeRadar, ExceptionReason.None);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -146,25 +153,89 @@ public class SwapDoneState : IState
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 车辆上锁
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
//public InvokeStatus LockCar(SwappingStateMachine machine)
|
|
|
|
|
//{
|
|
|
|
|
// return Invoker.Invoke("LockCar", 500, 100, machine.IsCanceled, machine.IsManualSwapSucc,
|
|
|
|
|
// () => machine.VelLockFlag, () =>
|
|
|
|
|
// {
|
|
|
|
|
// Task<bool> result = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelVin);
|
|
|
|
|
|
|
|
|
|
// bool unLock = result.Result;
|
|
|
|
|
// if (unLock)
|
|
|
|
|
// {
|
|
|
|
|
// //查询车辆锁止状态
|
|
|
|
|
// Task<TboxCarInfoModel> carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin);
|
|
|
|
|
// if (carInfo.Result?.CarStatus?.LockStatus == 2)
|
|
|
|
|
// {
|
|
|
|
|
// machine.BoxCarInfoModel = carInfo.Result;
|
|
|
|
|
// SoundApi.PlayOneSound(machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success
|
|
|
|
|
// ? (int)InfoEnum.SwapInfo.InfoCarLeave
|
|
|
|
|
// : (int)InfoEnum.SwapInfo.ErrInfoCarLeave);
|
|
|
|
|
|
|
|
|
|
// LedClient.SendMsgByKey(machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success
|
|
|
|
|
// ? InfoEnum.SwapInfo.InfoCarLeave.GetLed()
|
|
|
|
|
// : InfoEnum.SwapInfo.ErrInfoCarLeave.GetLed());
|
|
|
|
|
// machine.VelLockFlag = true;
|
|
|
|
|
// //断连Tbox
|
|
|
|
|
// if (StaticStationInfo.TboxStateDisConnect)
|
|
|
|
|
// {
|
|
|
|
|
// TBoxApi.DisConnect(machine.BoxCarInfoModel.CarNo);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag,
|
|
|
|
|
// machine);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }, () =>
|
|
|
|
|
// {
|
|
|
|
|
// // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrLockCar.GetLed());
|
|
|
|
|
// // SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrLockCar);
|
|
|
|
|
// var SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
// //SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address19"));
|
|
|
|
|
// SoundClient.SoundPlay(SoundEnum.music59);
|
|
|
|
|
// LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrLockCar.GetLed());
|
|
|
|
|
// }, false, () => { machine.ExceptionReason = ExceptionReason.LockCarError; }
|
|
|
|
|
// , 10, InvokeStatus.None);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 车辆上锁
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public InvokeStatus LockCar(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
int v = 0;
|
|
|
|
|
return Invoker.Invoke("LockCar", 500, 100, machine.IsCanceled, machine.IsManualSwapSucc,
|
|
|
|
|
() => machine.VelLockFlag, () =>
|
|
|
|
|
{
|
|
|
|
|
Task<bool> result = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelVin);
|
|
|
|
|
Task<bool> result = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelNo);
|
|
|
|
|
|
|
|
|
|
bool unLock = result.Result;
|
|
|
|
|
if (unLock)
|
|
|
|
|
{
|
|
|
|
|
//查询车辆锁止状态
|
|
|
|
|
Task<TboxCarInfoModel> carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin);
|
|
|
|
|
Task<TboxCarInfoModel> carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelNo);
|
|
|
|
|
if (carInfo.Result?.CarStatus?.LockStatus == 2)
|
|
|
|
|
{
|
|
|
|
|
machine.BoxCarInfoModel = carInfo.Result;
|
|
|
|
|
if (v == 0)
|
|
|
|
|
{
|
|
|
|
|
var SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
SoundClient.SoundPlay(SoundEnum.music77);
|
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
|
SoundClient.SoundPlay(SoundEnum.music76);
|
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag,
|
|
|
|
|
machine);
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarOutFlag,
|
|
|
|
|
machine);
|
|
|
|
|
|
|
|
|
|
v = 1;
|
|
|
|
|
}
|
|
|
|
|
machine.BoxCarInfoModel = carInfo.Result;
|
|
|
|
|
SoundApi.PlayOneSound(machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success
|
|
|
|
|
? (int)InfoEnum.SwapInfo.InfoCarLeave
|
|
|
|
|
: (int)InfoEnum.SwapInfo.ErrInfoCarLeave);
|
|
|
|
@ -173,29 +244,56 @@ public class SwapDoneState : IState
|
|
|
|
|
? InfoEnum.SwapInfo.InfoCarLeave.GetLed()
|
|
|
|
|
: InfoEnum.SwapInfo.ErrInfoCarLeave.GetLed());
|
|
|
|
|
machine.VelLockFlag = true;
|
|
|
|
|
|
|
|
|
|
//SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address19"));
|
|
|
|
|
|
|
|
|
|
//断连Tbox
|
|
|
|
|
if (StaticStationInfo.TboxStateDisConnect)
|
|
|
|
|
{
|
|
|
|
|
TBoxApi.DisConnect(machine.BoxCarInfoModel.CarNo);
|
|
|
|
|
}
|
|
|
|
|
//新增小步
|
|
|
|
|
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag,
|
|
|
|
|
machine);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}, () =>
|
|
|
|
|
{
|
|
|
|
|
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrLockCar.GetLed());
|
|
|
|
|
// SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrLockCar);
|
|
|
|
|
var SoundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
//SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address19"));
|
|
|
|
|
SoundClient.SoundPlay(SoundEnum.music59);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrLockCar.GetLed());
|
|
|
|
|
}, false, () => { machine.ExceptionReason = ExceptionReason.LockCarError; }
|
|
|
|
|
, 10, InvokeStatus.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public InvokeStatus AdjustCarByRadar(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return Invoker.Invoke("begin Radar", 1000, 20, machine.IsCanceled,
|
|
|
|
|
() =>
|
|
|
|
|
{
|
|
|
|
|
//新增小步
|
|
|
|
|
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarOutFlag,
|
|
|
|
|
machine);
|
|
|
|
|
var carState = PadarMgr._PadarClient?.CarState;
|
|
|
|
|
return carState.HasValue && (carState.Value == 1 || carState.Value == 2 || carState.Value == 3 || carState.Value == 4 || carState.Value == 5);
|
|
|
|
|
},
|
|
|
|
|
() =>
|
|
|
|
|
{
|
|
|
|
|
switch (PadarMgr._PadarClient?.CarState)
|
|
|
|
|
{
|
|
|
|
|
case 6:
|
|
|
|
|
_log.Info("车辆未驶离");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public InvokeStatus ExistRadar(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
return Invoker.Invoke("wait exist radar", 1000, 5, machine.IsCanceled, machine.IsManualSwapSucc,
|
|
|
|
@ -215,8 +313,8 @@ public class SwapDoneState : IState
|
|
|
|
|
|
|
|
|
|
//出口写红灯
|
|
|
|
|
//更新车辆离场时间,上报云平台
|
|
|
|
|
machine.BusinessSwappingForCloudState =
|
|
|
|
|
InfoEnum.BusinessSwappingForCloudState.SwapDoneWithoutVel;
|
|
|
|
|
//machine.BusinessSwappingForCloudState =
|
|
|
|
|
// InfoEnum.BusinessSwappingForCloudState.SwapDoneWithoutVel;
|
|
|
|
|
machine.SwapOrder!.VehicleLeaveTime = DateTime.Now;
|
|
|
|
|
_CommonMgr.UpdateSwapOrder(machine);
|
|
|
|
|
|
|
|
|
|