From e71014e3830a96ed7344048d3d9859a7623b3ac8 Mon Sep 17 00:00:00 2001
From: tq <1916474859@qq,com>
Date: Tue, 4 Jun 2024 16:24:16 +0800
Subject: [PATCH] =?UTF-8?q?=E5=85=85=E7=94=B5=E6=A8=A1=E5=BC=8F=E5=AD=97?=
=?UTF-8?q?=E6=AE=B5=E5=A2=9E=E5=8A=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Entity/DbModel/Station/EquipInfo.cs | 9 +-
Entity/Dto/Req/EquipInfoReq.cs | 37 ++++++++
Entity/Dto/Resp/BinInfoResp.cs | 88 +++++++++++++++++--
Repository/Station/EquipInfoRepository.cs | 23 +++++
Service/Station/BinInfoService.cs | 68 ++++++++++++++
Service/Station/EquipInfoService.cs | 79 +++++++++++++++++
WebStarter/Controllers/ChargeController.cs | 29 ++----
.../Station/EquipInfoController.cs | 56 ++++++++++++
8 files changed, 357 insertions(+), 32 deletions(-)
create mode 100644 Entity/Dto/Req/EquipInfoReq.cs
create mode 100644 Service/Station/BinInfoService.cs
create mode 100644 Service/Station/EquipInfoService.cs
create mode 100644 WebStarter/Controllers/Station/EquipInfoController.cs
diff --git a/Entity/DbModel/Station/EquipInfo.cs b/Entity/DbModel/Station/EquipInfo.cs
index d4129ef..1b71f8c 100644
--- a/Entity/DbModel/Station/EquipInfo.cs
+++ b/Entity/DbModel/Station/EquipInfo.cs
@@ -86,6 +86,13 @@ namespace Entity.DbModel.Station
///
[SugarColumn(ColumnName="updated_time")]
public DateTime? UpdatedTime {get;set;}
-
+
+ ///
+ /// Desc:0-手动;1-自动充电
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="auto_charge")]
+ public int? AutoCharge {get;set;}
}
}
diff --git a/Entity/Dto/Req/EquipInfoReq.cs b/Entity/Dto/Req/EquipInfoReq.cs
new file mode 100644
index 0000000..cf10789
--- /dev/null
+++ b/Entity/Dto/Req/EquipInfoReq.cs
@@ -0,0 +1,37 @@
+using Entity.DbModel.Station;
+
+namespace Entity.Dto.Req;
+
+public class EquipInfoReq : BaseIdReq
+{
+}
+
+public class PageEquipInfoReq : BasePageReq
+{
+ ///
+ /// 名称
+ ///
+ public string Name { get; set; } = "";
+
+ ///
+ /// 设备编码;0-充电机;1-电表
+ ///
+ public string Code { get; set; } = "";
+
+ ///
+ /// 设备状态
+ ///
+ public int? Status { get; set; }
+}
+
+public class AddEquipInfoReq : EquipInfo
+{
+}
+
+public class UpdateEquipInfoReq : AddEquipInfoReq
+{
+}
+
+public class DeleteEquipInfoReq : BaseIdReq
+{
+}
\ No newline at end of file
diff --git a/Entity/Dto/Resp/BinInfoResp.cs b/Entity/Dto/Resp/BinInfoResp.cs
index 8c8318e..a290780 100644
--- a/Entity/Dto/Resp/BinInfoResp.cs
+++ b/Entity/Dto/Resp/BinInfoResp.cs
@@ -160,31 +160,103 @@ public partial class BinInfoResp
///
public DateTime? UpdatedTime { get; set; }
+
///
- /// 功率
+ /// Desc:功率
+ /// Default:
+ /// Nullable:9.9
///
-
public float power { get; set; }
+
///
- /// 缓存仓标记 0:不是 1:是
+ /// Desc:缓存仓标记 0:不是 1:是
+ /// Default:
+ /// Nullable:0
///
public int CacheBinFlag { get; set; }
///
- /// 换电禁用标志 0:不可换电 1:可以换电
+ /// Desc:换电禁用标志 0:不可换电 1:可以换电
+ /// Default:
+ /// Nullable:0
///
public int CanSwapFlag { get; set; }
-
+
///
- /// 充电禁用标志 0:不可充电 1:可以充电
+ /// Desc:充电禁用标志 0:不可充电 1:可以充电
+ /// Default:
+ /// Nullable:0
///
public int CanChargeFlag { get; set; }
-
+
+
///
- /// 充电机是否连接
+ /// Desc:充电机是否连接
+ /// Default:
+ /// Nullable:0
///
public bool ChargeConnectFlag { get; set; }
+ ///
+ /// Desc:本次充电时间
+ /// Default:
+ /// Nullable:0
+ ///
+ public ushort ChargingTime { get; set; }
+ ///
+ /// Desc:估算剩余充电时间
+ /// Default:
+ /// Nullable:0
+ ///
+ public ushort EstimatedRemainingTime { get; set; }
+ ///
+ /// Desc:单次充电电量
+ /// Default:
+ /// Nullable:0
+ ///
+ public float OnceElectricCharge { get; set; }
+ ///
+ /// BMS 需求电压
+ /// Default:
+ /// Nullable:0
+ ///
+ public float BmsNeedVoltage { get; set; }
+ ///
+ /// BMS 需求电流
+ /// Default:
+ /// Nullable:0
+ ///
+ public float BmsNeedCurrent { get; set; }
+ ///
+ /// 电池包总电流,充电为负值,放电为正
+ /// Default:
+ /// Nullable:0
+ ///
+ public float TotalCurrent { get; set; }
+ ///
+ /// 电芯温度最大值
+ /// Default:
+ /// Nullable:0
+ ///
+ public Int16 CellTemperatureMax { get; set; }
+ ///
+ /// 电芯温度最小值
+ /// Default:
+ /// Nullable:0
+ ///
+ public Int16 CellTemperatureMin { get; set; }
+ ///
+ /// 充电开始时间
+ /// Default:
+ /// Nullable:
+ ///
+ public DateTime? ChargingStartTime { get; set; }
+ ///
+ /// 充电结束时间
+ /// Default:
+ /// Nullable:
+ ///
+ public DateTime? ChargingStopTime { get; set; }
}
\ No newline at end of file
diff --git a/Repository/Station/EquipInfoRepository.cs b/Repository/Station/EquipInfoRepository.cs
index d6583ff..d37390e 100644
--- a/Repository/Station/EquipInfoRepository.cs
+++ b/Repository/Station/EquipInfoRepository.cs
@@ -1,4 +1,6 @@
+using System.Linq.Expressions;
using Entity.DbModel.Station;
+using Entity.Dto.Req;
using HybirdFrameworkCore.Autofac.Attribute;
using SqlSugar;
@@ -6,7 +8,28 @@ namespace Repository.Station;
[Scope("SingleInstance")]
public class EquipInfoRepository: BaseRepository
{
+ private ISqlSugarClient DbBaseClient;
+
public EquipInfoRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
+ DbBaseClient = sqlSugar;
+ }
+
+ public async Task> EquipInfoQueryPageAsync(
+ bool isWhere1, Expression> expression1,
+ bool isWhere2, Expression> expression2,
+ bool isWhere3, Expression> expression3,
+ int pageNumber, int pageSize, RefAsync totalNumber,
+ PageEquipInfoReq input, bool blUseNoLock = false)
+ {
+ var page = await DbBaseClient
+ .Queryable()
+ .WhereIF(isWhere1, expression1)
+ .WhereIF(isWhere2, expression2)
+ .WhereIF(isWhere3, expression3)
+ .OrderBuilder(input)
+ .WithNoLockOrNot(blUseNoLock)
+ .ToPageListAsync(pageNumber, pageSize, totalNumber);
+ return page;
}
}
\ No newline at end of file
diff --git a/Service/Station/BinInfoService.cs b/Service/Station/BinInfoService.cs
new file mode 100644
index 0000000..e13164f
--- /dev/null
+++ b/Service/Station/BinInfoService.cs
@@ -0,0 +1,68 @@
+using AutoMapper;
+using Entity.DbModel.Station;
+using Entity.Dto.Resp;
+using HybirdFrameworkCore.Autofac.Attribute;
+using HybirdFrameworkCore.Entity;
+using Repository.Station;
+using Service.Charger.Client;
+
+namespace Service.Station;
+
+[Scope("SingleInstance")]
+public class BinInfoService : BaseServices
+{
+ private readonly BinInfoRepository _binInfoRepository;
+
+ public BinInfoService(BinInfoRepository binInfoRepository)
+ {
+ _binInfoRepository = binInfoRepository;
+ }
+ ///
+ /// 获取仓位数据
+ ///
+ /// 仓位数据列表
+ public List GetChargMonitorChargBinData()
+ {
+ 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.ChargerNo);
+ if (chargerClient != null)
+ {
+ binInfoResp.power = chargerClient.RealTimeChargePower;
+ binInfoResp.ChargeConnectFlag = chargerClient.Connected;
+ binInfoResp.ChargingTime = chargerClient.UploadTelemetryData.ChargingTime;
+ binInfoResp.EstimatedRemainingTime = chargerClient.UploadTelemetryData.EstimatedRemainingTime;
+ if (chargerClient.BatteryPackTotalElectricity != null)
+ binInfoResp.OnceElectricCharge = chargerClient.BatteryPackTotalElectricity.OnceElectricCharge;
+ binInfoResp.BmsNeedVoltage = chargerClient.UploadTelemetryData.BmsNeedVoltage;
+ binInfoResp.BmsNeedCurrent = chargerClient.UploadTelemetryData.BmsNeedCurrent;
+ if (chargerClient.BatteryPackData != null)
+ binInfoResp.TotalCurrent = chargerClient.BatteryPackData.TotalCurrent;
+ if (chargerClient.BatteryPackDataVoltage != null)
+ binInfoResp.CellTemperatureMax = chargerClient.BatteryPackDataVoltage.CellTemperatureMax;
+ if (chargerClient.BatteryPackDataVoltage != null)
+ binInfoResp.CellTemperatureMin = chargerClient.BatteryPackDataVoltage.CellTemperatureMin;
+ binInfoResp.ChargingStartTime = chargerClient.ChargingStartTime;
+ binInfoResp.ChargingStopTime = chargerClient.ChargingStopTime;
+ }
+ }
+
+ return binInfoList;
+ }
+ ///
+ /// 禁用仓位
+ ///
+ ///
+ /// 修改结果
+ public bool UpdateStatus(int id)
+ {
+ return _binInfoRepository.UpdateStatus(id);
+ }
+}
\ No newline at end of file
diff --git a/Service/Station/EquipInfoService.cs b/Service/Station/EquipInfoService.cs
new file mode 100644
index 0000000..402cbce
--- /dev/null
+++ b/Service/Station/EquipInfoService.cs
@@ -0,0 +1,79 @@
+using System.ComponentModel;
+using Entity.Base;
+using Entity.DbModel.Station;
+using Entity.Dto.Req;
+using HybirdFrameworkCore.Autofac.Attribute;
+using HybirdFrameworkCore.Entity;
+using Mapster;
+using Repository.Station;
+using SqlSugar;
+
+namespace Service.Station;
+
+[Scope("SingleInstance")]
+public class EquipInfoService : BaseServices
+{
+ private readonly EquipInfoRepository _equipInfoRepository;
+
+ public EquipInfoService(EquipInfoRepository equipInfoRepository)
+ {
+ _equipInfoRepository = equipInfoRepository;
+ }
+
+ ///
+ /// 获取分页列表 🔖
+ ///
+ /// 查询参数
+ /// 分页列表
+ public async Task> Page(PageEquipInfoReq input)
+ {
+ RefAsync total = 0;
+ var items = await _equipInfoRepository.EquipInfoQueryPageAsync(
+ !string.IsNullOrEmpty(input.Name), u => u.Name.Contains(input.Name),
+ !string.IsNullOrEmpty(input.Code), u => u.Code.Contains(input.Code),
+ input.Status != null, (u => input.Status != null && u.Status.Equals(input.Status.Value)),
+ input.Page, input.PageSize, total, input);
+ return SqlSugarPagedExtensions.CreateSqlSugarPagedList(items, total, input.Page, input.PageSize);
+ }
+
+ ///
+ /// 修改充电模式配置 🔖
+ ///
+ /// 修改参数
+ /// 修改结果
+ [DisplayName("更新充电模式配置")]
+ public async Task> UpdateEquipInfoReq(UpdateEquipInfoReq input)
+ {
+ var isExist = await _equipInfoRepository.QueryByClauseAsync
+ (u => (u.Name == input.Name || u.Code == input.Code) && u.Id != input.Id);
+ if (isExist != null)
+ {
+ return Result