|
|
|
|
using Autofac;
|
|
|
|
|
using Entity.Constant;
|
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
|
using HybirdFrameworkCore.Autofac;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Repository.Station;
|
|
|
|
|
using Service.Execute.Utils;
|
|
|
|
|
using Service.Mgr;
|
|
|
|
|
|
|
|
|
|
namespace Service.Execute.Step;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 人工确认失败
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class CancelState : IState
|
|
|
|
|
{
|
|
|
|
|
private readonly CommonMgr _CommonMgr = AppInfo.Container.Resolve<CommonMgr>();
|
|
|
|
|
|
|
|
|
|
private readonly SwapAmtOrderRepository _swapAmtOrderRepository =
|
|
|
|
|
AppInfo.Container.Resolve<SwapAmtOrderRepository>();
|
|
|
|
|
|
|
|
|
|
private static readonly ILog _log = LogManager.GetLogger(typeof(CancelState));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly ManualOperationRecordRepository _manualOperationRecordRepository =
|
|
|
|
|
AppInfo.Container.Resolve<ManualOperationRecordRepository>();
|
|
|
|
|
|
|
|
|
|
public StateResult Handle(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
_log.Info($"'goto cancel");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
machine.SwapOrder.SwapResult = (byte)InfoEnum.SwapOrderResult.Fail;
|
|
|
|
|
_CommonMgr.UpdateSwapOrder(machine);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var manualOperationRecord = new ManualOperationRecord()
|
|
|
|
|
{
|
|
|
|
|
Type = 2,
|
|
|
|
|
CreatedBy = UserManager.Account,
|
|
|
|
|
UpdatedBy = UserManager.Account,
|
|
|
|
|
Operator = machine.OperateModel.Operator,
|
|
|
|
|
Reason = machine.OperateModel.Reason,
|
|
|
|
|
};
|
|
|
|
|
if (machine.SwapOrder != null)
|
|
|
|
|
{
|
|
|
|
|
manualOperationRecord.SwapOrderSn = machine.SwapOrder.Sn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_manualOperationRecordRepository.Insert(manualOperationRecord);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
machine.Reset();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
machine.Reset();
|
|
|
|
|
_log.Error($"CancelState err={e}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new StateResult()
|
|
|
|
|
{
|
|
|
|
|
SwappingState = SwappingState.StationReady
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|