电池仓部分接口

master
tq 6 months ago
parent c2ebbeb006
commit aadf4317dc

@ -10,6 +10,19 @@ public class BinInfoRepository : BaseRepository<BinInfo>
public BinInfoRepository(ISqlSugarClient sqlSugar) : base(sqlSugar) public BinInfoRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{ {
} }
/// <summary>
/// 禁用仓位
/// </summary>
/// <param name="id"></param>
/// <returns>修改结果</returns>
public bool UpdateStatus(int id)
{
return DbBaseClient
.Updateable<BinInfo>()
.SetColumns(bin => new BinInfo { Status = 0 })
.Where(bin => bin.Id == id)
.ExecuteCommandHasChange();
}
/// <summary> /// <summary>
/// ///

@ -22,7 +22,7 @@ public static class ClientMgr
private static readonly ILog Log = LogManager.GetLogger(typeof(ClientMgr)); private static readonly ILog Log = LogManager.GetLogger(typeof(ClientMgr));
private static readonly Dictionary<string, ChargerClient> Dictionary = new(); public static readonly Dictionary<string, ChargerClient> Dictionary = new();
private static bool AutoChargeWorking { get; set; } private static bool AutoChargeWorking { get; set; }

@ -1,6 +1,10 @@
using HybirdFrameworkCore.Entity; using Entity.DbModel.Station;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Repository.Station;
using Service.Charger; using Service.Charger;
using Service.Charger.Client;
using Service.Charger.Msg.Charger.Req;
namespace WebStarter.Controllers; namespace WebStarter.Controllers;
@ -9,14 +13,54 @@ namespace WebStarter.Controllers;
/// </summary> /// </summary>
[Produces("application/json")] [Produces("application/json")]
[ApiController] [ApiController]
[Route("/api[controller]")] [Route("/api/[controller]")]
public class ChargeController : ControllerBase public class ChargeController : ControllerBase
{ {
private ChargerService _chargerService; private ChargerService _chargerService;
private BinInfoRepository _binInfoRepository;
public ChargeController(ChargerService chargerService) public ChargeController(ChargerService chargerService,BinInfoRepository binInfoRepository)
{ {
_chargerService = chargerService; _chargerService = chargerService;
_binInfoRepository = binInfoRepository;
}
/// <summary>
/// 仓位信息
/// </summary>
/// <returns>仓位信息列表</returns>
[HttpGet]
[Route("/api/ChrgMonitor/GetChargMonitorChargBinData")]
public Result<List<BinInfo>> GetChargMonitorChargBinData()
{
return Result<List<BinInfo>>.Success(_binInfoRepository.Query());
}
/// <summary>
/// 仓位禁用
/// </summary>
/// <param name="data">需要禁用仓id</param>
/// <returns>仓位信息列表</returns>
[HttpGet]
[Route("/api/TBsChargingBinInfo/ChargingBinDisable{data}")]
public Result<bool> ChargingBinDisable(int data)
{
return Result<bool>.Success(_binInfoRepository.UpdateStatus(data));
}
/// <summary>
/// 获取仓位实时功率
/// </summary>
/// <returns>仓位实时功率列表</returns>
[HttpPost]
[Route("/api/ChrgMonitor/GetBinPowers")]
public Result<float[]> GetBinPowers()
{
float[] results = ClientMgr.Dictionary.Values
.Select(chargerClient => chargerClient.RealTimeChargePower)
.ToArray();
return Result<float[]>.Success(results);
} }
/// <summary> /// <summary>
@ -25,7 +69,7 @@ public class ChargeController : ControllerBase
/// <param name="binNo">仓号</param> /// <param name="binNo">仓号</param>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
[Route("/StartChargeByBinNo/{binNo}")] [Route("/api/ChrgMonitor/StartChargeByBinNo/{binNo}")]
public Result<bool> StartChargeByBinNo(string binNo) public Result<bool> StartChargeByBinNo(string binNo)
{ {
return _chargerService.StartChargeByBinNo(binNo); return _chargerService.StartChargeByBinNo(binNo);
@ -37,7 +81,7 @@ public class ChargeController : ControllerBase
/// <param name="binNo">仓号</param> /// <param name="binNo">仓号</param>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
[Route("/StopChargeByBinNo/{binNo}")] [Route("/api/ChrgMonitor/StopChargeByBinNo/{binNo}")]
public Result<bool> StopChargeByBinNo(string binNo) public Result<bool> StopChargeByBinNo(string binNo)
{ {
return _chargerService.StartChargeByBinNo(binNo); return _chargerService.StartChargeByBinNo(binNo);

Loading…
Cancel
Save