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

119 lines
3.1 KiB
C#

11 months ago
using CommonModel;
using LanShengInterface;
using LanShengModel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace LanShengAPI.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class DeviceController : ControllerBase
{
public DeviceController(IDeviceService deviceService, ITcpService tcpService)
{
TcpService = tcpService;
DeviceService = deviceService;
}
private readonly ITcpService TcpService;
private readonly IDeviceService DeviceService;
[HttpPost("PushParams")]
public async Task<ActionResult> PushParams(DeviceData deviceData)
{
try
{
await TcpService.PushParams(deviceData);
return Ok();
}
catch (BadRequestException ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("GetDeviceData")]
public async Task<ActionResult> GetDeviceData([FromQuery] string id)
{
try
{
return Ok(await DeviceService.GetDeviceData(id));
}
catch (BadRequestException ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("ResetRunCount")]
11 months ago
public async Task<ActionResult> ResetRunCount([FromQuery] string id)
{
11 months ago
try
{
await DeviceService.ResetRunCount(id);
return Ok();
}
catch (BadRequestException ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost("GetDeviceDatas")]
11 months ago
public async Task<ActionResult> GetDeviceData(string[] ids)
{
11 months ago
try
{
return Ok(await DeviceService.GetDeviceData(ids));
}
catch (BadRequestException ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost("GetDeviceError")]
public async Task<ActionResult> GetDeviceError(PageYearSearch<DeviceError> page)
{
try
{
return Ok(await DeviceService.GetDeviceErrorPage(page));
}
catch (BadRequestException ex)
{
return BadRequest(ex.Message);
}
}
11 months ago
[HttpPost("DeviceErrorReport")]
public async Task<ActionResult> DeviceErrorReport(DeviceErrorReport report)
{
try
{
return Ok(await DeviceService.GetDeviceErrorReport(report));
}
catch (BadRequestException ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("DeviceErrorList")]
public async Task<ActionResult> DeviceErrorList()
{
try
{
return Ok(await DeviceService.GetErrorList());
}
catch (BadRequestException ex)
{
return BadRequest(ex.Message);
}
}
11 months ago
}
}