forked from ddrilling/AsbCloudServer
Исправления после ревью
This commit is contained in:
parent
ecc62c8404
commit
34009b9737
29
AsbCloudApp/Requests/GtrWithGetDataRequest.cs
Normal file
29
AsbCloudApp/Requests/GtrWithGetDataRequest.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace AsbCloudApp.Requests;
|
||||
|
||||
/// <summary>
|
||||
/// Параметры запроса для получения загруженных данных ГТИ по скважине
|
||||
/// </summary>
|
||||
public class GtrWithGetDataRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Id скважины
|
||||
/// </summary>
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата начала выборки.По умолчанию: текущее время - IntervalSec
|
||||
/// </summary>
|
||||
public DateTime? Begin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Интервал времени даты начала выборки, секунды
|
||||
/// </summary>
|
||||
public int IntervalSec { get; set; } = 600;
|
||||
|
||||
/// <summary>
|
||||
/// Желаемое количество точек. Если в выборке точек будет больше, то выборка будет прорежена.
|
||||
/// </summary>
|
||||
public int ApproxPointsCount { get; set; } = 1024;
|
||||
}
|
34
AsbCloudApp/Requests/ReportCreateRequest.cs
Normal file
34
AsbCloudApp/Requests/ReportCreateRequest.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
|
||||
namespace AsbCloudApp.Requests;
|
||||
|
||||
/// <summary>
|
||||
/// Ïàðàìåòðû çàïðîñà äëÿ ñîçäàíèÿ îò÷¸òà
|
||||
/// </summary>
|
||||
public class ReportCreateRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Id ñêâàæèíû
|
||||
/// </summary>
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Øàã èíòåðâàëà
|
||||
/// </summary>
|
||||
public int StepSeconds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ôîðìàò îò÷åòà (0-PDF, 1-LAS)
|
||||
/// </summary>
|
||||
public int Format { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Äàòà íà÷àëà èíòåðâàëà
|
||||
/// </summary>
|
||||
public DateTime Begin { get; set; } = default;
|
||||
|
||||
/// <summary>
|
||||
/// Äàòà îêîí÷àíèÿ èíòåðâàëà
|
||||
/// </summary>
|
||||
public DateTime End { get; set; } = default;
|
||||
}
|
34
AsbCloudApp/Requests/ReportGetSizeRequest.cs
Normal file
34
AsbCloudApp/Requests/ReportGetSizeRequest.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
|
||||
namespace AsbCloudApp.Requests;
|
||||
|
||||
/// <summary>
|
||||
/// Ïàðàìåòðû çàïðîñà äëÿ ïîëó÷åíèÿ ïðîãíîçèðóåìîãî êîëè÷åñòâî ñòðàíèö áóäóùåãî îò÷åòà
|
||||
/// </summary>
|
||||
public class ReportGetSizeRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Id ñêâàæèíû
|
||||
/// </summary>
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Øàã èíòåðâàëà
|
||||
/// </summary>
|
||||
public int StepSeconds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ôîðìàò îò÷åòà (0-PDF, 1-LAS)
|
||||
/// </summary>
|
||||
public int Format { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Äàòà íà÷àëà èíòåðâàëà
|
||||
/// </summary>
|
||||
public DateTime Begin { get; set; } = default;
|
||||
|
||||
/// <summary>
|
||||
/// Äàòà îêîí÷àíèÿ èíòåðâàëà
|
||||
/// </summary>
|
||||
public DateTime End { get; set; } = default;
|
||||
}
|
@ -3,10 +3,10 @@ using AsbCloudApp.Services;
|
||||
using AsbCloudWebApi.SignalR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudApp.Requests;
|
||||
|
||||
namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
@ -34,19 +34,14 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// <summary>
|
||||
/// Создает отчет по скважине с указанными параметрами
|
||||
/// </summary>
|
||||
/// <param name="idWell">id скважины</param>
|
||||
/// <param name="stepSeconds">шаг интервала</param>
|
||||
/// <param name="format">формат отчета (0-PDF, 1-LAS)</param>
|
||||
/// <param name="begin">дата начала интервала</param>
|
||||
/// <param name="end">дата окончания интервала</param>
|
||||
/// <param name="request">Параметры запроса</param>
|
||||
/// <param name="token">Токен для отмены задачи</param>
|
||||
/// <returns>id фоновой задачи формирования отчета</returns>
|
||||
[HttpPost]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> CreateReportAsync(int idWell, int stepSeconds, int format,
|
||||
CancellationToken token,
|
||||
DateTime begin = default, DateTime end = default)
|
||||
public async Task<IActionResult> CreateReportAsync(ReportCreateRequest request,
|
||||
CancellationToken token)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
var idUser = User.GetUserId();
|
||||
@ -55,7 +50,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
return Forbid();
|
||||
|
||||
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||
idWell, token).ConfigureAwait(false))
|
||||
request.IdWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
void HandleReportProgressAsync(object progress, string id) =>
|
||||
@ -68,8 +63,8 @@ namespace AsbCloudWebApi.Controllers
|
||||
).ConfigureAwait(false);
|
||||
}, token);
|
||||
|
||||
var id = reportService.EnqueueCreateReportWork(idWell, (int)idUser,
|
||||
stepSeconds, format, begin, end, HandleReportProgressAsync);
|
||||
var id = reportService.EnqueueCreateReportWork(request.IdWell, (int)idUser,
|
||||
request.StepSeconds, request.Format, request.Begin, request.End, HandleReportProgressAsync);
|
||||
|
||||
return Ok(id);
|
||||
}
|
||||
@ -102,35 +97,27 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// <summary>
|
||||
/// Возвращает прогнозируемое количество страниц будущего отчета
|
||||
/// </summary>
|
||||
/// <param name="idWell">id скважины</param>
|
||||
/// <param name="begin">дата начала интервала</param>
|
||||
/// <param name="end">дата окончания интервала</param>
|
||||
/// <param name="stepSeconds">шаг интервала</param>
|
||||
/// <param name="format">формат отчета (0-PDF, 1-LAS)</param>
|
||||
/// <param name="request">Параметры запроса</param>
|
||||
/// <param name="token">Токен для отмены задачи</param>
|
||||
/// <returns>прогнозируемое кол-во страниц отчета</returns>
|
||||
[HttpGet]
|
||||
[Route("reportSize")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(string), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetReportSizeAsync(int idWell,
|
||||
int stepSeconds,
|
||||
int format,
|
||||
CancellationToken token,
|
||||
DateTime begin = default,
|
||||
DateTime end = default)
|
||||
public async Task<IActionResult> GetReportSizeAsync(ReportGetSizeRequest request,
|
||||
CancellationToken token)
|
||||
{
|
||||
int? idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null)
|
||||
return Forbid();
|
||||
|
||||
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||
idWell, token).ConfigureAwait(false))
|
||||
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||
request.IdWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
int reportSize = reportService.GetReportPagesCount(idWell,
|
||||
begin, end, stepSeconds, format);
|
||||
int reportSize = reportService.GetReportPagesCount(request.IdWell,
|
||||
request.Begin, request.End, request.StepSeconds, request.Format);
|
||||
|
||||
return Ok(reportSize);
|
||||
}
|
||||
|
@ -4,10 +4,10 @@ using AsbCloudApp.Services;
|
||||
using AsbCloudWebApi.SignalR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudApp.Requests;
|
||||
|
||||
namespace AsbCloudWebApi.Controllers.SAUB
|
||||
{
|
||||
@ -39,16 +39,13 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
||||
/// <summary>
|
||||
/// Получить загруженные данные ГТИ по скважине
|
||||
/// </summary>
|
||||
/// <param name = "idWell" > id скважины</param>
|
||||
/// <param name = "begin" > дата начала выборки.По умолчанию: текущее время - intervalSec</param>
|
||||
/// <param name = "intervalSec" > интервал времени даты начала выборки, секунды</param>
|
||||
/// <param name = "approxPointsCount" > желаемое количество точек. Если в выборке точек будет больше, то выборка будет прорежена.</param>
|
||||
/// <param name = "token" > Токен завершения задачи</param>
|
||||
/// <param name="request">Параметры запроса</param>
|
||||
/// <param name = "token" >Токен завершения задачи</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{idWell}")]
|
||||
[Permission]
|
||||
public async Task<ActionResult<IEnumerable<WitsRecordDto>>> GetDataAsync(int idWell, DateTime? begin,
|
||||
CancellationToken token, int intervalSec = 600, int approxPointsCount = 1024)
|
||||
public async Task<ActionResult<IEnumerable<WitsRecordDto>>> GetDataAsync(GtrWithGetDataRequest request,
|
||||
CancellationToken token)
|
||||
{
|
||||
int? idCompany = User.GetCompanyId();
|
||||
|
||||
@ -56,13 +53,13 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
||||
return Forbid();
|
||||
|
||||
bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||
idWell, token).ConfigureAwait(false);
|
||||
request.IdWell, token).ConfigureAwait(false);
|
||||
|
||||
if (!isCompanyOwnsWell)
|
||||
return Forbid();
|
||||
|
||||
var content = await gtrRepository.GetAsync(idWell, begin,
|
||||
intervalSec, approxPointsCount, token).ConfigureAwait(false);
|
||||
var content = await gtrRepository.GetAsync(request.IdWell, request.Begin,
|
||||
request.IntervalSec, request.ApproxPointsCount, token).ConfigureAwait(false);
|
||||
|
||||
return Ok(content);
|
||||
}
|
||||
|
@ -72,10 +72,12 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
||||
/// <returns></returns>
|
||||
[HttpGet("{idWell}")]
|
||||
[Permission]
|
||||
public virtual async Task<ActionResult<IEnumerable<TDto>>> GetDataAsync(int idWell, CancellationToken token,
|
||||
public virtual async Task<ActionResult<IEnumerable<TDto>>> GetDataAsync(int idWell,
|
||||
DateTime begin = default,
|
||||
int intervalSec = 600,
|
||||
int approxPointsCount = 1024)
|
||||
int approxPointsCount = 1024,
|
||||
//TODO: сделать cancellationToken обязательным
|
||||
CancellationToken token = default)
|
||||
{
|
||||
int? idCompany = User.GetCompanyId();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user