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.

133 lines
4.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Entity.Api.Req;
using Entity.Api.Resp;
using Entity.Base;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Entity;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.VisualBasic;
using Service.Plc.Client;
using Service.Station;
using Service.System;
namespace WebStarter.Controllers;
/// <summary>
/// 充电大屏
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class ChargeMonitorController
{
private readonly BinInfoService _binInfoService;
private readonly MonitorService _monitorService;
public ChargeMonitorController(BinInfoService binInfoService, MonitorService monitorService)
{
_binInfoService = binInfoService;
_monitorService = monitorService;
}
/// <summary>
/// 仓位预约
/// </summary>
/// <param name="binNo">仓位</param>
/// <param name="amtLock"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
[HttpPost("BinInfoMakeAnAppointment/{binNo}/{amtLock}")]
public async Task<Result<bool>> BinInfoMakeAnAppointment(string binNo,int amtLock)
{
BinInfo binInfo = await _binInfoService.QueryByClauseAsync(u => u.No == binNo);
if (binInfo == null)
throw new Exception("充电仓不存在");
binInfo.AmtLock = amtLock;
bool result = await _binInfoService.UpdateAsync(binInfo);
if (result)
return Result<bool>.Success(result);
else
return Result<bool>.Fail(result);
}
/// <summary>
/// 修改仓位电池编码
/// </summary>
/// <param name="binNo"></param>
/// <param name="batteryNo"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
[HttpPost("UpdateBatteryNo/{binNo}/{batteryNo}")]
public async Task<Result<bool>> UpdateBatteryNo(string binNo, string batteryNo)
{
BinInfo binInfo = await _binInfoService.QueryByClauseAsync(u => u.No == binNo);
if (binInfo == null)
throw new Exception("充电仓不存在");
BinInfo binInfoBatteryNo = await _binInfoService.QueryByClauseAsync(u => u.BatteryNo == batteryNo);
if (binInfoBatteryNo != null)
{
throw new Exception("已存在相同电池编码");
}
binInfo.BatteryNo = batteryNo;
bool result = await _binInfoService.UpdateAsync(binInfo);
if (result)
return Result<bool>.Success(result);
else
return Result<bool>.Fail(result);
}
/// <summary>
/// 充电仓查询:条件:仓位编号 仓位名称
/// </summary>
[HttpPost("ChargePositionQuery")]
public async Task<Result<PageResult<BinInfo>>> ChargePositionQuery(
[FromBody] ChargePositionQueryReq chargePositionQueryReq)
{
return Result<PageResult<BinInfo>>.Success( await _binInfoService.ChargePositionQuery(chargePositionQueryReq));
}
/// <summary>
/// 充电仓 0禁用 1启用
/// </summary>
/// <param name="binNo">仓位编号</param>
/// <param name="status">仓位状态0-禁用、1-启用</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
[HttpPost("SetChargingBinStatus/{binNo}/{status}")]
public async Task<Result<bool>> ChargingBinDisable(string binNo, int status)
{
BinInfo binInfo = await _binInfoService.QueryByClauseAsync(u => u.No == binNo);
if (binInfo == null)
throw new Exception("充电仓不存在");
binInfo.Status = status;
bool result = await _binInfoService.UpdateAsync(binInfo);
if (result)
return Result<bool>.Success(result);
else
return Result<bool>.Fail(result);
}
/// <summary>
/// 电池移仓
/// </summary>
/// <param name="removeBinNo">取仓号</param>
/// <param name="putBinNo">放仓号</param>
/// <returns></returns>
[HttpGet("BatteryRelocation")]
public async Task<Result<bool>> BatteryRelocation(ushort removeBinNo, ushort putBinNo)
{
return _monitorService.BatteryRelocation(removeBinNo, putBinNo);
}
/// <summary>
/// 移仓时下拉项 仓位电池状态
/// </summary>
[HttpGet("GetChargeBinOption")]
public Result<List<BinInfoResp>> GetChargeBinOption()
{
return _monitorService.GetChargeBinOption();
}
}