From a73ec84a8d2d75973f9c69e5b6c0fca119916e60 Mon Sep 17 00:00:00 2001 From: lxw Date: Tue, 11 Jun 2024 10:36:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=B7=A5=E6=93=8D=E4=BD=9Cbug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service/Execute/Step/CancelState.cs | 49 +++++++++++++++---------- Service/Execute/Step/ManualSuccState.cs | 47 ++++++++++++++---------- 2 files changed, 58 insertions(+), 38 deletions(-) diff --git a/Service/Execute/Step/CancelState.cs b/Service/Execute/Step/CancelState.cs index a8e8ff1..a36ce40 100644 --- a/Service/Execute/Step/CancelState.cs +++ b/Service/Execute/Step/CancelState.cs @@ -24,30 +24,41 @@ public class CancelState : IState public StateResult Handle(SwappingStateMachine machine) { _log.Info($"'goto cancel"); - machine.CancelFlag = false; - if (machine.SwapOrderBatteryInfo!=null && machine.SwapOrderBatteryInfo.swapAmtOrder != null) - { - machine.SwapOrderBatteryInfo.swapAmtOrder.Status = (byte)InfoEnum.AmtOrderStatus.SwapFail; - _swapAmtOrderRepository.Update(machine.SwapOrderBatteryInfo.swapAmtOrder); - } - if (machine.SwapOrder != null) + try { - machine.SwapOrder.SwapResult = (byte)InfoEnum.SwapOrderResult.Fail; - _swapOrderRepository.Update(machine.SwapOrder); - } + machine.CancelFlag = false; + if (machine.SwapOrderBatteryInfo!=null && machine.SwapOrderBatteryInfo.swapAmtOrder != null) + { + machine.SwapOrderBatteryInfo.swapAmtOrder.Status = (byte)InfoEnum.AmtOrderStatus.SwapFail; + _swapAmtOrderRepository.Update(machine.SwapOrderBatteryInfo.swapAmtOrder); + } - _manualOperationRecordRepository.Insert(new ManualOperationRecord() - { - Type = 2, - CreatedBy = UserManager.Account, - UpdatedBy = UserManager.Account, - Operator = machine.OperateModel.Operator, - Reason = machine.OperateModel.Reason, - }); + if (machine.SwapOrder != null) + { + machine.SwapOrder.SwapResult = (byte)InfoEnum.SwapOrderResult.Fail; + _swapOrderRepository.Update(machine.SwapOrder); + } + + _manualOperationRecordRepository.Insert(new ManualOperationRecord() + { + Type = 2, + CreatedBy = UserManager.Account, + UpdatedBy = UserManager.Account, + Operator = machine.OperateModel.Operator, + Reason = machine.OperateModel.Reason, + }); - machine.Reset(); + machine.Reset(); + + } + catch (Exception e) + { + machine.Reset(); + _log.Error($"CancelState err={e}"); + } + return new StateResult() { SwappingState = SwappingState.StationReady diff --git a/Service/Execute/Step/ManualSuccState.cs b/Service/Execute/Step/ManualSuccState.cs index 6fac46c..91ad0e6 100644 --- a/Service/Execute/Step/ManualSuccState.cs +++ b/Service/Execute/Step/ManualSuccState.cs @@ -24,29 +24,38 @@ public class ManualSuccState : IState public StateResult Handle(SwappingStateMachine machine) { _log.Info($"'goto ManualSucc"); - machine.ManualSwapSuccFlag = false; - if (machine.SwapOrderBatteryInfo.swapAmtOrder != null) + try { - machine.SwapOrderBatteryInfo.swapAmtOrder.Status = (byte)InfoEnum.AmtOrderStatus.SwapFinish; - _swapAmtOrderRepository.Update(machine.SwapOrderBatteryInfo.swapAmtOrder); - } + machine.ManualSwapSuccFlag = false; + if (machine.SwapOrderBatteryInfo.swapAmtOrder != null) + { + machine.SwapOrderBatteryInfo.swapAmtOrder.Status = (byte)InfoEnum.AmtOrderStatus.SwapFinish; + _swapAmtOrderRepository.Update(machine.SwapOrderBatteryInfo.swapAmtOrder); + } - if (machine.SwapOrder != null) - { - machine.SwapOrder.SwapResult = (byte)InfoEnum.SwapOrderResult.Success; - machine.SwapOrder.VehicleLeaveTime = DateTime.Now; - _swapOrderRepository.Update(machine.SwapOrder); - } + if (machine.SwapOrder != null) + { + machine.SwapOrder.SwapResult = (byte)InfoEnum.SwapOrderResult.Success; + machine.SwapOrder.VehicleLeaveTime = DateTime.Now; + _swapOrderRepository.Update(machine.SwapOrder); + } - _manualOperationRecordRepository.Insert(new ManualOperationRecord() + _manualOperationRecordRepository.Insert(new ManualOperationRecord() + { + Type = 2, + CreatedBy = UserManager.Account, + UpdatedBy = UserManager.Account, + Operator = machine.OperateModel.Operator, + Reason = machine.OperateModel.Reason, + }); + machine.Reset(); + } + catch (Exception e) { - Type = 2, - CreatedBy = UserManager.Account, - UpdatedBy = UserManager.Account, - Operator = machine.OperateModel.Operator, - Reason = machine.OperateModel.Reason, - }); - machine.Reset(); + machine.Reset(); + _log.Error($"ManualSuccState err={e}"); + } + return new StateResult() { SwappingState = SwappingState.StationReady