forked from ddrilling/AsbCloudServer
CS2-107: Added ClusterOperationStatController
This commit is contained in:
parent
7b3e979bac
commit
00798becb0
8
AsbCloudApp/Data/ClusterMseStatDto.cs
Normal file
8
AsbCloudApp/Data/ClusterMseStatDto.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace AsbCloudApp.Data
|
||||||
|
{
|
||||||
|
public class ClusterMseStatDto
|
||||||
|
{
|
||||||
|
public double MseMax { get; set; }
|
||||||
|
public double MseAverage { get; set; }
|
||||||
|
}
|
||||||
|
}
|
67
AsbCloudWebApi/Controllers/ClusterOperationStatController.cs
Normal file
67
AsbCloudWebApi/Controllers/ClusterOperationStatController.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudWebApi.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Контроллер статистики вручную внесенных операций на кусту
|
||||||
|
/// </summary>
|
||||||
|
[Route("api/cluster")]
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
public class ClusterOperationStatController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IWellOperationService operationService;
|
||||||
|
private readonly IWellService wellService;
|
||||||
|
private readonly IWellOperationImportService wellOperationImportService;
|
||||||
|
|
||||||
|
public ClusterOperationStatController(IWellOperationService operationService,
|
||||||
|
IWellService wellService, IWellOperationImportService wellOperationImportService)
|
||||||
|
{
|
||||||
|
this.operationService = operationService;
|
||||||
|
this.wellService = wellService;
|
||||||
|
this.wellOperationImportService = wellOperationImportService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Формирует данные по среднему и максимальному МСП на кусту
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell">id скважины с данного куста (через нее будут полуены данные)</param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns>Возвращает данные по среднему и максимальному МСП на кусту</returns>
|
||||||
|
[HttpGet("{idWell}/mseStat")]
|
||||||
|
[ProducesResponseType(typeof(ClusterMseStatDto), (int)System.Net.HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> GetClusterMseStatAsync([FromRoute] int idWell,
|
||||||
|
CancellationToken token = default)
|
||||||
|
{
|
||||||
|
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
|
// var result = await operationService.GetOperationsAsync(
|
||||||
|
// idWell, token).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var result = new ClusterMseStatDto()
|
||||||
|
{
|
||||||
|
MseMax = 3.2,
|
||||||
|
MseAverage = 1.1
|
||||||
|
};
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
int? idCompany = User.GetCompanyId();
|
||||||
|
return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
|
idWell, token).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -33,7 +33,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("cluster/{idCluster}/stat")]
|
[Route("cluster/{idCluster}/stat")] // TODO: Это статистика клатера, перенести в ClusterOperationStatController
|
||||||
[ProducesResponseType(typeof(StatClusterDto), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(StatClusterDto), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> GetStatClusterAsync(int idCluster,
|
public async Task<IActionResult> GetStatClusterAsync(int idCluster,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
|
Loading…
Reference in New Issue
Block a user