人工操作bug修复

master
lxw 6 months ago
parent c5cafea201
commit a73ec84a8d

@ -24,30 +24,41 @@ public class CancelState : IState
public StateResult Handle(SwappingStateMachine machine) public StateResult Handle(SwappingStateMachine machine)
{ {
_log.Info($"'goto cancel"); _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; machine.CancelFlag = false;
_swapOrderRepository.Update(machine.SwapOrder); 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() if (machine.SwapOrder != null)
{ {
Type = 2, machine.SwapOrder.SwapResult = (byte)InfoEnum.SwapOrderResult.Fail;
CreatedBy = UserManager.Account, _swapOrderRepository.Update(machine.SwapOrder);
UpdatedBy = UserManager.Account, }
Operator = machine.OperateModel.Operator,
Reason = machine.OperateModel.Reason, _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() return new StateResult()
{ {
SwappingState = SwappingState.StationReady SwappingState = SwappingState.StationReady

@ -24,29 +24,38 @@ public class ManualSuccState : IState
public StateResult Handle(SwappingStateMachine machine) public StateResult Handle(SwappingStateMachine machine)
{ {
_log.Info($"'goto ManualSucc"); _log.Info($"'goto ManualSucc");
machine.ManualSwapSuccFlag = false; try
if (machine.SwapOrderBatteryInfo.swapAmtOrder != null)
{ {
machine.SwapOrderBatteryInfo.swapAmtOrder.Status = (byte)InfoEnum.AmtOrderStatus.SwapFinish; machine.ManualSwapSuccFlag = false;
_swapAmtOrderRepository.Update(machine.SwapOrderBatteryInfo.swapAmtOrder); if (machine.SwapOrderBatteryInfo.swapAmtOrder != null)
} {
machine.SwapOrderBatteryInfo.swapAmtOrder.Status = (byte)InfoEnum.AmtOrderStatus.SwapFinish;
_swapAmtOrderRepository.Update(machine.SwapOrderBatteryInfo.swapAmtOrder);
}
if (machine.SwapOrder != null) if (machine.SwapOrder != null)
{ {
machine.SwapOrder.SwapResult = (byte)InfoEnum.SwapOrderResult.Success; machine.SwapOrder.SwapResult = (byte)InfoEnum.SwapOrderResult.Success;
machine.SwapOrder.VehicleLeaveTime = DateTime.Now; machine.SwapOrder.VehicleLeaveTime = DateTime.Now;
_swapOrderRepository.Update(machine.SwapOrder); _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, machine.Reset();
CreatedBy = UserManager.Account, _log.Error($"ManualSuccState err={e}");
UpdatedBy = UserManager.Account, }
Operator = machine.OperateModel.Operator,
Reason = machine.OperateModel.Reason,
});
machine.Reset();
return new StateResult() return new StateResult()
{ {
SwappingState = SwappingState.StationReady SwappingState = SwappingState.StationReady

Loading…
Cancel
Save