forked from ddrilling/AsbCloudServer
#28835068 Документирование, мелкие имправления.
This commit is contained in:
parent
ea8352f4de
commit
6b94f79f8d
@ -3,10 +3,23 @@ using AsbCloudApp.Data.Subsystems;
|
||||
|
||||
namespace AsbCloudApp.Data;
|
||||
|
||||
public record DrillerDetectedOperationStatDto
|
||||
/// <summary>
|
||||
/// ñòàòèñòèêà íàðàáîòêè ïî áóðèëüùèêàì
|
||||
/// </summary>
|
||||
public class DrillerDetectedOperationStatDto
|
||||
{
|
||||
public DrillerDto driller;
|
||||
public IEnumerable<SubsystemStatDto> statistic;
|
||||
public ScheduleDto schedule;
|
||||
public IEnumerable<WellDto> well;
|
||||
/// <summary>
|
||||
/// Ñòàòèñòèêè ïîäñèñòåì
|
||||
/// </summary>
|
||||
public IEnumerable<SubsystemStatDto> Statistic { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Ðàñïèñàíèå áóðèëüùèêà
|
||||
/// </summary>
|
||||
public ScheduleDto Schedule { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Ñêâàæèíà
|
||||
/// </summary>
|
||||
public WellDto Well { get; set; } = null!;
|
||||
}
|
@ -1,9 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AsbCloudApp.Requests;
|
||||
|
||||
/// <summary>
|
||||
/// Запрос на получение статистики использования подсистем бурильщиком
|
||||
/// </summary>
|
||||
public class GetStatRequest: RequestBase
|
||||
{
|
||||
public IEnumerable<int> idWell;
|
||||
public int? idDriller;
|
||||
/// <summary>
|
||||
/// id скважин
|
||||
/// </summary>
|
||||
public IEnumerable<int> IdsWells { get; set; } = Enumerable.Empty<int>();
|
||||
|
||||
/// <summary>
|
||||
/// id Бурильщика
|
||||
/// </summary>
|
||||
public int? IdDriller { get; set; }
|
||||
}
|
@ -29,6 +29,12 @@ public interface ISubsystemService
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<SubsystemActiveWellStatDto>> GetStatByActiveWells(IEnumerable<int> wellIds, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получение статистики по бурильщику
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<DrillerDetectedOperationStatDto>> GetByWellsAsync(GetStatRequest request,
|
||||
CancellationToken token);
|
||||
}
|
@ -56,9 +56,9 @@ namespace AsbCloudInfrastructure.Repository
|
||||
|
||||
public async Task<IEnumerable<ScheduleDto>> GetPageAsync(GetStatRequest request, CancellationToken token)
|
||||
{
|
||||
var idWell = request.idWell;
|
||||
var idDriller = request.idDriller;
|
||||
var query = GetQuery().Where(s => request.idWell.Contains(s.IdWell));
|
||||
var idWell = request.IdsWells;
|
||||
var idDriller = request.IdDriller;
|
||||
var query = GetQuery().Where(s => request.IdsWells.Contains(s.IdWell));
|
||||
if (idDriller is not null)
|
||||
{
|
||||
query.Where(s => s.IdDriller == idDriller);
|
||||
|
@ -56,13 +56,12 @@ internal class SubsystemService : ISubsystemService
|
||||
{
|
||||
var result = new List<DrillerDetectedOperationStatDto>();
|
||||
var schedulePage = await scheduleRepository.GetPageAsync(request, token);
|
||||
var wellTree = await wellService.GetAsync(new WellRequest { Ids = request.idWell }, token);
|
||||
var wellGroup = wellTree.GroupBy(w => w.Id);
|
||||
var wells = await wellService.GetAsync(new WellRequest { Ids = request.IdsWells }, token);
|
||||
|
||||
foreach (var schedule in schedulePage)
|
||||
{
|
||||
var idWell = schedule.IdWell;
|
||||
var well = wellGroup?.FirstOrDefault(w=> w.Key == idWell);
|
||||
var well = wells.FirstOrDefault(w=> w.Id == idWell)!;
|
||||
|
||||
var byWellRequest = new DetectedOperationByWellRequest(idWell, new DetectedOperationRequest());
|
||||
|
||||
@ -78,16 +77,15 @@ internal class SubsystemService : ISubsystemService
|
||||
var drillerOperationsStat = await CalcStatAsync(entry, token);
|
||||
var dto = new DrillerDetectedOperationStatDto
|
||||
{
|
||||
driller = entry.Key!,
|
||||
statistic = drillerOperationsStat,
|
||||
schedule = schedule,
|
||||
well = well!
|
||||
Statistic = drillerOperationsStat,
|
||||
Schedule = schedule,
|
||||
Well = well,
|
||||
};
|
||||
result.Add(dto);
|
||||
}
|
||||
}
|
||||
|
||||
return await Task.FromResult(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SubsystemStatDto>> GetStatAsync(SubsystemRequest request, CancellationToken token)
|
||||
|
@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -62,13 +63,17 @@ namespace AsbCloudWebApi.Controllers.Subsystems
|
||||
return Ok(dateRange);
|
||||
}
|
||||
|
||||
[HttpGet("operationsReport/{idWell}")]
|
||||
[ProducesResponseType(typeof(DrillerDetectedOperationStatDto), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetStatDateRangeAsync([FromRoute] int idWell, GetStatRequest request,
|
||||
[HttpGet("drillerDetectedOperationStat")]
|
||||
[ProducesResponseType(typeof(IEnumerable<DrillerDetectedOperationStatDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetByWellsAsync(GetStatRequest request,
|
||||
CancellationToken token)
|
||||
{
|
||||
if (!await UserHasAccessToWellAsync(idWell, token))
|
||||
return Forbid();
|
||||
if (!request.IdsWells.Any())
|
||||
return NoContent();
|
||||
|
||||
foreach(var idWell in request.IdsWells)
|
||||
if (!await UserHasAccessToWellAsync(idWell, token))
|
||||
return Forbid();
|
||||
|
||||
var result = await subsystemService.GetByWellsAsync(request, token);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user