From bb83d2086de1844d10d4a744f99b8dfd34b5943e Mon Sep 17 00:00:00 2001 From: rszn <645583145@qq.com> Date: Tue, 9 Jul 2024 13:45:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E6=B1=A0=E4=BF=A1=E6=81=AF=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service/MyTask/BatteryInfoUploadTask.cs | 82 ++++++++++++++++++++++++ Service/Swap/Dto/BatDataInfo.cs | 23 +++++++ Service/Swap/Dto/SingleBatInfo.cs | 84 +++++++++++++++++++++++++ 3 files changed, 189 insertions(+) create mode 100644 Service/MyTask/BatteryInfoUploadTask.cs create mode 100644 Service/Swap/Dto/BatDataInfo.cs create mode 100644 Service/Swap/Dto/SingleBatInfo.cs diff --git a/Service/MyTask/BatteryInfoUploadTask.cs b/Service/MyTask/BatteryInfoUploadTask.cs new file mode 100644 index 0000000..7e9a571 --- /dev/null +++ b/Service/MyTask/BatteryInfoUploadTask.cs @@ -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(); + private BinInfoRepository BinInfoRepository = AppInfo.Container.Resolve(); + + private static bool _stop; + + public string Name() + { + return nameof(BatteryInfoUploadTask); + } + + public int Interval() + { + return 1000 * 30; + } + + public void Handle() + { + + DateTime now = DateTime.Now; + List binInfos = BinInfoRepository.Query(); + List 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; + } +} diff --git a/Service/Swap/Dto/BatDataInfo.cs b/Service/Swap/Dto/BatDataInfo.cs new file mode 100644 index 0000000..23346a6 --- /dev/null +++ b/Service/Swap/Dto/BatDataInfo.cs @@ -0,0 +1,23 @@ +namespace Service.Swap.Dto +{ + /// + /// 4.2.11.1 换电站电池包数据信息 + /// + public class BatDataInfo + { + /// + /// 场站编码 换电站唯一码 + /// + public string sn { get; set; } + + /// + /// 换电站电池包总 数量 + /// + public int batn { get; set; } + + /// + /// 电池信息 + /// + public List datainfo { get; set; } + } +} diff --git a/Service/Swap/Dto/SingleBatInfo.cs b/Service/Swap/Dto/SingleBatInfo.cs new file mode 100644 index 0000000..e906248 --- /dev/null +++ b/Service/Swap/Dto/SingleBatInfo.cs @@ -0,0 +1,84 @@ +namespace Service.Swap.Dto; + +public class SingleBatInfo +{ + /// + /// 电池序列号 + /// + public string bn { get; set; } + + /// + /// 充电架 ID 按电池架的编号 A1,A2… + /// + public string sd { get; set; } + + /// + /// 所在充电机序号 从 1 开始递增 + /// + public int cno { get; set; } + + /// + /// 是否在充电 0:未知 1:正在充电 2:未电池 + /// + public int hc { get; set; } + + /// + /// 电接头连接状态 0:未知 1:已经连接 2:未连接 + /// + public int el { get; set; } + + /// + /// 剩余能量 单位 0.1 kwh + /// + public float soe { get; set; } + + /// + /// 当前 SOC 0-100 单位 0.1 ,没有充电填 0 + /// + public float soc { get; set; } + + /// + /// 当前 SOH 0-100 单位 0.1 ,没有充电填 0 + /// + public float soh { get; set; } + + /// + /// 最低单体电压 单位 0.01V + /// + public float lsv { get; set; } + + /// + /// 最高单体电压 单位 0.01V + /// + public float hsv { get; set; } + + /// + /// 最低单体温度 单位 0.1℃ + /// + public float lst { get; set; } + + /// + /// 最高单体温度 单位 0.1℃ + /// + public float hst { get; set; } + + /// + /// 单体电池号 从 1 开始递增 + /// + public int sl { get; set; } + + /// + /// 单体电压 每一节电芯的单体电压 单位 0.1V ,如果没有该节电芯的数据,填65535.0 无效值 + /// + public float sv { get; set; } + + /// + /// 单体温度 每一节电芯的单体温度 单位 0.1℃ ,如果没有该节电芯的数据,填65535.0 无效值 + /// + public float st { get; set; } + + /// + /// 更新时间 格式 ”yyyy-MM-dd HH:mm:ss ” + /// + public DateTime bt { get; set; } +}