diff --git a/AsbCloudApp/Repositories/IWellOperationRepository.cs b/AsbCloudApp/Repositories/IWellOperationRepository.cs
index 7d507a0d..8a5bf81c 100644
--- a/AsbCloudApp/Repositories/IWellOperationRepository.cs
+++ b/AsbCloudApp/Repositories/IWellOperationRepository.cs
@@ -12,23 +12,6 @@ namespace AsbCloudApp.Repositories
///
public interface IWellOperationRepository
{
- ///
- /// Получить индекс страницы с операцией
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- Task GetIndexPageWithOperationAsync(int idWell,
- int id,
- int operationType,
- int? take,
- IEnumerable? sortFields,
- CancellationToken token);
-
///
/// Список секций
///
@@ -50,6 +33,23 @@ namespace AsbCloudApp.Repositories
///
///
Task> GetPageAsync(WellOperationRequest request, CancellationToken token);
+
+ ///
+ /// Получить страницу с операцией
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task?> GetPageAsync(int idWell,
+ int id,
+ int operationType,
+ int? take,
+ IEnumerable sortFields,
+ CancellationToken token);
///
/// Получить статистику операции по скважине с группировкой по категориям
diff --git a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs
index 4907961c..0967bafb 100644
--- a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs
+++ b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs
@@ -41,44 +41,6 @@ public class WellOperationRepository : CrudRepositoryBase GetSectionTypes().ToDictionary(c => c.Id));
}
- public async Task GetIndexPageWithOperationAsync(int idWell,
- int id,
- int operationType,
- int? take,
- IEnumerable? sortFields,
- CancellationToken cancellationToken = default)
- {
- var query = GetQuery()
- .Where(o => o.IdType == operationType &&
- o.IdWell == idWell);
-
- if (!await query.AnyAsync(x => x.Id == id, cancellationToken))
- return null;
-
- query = sortFields?.Any() is true ? query.SortBy(sortFields) : query.OrderBy(e => e.DateStart);
-
- var count = await query.CountAsync(cancellationToken);
-
- var indexPage = 1;
-
- var skip = 0;
- take ??= 32;
-
- for (; skip < count; skip += take.Value)
- {
- var isExists = await query.Skip(skip)
- .Take(take.Value)
- .AnyAsync(x => x.Id == id, cancellationToken);
-
- if (isExists)
- break;
-
- indexPage++;
- }
-
- return indexPage;
- }
-
public IEnumerable GetSectionTypes() =>
memoryCache
.GetOrCreateBasic(dbContext.WellSectionTypes)
@@ -109,6 +71,50 @@ public class WellOperationRepository : CrudRepositoryBase?> GetPageAsync(int idWell,
+ int id,
+ int operationType,
+ int? take,
+ IEnumerable sortFields,
+ CancellationToken token)
+ {
+ var query = GetQuery()
+ .Where(o => o.IdType == operationType &&
+ o.IdWell == idWell);
+
+ if (!await query.AnyAsync(x => x.Id == id, token))
+ return null;
+
+ query = sortFields?.Any() is true ? query.SortBy(sortFields) : query.OrderBy(e => e.DateStart);
+
+ var skip = 0;
+ take ??= 32;
+
+ var count = await query.CountAsync(token);
+
+ while (skip < count)
+ {
+ var isExists = await query.Skip(skip)
+ .Take(take.Value)
+ .AnyAsync(x => x.Id == id, token);
+
+ if (isExists)
+ break;
+
+ skip += take.Value;
+ }
+
+ var request = new WellOperationRequest(new[] { idWell })
+ {
+ OperationType = operationType,
+ Skip = skip,
+ Take = take,
+ SortFields = sortFields
+ };
+
+ return await GetPageAsync(request, token);
+ }
+
public async Task> GetGroupOperationsStatAsync(WellOperationRequest request, CancellationToken token)
{
var query = BuildQuery(request);
diff --git a/AsbCloudWebApi/Controllers/WellOperationController.cs b/AsbCloudWebApi/Controllers/WellOperationController.cs
index 21540ae0..2019615f 100644
--- a/AsbCloudWebApi/Controllers/WellOperationController.cs
+++ b/AsbCloudWebApi/Controllers/WellOperationController.cs
@@ -187,7 +187,7 @@ public class WellOperationController : ControllerBase
[HttpGet]
[Permission]
[ProducesResponseType(typeof(PaginationContainer), StatusCodes.Status200OK)]
- public async Task GetPageOperationsAsync(
+ public async Task GetPageAsync(
[FromRoute] int idWell,
[FromQuery] WellOperationRequestBase request,
CancellationToken token)
@@ -202,7 +202,7 @@ public class WellOperationController : ControllerBase
}
///
- /// Получение индекса страницы с нужной операцией
+ /// Получение страницу с нужной операцией
///
/// id скважины
/// id операции
@@ -211,11 +211,11 @@ public class WellOperationController : ControllerBase
/// параметры сортировки страниц
///
///
- [HttpGet("{id}")]
+ [HttpGet("getPageWithOperation")]
[Permission]
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
- public async Task GetIndexPageWithOperationAsync([FromRoute] int idWell,
- [FromRoute] int id,
+ public async Task GetPageWithOperationAsync([FromRoute] int idWell,
+ int id,
int operationType,
int? take,
[FromQuery] IEnumerable? sortFields,
@@ -224,9 +224,9 @@ public class WellOperationController : ControllerBase
if (!await CanUserAccessToWellAsync(idWell, token))
return Forbid();
- var indexPage = await wellOperationRepository.GetIndexPageWithOperationAsync(idWell, id, operationType, take, sortFields, token);
+ var indexPage = await wellOperationRepository.GetPageAsync(idWell, id, operationType, take, sortFields, token);
- if (!indexPage.HasValue)
+ if (indexPage == null)
return NoContent();
return Ok(indexPage);