|
|
|
|
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")]
|
|
|
|
|
public async Task<ActionResult> ResetRunCount([FromQuery] string id)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await DeviceService.ResetRunCount(id);
|
|
|
|
|
return Ok();
|
|
|
|
|
}
|
|
|
|
|
catch (BadRequestException ex)
|
|
|
|
|
{
|
|
|
|
|
return BadRequest(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost("GetDeviceDatas")]
|
|
|
|
|
public async Task<ActionResult> GetDeviceData(string[] ids)
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[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([FromQuery] string search = "")
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return Ok(await DeviceService.GetErrorList(search));
|
|
|
|
|
}
|
|
|
|
|
catch (BadRequestException ex)
|
|
|
|
|
{
|
|
|
|
|
return BadRequest(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|