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.

60 lines
1.7 KiB

using Entity.Constant;
using Entity.DbModel.Station;
7 months ago
using HybirdFrameworkCore.Autofac.Attribute;
using Newtonsoft.Json;
7 months ago
using Repository.Station;
using Service.Cloud.Common;
using Service.Cloud.Msg.Cloud.Req;
7 months ago
using Service.Cloud.Msg.Host.Resp;
using Service.Init;
namespace Service.Cloud.Handler;
[Scope("InstancePerDependency")]
public class AmtBatHandler : IBaseHandler
{
7 months ago
private BinInfoRepository _binInfoRepository;
private SwapAmtOrderRepository _swapAmtOrderRepository;
7 months ago
public AmtBatHandler(BinInfoRepository binInfoRepository, SwapAmtOrderRepository swapAmtOrderRepository)
7 months ago
{
_binInfoRepository = binInfoRepository;
_swapAmtOrderRepository = swapAmtOrderRepository;
7 months ago
}
public void Handle(string t)
{
7 months ago
AmtBatRes abRes = new AmtBatRes();
abRes.rs = 3;
AmtBat? amtBat = JsonConvert.DeserializeObject<AmtBat>(t);
7 months ago
if (amtBat != null)
{
int count = _swapAmtOrderRepository.GetCount(it =>
7 months ago
it.CarNo == amtBat.cn && it.Status == (byte)InfoEnum.AmtOrderStatus.Success);
if (count > 0)
{
abRes.rs = 1;
}
else
{
SwapAmtOrder amtOrderInfo = new SwapAmtOrder()
7 months ago
{
Sn = StaticStationInfo.StationNo,
CarNo = amtBat.cn,
BatteryCount = amtBat.bm,
7 months ago
BatteryType = amtBat.bn,
AmtTime = amtBat.at,
ExpireTime = amtBat.at.AddMinutes(amtBat.am)
7 months ago
};
}
}
}
public bool CanHandle(string cmd)
{
return CloudConst.amtBat == cmd;
}
}