|
|
|
@ -1,16 +1,18 @@
|
|
|
|
|
using AutoMapper;
|
|
|
|
|
using Autofac;
|
|
|
|
|
using AutoMapper;
|
|
|
|
|
using Entity.Attr;
|
|
|
|
|
using Entity.Constant;
|
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
|
using Entity.Dto;
|
|
|
|
|
using HybirdFrameworkCore.Autofac;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Repository.Station;
|
|
|
|
|
using Service.Execute.Api;
|
|
|
|
|
using Service.Execute.Enum;
|
|
|
|
|
using Service.Execute.Model;
|
|
|
|
|
using Service.Execute.StaticTools;
|
|
|
|
|
using Service.Execute.SwapException;
|
|
|
|
|
using Service.Init;
|
|
|
|
|
using Service.Station;
|
|
|
|
|
using Swapping.Business.Tech;
|
|
|
|
|
|
|
|
|
|
namespace Service.Execute.Step;
|
|
|
|
|
|
|
|
|
@ -19,11 +21,11 @@ public class CarPrepareState : IState
|
|
|
|
|
private readonly ILog _log = LogManager.GetLogger(typeof(CarPrepareState));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private BinInfoRepository BinInfoRepository { get; set; }
|
|
|
|
|
public SwapOrderStepService SwapOrderStepService { get; set; }
|
|
|
|
|
private SwapAmtOrderRepository AmtOrderRepository { get; set; }
|
|
|
|
|
private readonly BinInfoRepository _binInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
|
|
|
|
|
private readonly SwapOrderStepService _swapOrderStepService = AppInfo.Container.Resolve<SwapOrderStepService>();
|
|
|
|
|
private readonly SwapAmtOrderRepository _amtOrderRepository = AppInfo.Container.Resolve<SwapAmtOrderRepository>();
|
|
|
|
|
|
|
|
|
|
private SwapOrderBatteryRepository SwapOrderBatteryRepository { get; set; }
|
|
|
|
|
private readonly SwapOrderBatteryRepository _swapOrderBatteryRepository = AppInfo.Container.Resolve<SwapOrderBatteryRepository>();
|
|
|
|
|
|
|
|
|
|
public StateResult Handle(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
@ -119,7 +121,7 @@ public class CarPrepareState : IState
|
|
|
|
|
//清除下发的指令,等待新的指令
|
|
|
|
|
CloudApi.ClearCarCanStartInfo();
|
|
|
|
|
|
|
|
|
|
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.CarInPositionFlag,
|
|
|
|
|
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.CarInPositionFlag,
|
|
|
|
|
machine.StepSort++, machine.SwapOrder.Sn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -158,7 +160,7 @@ public class CarPrepareState : IState
|
|
|
|
|
machine.CloudVelCheckFlag = true;
|
|
|
|
|
machine.LedTool.WriteProgramContent("换电准备中:云平台车辆验证完成");
|
|
|
|
|
|
|
|
|
|
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.CloudVelCheckFlag,
|
|
|
|
|
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.CloudVelCheckFlag,
|
|
|
|
|
machine.StepSort++, machine.SwapOrder.Sn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -266,8 +268,8 @@ public class CarPrepareState : IState
|
|
|
|
|
public InvokeStatus SelectPack(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
SwapAmtOrder? swapAmtOrder =
|
|
|
|
|
AmtOrderRepository.QueryByClause(i =>
|
|
|
|
|
i.Status == (int)InfoEnum.AmtOrderStatus.Success && i.VehicleNo.Equals(machine.BoxCarInfoModel.CarNo));
|
|
|
|
|
_amtOrderRepository.QueryByClause(i =>
|
|
|
|
|
i.Status == (int)InfoEnum.AmtOrderStatus.Success && i.CarNo.Equals(machine.BoxCarInfoModel.CarNo));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Invoker.Invoke("selectPack", 500, 20, machine.IsCanceled,
|
|
|
|
@ -315,7 +317,7 @@ public class CarPrepareState : IState
|
|
|
|
|
UpBatteryBinNo = int.Parse(UpBin.No),
|
|
|
|
|
DownBatteryBinNo = int.Parse(InBin.No),
|
|
|
|
|
};
|
|
|
|
|
SwapOrderBatteryRepository.Insert(swapOrderBattery);
|
|
|
|
|
_swapOrderBatteryRepository.Insert(swapOrderBattery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -330,7 +332,7 @@ public class CarPrepareState : IState
|
|
|
|
|
BinInfo dbBinInfo = mapperBinInfo.Map<BinInfo>(orderBatteryInfo.UpBinInfo);
|
|
|
|
|
|
|
|
|
|
dbBinInfo.AmtLock = (int)InfoEnum.AmtBatLockStatus.Lock;
|
|
|
|
|
BinInfoRepository.Update(dbBinInfo);
|
|
|
|
|
_binInfoRepository.Update(dbBinInfo);
|
|
|
|
|
if (!orderBatteryInfo.isAmt)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
@ -341,7 +343,7 @@ public class CarPrepareState : IState
|
|
|
|
|
IMapper mapperAmt = configAmt.CreateMapper();
|
|
|
|
|
SwapAmtOrder swapAmtOrder = mapperAmt.Map<SwapAmtOrder>(orderBatteryInfo.swapAmtOrder);
|
|
|
|
|
swapAmtOrder.Status = (int)InfoEnum.AmtOrderStatus.Swapping;
|
|
|
|
|
AmtOrderRepository.Update(swapAmtOrder);
|
|
|
|
|
_amtOrderRepository.Update(swapAmtOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 1.仓位状态:启动
|
|
|
|
@ -377,7 +379,7 @@ public class CarPrepareState : IState
|
|
|
|
|
SwapOrderBatteryInfo orderBatteryInfo = new SwapOrderBatteryInfo();
|
|
|
|
|
orderBatteryInfo.swapAmtOrder = swapAmtOrder;
|
|
|
|
|
orderBatteryInfo.isAmt = true;
|
|
|
|
|
BinInfo UpBin = BinInfoRepository.QueryByClause(i => i.No.Equals(swapAmtOrder.AmtBinNoList));
|
|
|
|
|
BinInfo UpBin = _binInfoRepository.QueryByClause(i => i.No.Equals(swapAmtOrder.AmtBinNoList));
|
|
|
|
|
bool CanSwap = UpBin.Exists == 1 && UpBin.Status == 1 && UpBin.ChargeStatus == 2
|
|
|
|
|
&& UpBin.AmtLock == (int)InfoEnum.AmtBatLockStatus.Lock && new TimeSpan(DateTime.Now.Ticks -
|
|
|
|
|
UpBin.LastChargeFinishTime.ToDateTime()
|
|
|
|
@ -402,52 +404,22 @@ public class CarPrepareState : IState
|
|
|
|
|
/// <param name="orderBatteryInfo"></param>
|
|
|
|
|
private void UpBin(SwapOrderBatteryInfo orderBatteryInfo)
|
|
|
|
|
{
|
|
|
|
|
List<BinInfo> list =
|
|
|
|
|
BinInfoRepository.QueryListByClause(i =>
|
|
|
|
|
i.Exists == 1 && i.Status == 1 && i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock);
|
|
|
|
|
if (list.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|
orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.NoBattery;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list = list.Where(i => i.ChargeStatus == 2).ToList();
|
|
|
|
|
if (list.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|
orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.LessOfFinishCharging;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SelectPackDto selectPack =
|
|
|
|
|
_binInfoRepository.SelectPack(StaticStationInfo.SwapSoc, StaticStationInfo.SwapFinishChargeTime);
|
|
|
|
|
|
|
|
|
|
list = list.Where(i => i.Soc > int.Parse(StaticStationInfo.SwapSoc)).ToList();
|
|
|
|
|
if (list.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|
orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.LessOfSoc;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list = list.Where(i => new TimeSpan(DateTime.Now.Ticks -
|
|
|
|
|
i.LastChargeFinishTime.ToDateTime().Ticks)
|
|
|
|
|
.TotalMinutes > int.Parse(StaticStationInfo.SwapFinishChargeTime)).ToList();
|
|
|
|
|
if (list.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|
orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.LessOf3Minute;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
orderBatteryInfo.UpBinInfo = list[0];
|
|
|
|
|
orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.Success;
|
|
|
|
|
orderBatteryInfo.UpBinInfo = selectPack.BinInfo;
|
|
|
|
|
orderBatteryInfo.CanSwap = selectPack.Info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 放电池判断
|
|
|
|
|
/// 放电池判断:取出来的电池仓位能不能放
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="orderBatteryInfo"></param>
|
|
|
|
|
private void InBin(SwapOrderBatteryInfo orderBatteryInfo)
|
|
|
|
|
{
|
|
|
|
|
List<BinInfo> list =
|
|
|
|
|
BinInfoRepository.QueryListByClause(i =>
|
|
|
|
|
i.Exists == 1 && i.Status == 1 && i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock
|
|
|
|
|
_binInfoRepository.QueryListByClause(i =>
|
|
|
|
|
i.Status == 1 && i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock
|
|
|
|
|
&& i.Exists == 0);
|
|
|
|
|
if (list.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|