forked from ddrilling/AsbCloudServer
Merge branch 'dev' into feature/#32021538-match-categories-integration-test
This commit is contained in:
commit
b8c58030b9
@ -72,6 +72,7 @@ namespace AsbCloudApp.Services
|
||||
/// <param name="request"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[Obsolete]
|
||||
Task<IEnumerable<DetectedOperationStatDto>> GetOperationsStatAsync(DetectedOperationByWellRequest request, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
|
@ -133,18 +133,22 @@ namespace AsbCloudInfrastructure.Repository
|
||||
if (ids.Length != dtos.Count())
|
||||
throw new ArgumentInvalidException(nameof(dtos), "Все записи должны иметь уникальные Id");
|
||||
|
||||
var dbSet = dbContext.Set<TEntity>();
|
||||
|
||||
var existingEntitiesCount = await dbSet
|
||||
var existingEntitiesCount = await dbContext.Set<TEntity>()
|
||||
.Where(o => ids.Contains(o.Id))
|
||||
.CountAsync(token);
|
||||
|
||||
if (ids.Length != existingEntitiesCount)
|
||||
throw new ArgumentInvalidException(nameof(dtos), "Все записи должны существовать в БД");
|
||||
|
||||
var entities = dtos.Select(Convert);
|
||||
|
||||
var entities = dbContext.Set<TEntity>().Where(e => ids.Contains(e.Id));
|
||||
dbContext.Set<TEntity>().UpdateRange(entities);
|
||||
return await dbContext.SaveChangesAsync(token);
|
||||
var entries = entities.Select(entity => dbContext.Set<TEntity>().Update(entity)).ToList();
|
||||
|
||||
var affected = await dbContext.SaveChangesAsync(token);
|
||||
|
||||
entries.ForEach(entry => entry.State = EntityState.Detached);
|
||||
|
||||
return affected;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
@ -143,6 +143,7 @@ public class DetectedOperationService : IDetectedOperationService
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public async Task<IEnumerable<DetectedOperationStatDto>> GetOperationsStatAsync(DetectedOperationByWellRequest request, CancellationToken token)
|
||||
{
|
||||
var well = await wellService.GetOrDefaultAsync(request.IdWell, token);
|
||||
|
@ -96,7 +96,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
return 0;
|
||||
|
||||
entity.IdState = setpointsRequestDto.IdState;
|
||||
var affected = await setpointsRepository.UpdateAsync(entity, token);
|
||||
var affected = await setpointsRepository.UpdateRangeAsync(new[] { entity }, token);
|
||||
return affected;
|
||||
}
|
||||
|
||||
|
@ -274,6 +274,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
dto.Timezone = GetTimezone(entity.Id);
|
||||
|
||||
dto.StartDate = dbContext.WellOperations.Where(e => e.IdType == WellOperation.IdOperationTypeFact)
|
||||
.AsNoTracking()
|
||||
.MinOrDefault(e => e.DateStart)?.ToRemoteDateTime(dto.Timezone.Hours);
|
||||
dto.WellType = entity.WellType.Caption;
|
||||
dto.Cluster = entity.Cluster.Caption;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AsbCloudApp.Data.DetectedOperation;
|
||||
using System;
|
||||
using AsbCloudApp.Data.DetectedOperation;
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudApp.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@ -110,7 +111,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получить фильтрованный список операций по телеметрии САУБ
|
||||
/// Получить список автоопределенных операций для редактирования
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="request"></param>
|
||||
@ -118,7 +119,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(PaginationContainer<DetectedOperationDto>), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> GetAsync(int idWell, [FromQuery] DetectedOperationRequest request,
|
||||
public async Task<IActionResult> GetPageAsync(int idWell, [FromQuery] DetectedOperationRequest request,
|
||||
CancellationToken token)
|
||||
{
|
||||
await AssertUserHasAccessToWellAsync(idWell, token);
|
||||
@ -133,24 +134,23 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
||||
var result = await detectedOperationRepository.GetPageAsync(requestToService, token);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить статистику по фильтрованному списку операций по телеметрии САУБ
|
||||
/// Получить статистику по автоопределенным операциям
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("stat")]
|
||||
[ProducesResponseType(typeof(IEnumerable<DetectedOperationStatDto>), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> GetStatAsync(int idWell, [FromQuery] DetectedOperationRequest request,
|
||||
CancellationToken token)
|
||||
[ProducesResponseType(typeof(DetectedOperationListDto), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> GetAsync(int idWell, [FromQuery] DetectedOperationRequest request, CancellationToken token)
|
||||
{
|
||||
await AssertUserHasAccessToWellAsync(idWell, token);
|
||||
|
||||
|
||||
var requestToService = new DetectedOperationByWellRequest(idWell, request);
|
||||
|
||||
var result = await detectedOperationService.GetOperationsStatAsync(requestToService, token);
|
||||
var result = await detectedOperationService.GetAsync(requestToService, token);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user