CS2-24: Добавлен Analytics controller.

This commit is contained in:
KharchenkoVV 2021-06-16 14:47:36 +05:00
parent 098b0906f9
commit 7069e8af24
2 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,8 @@
namespace AsbCloudApp.Data
{
public class OperationPercentageDto
{
public string ProcessName { get; set; }
public double Percentage { get; set; }
}
}

View File

@ -0,0 +1,41 @@
using System;
using AsbCloudApp.Data;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
namespace AsbCloudWebApi.Controllers
{
[Route("api/analytics")]
[ApiController]
[Authorize]
public class AnalyticsController : ControllerBase
{
/// <summary>
/// Возвращает данные по операциям на скважине за период
/// </summary>
/// <param name="wellId">id скважины</param>
/// <param name="begin">дата начала интервала</param>
/// <param name="end">дата окончания интервала</param>
/// <returns>Коллекцию операций на скважине</returns>
[HttpGet]
[Route("{wellId}/get")]
[ProducesResponseType(typeof(List<OperationPercentageDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetAnalytics(int wellId, DateTime begin = default, DateTime end = default)
{
var analytics = new List<OperationPercentageDto>
{
new OperationPercentageDto { ProcessName = "Роторное бурение", Percentage = 19.7 },
new OperationPercentageDto { ProcessName = "Подъем с проработкой", Percentage = 6.2 },
new OperationPercentageDto { ProcessName = "Спуск с проработкой", Percentage = 9.4 },
new OperationPercentageDto { ProcessName = "Подъем с промывкой", Percentage = 18.4 },
new OperationPercentageDto { ProcessName = "Неподвижное состояние", Percentage = 12.1 },
new OperationPercentageDto { ProcessName = "Вращение без циркуляции", Percentage = 7.4 },
new OperationPercentageDto { ProcessName = "Спуск в скважину", Percentage = 16.7 },
new OperationPercentageDto { ProcessName = "На поверхности", Percentage = 10.1 }
};
return Ok(analytics);
}
}
}