|
|
|
|
using Autofac;
|
|
|
|
|
using Entity.Api.Req;
|
|
|
|
|
using Entity.Api.Resp;
|
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
|
using HybirdFrameworkCore.Autofac;
|
|
|
|
|
using HybirdFrameworkCore.Entity;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Localization;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Service.Charger.Msg.Host.Req;
|
|
|
|
|
using Service.Charger.Server;
|
|
|
|
|
using Service.Execute.Api;
|
|
|
|
|
using Service.RealTime;
|
|
|
|
|
using Service.Sound.SoundClient;
|
|
|
|
|
using Service.Station;
|
|
|
|
|
|
|
|
|
|
namespace WebStarter.Controllers;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 充电大屏
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiController]
|
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
|
public class ChargeMonitorController
|
|
|
|
|
{
|
|
|
|
|
private readonly BinInfoService _binInfoService;
|
|
|
|
|
private readonly MonitorService _monitorService;
|
|
|
|
|
private readonly IStringLocalizer<ChargeMonitorController> _localizer;
|
|
|
|
|
|
|
|
|
|
public ChargeMonitorController(IStringLocalizer<ChargeMonitorController> localizer, BinInfoService binInfoService,
|
|
|
|
|
MonitorService monitorService)
|
|
|
|
|
{
|
|
|
|
|
_localizer = localizer;
|
|
|
|
|
|
|
|
|
|
_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)
|
|
|
|
|
{
|
|
|
|
|
PageResult<BinInfo> respList = await _binInfoService.ChargePositionQuery(chargePositionQueryReq);
|
|
|
|
|
if (respList.Rows != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var resp in respList.Rows)
|
|
|
|
|
{
|
|
|
|
|
resp.Name = _localizer[resp.Name];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Result<PageResult<BinInfo>>.Success(respList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <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>
|
|
|
|
|
/// <param name="removeBinNo">取仓号</param>
|
|
|
|
|
/// <param name="putBinNo">放仓号</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("Relocation")]
|
|
|
|
|
public async Task<Result<bool>> Relocation(ushort removeBinNo, ushort putBinNo)
|
|
|
|
|
{
|
|
|
|
|
return _monitorService.Relocation(removeBinNo, putBinNo, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*/// <summary>
|
|
|
|
|
/// 维修仓-车辆
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="removeBinNo">取仓号</param>
|
|
|
|
|
/// <param name="putBinNo">放仓号</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("MaintenanceVehicle")]
|
|
|
|
|
public async Task<Result<bool>> MaintenanceVehicle(ushort removeBinNo, ushort putBinNo)
|
|
|
|
|
{
|
|
|
|
|
return _monitorService.Maintenance(removeBinNo, putBinNo, 2);
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 移仓时下拉项 仓位电池状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpGet("GetChargeBinOption")]
|
|
|
|
|
public Result<List<BinInfoResp>> GetChargeBinOption()
|
|
|
|
|
{
|
|
|
|
|
Result<List<BinInfoResp>> respList = _monitorService.GetChargeBinOption();
|
|
|
|
|
if (respList.Data != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var resp in respList.Data)
|
|
|
|
|
{
|
|
|
|
|
resp.Name = _localizer[resp.Name];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return respList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 增加维修仓 车辆仓
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpGet("GetMaintenanceBinNo")]
|
|
|
|
|
public Result<List<BinInfoResp>> GetMaintenanceBinNo()
|
|
|
|
|
{
|
|
|
|
|
Result<List<BinInfoResp>> respList = _monitorService.GetChargeBinOption();
|
|
|
|
|
BinInfoResp weiXiu = new BinInfoResp()
|
|
|
|
|
{
|
|
|
|
|
No = "9",
|
|
|
|
|
Name = "维修仓",
|
|
|
|
|
Id = 777,
|
|
|
|
|
};
|
|
|
|
|
BinInfoResp vehicle = new BinInfoResp()
|
|
|
|
|
{
|
|
|
|
|
No = "10",
|
|
|
|
|
Name = "车辆",
|
|
|
|
|
Id = 888,
|
|
|
|
|
};
|
|
|
|
|
BinInfoResp self = new BinInfoResp()
|
|
|
|
|
{
|
|
|
|
|
No = "0",
|
|
|
|
|
Name = "主体",
|
|
|
|
|
Id = 999,
|
|
|
|
|
};
|
|
|
|
|
respList.Data.Add(weiXiu);
|
|
|
|
|
respList.Data.Add(vehicle);
|
|
|
|
|
respList.Data.Add(self);
|
|
|
|
|
if (respList.Data != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var resp in respList.Data)
|
|
|
|
|
{
|
|
|
|
|
resp.Name = _localizer[resp.Name];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return respList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 消防出仓
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpGet("FireRemoval")]
|
|
|
|
|
public Result<bool> FireRemoval(int level, string levelStr, string binNo)
|
|
|
|
|
{
|
|
|
|
|
HubHolder.S2CMsg(JsonConvert.SerializeObject(new RtMsg
|
|
|
|
|
{
|
|
|
|
|
Cmd = "BatteryAlarm",
|
|
|
|
|
Msg = $"电池过温报警,等级:{levelStr},仓位号:{binNo},请人工检查电池是否异常"
|
|
|
|
|
})).Wait();
|
|
|
|
|
|
|
|
|
|
if (level != 3)
|
|
|
|
|
{
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//报警提示
|
|
|
|
|
var soundClient = AppInfo.Container.Resolve<SoundClient>();
|
|
|
|
|
|
|
|
|
|
//TODO:: 录入播报素材
|
|
|
|
|
soundClient.SoundPlay(SoundEnum.music110);
|
|
|
|
|
Thread.Sleep(4000);
|
|
|
|
|
soundClient.SoundPlay(SoundEnum.music111);
|
|
|
|
|
//判断是否在换电中 通道是否有车
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
|
}
|
|
|
|
|
}
|