You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.7 KiB

using Entity.DbModel.Station;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Repository.Station;
namespace WebStarter.Controllers;
/// <summary>
/// 换电大屏
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class BinInfoController : ControllerBase
{
private readonly BinInfoRepository _BinInfoRepository;
6 months ago
private readonly EquipInfoRepository _equipInfoRepository;
public BinInfoController(BinInfoRepository infoRepository,EquipInfoRepository equipInfoRepository)
{
_BinInfoRepository = infoRepository;
_equipInfoRepository = equipInfoRepository;
}
/// <summary>
/// 启用禁用充电
/// id:仓位id
/// flag 1启用 0:禁用
/// </summary>
/// <param name="removeBinNo"></param>
/// <param name="putBinNo"></param>
/// <returns></returns>
[HttpGet("UpdateCanChargeFlag/{id}/{flag}")]
6 months ago
public Result<bool> UpdateCanChargeFlag(int id, int flag)
{
6 months ago
_BinInfoRepository.Update(it => it.CanChargeFlag == flag, it => it.Id == id);
return Result<bool>.Success();
}
6 months ago
[HttpGet("insert")]
6 months ago
public Result<bool> insert()
{
_BinInfoRepository.Insert(new BinInfo()
{
No = "10"
});
6 months ago
BinInfo queryByClause = _BinInfoRepository.QueryByClause(i => i.Id == 16);
return Result<bool>.Success();
}
6 months ago
/// <summary>
/// 启用禁用换电
/// id:仓位id
/// flag 1启用 0:禁用
/// </summary>
/// <param name="removeBinNo"></param>
/// <param name="putBinNo"></param>
/// <returns></returns>
[HttpGet("UpdateCanSwapFlag/{id}/{flag}")]
public async Task<Result<bool>> UpdateCanSwapFlag(int id, int flag)
{
6 months ago
_BinInfoRepository.Update(it => it.CanSwapFlag == flag, it => it.Id == id);
return Result<bool>.Success();
}
6 months ago
/// <summary>
/// 获取仓位充电功率
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
[HttpGet("ChargePower/{code}")]
public Result<float> ChargePower(string code)
{
BinInfo binInfo = _BinInfoRepository.QueryByClause(it => it.No == code);
if (binInfo == null)
{
return Result<float>.Fail("仓位不存在");
}
EquipInfo equipInfo = _equipInfoRepository.QueryByClause(i => i.Code == binInfo.ChargerNo);
if (equipInfo == null)
{
return Result<float>.Fail("充电机不存在");
}
float? chargePower = equipInfo.ChargePower;
if (chargePower == null)
{
return Result<float>.Fail("该仓没有充电功率");
}
return Result<float>.Success((float)chargePower);
}
}