You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.2 KiB

using Autofac;
using Entity.Constant;
using HybirdFrameworkCore.Autofac;
using log4net;
using Repository.Station;
namespace Service.Execute.Step;
public class CancelState : IState
{
private readonly SwapOrderRepository _swapOrderRepository= AppInfo.Container.Resolve<SwapOrderRepository>();
private readonly SwapAmtOrderRepository _swapAmtOrderRepository = AppInfo.Container.Resolve<SwapAmtOrderRepository>();
private static readonly ILog _log = LogManager.GetLogger(typeof(CancelState));
public StateResult Handle(SwappingStateMachine machine)
{
_log.Info($"'goto cancel");
machine.CancelFlag = false;
if (machine.SwapOrderBatteryInfo.swapAmtOrder != null)
{
machine.SwapOrderBatteryInfo.swapAmtOrder.Status = (byte)InfoEnum.AmtOrderStatus.SwapFail;
_swapAmtOrderRepository.Update(machine.SwapOrderBatteryInfo.swapAmtOrder);
}
if (machine.SwapOrder != null)
{
machine.SwapOrder.SwapResult = (byte)InfoEnum.SwapOrderResult.Fail;
_swapOrderRepository.Update(machine.SwapOrder);
}
machine.Reset();
return new StateResult()
{
SwappingState = SwappingState.StationReady
};
}
}