|
|
|
|
using COSXML.Utils;
|
|
|
|
|
using DotNetty.Common.Utilities;
|
|
|
|
|
using Entity.Api.Req;
|
|
|
|
|
using Entity.Api.Resp;
|
|
|
|
|
using Entity.Constant;
|
|
|
|
|
using HybirdFrameworkCore.Entity;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Localization;
|
|
|
|
|
using Service.Execute;
|
|
|
|
|
using Service.Execute.Api;
|
|
|
|
|
using Service.Execute.Model;
|
|
|
|
|
using Service.Execute.Model.Tbox;
|
|
|
|
|
using Service.Init;
|
|
|
|
|
using Service.Station;
|
|
|
|
|
|
|
|
|
|
namespace WebStarter.Controllers;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换电大屏
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiController]
|
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
|
public class SwapMonitorController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
private readonly MonitorService _swapMonitorService;
|
|
|
|
|
private readonly BinInfoService _binInfoService;
|
|
|
|
|
private readonly IStringLocalizer<SwapMonitorController> _localizer;
|
|
|
|
|
|
|
|
|
|
public SwapMonitorController(MonitorService swapMonitorService, BinInfoService binInfoService)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
_swapMonitorService = swapMonitorService;
|
|
|
|
|
_binInfoService = binInfoService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取设备连接状态 目前 Tbox 云平台 plc
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("GetDeviceState")]
|
|
|
|
|
public Result<DeviceStateResp> GetDeviceState()
|
|
|
|
|
{
|
|
|
|
|
return _swapMonitorService.GetDeviceState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 首页换电状态信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("GetSwapMonitorData")]
|
|
|
|
|
public async Task<Result<SwapMonitorScreenResp>> GetSwapMonitorData()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var respList = _swapMonitorService.GetSwapMonitorData();
|
|
|
|
|
|
|
|
|
|
return respList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 手动写入车辆vin码
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("WriteVin")]
|
|
|
|
|
public Result<bool> WriteVin([FromBody] RfidReadModel req)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (StaticStationInfo.VehicleManually != 1)
|
|
|
|
|
{
|
|
|
|
|
return Result<bool>.Fail("此模式不支持手动写车辆数据,请先切换换电执行模式");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StationSoftMgr.SwappingStateMachine.BeginRfidReadFlag || StationSoftMgr.SwappingStateMachine.RfidReadFlag)
|
|
|
|
|
{
|
|
|
|
|
return Result<bool>.Fail("目前换电进行中,请勿修改数据");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StationSoftMgr.SwappingStateMachine.BeginRfidReadFlag = true;
|
|
|
|
|
StationSoftMgr.SwappingStateMachine.RfidReadModel = req;
|
|
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取模式类
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("GetModel")]
|
|
|
|
|
public async Task<Result<SwapModelResp>> GetModel()
|
|
|
|
|
{
|
|
|
|
|
return _swapMonitorService.GetModel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 车辆手动上锁解锁
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("LockCar")]
|
|
|
|
|
public async Task<Result<bool>> LockCar(string carNo)
|
|
|
|
|
{
|
|
|
|
|
var success = await TBoxApi.LockCarManyTimes(carNo);
|
|
|
|
|
return success ? Result<bool>.Success() : Result<bool>.Fail();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 车辆手动解锁
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("UnLockCar")]
|
|
|
|
|
public async Task<Result<bool>> UnLockCar(string carNo)
|
|
|
|
|
{
|
|
|
|
|
var success = await TBoxApi.UnLockCarManyTimes(carNo);
|
|
|
|
|
return success ? Result<bool>.Success() : Result<bool>.Fail();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取充电监控大屏 充电次数 每五分钟获取一次
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpPost("GetSwapAndChargingCount")]
|
|
|
|
|
public async Task<Result<SwapAndChargingCountResp>> SwapAndChargingCount()
|
|
|
|
|
{
|
|
|
|
|
return _swapMonitorService.SwapAndChargingCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设置换电模式:1:本地换电 2:远程换电
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpPost("SetSwapModel/{swapModel}")]
|
|
|
|
|
public async Task<Result<bool>> SetSwapModel(int swapModel)
|
|
|
|
|
{
|
|
|
|
|
StaticStationInfo.StationModel = swapModel;
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换电复位
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpPost("SwapReset")]
|
|
|
|
|
public async Task<Result<bool>> SwapReset()
|
|
|
|
|
{
|
|
|
|
|
StationSoftMgr.SwappingStateMachineCancel();
|
|
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 人工操作换电成功标识
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("SwapPlcSucc")]
|
|
|
|
|
public Result<bool> SwapPlcSucc()
|
|
|
|
|
{
|
|
|
|
|
return Result<bool>.Success(StationSoftMgr.SwappingStateMachine.PlcSwapFlag);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 人工操作换电成功还是失败
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("ManualOperateSwap")]
|
|
|
|
|
public Result<bool> ManualOperateSwap([FromBody] OperateModelReq req)
|
|
|
|
|
{
|
|
|
|
|
StationSoftMgr.SwappingStateMachine.OperateModel = new OperateModel()
|
|
|
|
|
{
|
|
|
|
|
Type = req.Type,
|
|
|
|
|
Operator = req.Operator,
|
|
|
|
|
Reason = req.Reason
|
|
|
|
|
};
|
|
|
|
|
if (req.Type == 1)
|
|
|
|
|
{
|
|
|
|
|
if (!StationSoftMgr.SwappingStateMachine.PlcSwapFlag)
|
|
|
|
|
{
|
|
|
|
|
return Result<bool>.Fail("不满足确认换电成功条件");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Task.Run(StationSoftMgr.SwappingStateMachineManual);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Task.Run(StationSoftMgr.SwappingStateMachineCancel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 消防移仓
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="entrySelect">入仓位选择:移仓仓位号</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("FireProtectionRelocation/{entrySelect}")]
|
|
|
|
|
public Result<bool> FireProtectionRelocation(string entrySelect)
|
|
|
|
|
{
|
|
|
|
|
return _binInfoService.FireProtectionRelocation(entrySelect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 切换成 手动换电
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpPost("ManualSwapping")]
|
|
|
|
|
public Result<bool> ManualSwapping()
|
|
|
|
|
{
|
|
|
|
|
StaticStationInfo.StationWay = (int)StationConstant.StationWay.Manual;
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 切换成 自动换电
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpPost("AutoSwapping")]
|
|
|
|
|
public Result<bool> AutoSwapping()
|
|
|
|
|
{
|
|
|
|
|
StaticStationInfo.StationWay = (int)StationConstant.StationWay.Auto;
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 切换成 营业状态
|
|
|
|
|
/// 换电站状态: 1:营运中 2:歇业中 3:设备维护状态 4:暂停营业
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpPost("HandoverStationStatus/{status}")]
|
|
|
|
|
public Result<bool> HandoverStationStatus(int status)
|
|
|
|
|
{
|
|
|
|
|
StaticStationInfo.StationStatus = status;
|
|
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取所有连接车辆
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpGet("GetCarList")]
|
|
|
|
|
public async Task<Result<List<TboxCarInfoModel>>> GetCarList()
|
|
|
|
|
{
|
|
|
|
|
//兼容不能查车辆列表的,就获取当前换电车辆
|
|
|
|
|
if (!StaticStationInfo.TboxStateCarList)
|
|
|
|
|
{
|
|
|
|
|
if (StationSoftMgr.SwappingStateMachine.BoxCarInfoModel == null)
|
|
|
|
|
{
|
|
|
|
|
return Result<List<TboxCarInfoModel>>.Success(new List<TboxCarInfoModel>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Result<List<TboxCarInfoModel>>.Success(new()
|
|
|
|
|
{
|
|
|
|
|
StationSoftMgr.SwappingStateMachine.BoxCarInfoModel
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var carInfoList = await TBoxApi.GetCarInfoList();
|
|
|
|
|
if (carInfoList == null || carInfoList.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|
return Result<List<TboxCarInfoModel>>.Success(new List<TboxCarInfoModel>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Result<List<TboxCarInfoModel>>.Success(carInfoList.Where(i => i.CarNo.Length >= 17).ToList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 确认上锁成功
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpGet("ConfirmLockSucc")]
|
|
|
|
|
public async Task<Result<bool>> ConfirmLockSucc()
|
|
|
|
|
{
|
|
|
|
|
StationSoftMgr.SwappingStateMachine.ManualConfirmLockCar();
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 确认解锁成功
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpGet("ConfirmUnLockSucc")]
|
|
|
|
|
public async Task<Result<bool>> ConfirmUnLockSucc()
|
|
|
|
|
{
|
|
|
|
|
StationSoftMgr.SwappingStateMachine.ManualConfirmUnLockCar();
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
|
}
|
|
|
|
|
}
|