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