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

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