|
|
|
|
using Entity.Constant;
|
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Repository.Station;
|
|
|
|
|
using Service.Cloud.Client;
|
|
|
|
|
using Service.Cloud.Common;
|
|
|
|
|
using Service.Cloud.Msg.Cloud.Req;
|
|
|
|
|
using Service.Cloud.Msg.Host.Resp;
|
|
|
|
|
using Service.Init;
|
|
|
|
|
|
|
|
|
|
namespace Service.Cloud.Handler;
|
|
|
|
|
|
|
|
|
|
[Scope("InstancePerDependency")]
|
|
|
|
|
public class AmtBatHandler : IBaseHandler
|
|
|
|
|
{
|
|
|
|
|
private BinInfoRepository _binInfoRepository;
|
|
|
|
|
private SwapAmtOrderRepository _swapAmtOrderRepository;
|
|
|
|
|
|
|
|
|
|
public AmtBatHandler(BinInfoRepository binInfoRepository, SwapAmtOrderRepository swapAmtOrderRepository)
|
|
|
|
|
{
|
|
|
|
|
_binInfoRepository = binInfoRepository;
|
|
|
|
|
_swapAmtOrderRepository = swapAmtOrderRepository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Handle(string t)
|
|
|
|
|
{
|
|
|
|
|
AmtBatRes abRes = new AmtBatRes();
|
|
|
|
|
AmtBat? amtBat = JsonConvert.DeserializeObject<AmtBat>(t);
|
|
|
|
|
abRes.result = 3;
|
|
|
|
|
if (amtBat != null)
|
|
|
|
|
{
|
|
|
|
|
int count = _swapAmtOrderRepository.GetCount(it =>
|
|
|
|
|
it.CarNo == amtBat.carNo && it.Status == (byte)InfoEnum.AmtOrderStatus.Success);
|
|
|
|
|
|
|
|
|
|
if (count > 0)
|
|
|
|
|
{
|
|
|
|
|
abRes.result = 1;
|
|
|
|
|
CloudClientMgr.CloudClient?.Publish(abRes);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SwapAmtOrder amtOrderInfo = new SwapAmtOrder();
|
|
|
|
|
amtOrderInfo.CarNo = amtBat.carNo;
|
|
|
|
|
amtOrderInfo.Status = (byte)InfoEnum.AmtOrderStatus.Success;
|
|
|
|
|
amtOrderInfo.BatteryCount = amtBat.batteryCount;
|
|
|
|
|
amtOrderInfo.BatteryType = amtBat.batteryTypeNo;
|
|
|
|
|
amtOrderInfo.AmtTime = amtBat.appointmentTime;
|
|
|
|
|
amtOrderInfo.ExpireTime = amtBat.appointmentTime.AddMinutes(amtBat.lockTime);
|
|
|
|
|
_swapAmtOrderRepository.Insert(amtOrderInfo);
|
|
|
|
|
CloudClientMgr.CloudClient?.Publish(abRes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CanHandle(string cmd)
|
|
|
|
|
{
|
|
|
|
|
return CloudConst.amtBat == cmd;
|
|
|
|
|
}
|
|
|
|
|
}
|