From a7c8b103a6e4a721f2a95158fa5bc00b4476075b Mon Sep 17 00:00:00 2001
From: tq <1916474859@qq,com>
Date: Tue, 28 May 2024 17:50:44 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E7=8E=87=E8=B5=8B=E5=80=BC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Entity/Dto/Resp/BinInfoResp.cs | 167 +++++++++++++++++++++
WebStarter/Controllers/ChargeController.cs | 36 +++--
2 files changed, 194 insertions(+), 9 deletions(-)
create mode 100644 Entity/Dto/Resp/BinInfoResp.cs
diff --git a/Entity/Dto/Resp/BinInfoResp.cs b/Entity/Dto/Resp/BinInfoResp.cs
new file mode 100644
index 0000000..dbc7115
--- /dev/null
+++ b/Entity/Dto/Resp/BinInfoResp.cs
@@ -0,0 +1,167 @@
+namespace Entity.Dto.Resp;
+
+public partial class BinInfoResp
+{
+ public BinInfoResp()
+ {
+ }
+
+ ///
+ /// Desc:id
+ /// Default:
+ /// Nullable:False
+ ///
+ public int Id { get; set; }
+
+ ///
+ /// Desc:仓位编号
+ /// Default:
+ /// Nullable:True
+ ///
+ public string No { get; set; }
+
+ ///
+ /// Desc:仓位编码
+ /// Default:
+ /// Nullable:True
+ ///
+ public string Code { get; set; }
+
+ ///
+ /// Desc:仓位名称
+ /// Default:
+ /// Nullable:True
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// Desc:电池编号
+ /// Default:
+ /// Nullable:True
+ ///
+ public string BatteryNo { get; set; }
+
+ ///
+ /// Desc:充电机编号
+ /// Default:
+ /// Nullable:True
+ ///
+ public string ChargerNo { get; set; }
+
+ ///
+ /// Desc:充电枪编号
+ /// Default:
+ /// Nullable:True
+ ///
+ public string ChargerGunNo { get; set; }
+
+ ///
+ /// Desc:水冷编号
+ /// Default:
+ /// Nullable:True
+ ///
+ public string WaterCoolNo { get; set; }
+
+ ///
+ /// Desc:是否有电插头;0-无电插头;1-有电插头
+ /// Default:
+ /// Nullable:True
+ ///
+ public int? ElecPluginFlag { get; set; }
+
+ ///
+ /// Desc:电插头状态;0-未知;1-已经连接;2-未连接
+ /// Default:
+ /// Nullable:True
+ ///
+ public string ElecPluginStatus { get; set; }
+
+ ///
+ /// Desc:是否有水插头;0-无水插头;1-有水插头
+ /// Default:
+ /// Nullable:False
+ ///
+ public string WaterPluginFlag { get; set; }
+
+ ///
+ /// Desc:预约锁定;0-未锁定;1-锁定
+ /// Default:
+ /// Nullable:True
+ ///
+ public string AmtLock { get; set; }
+
+ ///
+ /// Desc:soc
+ /// Default:
+ /// Nullable:True
+ ///
+ public decimal? Soc { get; set; }
+
+ ///
+ /// Desc:soe
+ /// Default:
+ /// Nullable:True
+ ///
+ public decimal? Soe { get; set; }
+
+ ///
+ /// Desc:soh
+ /// Default:
+ /// Nullable:True
+ ///
+ public decimal? Soh { get; set; }
+
+ ///
+ /// Desc:电池入仓顺序
+ /// Default:
+ /// Nullable:True
+ ///
+ public int? BatteryEnterSeq { get; set; }
+
+ ///
+ /// Desc:充电状态;0-未知;1-正在充电;2-无电池;3-禁用;4-充电停止
+ /// Default:0
+ /// Nullable:True
+ ///
+ public int? ChargeStatus { get; set; }
+
+ ///
+ /// Desc:仓位状态;0-禁用;1-启用
+ /// Default:1
+ /// Nullable:True
+ ///
+ public int? Status { get; set; }
+
+ ///
+ /// Desc:创建人
+ /// Default:
+ /// Nullable:True
+ ///
+ public string CreatedBy { get; set; }
+
+ ///
+ /// Desc:创建时间
+ /// Default:CURRENT_TIMESTAMP
+ /// Nullable:True
+ ///
+ public DateTime? CreatedTime { get; set; }
+
+ ///
+ /// Desc:更新人
+ /// Default:
+ /// Nullable:True
+ ///
+ public string UpdatedBy { get; set; }
+
+ ///
+ /// Desc:更新时间
+ /// Default:CURRENT_TIMESTAMP
+ /// Nullable:True
+ ///
+ public DateTime? UpdatedTime { get; set; }
+ ///
+ /// 功率
+ ///
+
+ public float power { get; set; }
+}
\ No newline at end of file
diff --git a/WebStarter/Controllers/ChargeController.cs b/WebStarter/Controllers/ChargeController.cs
index 4e5e5a2..58f58b8 100644
--- a/WebStarter/Controllers/ChargeController.cs
+++ b/WebStarter/Controllers/ChargeController.cs
@@ -1,4 +1,6 @@
-using Entity.DbModel.Station;
+using AutoMapper;
+using Entity.DbModel.Station;
+using Entity.Dto.Resp;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Repository.Station;
@@ -19,24 +21,40 @@ public class ChargeController : ControllerBase
private ChargerService _chargerService;
private BinInfoRepository _binInfoRepository;
- public ChargeController(ChargerService chargerService,BinInfoRepository binInfoRepository)
+ public ChargeController(ChargerService chargerService, BinInfoRepository binInfoRepository)
{
_chargerService = chargerService;
_binInfoRepository = binInfoRepository;
}
-
-
+
+
///
/// 仓位信息
///
/// 仓位信息列表
[HttpGet]
[Route("/api/ChrgMonitor/GetChargMonitorChargBinData")]
- public Result> GetChargMonitorChargBinData()
+ public Result> GetChargMonitorChargBinData()
{
- return Result>.Success(_binInfoRepository.Query());
+ List binInfos = _binInfoRepository.Query();
+ var configuration = new MapperConfiguration(cfg => cfg.CreateMap());
+ var mapper = configuration.CreateMapper();
+
+ // 转换为 BinInfoResp 列表
+ List binInfoList = mapper.Map>(binInfos);
+ // 功率赋值
+ foreach (var binInfoResp in binInfoList)
+ {
+ ChargerClient? chargerClient = ClientMgr.GetBySn(binInfoResp.Code);
+ if (chargerClient != null)
+ {
+ binInfoResp.power = chargerClient.RealTimeChargePower;
+ }
+ }
+
+ return Result>.Success(binInfoList);
}
-
+
///
/// 仓位禁用
///
@@ -48,7 +66,7 @@ public class ChargeController : ControllerBase
{
return Result.Success(_binInfoRepository.UpdateStatus(data));
}
-
+
///
/// 获取仓位实时功率
///
@@ -62,7 +80,7 @@ public class ChargeController : ControllerBase
.ToArray();
return Result.Success(results);
}
-
+
///
/// 通过仓号启动充电
///