2021-06-16 14:47:36 +05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2021-06-17 15:12:39 +05:00
|
|
|
|
using AsbCloudApp.Data;
|
|
|
|
|
using AsbCloudApp.Services;
|
2021-06-16 14:47:36 +05:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudWebApi.Controllers
|
|
|
|
|
{
|
|
|
|
|
[Route("api/analytics")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
[Authorize]
|
|
|
|
|
public class AnalyticsController : ControllerBase
|
|
|
|
|
{
|
2021-06-17 15:12:39 +05:00
|
|
|
|
private readonly IAnalyticsService analyticsService;
|
|
|
|
|
private readonly IWellService wellService;
|
|
|
|
|
|
|
|
|
|
public AnalyticsController(IAnalyticsService analyticsService, IWellService wellService)
|
|
|
|
|
{
|
|
|
|
|
this.analyticsService = analyticsService;
|
|
|
|
|
this.wellService = wellService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Возвращает данные по скважине "глубина-день"
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="wellId">id скважины</param>
|
|
|
|
|
/// <returns>Коллекцию данных по скважине "глубина-день"</returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Route("{wellId}/wellDepthToDay")]
|
|
|
|
|
[ProducesResponseType(typeof(List<WellDepthToDayDto>), (int)System.Net.HttpStatusCode.OK)]
|
|
|
|
|
public IActionResult GetWellDepthToDay(int wellId)
|
|
|
|
|
{
|
|
|
|
|
int? idCustomer = User.GetCustomerId();
|
|
|
|
|
|
|
|
|
|
if (idCustomer is null)
|
|
|
|
|
return BadRequest();
|
|
|
|
|
|
|
|
|
|
if (!wellService.CheckWellOwnership((int)idCustomer, wellId))
|
|
|
|
|
return Forbid();
|
|
|
|
|
|
|
|
|
|
var wellDepthToDayData = analyticsService.GetWellDepthToDayData(wellId);
|
|
|
|
|
|
|
|
|
|
return Ok(wellDepthToDayData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Возвращает данные по глубине скважины за период
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="wellId">id скважины</param>
|
|
|
|
|
/// <returns>Коллекцию данных по глубине скважины за период</returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Route("{wellId}/wellDepthToInterval")]
|
|
|
|
|
[ProducesResponseType(typeof(List<WellDepthToIntervalDto>), (int)System.Net.HttpStatusCode.OK)]
|
|
|
|
|
public IActionResult GetWellDepthToInterval(int wellId)
|
|
|
|
|
{
|
|
|
|
|
int? idCustomer = User.GetCustomerId();
|
|
|
|
|
|
|
|
|
|
if (idCustomer is null)
|
|
|
|
|
return BadRequest();
|
|
|
|
|
|
|
|
|
|
if (!wellService.CheckWellOwnership((int)idCustomer, wellId))
|
|
|
|
|
return Forbid();
|
|
|
|
|
|
|
|
|
|
var wellDepthToIntervalData = analyticsService.GetWellDepthToIntervalData(wellId);
|
|
|
|
|
|
|
|
|
|
return Ok(wellDepthToIntervalData);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-16 14:47:36 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Возвращает данные по операциям на скважине за период
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="wellId">id скважины</param>
|
|
|
|
|
/// <param name="begin">дата начала интервала</param>
|
|
|
|
|
/// <param name="end">дата окончания интервала</param>
|
|
|
|
|
/// <returns>Коллекцию операций на скважине</returns>
|
|
|
|
|
[HttpGet]
|
2021-06-17 15:12:39 +05:00
|
|
|
|
[Route("{wellId}/operationsToTime")]
|
2021-06-16 14:47:36 +05:00
|
|
|
|
[ProducesResponseType(typeof(List<OperationPercentageDto>), (int)System.Net.HttpStatusCode.OK)]
|
2021-06-17 15:12:39 +05:00
|
|
|
|
public IActionResult GetOperationsToTime(int wellId, DateTime begin = default, DateTime end = default)
|
2021-06-16 14:47:36 +05:00
|
|
|
|
{
|
2021-06-17 15:12:39 +05:00
|
|
|
|
int? idCustomer = User.GetCustomerId();
|
|
|
|
|
|
|
|
|
|
if (idCustomer is null)
|
|
|
|
|
return BadRequest();
|
|
|
|
|
|
|
|
|
|
if (!wellService.CheckWellOwnership((int)idCustomer, wellId))
|
|
|
|
|
return Forbid();
|
|
|
|
|
|
2021-06-16 14:47:36 +05:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|