diff --git a/Repository/Station/BinInfoRepository.cs b/Repository/Station/BinInfoRepository.cs index 214f21a..ed051b1 100644 --- a/Repository/Station/BinInfoRepository.cs +++ b/Repository/Station/BinInfoRepository.cs @@ -10,7 +10,20 @@ public class BinInfoRepository : BaseRepository public BinInfoRepository(ISqlSugarClient sqlSugar) : base(sqlSugar) { } - + /// + /// 禁用仓位 + /// + /// + /// 修改结果 + public bool UpdateStatus(int id) + { + return DbBaseClient + .Updateable() + .SetColumns(bin => new BinInfo { Status = 0 }) + .Where(bin => bin.Id == id) + .ExecuteCommandHasChange(); + } + /// /// /// diff --git a/Service/Charger/Client/ClientMgr.cs b/Service/Charger/Client/ClientMgr.cs index b01e218..29b567f 100644 --- a/Service/Charger/Client/ClientMgr.cs +++ b/Service/Charger/Client/ClientMgr.cs @@ -22,7 +22,7 @@ public static class ClientMgr private static readonly ILog Log = LogManager.GetLogger(typeof(ClientMgr)); - private static readonly Dictionary Dictionary = new(); + public static readonly Dictionary Dictionary = new(); private static bool AutoChargeWorking { get; set; } diff --git a/WebStarter/Controllers/ChargeController.cs b/WebStarter/Controllers/ChargeController.cs index feffa61..4e5e5a2 100644 --- a/WebStarter/Controllers/ChargeController.cs +++ b/WebStarter/Controllers/ChargeController.cs @@ -1,6 +1,10 @@ -using HybirdFrameworkCore.Entity; +using Entity.DbModel.Station; +using HybirdFrameworkCore.Entity; using Microsoft.AspNetCore.Mvc; +using Repository.Station; using Service.Charger; +using Service.Charger.Client; +using Service.Charger.Msg.Charger.Req; namespace WebStarter.Controllers; @@ -9,23 +13,63 @@ namespace WebStarter.Controllers; /// [Produces("application/json")] [ApiController] -[Route("/api[controller]")] +[Route("/api/[controller]")] public class ChargeController : ControllerBase { private ChargerService _chargerService; + private BinInfoRepository _binInfoRepository; - public ChargeController(ChargerService chargerService) + public ChargeController(ChargerService chargerService,BinInfoRepository binInfoRepository) { _chargerService = chargerService; + _binInfoRepository = binInfoRepository; } - + + + /// + /// 仓位信息 + /// + /// 仓位信息列表 + [HttpGet] + [Route("/api/ChrgMonitor/GetChargMonitorChargBinData")] + public Result> GetChargMonitorChargBinData() + { + return Result>.Success(_binInfoRepository.Query()); + } + + /// + /// 仓位禁用 + /// + /// 需要禁用仓id + /// 仓位信息列表 + [HttpGet] + [Route("/api/TBsChargingBinInfo/ChargingBinDisable{data}")] + public Result ChargingBinDisable(int data) + { + return Result.Success(_binInfoRepository.UpdateStatus(data)); + } + + /// + /// 获取仓位实时功率 + /// + /// 仓位实时功率列表 + [HttpPost] + [Route("/api/ChrgMonitor/GetBinPowers")] + public Result GetBinPowers() + { + float[] results = ClientMgr.Dictionary.Values + .Select(chargerClient => chargerClient.RealTimeChargePower) + .ToArray(); + return Result.Success(results); + } + /// /// 通过仓号启动充电 /// /// 仓号 /// [HttpGet] - [Route("/StartChargeByBinNo/{binNo}")] + [Route("/api/ChrgMonitor/StartChargeByBinNo/{binNo}")] public Result StartChargeByBinNo(string binNo) { return _chargerService.StartChargeByBinNo(binNo); @@ -37,7 +81,7 @@ public class ChargeController : ControllerBase /// 仓号 /// [HttpGet] - [Route("/StopChargeByBinNo/{binNo}")] + [Route("/api/ChrgMonitor/StopChargeByBinNo/{binNo}")] public Result StopChargeByBinNo(string binNo) { return _chargerService.StartChargeByBinNo(binNo);