电池信息上传

zw
rszn 4 months ago
parent 2b469ccd40
commit bb83d2086d

@ -0,0 +1,82 @@
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;
}
}

@ -0,0 +1,23 @@
namespace Service.Swap.Dto
{
/// <summary>
/// 4.2.11.1 换电站电池包数据信息
/// </summary>
public class BatDataInfo
{
/// <summary>
/// 场站编码 换电站唯一码
/// </summary>
public string sn { get; set; }
/// <summary>
/// 换电站电池包总 数量
/// </summary>
public int batn { get; set; }
/// <summary>
/// 电池信息
/// </summary>
public List<SingleBatInfo> datainfo { get; set; }
}
}

@ -0,0 +1,84 @@
namespace Service.Swap.Dto;
public class SingleBatInfo
{
/// <summary>
/// 电池序列号
/// </summary>
public string bn { get; set; }
/// <summary>
/// 充电架 ID 按电池架的编号 A1A2…
/// </summary>
public string sd { get; set; }
/// <summary>
/// 所在充电机序号 从 1 开始递增
/// </summary>
public int cno { get; set; }
/// <summary>
/// 是否在充电 0未知 1正在充电 2未电池
/// </summary>
public int hc { get; set; }
/// <summary>
/// 电接头连接状态 0未知 1已经连接 2未连接
/// </summary>
public int el { get; set; }
/// <summary>
/// 剩余能量 单位 0.1 kwh
/// </summary>
public float soe { get; set; }
/// <summary>
/// 当前 SOC 0-100 单位 0.1 ,没有充电填 0
/// </summary>
public float soc { get; set; }
/// <summary>
/// 当前 SOH 0-100 单位 0.1 ,没有充电填 0
/// </summary>
public float soh { get; set; }
/// <summary>
/// 最低单体电压 单位 0.01V
/// </summary>
public float lsv { get; set; }
/// <summary>
/// 最高单体电压 单位 0.01V
/// </summary>
public float hsv { get; set; }
/// <summary>
/// 最低单体温度 单位 0.1℃
/// </summary>
public float lst { get; set; }
/// <summary>
/// 最高单体温度 单位 0.1℃
/// </summary>
public float hst { get; set; }
/// <summary>
/// 单体电池号 从 1 开始递增
/// </summary>
public int sl { get; set; }
/// <summary>
/// 单体电压 每一节电芯的单体电压 单位 0.1V 如果没有该节电芯的数据填65535.0 无效值
/// </summary>
public float sv { get; set; }
/// <summary>
/// 单体温度 每一节电芯的单体温度 单位 0.1℃ ,如果没有该节电芯的数据填65535.0 无效值
/// </summary>
public float st { get; set; }
/// <summary>
/// 更新时间 格式 ”yyyy-MM-dd HH:mm:ss ”
/// </summary>
public DateTime bt { get; set; }
}
Loading…
Cancel
Save