87 lines
2.5 KiB
C#
87 lines
2.5 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Dlhis.Basic.Device.Dtos;
|
|
using Dlhis.Basic.Device.Request;
|
|
using Dlhis.Basic.Device.Services;
|
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
|
using Kurisu.AspNetCore.UnifyResultAndValidation.Aop;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Dlhis.Basic.Device.Controllers;
|
|
|
|
/// <summary>
|
|
/// 设备连接控制器
|
|
/// </summary>
|
|
[Authorize]
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class DevicesConnectController : ControllerBase
|
|
{
|
|
private readonly IDeviceConnectService _deviceConnectService;
|
|
|
|
public DevicesConnectController(IDeviceConnectService deviceConnectService)
|
|
{
|
|
_deviceConnectService = deviceConnectService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设备心跳
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[DisableApiLog]
|
|
[HttpPost("heartbeat")]
|
|
[IgnoreTenant]
|
|
public async Task HeartbeatAsync(DeviceHeartbeatRequest request)
|
|
{
|
|
await _deviceConnectService.HeartbeatAsync(request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设备注册
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("register")]
|
|
[IgnoreTenant]
|
|
public async Task<string> RegisterAsync(DeviceResigterRequest request)
|
|
{
|
|
return await _deviceConnectService.RegisterAsync(request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 尝试连接
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("tryConnect")]
|
|
public async Task<bool> TryConnectAsync(DeviceConnectionTryRequest request)
|
|
{
|
|
return await _deviceConnectService.TryConnectAsync(request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取在线设备
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("online-devices")]
|
|
public async Task<List<DeviceUniqueWithConnectionInfoDto>> GetOnlineDeviceUniqueInfoAsync()
|
|
{
|
|
return await _deviceConnectService.GetOnlineDeviceUniqueInfoAsync();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取品牌设备
|
|
/// </summary>
|
|
/// <param name="brand"></param>
|
|
/// <param name="factory"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("brand-devices")]
|
|
[IgnoreTenant]
|
|
public async Task<List<DeviceUniqueWithConnectionInfoDto>> GetDeviceUniqueInfoByBrandAsync(
|
|
[Required(ErrorMessage = "请明确设备品牌")] string brand,
|
|
[Required(ErrorMessage = "请明确厂区")] string factory)
|
|
{
|
|
return await _deviceConnectService.GetDeviceUniqueInfoByBrandAsync(brand, factory);
|
|
}
|
|
} |