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.
83 lines
2.3 KiB
83 lines
2.3 KiB
using Autofac;
|
|
using Entity.DbModel.Station;
|
|
using HybirdFrameworkCore.Autofac;
|
|
using HybirdFrameworkCore.AutoTask;
|
|
using HybirdFrameworkCore.Redis;
|
|
using Newtonsoft.Json;
|
|
using Repository.Station;
|
|
using Service.Charger.Client;
|
|
using Service.Init;
|
|
using Service.Swap.Dto;
|
|
|
|
namespace Service.MyTask;
|
|
|
|
public class BatteryInfoUploadTask : ITask
|
|
{
|
|
private RedisHelper RedisHelper { get; set; } = AppInfo.Container.Resolve<RedisHelper>();
|
|
private BinInfoRepository BinInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
|
|
|
|
private static bool _stop;
|
|
|
|
public string Name()
|
|
{
|
|
return nameof(BatteryInfoUploadTask);
|
|
}
|
|
|
|
public int Interval()
|
|
{
|
|
return 1000 * 30;
|
|
}
|
|
|
|
public void Handle()
|
|
{
|
|
|
|
DateTime now = DateTime.Now;
|
|
List<BinInfo> binInfos = BinInfoRepository.Query();
|
|
List<SingleBatInfo> batInfos = binInfos.Where(it => it.Exists == 1).Select(it =>
|
|
{
|
|
ChargerClient? client = ClientMgr.GetBySn(it.ChargerNo);
|
|
SingleBatInfo batInfo = new SingleBatInfo()
|
|
{
|
|
bn = it.BatteryNo,
|
|
bt = now,
|
|
sd = it.ChargerNo,
|
|
cno = Convert.ToInt32(it.ChargerNo.Substring(1)),
|
|
el = 0,
|
|
hc = Convert.ToInt32(it.ChargeStatus),
|
|
hst=Convert.ToSingle(client?.BatteryPackDataVoltage?.CellTemperatureMax),
|
|
hsv = Convert.ToSingle(client?.BatteryPackDataVoltage?.CellVoltageMax),
|
|
lst = Convert.ToSingle(client?.BatteryPackDataVoltage?.CellTemperatureMin),
|
|
lsv = Convert.ToSingle(client?.BatteryPackDataVoltage?.CellVoltageMin),
|
|
soc = Convert.ToSingle(it.Soc),
|
|
soe = Convert.ToSingle(it.Soe),
|
|
soh = Convert.ToSingle(it.Soh)
|
|
};
|
|
return batInfo;
|
|
}).ToList();
|
|
BatDataInfo batDataInfo = new BatDataInfo
|
|
{
|
|
batn = batInfos.Count,
|
|
sn = StaticStationInfo.StationNo,
|
|
datainfo = batInfos
|
|
};
|
|
|
|
|
|
RedisHelper.PublishAsync("BatteryInfoUploadTask", JsonConvert.SerializeObject(batDataInfo));
|
|
}
|
|
|
|
public bool Stoped()
|
|
{
|
|
return _stop;
|
|
}
|
|
|
|
public void Stop()
|
|
{
|
|
_stop = true;
|
|
}
|
|
|
|
public void ResetStop()
|
|
{
|
|
_stop = false;
|
|
}
|
|
}
|