forked from ddrilling/AsbCloudServer
IWellOperationService/Controller replace arguments by request class
This commit is contained in:
parent
1afbafdf81
commit
7b0e6ce23d
@ -2,6 +2,7 @@
|
||||
|
||||
namespace AsbCloudApp.Requests
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// Базовые параметры запроса
|
||||
/// </summary>
|
||||
@ -22,6 +23,7 @@ namespace AsbCloudApp.Requests
|
||||
/// Содержат список названий полей сортировки
|
||||
/// Указать направление сортировки можно через пробел "asc" или "desc"
|
||||
/// </summary>
|
||||
public IEnumerable<string> SortFields { get; set; }
|
||||
public IEnumerable<string>? SortFields { get; set; }
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
87
AsbCloudApp/Requests/WellOperationRequest.cs
Normal file
87
AsbCloudApp/Requests/WellOperationRequest.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AsbCloudApp.Requests
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// параметры для запроса списка операций
|
||||
/// </summary>
|
||||
public class WellOperationRequestBase: RequestBase
|
||||
{
|
||||
/// <summary>
|
||||
/// фильтр по дате начала операции
|
||||
/// </summary>
|
||||
public DateTime? GeDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// фильтр по дате окончания операции
|
||||
/// </summary>
|
||||
public DateTime? LeDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// фильтр по максимальной глубине скважины
|
||||
/// </summary>
|
||||
public double? LeDepth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// фильтр по минимальной глубине скважины
|
||||
/// </summary>
|
||||
public double? GeDepth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// фильтр по списку id категорий операции
|
||||
/// </summary>
|
||||
public IEnumerable<int>? OperationCategoryIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// фильтр по план = 0, факт = 1
|
||||
/// </summary>
|
||||
public int? OperationType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// фильтр по списку id конструкций секции
|
||||
/// </summary>
|
||||
public IEnumerable<int>? SectionTypeIds { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Параметры для запроса списка операций (с id скважины)
|
||||
/// </summary>
|
||||
public class WellOperationRequest: WellOperationRequestBase
|
||||
{
|
||||
/// <summary>
|
||||
/// id скважины
|
||||
/// </summary>
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public WellOperationRequest(){}
|
||||
|
||||
/// <summary>
|
||||
/// копирующий конструктор
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="idWell"></param>
|
||||
public WellOperationRequest(WellOperationRequestBase request, int idWell)
|
||||
{
|
||||
this.IdWell = idWell;
|
||||
|
||||
this.GeDepth = request.GeDepth;
|
||||
this.LeDepth = request.LeDepth;
|
||||
this.GeDate = request.GeDate;
|
||||
this.LeDate = request.LeDate;
|
||||
|
||||
this.OperationCategoryIds = request.OperationCategoryIds;
|
||||
this.OperationType = request.OperationType;
|
||||
this.SectionTypeIds = request.SectionTypeIds;
|
||||
|
||||
this.Skip= request.Skip;
|
||||
this.Take= request.Take;
|
||||
this.SortFields = request.SortFields;
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Requests;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
@ -6,6 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudApp.Services
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// сервис операций по скважине
|
||||
/// </summary>
|
||||
@ -21,53 +23,21 @@ namespace AsbCloudApp.Services
|
||||
/// <summary>
|
||||
/// Получить список операций
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="operationType"></param>
|
||||
/// <param name="sectionTypeIds"></param>
|
||||
/// <param name="operationCategoryIds"></param>
|
||||
/// <param name="begin"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="minDepth"></param>
|
||||
/// <param name="maxDepth"></param>
|
||||
/// <param name="skip"></param>
|
||||
/// <param name="take"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<PaginationContainer<WellOperationDto>> GetOperationsAsync(
|
||||
int idWell,
|
||||
int? operationType = null,
|
||||
IEnumerable<int> sectionTypeIds = null,
|
||||
IEnumerable<int> operationCategoryIds = null,
|
||||
DateTime begin = default,
|
||||
DateTime end = default,
|
||||
double minDepth = double.MinValue,
|
||||
double maxDepth = double.MaxValue,
|
||||
int skip = 0,
|
||||
int take = 32,
|
||||
WellOperationRequest request,
|
||||
CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// Получить статистику операции по скважине с группировкой по категориям
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="operationType"></param>
|
||||
/// <param name="sectionTypeIds"></param>
|
||||
/// <param name="operationCategoryIds"></param>
|
||||
/// <param name="begin"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="minDepth"></param>
|
||||
/// <param name="maxDepth"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<WellGroupOpertionDto>> GetGroupOperationsStatAsync(
|
||||
int idWell,
|
||||
int? operationType = null,
|
||||
IEnumerable<int> sectionTypeIds = null,
|
||||
IEnumerable<int> operationCategoryIds = null,
|
||||
DateTime begin = default,
|
||||
DateTime end = default,
|
||||
double minDepth = double.MinValue,
|
||||
double maxDepth = double.MaxValue,
|
||||
WellOperationRequest request,
|
||||
CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
@ -78,27 +48,22 @@ namespace AsbCloudApp.Services
|
||||
/// <returns></returns>
|
||||
Task<WellOperationDto> GetOrDefaultAsync(int id, CancellationToken token);
|
||||
|
||||
//todo: idWell Не нужен
|
||||
/// <summary>
|
||||
/// Добавить несколько операций за один раз
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="wellOperationDtos"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> InsertRangeAsync(int idWell,
|
||||
Task<int> InsertRangeAsync(
|
||||
IEnumerable<WellOperationDto> wellOperationDtos, CancellationToken token);
|
||||
|
||||
//todo: id Не нужны
|
||||
/// <summary>
|
||||
/// Обновить существующую операцию
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="idOperation"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> UpdateAsync(int idWell, int idOperation, WellOperationDto item,
|
||||
Task<int> UpdateAsync(WellOperationDto item,
|
||||
CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
@ -122,4 +87,5 @@ namespace AsbCloudApp.Services
|
||||
/// <returns></returns>
|
||||
DateTimeOffset? FirstOperationDate(int idWell);
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb;
|
||||
using AsbCloudDb.Model;
|
||||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@ -75,47 +77,24 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
}
|
||||
|
||||
public async Task<PaginationContainer<WellOperationDto>> GetOperationsAsync(
|
||||
int idWell,
|
||||
int? operationType = default,
|
||||
IEnumerable<int>? sectionTypeIds = null,
|
||||
IEnumerable<int>? operationCategoryIds = null,
|
||||
DateTime begin = default,
|
||||
DateTime end = default,
|
||||
double minDepth = double.MinValue,
|
||||
double maxDepth = double.MaxValue,
|
||||
int skip = 0,
|
||||
int take = 32,
|
||||
WellOperationRequest request,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
var timezone = wellService.GetTimezone(request.IdWell);
|
||||
|
||||
var query = BuildQuery(
|
||||
idWell,
|
||||
operationType,
|
||||
sectionTypeIds,
|
||||
operationCategoryIds,
|
||||
begin,
|
||||
end,
|
||||
minDepth,
|
||||
maxDepth,
|
||||
token);
|
||||
var query = BuildQuery(request);
|
||||
|
||||
var result = new PaginationContainer<WellOperationDto>
|
||||
{
|
||||
Skip = skip,
|
||||
Take = take,
|
||||
Skip = request.Skip ?? 0,
|
||||
Take = request.Take ?? 32,
|
||||
Count = await query.CountAsync(token).ConfigureAwait(false),
|
||||
};
|
||||
|
||||
query = query
|
||||
.OrderBy(e => e.DateStart)
|
||||
.ThenBy(e => e.DepthEnd)
|
||||
.ThenBy(e => e.Id);
|
||||
|
||||
if (skip > 0)
|
||||
query = query.Skip(skip);
|
||||
if (result.Skip > 0)
|
||||
query = query.Skip(result.Skip!);
|
||||
|
||||
var entities = await query.Take(take).AsNoTracking()
|
||||
var entities = await query.Take(result.Take).AsNoTracking()
|
||||
.ToListAsync(token).ConfigureAwait(false);
|
||||
|
||||
if (!entities.Any())
|
||||
@ -144,26 +123,10 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<WellGroupOpertionDto>> GetGroupOperationsStatAsync(
|
||||
int idWell,
|
||||
int? operationType = default,
|
||||
IEnumerable<int>? sectionTypeIds = default,
|
||||
IEnumerable<int>? operationCategoryIds = default,
|
||||
DateTime begin = default,
|
||||
DateTime end = default,
|
||||
double minDepth = double.MinValue,
|
||||
double maxDepth = double.MaxValue,
|
||||
WellOperationRequest request,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var query = BuildQuery(
|
||||
idWell,
|
||||
operationType,
|
||||
sectionTypeIds,
|
||||
operationCategoryIds,
|
||||
begin,
|
||||
end,
|
||||
minDepth,
|
||||
maxDepth,
|
||||
token);
|
||||
var query = BuildQuery(request);
|
||||
var entities = await query
|
||||
.Select(o => new {
|
||||
o.IdCategory,
|
||||
@ -172,11 +135,12 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
})
|
||||
.ToListAsync(token);
|
||||
var parentRelationDictionary = GetCategories()
|
||||
.ToDictionary(c => c.Id, cc => new
|
||||
.ToDictionary(c => c.Id, c => new
|
||||
{
|
||||
Name = cc.Name,
|
||||
IdParent = cc.IdParent
|
||||
c.Name,
|
||||
c.IdParent
|
||||
});
|
||||
|
||||
var dtos = entities
|
||||
.GroupBy(o => o.IdCategory)
|
||||
.Select(g => new WellGroupOpertionDto
|
||||
@ -206,7 +170,6 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
TotalMinutes = g.Sum(o => o.TotalMinutes),
|
||||
Items = g.ToList(),
|
||||
IdParent = g.Key.HasValue ? parentRelationDictionary[g.Key.Value].IdParent : defaultId,
|
||||
|
||||
});
|
||||
}
|
||||
return dtos;
|
||||
@ -215,7 +178,6 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
public async Task<WellOperationDto?> GetOrDefaultAsync(int id,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
|
||||
var entity = await db.WellOperations
|
||||
.Include(s => s.WellSectionType)
|
||||
.Include(s => s.OperationCategory)
|
||||
@ -234,10 +196,17 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
return dto;
|
||||
}
|
||||
|
||||
public async Task<int> InsertRangeAsync(int idWell,
|
||||
public async Task<int> InsertRangeAsync(
|
||||
IEnumerable<WellOperationDto> wellOperationDtos,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var firstOperation = wellOperationDtos
|
||||
.FirstOrDefault();
|
||||
if (firstOperation is null)
|
||||
return 0;
|
||||
|
||||
var idWell = firstOperation.IdWell;
|
||||
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
foreach (var dto in wellOperationDtos)
|
||||
{
|
||||
@ -252,12 +221,11 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<int> UpdateAsync(int idWell, int idOperation,
|
||||
public async Task<int> UpdateAsync(
|
||||
WellOperationDto dto, CancellationToken token = default)
|
||||
{
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
var timezone = wellService.GetTimezone(dto.IdWell);
|
||||
var entity = dto.Adapt<WellOperation>();
|
||||
entity.Id = idOperation;
|
||||
entity.DateStart = dto.DateStart.ToUtcDateTimeOffset(timezone.Hours);
|
||||
db.WellOperations.Update(entity);
|
||||
return await db.SaveChangesAsync(token)
|
||||
@ -273,57 +241,55 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private IQueryable<WellOperation> BuildQuery(
|
||||
int idWell,
|
||||
int? operationType = default,
|
||||
IEnumerable<int>? sectionTypeIds = null,
|
||||
IEnumerable<int>? operationCategoryIds = null,
|
||||
DateTime begin = default,
|
||||
DateTime end = default,
|
||||
double minDepth = double.MinValue,
|
||||
double maxDepth = double.MaxValue,
|
||||
CancellationToken token = default)
|
||||
private IQueryable<WellOperation> BuildQuery(WellOperationRequest request)
|
||||
{
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
var timezone = wellService.GetTimezone(request.IdWell);
|
||||
|
||||
var query = db.WellOperations
|
||||
.Include(s => s.WellSectionType)
|
||||
.Include(s => s.OperationCategory)
|
||||
.Where(s => s.IdWell == idWell);
|
||||
.Where(s => s.IdWell == request.IdWell);
|
||||
|
||||
if (operationType.HasValue)
|
||||
query = query.Where(e => e.IdType == operationType.Value);
|
||||
if (request.OperationType.HasValue)
|
||||
query = query.Where(e => e.IdType == request.OperationType.Value);
|
||||
|
||||
if (sectionTypeIds != default && sectionTypeIds.Any())
|
||||
query = query.Where(e => sectionTypeIds.Contains(e.IdWellSectionType));
|
||||
if (request.SectionTypeIds?.Any() == true)
|
||||
query = query.Where(e => request.SectionTypeIds.Contains(e.IdWellSectionType));
|
||||
|
||||
if (operationCategoryIds != default && operationCategoryIds.Any())
|
||||
query = query.Where(e => operationCategoryIds.Contains(e.IdCategory));
|
||||
if (request.OperationCategoryIds?.Any() == true)
|
||||
query = query.Where(e => request.OperationCategoryIds.Contains(e.IdCategory));
|
||||
|
||||
if (minDepth != double.MinValue)
|
||||
query = query.Where(e => e.DepthEnd >= minDepth);
|
||||
if (request.GeDepth.HasValue)
|
||||
query = query.Where(e => e.DepthEnd >= request.GeDepth.Value);
|
||||
|
||||
if (maxDepth != double.MaxValue)
|
||||
query = query.Where(e => e.DepthEnd <= maxDepth);
|
||||
if (request.LeDepth.HasValue)
|
||||
query = query.Where(e => e.DepthEnd <= request.LeDepth.Value);
|
||||
|
||||
if (begin != default)
|
||||
if (request.GeDate.HasValue)
|
||||
{
|
||||
var beginOffset = begin.ToUtcDateTimeOffset(timezone.Hours);
|
||||
query = query.Where(e => e.DateStart >= beginOffset);
|
||||
var geDateOffset = request.GeDate.Value.ToUtcDateTimeOffset(timezone.Hours);
|
||||
query = query.Where(e => e.DateStart >= geDateOffset);
|
||||
}
|
||||
|
||||
if (end != default)
|
||||
if (request.LeDate.HasValue)
|
||||
{
|
||||
var endOffset = end.ToUtcDateTimeOffset(timezone.Hours);
|
||||
query = query.Where(e => e.DateStart <= endOffset);
|
||||
var leDateOffset = request.LeDate.Value.ToUtcDateTimeOffset(timezone.Hours);
|
||||
query = query.Where(e => e.DateStart <= leDateOffset);
|
||||
}
|
||||
|
||||
if (request.SortFields?.Any() == true)
|
||||
{
|
||||
query = query.SortBy(request.SortFields);
|
||||
}
|
||||
else
|
||||
{
|
||||
query = query
|
||||
.OrderBy(e => e.DateStart)
|
||||
.ThenBy(e => e.DepthEnd)
|
||||
.ThenBy(e => e.Id);
|
||||
}
|
||||
|
||||
query = query
|
||||
.OrderBy(e => e.DateStart)
|
||||
.ThenBy(e => e.DepthEnd)
|
||||
.ThenBy(e => e.Id);
|
||||
return query;
|
||||
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
|
@ -1,9 +1,9 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Requests;
|
||||
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;
|
||||
@ -11,6 +11,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// Буровые операции (вводимые вручную)
|
||||
/// </summary>
|
||||
@ -44,7 +45,6 @@ namespace AsbCloudWebApi.Controllers
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает список имен типов операций на скважине
|
||||
/// </summary>
|
||||
@ -63,15 +63,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// Отфильтрованный список операций на скважине. Если не применять фильтр, то вернется весь список. Сортированный по глубине затем по дате
|
||||
/// </summary>
|
||||
/// <param name="idWell">id скважины</param>
|
||||
/// <param name="opertaionType">фильтр по план = 0, факт = 1</param>
|
||||
/// <param name="sectionTypeIds">фильтр по списку id конструкций секции</param>
|
||||
/// <param name="operationCategoryIds">фильтр по списку id категорий операции</param>
|
||||
/// <param name="begin">фильтр по началу операции</param>
|
||||
/// <param name="end">фильтр по окончанию операции</param>
|
||||
/// <param name="minDepth">фильтр по минимальной глубине скважины</param>
|
||||
/// <param name="maxDepth">фильтр по максимальной глубине скважины</param>
|
||||
/// <param name="skip"></param>
|
||||
/// <param name="take"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns>Список операций на скважине в контейнере для постраничного просмотра</returns>
|
||||
[HttpGet]
|
||||
@ -79,31 +71,15 @@ namespace AsbCloudWebApi.Controllers
|
||||
[ProducesResponseType(typeof(PaginationContainer<WellOperationDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetOperationsAsync(
|
||||
[FromRoute] int idWell,
|
||||
[FromQuery] int? opertaionType = default,
|
||||
[FromQuery] IEnumerable<int> sectionTypeIds = default,
|
||||
[FromQuery] IEnumerable<int> operationCategoryIds = default,
|
||||
[FromQuery] DateTime begin = default,
|
||||
[FromQuery] DateTime end = default,
|
||||
[FromQuery] double minDepth = double.MinValue,
|
||||
[FromQuery] double maxDepth = double.MaxValue,
|
||||
[FromQuery] int skip = 0,
|
||||
[FromQuery] int take = 32,
|
||||
CancellationToken token = default)
|
||||
[FromQuery] WellOperationRequestBase request,
|
||||
CancellationToken token)
|
||||
{
|
||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var requestToService = new WellOperationRequest(request, idWell);
|
||||
var result = await operationService.GetOperationsAsync(
|
||||
idWell,
|
||||
opertaionType,
|
||||
sectionTypeIds,
|
||||
operationCategoryIds,
|
||||
begin,
|
||||
end,
|
||||
minDepth,
|
||||
maxDepth,
|
||||
skip,
|
||||
take,
|
||||
requestToService,
|
||||
token)
|
||||
.ConfigureAwait(false);
|
||||
return Ok(result);
|
||||
@ -113,13 +89,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// Статистика операций по скважине, группированая по категориям
|
||||
/// </summary>
|
||||
/// <param name="idWell">id скважины</param>
|
||||
/// <param name="opertaionType"></param>
|
||||
/// <param name="sectionTypeIds"></param>
|
||||
/// <param name="operationCategoryIds"></param>
|
||||
/// <param name="begin"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="minDepth"></param>
|
||||
/// <param name="maxDepth"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
@ -128,27 +98,15 @@ namespace AsbCloudWebApi.Controllers
|
||||
[ProducesResponseType(typeof(IEnumerable<WellGroupOpertionDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetGroupOperationsAsync(
|
||||
[FromRoute] int idWell,
|
||||
[FromQuery] int? opertaionType = default,
|
||||
[FromQuery] IEnumerable<int> sectionTypeIds = default,
|
||||
[FromQuery] IEnumerable<int> operationCategoryIds = default,
|
||||
[FromQuery] DateTime begin = default,
|
||||
[FromQuery] DateTime end = default,
|
||||
[FromQuery] double minDepth = double.MinValue,
|
||||
[FromQuery] double maxDepth = double.MaxValue,
|
||||
CancellationToken token = default)
|
||||
[FromQuery] WellOperationRequestBase request,
|
||||
CancellationToken token)
|
||||
{
|
||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var requestToService = new WellOperationRequest(request, idWell);
|
||||
var result = await operationService.GetGroupOperationsStatAsync(
|
||||
idWell,
|
||||
opertaionType,
|
||||
sectionTypeIds,
|
||||
operationCategoryIds,
|
||||
begin,
|
||||
end,
|
||||
minDepth,
|
||||
maxDepth,
|
||||
requestToService,
|
||||
token)
|
||||
.ConfigureAwait(false);
|
||||
return Ok(result);
|
||||
@ -166,7 +124,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(WellOperationDto), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetAsync(int idWell, int idOperation,
|
||||
CancellationToken token = default)
|
||||
CancellationToken token)
|
||||
{
|
||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
@ -186,13 +144,17 @@ namespace AsbCloudWebApi.Controllers
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(IEnumerable<WellOperationDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> InsertRangeAsync(int idWell, [FromBody] IEnumerable<WellOperationDto> values,
|
||||
CancellationToken token = default)
|
||||
CancellationToken token)
|
||||
{
|
||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var result = await operationService.InsertRangeAsync(idWell, values, token)
|
||||
foreach(var value in values)
|
||||
value.IdWell= idWell;
|
||||
|
||||
var result = await operationService.InsertRangeAsync(values, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
@ -208,12 +170,15 @@ namespace AsbCloudWebApi.Controllers
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(WellOperationDto), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> UpdateAsync(int idWell, int idOperation,
|
||||
[FromBody] WellOperationDto value, CancellationToken token = default)
|
||||
[FromBody] WellOperationDto value, CancellationToken token)
|
||||
{
|
||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var result = await operationService.UpdateAsync(idWell, idOperation, value, token)
|
||||
value.IdWell= idWell;
|
||||
value.Id = idOperation;
|
||||
|
||||
var result = await operationService.UpdateAsync(value, token)
|
||||
.ConfigureAwait(false);
|
||||
return Ok(result);
|
||||
}
|
||||
@ -228,7 +193,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
[HttpDelete("{idOperation}")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> DeleteAsync(int idWell, int idOperation, CancellationToken token = default)
|
||||
public async Task<IActionResult> DeleteAsync(int idWell, int idOperation, CancellationToken token)
|
||||
{
|
||||
if (!await CanUserAccessToWellAsync(idWell,
|
||||
token).ConfigureAwait(false))
|
||||
@ -254,8 +219,8 @@ namespace AsbCloudWebApi.Controllers
|
||||
[Route("import/{options}")]
|
||||
public async Task<IActionResult> ImportAsync(int idWell,
|
||||
[FromForm] IFormFileCollection files,
|
||||
int options = 0,
|
||||
CancellationToken token = default)
|
||||
int options,
|
||||
CancellationToken token)
|
||||
{
|
||||
int? idCompany = User.GetCompanyId();
|
||||
int? idUser = User.GetUserId();
|
||||
@ -297,7 +262,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
[Route("export")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> ExportAsync([FromRoute] int idWell, CancellationToken token = default)
|
||||
public async Task<IActionResult> ExportAsync([FromRoute] int idWell, CancellationToken token)
|
||||
{
|
||||
int? idCompany = User.GetCompanyId();
|
||||
|
||||
@ -324,7 +289,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
[Route("scheduleReport")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> ScheduleReportAsync([FromRoute] int idWell, [FromServices] IScheduleReportService scheduleReportService, CancellationToken token = default)
|
||||
public async Task<IActionResult> ScheduleReportAsync([FromRoute] int idWell, [FromServices] IScheduleReportService scheduleReportService, CancellationToken token)
|
||||
{
|
||||
int? idCompany = User.GetCompanyId();
|
||||
|
||||
@ -362,4 +327,5 @@ namespace AsbCloudWebApi.Controllers
|
||||
idWell, token).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user