2024-07-04 11:02:45 +05:00
|
|
|
|
using AsbCloudApp.Data;
|
2024-02-21 15:08:51 +05:00
|
|
|
|
using AsbCloudApp.Data.ProcessMaps;
|
2024-06-30 21:02:55 +05:00
|
|
|
|
using AsbCloudApp.Data.ProcessMaps.Operations;
|
2024-02-12 16:55:50 +05:00
|
|
|
|
using AsbCloudApp.Data.ProcessMaps.Report;
|
2024-06-05 12:08:38 +05:00
|
|
|
|
using AsbCloudApp.Data.WellOperation;
|
2024-02-12 16:55:50 +05:00
|
|
|
|
using AsbCloudApp.Exceptions;
|
2024-02-13 16:35:01 +05:00
|
|
|
|
using AsbCloudApp.Extensions;
|
2024-02-12 16:55:50 +05:00
|
|
|
|
using AsbCloudApp.Repositories;
|
|
|
|
|
using AsbCloudApp.Requests;
|
|
|
|
|
using AsbCloudApp.Services;
|
|
|
|
|
using AsbCloudApp.Services.ProcessMaps.WellDrilling;
|
|
|
|
|
using AsbCloudDb.Model;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2024-02-14 13:43:19 +05:00
|
|
|
|
namespace AsbCloudInfrastructure.Services.ProcessMaps.Report;
|
|
|
|
|
|
2024-02-21 15:08:51 +05:00
|
|
|
|
public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
|
2024-02-12 16:55:50 +05:00
|
|
|
|
{
|
2024-02-14 13:43:19 +05:00
|
|
|
|
private readonly IWellService wellService;
|
2024-06-21 09:53:45 +05:00
|
|
|
|
private readonly IChangeLogRepository<ProcessMapPlanRotorDto, ProcessMapPlanBaseRequestWithWell> processMapPlanRotorRepository;
|
|
|
|
|
private readonly IChangeLogRepository<ProcessMapPlanSlideDto, ProcessMapPlanBaseRequestWithWell> processMapPlanSlideRepository;
|
2024-10-07 15:46:57 +05:00
|
|
|
|
private readonly IDataSaubStatRepository<DataSaubStatDto> dataSaubStatRepository;
|
2024-02-14 13:43:19 +05:00
|
|
|
|
private readonly IWellOperationRepository wellOperationRepository;
|
|
|
|
|
private readonly IWellOperationCategoryRepository wellOperationCategoryRepository;
|
2024-08-14 12:24:54 +05:00
|
|
|
|
private readonly IWellOperationService wellOperationService;
|
2024-02-14 13:43:19 +05:00
|
|
|
|
|
2024-02-21 15:08:51 +05:00
|
|
|
|
public ProcessMapReportDrillingService(IWellService wellService,
|
2024-06-21 09:53:45 +05:00
|
|
|
|
IChangeLogRepository<ProcessMapPlanRotorDto, ProcessMapPlanBaseRequestWithWell> processMapPlanRotorRepository,
|
|
|
|
|
IChangeLogRepository<ProcessMapPlanSlideDto, ProcessMapPlanBaseRequestWithWell> processMapPlanSlideRepository,
|
2024-10-07 15:46:57 +05:00
|
|
|
|
IDataSaubStatRepository<DataSaubStatDto> dataSaubStatRepository,
|
2024-02-14 13:43:19 +05:00
|
|
|
|
IWellOperationRepository wellOperationRepository,
|
2024-08-14 12:24:54 +05:00
|
|
|
|
IWellOperationCategoryRepository wellOperationCategoryRepository,
|
|
|
|
|
IWellOperationService wellOperationService
|
2024-02-14 13:43:19 +05:00
|
|
|
|
)
|
2024-02-12 16:55:50 +05:00
|
|
|
|
{
|
2024-02-14 13:43:19 +05:00
|
|
|
|
this.wellService = wellService;
|
2024-06-21 09:53:45 +05:00
|
|
|
|
this.processMapPlanRotorRepository = processMapPlanRotorRepository;
|
|
|
|
|
this.processMapPlanSlideRepository = processMapPlanSlideRepository;
|
2024-02-14 13:43:19 +05:00
|
|
|
|
this.dataSaubStatRepository = dataSaubStatRepository;
|
|
|
|
|
this.wellOperationRepository = wellOperationRepository;
|
|
|
|
|
this.wellOperationCategoryRepository = wellOperationCategoryRepository;
|
2024-08-14 12:24:54 +05:00
|
|
|
|
this.wellOperationService = wellOperationService;
|
2024-02-14 13:43:19 +05:00
|
|
|
|
}
|
2024-02-12 16:55:50 +05:00
|
|
|
|
|
2024-02-14 13:43:19 +05:00
|
|
|
|
public async Task<IEnumerable<ProcessMapReportDataSaubStatDto>> GetAsync(int idWell, DataSaubStatRequest request, CancellationToken token)
|
|
|
|
|
{
|
|
|
|
|
var well = await wellService.GetOrDefaultAsync(idWell, token)
|
|
|
|
|
?? throw new ArgumentInvalidException(nameof(idWell), $"Скважина с Id: {idWell} не найдена");
|
2024-02-12 16:55:50 +05:00
|
|
|
|
|
2024-02-14 13:43:19 +05:00
|
|
|
|
if (!well.IdTelemetry.HasValue)
|
|
|
|
|
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
|
2024-02-12 16:55:50 +05:00
|
|
|
|
|
2024-02-14 13:43:19 +05:00
|
|
|
|
var requestProcessMapPlan = new ProcessMapPlanBaseRequestWithWell(idWell);
|
2024-06-21 09:53:45 +05:00
|
|
|
|
|
|
|
|
|
var changeLogProcessMapsRotor = await processMapPlanRotorRepository.GetChangeLogForDate(requestProcessMapPlan, null, token);
|
|
|
|
|
var changeLogProcessMapsSlide = await processMapPlanSlideRepository.GetChangeLogForDate(requestProcessMapPlan, null, token);
|
|
|
|
|
|
|
|
|
|
var changeLogProcessMaps = changeLogProcessMapsRotor
|
|
|
|
|
.Select(p => ConvertToChangeLogDtoWithProcessMapPlanBase(p))
|
|
|
|
|
.Union(changeLogProcessMapsSlide.Select(p => ConvertToChangeLogDtoWithProcessMapPlanBase(p)));
|
2024-02-12 16:55:50 +05:00
|
|
|
|
|
2024-05-28 16:34:42 +05:00
|
|
|
|
if (!changeLogProcessMaps.Any())
|
2024-02-14 13:43:19 +05:00
|
|
|
|
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
|
2024-02-12 16:55:50 +05:00
|
|
|
|
|
2024-05-28 16:34:42 +05:00
|
|
|
|
var geDepth = changeLogProcessMaps.Min(p => p.Item.DepthStart);
|
|
|
|
|
var leDepth = changeLogProcessMaps.Max(p => p.Item.DepthEnd);
|
2024-02-12 16:55:50 +05:00
|
|
|
|
|
2024-03-27 09:53:54 +05:00
|
|
|
|
var requestWellOperationFact = new WellOperationRequest(new[] { idWell })
|
2024-02-14 13:43:19 +05:00
|
|
|
|
{
|
|
|
|
|
OperationType = WellOperation.IdOperationTypeFact,
|
|
|
|
|
GeDepth = geDepth,
|
|
|
|
|
LeDepth = leDepth
|
|
|
|
|
};
|
2024-08-14 12:24:54 +05:00
|
|
|
|
var wellOperations = await wellOperationService
|
2024-02-14 13:43:19 +05:00
|
|
|
|
.GetAsync(requestWellOperationFact, token);
|
2024-03-28 12:12:15 +05:00
|
|
|
|
|
|
|
|
|
var orderedWellOperations = wellOperations
|
|
|
|
|
.OrderBy(operation => operation.DateStart)
|
|
|
|
|
.ToArray();
|
|
|
|
|
|
2024-02-14 13:43:19 +05:00
|
|
|
|
if (!wellOperations.Any())
|
|
|
|
|
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
|
|
|
|
|
|
2024-02-15 10:52:18 +05:00
|
|
|
|
var geDate = wellOperations.Min(p => p.DateStart);
|
|
|
|
|
var leDate = wellOperations.Max(p => (p.DateStart.AddHours(p.DurationHours)));
|
2024-02-14 13:43:19 +05:00
|
|
|
|
var dataSaubStats =
|
2024-10-16 18:02:38 +05:00
|
|
|
|
(await dataSaubStatRepository.GetAsync([well.IdTelemetry.Value], geDate, leDate, token)).ToArray();
|
2024-02-14 13:43:19 +05:00
|
|
|
|
|
|
|
|
|
if (!dataSaubStats.Any())
|
|
|
|
|
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
|
|
|
|
|
|
|
|
|
|
var wellOperationCategories = wellOperationCategoryRepository.Get(false);
|
2024-03-28 12:12:15 +05:00
|
|
|
|
|
2024-02-14 13:43:19 +05:00
|
|
|
|
var wellSectionTypes = wellOperationRepository.GetSectionTypes();
|
|
|
|
|
|
|
|
|
|
var result = CalcByIntervals(
|
2024-06-05 12:08:38 +05:00
|
|
|
|
request,
|
|
|
|
|
changeLogProcessMaps,
|
2024-03-28 12:12:15 +05:00
|
|
|
|
dataSaubStats,
|
2024-06-05 12:08:38 +05:00
|
|
|
|
orderedWellOperations,
|
2024-02-14 13:43:19 +05:00
|
|
|
|
wellOperationCategories,
|
|
|
|
|
wellSectionTypes);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2024-02-12 16:55:50 +05:00
|
|
|
|
|
2024-06-21 09:53:45 +05:00
|
|
|
|
private ChangeLogDto<ProcessMapPlanBaseDto> ConvertToChangeLogDtoWithProcessMapPlanBase<T>(ChangeLogDto<T> p)
|
|
|
|
|
where T: ProcessMapPlanBaseDto
|
|
|
|
|
{
|
|
|
|
|
return new ChangeLogDto<ProcessMapPlanBaseDto>()
|
|
|
|
|
{
|
|
|
|
|
Item = p.Item,
|
|
|
|
|
Author = p.Author,
|
|
|
|
|
Creation = p.Creation,
|
|
|
|
|
Editor = p.Editor,
|
|
|
|
|
IdPrevious = p.IdPrevious,
|
|
|
|
|
IdState = p.IdState,
|
|
|
|
|
Obsolete = p.Obsolete,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-15 12:09:33 +05:00
|
|
|
|
private static IEnumerable<ProcessMapReportDataSaubStatDto> CalcByIntervals(
|
2024-02-14 13:43:19 +05:00
|
|
|
|
DataSaubStatRequest request,
|
2024-06-21 09:53:45 +05:00
|
|
|
|
IEnumerable<ChangeLogDto<ProcessMapPlanBaseDto>> changeLogProcessMaps,
|
2024-02-14 13:43:19 +05:00
|
|
|
|
Span<DataSaubStatDto> dataSaubStats,
|
|
|
|
|
IEnumerable<WellOperationDto> wellOperations,
|
|
|
|
|
IEnumerable<WellOperationCategoryDto> wellOperationCategories,
|
|
|
|
|
IEnumerable<WellSectionTypeDto> wellSectionTypes
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
var list = new List<ProcessMapReportDataSaubStatDto>();
|
|
|
|
|
var firstElemInInterval = dataSaubStats[0];
|
|
|
|
|
|
2024-03-28 12:12:15 +05:00
|
|
|
|
var orderedWellOperations = wellOperations
|
|
|
|
|
.OrderBy(o => o.DateStart)
|
|
|
|
|
.ToArray();
|
|
|
|
|
|
2024-04-01 09:54:57 +05:00
|
|
|
|
var lastFoundIndex = 0;
|
2024-03-28 12:12:15 +05:00
|
|
|
|
|
|
|
|
|
int GetSection(DataSaubStatDto data)
|
|
|
|
|
{
|
2024-06-05 12:08:38 +05:00
|
|
|
|
if (lastFoundIndex < orderedWellOperations.Length - 1)
|
2024-03-28 12:12:15 +05:00
|
|
|
|
{
|
|
|
|
|
lastFoundIndex = Array.FindIndex(orderedWellOperations, lastFoundIndex, o => o.DateStart > data.DateStart) - 1;
|
|
|
|
|
lastFoundIndex = lastFoundIndex < 0 ? orderedWellOperations.Length - 1 : lastFoundIndex;
|
|
|
|
|
}
|
2024-06-05 12:08:38 +05:00
|
|
|
|
|
2024-03-28 12:12:15 +05:00
|
|
|
|
var operation = orderedWellOperations[lastFoundIndex];
|
|
|
|
|
return operation.IdWellSectionType;
|
2024-06-05 12:08:38 +05:00
|
|
|
|
}
|
2024-02-14 13:43:19 +05:00
|
|
|
|
|
2024-06-21 09:53:45 +05:00
|
|
|
|
ProcessMapPlanBaseDto? GetProcessMapPlan(int idWellSectionType, DataSaubStatDto data)
|
|
|
|
|
=> changeLogProcessMaps
|
|
|
|
|
.Where(p => p.Item.IdWellSectionType == idWellSectionType)
|
|
|
|
|
.Where(p => p.Item.DepthStart <= data.DepthStart)
|
|
|
|
|
.Where(p => p.Item.DepthEnd >= data.DepthStart)
|
|
|
|
|
.Where(p => IsModeMatchOperationCategory(p.Item, data.IdCategory))
|
|
|
|
|
.WhereActualAtMoment(data.DateStart)
|
|
|
|
|
.Select(p => p.Item)
|
|
|
|
|
.FirstOrDefault();
|
2024-02-14 13:43:19 +05:00
|
|
|
|
|
|
|
|
|
var idWellSectionType = GetSection(firstElemInInterval);
|
|
|
|
|
var prevProcessMapPlan = GetProcessMapPlan(idWellSectionType, firstElemInInterval);
|
|
|
|
|
var indexStart = 0;
|
|
|
|
|
|
|
|
|
|
for (var i = 1; i < dataSaubStats.Length; i++)
|
2024-02-12 16:55:50 +05:00
|
|
|
|
{
|
2024-02-14 13:43:19 +05:00
|
|
|
|
var currentElem = dataSaubStats[i];
|
|
|
|
|
idWellSectionType = GetSection(currentElem);
|
|
|
|
|
var processMapPlan = GetProcessMapPlan(idWellSectionType, currentElem);
|
2024-02-13 17:29:20 +05:00
|
|
|
|
|
2024-02-14 13:43:19 +05:00
|
|
|
|
if (IsNewInterval(currentElem, firstElemInInterval, request) || i == dataSaubStats.Length - 1 || processMapPlan != prevProcessMapPlan)
|
|
|
|
|
{
|
|
|
|
|
prevProcessMapPlan = processMapPlan;
|
|
|
|
|
var length = i - indexStart;
|
2024-02-13 16:35:01 +05:00
|
|
|
|
|
2024-02-14 13:43:19 +05:00
|
|
|
|
var span = dataSaubStats.Slice(indexStart, length);
|
2024-02-12 16:55:50 +05:00
|
|
|
|
|
2024-02-14 13:43:19 +05:00
|
|
|
|
indexStart = i;
|
|
|
|
|
firstElemInInterval = currentElem;
|
2024-02-13 16:35:01 +05:00
|
|
|
|
|
2024-02-14 13:43:19 +05:00
|
|
|
|
var firstElemInSpan = span[0];
|
|
|
|
|
var lastElemInISpan = span[^1];
|
2024-02-13 16:35:01 +05:00
|
|
|
|
|
2024-02-14 13:43:19 +05:00
|
|
|
|
var wellOperationCategoryName = wellOperationCategories
|
|
|
|
|
.Where(c => c.Id == firstElemInSpan.IdCategory)
|
|
|
|
|
.FirstOrDefault()?.Name ?? string.Empty;
|
2024-02-14 11:33:35 +05:00
|
|
|
|
|
2024-02-15 15:59:34 +05:00
|
|
|
|
var wellSectionType = wellSectionTypes
|
2024-02-14 13:43:19 +05:00
|
|
|
|
.Where(c => c.Id == idWellSectionType)
|
2024-02-15 15:59:34 +05:00
|
|
|
|
.First();
|
2024-02-14 11:33:35 +05:00
|
|
|
|
|
2024-02-15 15:59:34 +05:00
|
|
|
|
var elem = CalcStat(processMapPlan, span, wellOperationCategoryName, wellSectionType);
|
2024-03-28 12:12:15 +05:00
|
|
|
|
|
2024-02-14 13:43:19 +05:00
|
|
|
|
if (elem is not null)
|
2024-06-05 12:08:38 +05:00
|
|
|
|
list.Add(elem);
|
2024-02-12 16:55:50 +05:00
|
|
|
|
}
|
2024-02-13 17:29:20 +05:00
|
|
|
|
}
|
2024-02-14 13:43:19 +05:00
|
|
|
|
return list;
|
|
|
|
|
}
|
2024-02-13 17:29:20 +05:00
|
|
|
|
|
2024-06-21 09:53:45 +05:00
|
|
|
|
private static bool IsModeMatchOperationCategory(ProcessMapPlanBaseDto dto, int idCategory)
|
2024-02-14 13:43:19 +05:00
|
|
|
|
{
|
2024-06-21 09:53:45 +05:00
|
|
|
|
return (dto is ProcessMapPlanRotorDto && idCategory == 5003) || (dto is ProcessMapPlanSlideDto && idCategory == 5002);
|
2024-02-14 13:43:19 +05:00
|
|
|
|
}
|
2024-02-13 16:35:01 +05:00
|
|
|
|
|
2024-02-15 12:09:33 +05:00
|
|
|
|
private static ProcessMapReportDataSaubStatDto? CalcStat(
|
2024-06-21 09:53:45 +05:00
|
|
|
|
ProcessMapPlanBaseDto? processMapPlanFilteredByDepth,
|
2024-02-14 13:43:19 +05:00
|
|
|
|
Span<DataSaubStatDto> span,
|
|
|
|
|
string wellOperationCategoryName,
|
2024-02-15 15:59:34 +05:00
|
|
|
|
WellSectionTypeDto wellSectionType
|
2024-02-14 13:43:19 +05:00
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
var firstElemInInterval = span[0];
|
|
|
|
|
var lastElemInInterval = span[^1];
|
2024-02-12 16:55:50 +05:00
|
|
|
|
|
2024-02-14 13:43:19 +05:00
|
|
|
|
var deltaDepth = lastElemInInterval.DepthEnd - firstElemInInterval.DepthStart;
|
2024-02-12 16:55:50 +05:00
|
|
|
|
|
2024-02-14 13:43:19 +05:00
|
|
|
|
var aggregatedValues = CalcAggregate(span);
|
2024-02-12 16:55:50 +05:00
|
|
|
|
|
2024-02-15 15:59:34 +05:00
|
|
|
|
var result = new ProcessMapReportDataSaubStatDto()
|
2024-02-12 16:55:50 +05:00
|
|
|
|
{
|
2024-02-15 15:59:34 +05:00
|
|
|
|
IdWellSectionType = wellSectionType.Id,
|
2024-03-22 17:59:03 +05:00
|
|
|
|
DateStart = firstElemInInterval.DateStart,
|
2024-02-15 15:59:34 +05:00
|
|
|
|
WellSectionTypeName = wellSectionType.Caption,
|
2024-02-14 13:43:19 +05:00
|
|
|
|
DepthStart = firstElemInInterval.DepthStart,
|
|
|
|
|
DepthEnd = lastElemInInterval.DepthEnd,
|
|
|
|
|
DeltaDepth = deltaDepth,
|
|
|
|
|
DrilledTime = aggregatedValues.DrilledTime,
|
|
|
|
|
DrillingMode = wellOperationCategoryName,
|
|
|
|
|
PressureDiff = new ProcessMapReportDataSaubStatParamsDto()
|
2024-02-12 16:55:50 +05:00
|
|
|
|
{
|
2024-02-14 13:43:19 +05:00
|
|
|
|
SetpointFact = firstElemInInterval.PressureSp - firstElemInInterval.PressureIdle,
|
|
|
|
|
FactWavg = aggregatedValues.Pressure,
|
|
|
|
|
SetpointUsage = aggregatedValues.SetpointUsagePressure
|
|
|
|
|
},
|
|
|
|
|
AxialLoad = new ProcessMapReportDataSaubStatParamsDto()
|
|
|
|
|
{
|
|
|
|
|
SetpointFact = aggregatedValues.AxialLoadSp,
|
|
|
|
|
FactWavg = aggregatedValues.AxialLoad,
|
|
|
|
|
SetpointUsage = aggregatedValues.SetpointUsageAxialLoad
|
|
|
|
|
},
|
|
|
|
|
TopDriveTorque = new ProcessMapReportDataSaubStatParamsDto()
|
|
|
|
|
{
|
|
|
|
|
SetpointFact = aggregatedValues.RotorTorqueSp,
|
|
|
|
|
FactWavg = aggregatedValues.RotorTorque,
|
|
|
|
|
FactMax = aggregatedValues.RotorTorqueMax,
|
|
|
|
|
SetpointUsage = aggregatedValues.SetpointUsageRotorTorque
|
|
|
|
|
},
|
|
|
|
|
SpeedLimit = new ProcessMapReportDataSaubStatParamsDto
|
|
|
|
|
{
|
|
|
|
|
SetpointFact = aggregatedValues.BlockSpeedSp,
|
|
|
|
|
FactWavg = deltaDepth / aggregatedValues.DrilledTime,
|
|
|
|
|
SetpointUsage = aggregatedValues.SetpointUsageRopPlan
|
|
|
|
|
},
|
|
|
|
|
TopDriveSpeed = new ProcessMapReportDataSaubStatParamsDto
|
|
|
|
|
{
|
|
|
|
|
FactWavg = aggregatedValues.RotorSpeed,
|
|
|
|
|
FactMax = aggregatedValues.RotorSpeedMax
|
|
|
|
|
},
|
|
|
|
|
Flow = new ProcessMapReportDataSaubStatParamsDto
|
|
|
|
|
{
|
|
|
|
|
FactWavg = aggregatedValues.MaxFlow,
|
|
|
|
|
},
|
|
|
|
|
Rop = new PlanFactDto<double?>
|
|
|
|
|
{
|
|
|
|
|
Fact = deltaDepth / aggregatedValues.DrilledTime
|
|
|
|
|
},
|
|
|
|
|
};
|
2024-06-21 09:53:45 +05:00
|
|
|
|
|
|
|
|
|
if(processMapPlanFilteredByDepth is ProcessMapPlanRotorDto processMapPlanRotorFilteredByDepth)
|
|
|
|
|
{
|
2024-06-21 17:22:29 +05:00
|
|
|
|
result.PressureDiff.SetpointPlan = processMapPlanRotorFilteredByDepth.DifferentialPressure;
|
2024-06-29 20:46:11 +05:00
|
|
|
|
result.PressureDiff.Limit = processMapPlanRotorFilteredByDepth.DifferentialPressureMax;
|
2024-06-21 17:22:29 +05:00
|
|
|
|
result.AxialLoad.SetpointPlan = processMapPlanRotorFilteredByDepth.WeightOnBit;
|
2024-06-29 20:46:11 +05:00
|
|
|
|
result.AxialLoad.Limit = processMapPlanRotorFilteredByDepth.WeightOnBitMax;
|
2024-06-21 17:22:29 +05:00
|
|
|
|
result.TopDriveTorque.SetpointPlan = processMapPlanRotorFilteredByDepth.TopDriveTorque;
|
2024-06-29 20:46:11 +05:00
|
|
|
|
result.TopDriveTorque.Limit = processMapPlanRotorFilteredByDepth.TopDriveTorqueMax;
|
|
|
|
|
result.SpeedLimit.SetpointPlan = processMapPlanRotorFilteredByDepth.RopMax;
|
|
|
|
|
result.TopDriveSpeed.SetpointPlan = processMapPlanRotorFilteredByDepth.Rpm;
|
2024-06-21 17:22:29 +05:00
|
|
|
|
result.Flow.SetpointPlan = processMapPlanRotorFilteredByDepth.FlowRate;
|
2024-06-29 20:46:11 +05:00
|
|
|
|
result.Flow.Limit = processMapPlanRotorFilteredByDepth.FlowRateMax;
|
|
|
|
|
result.Rop.Plan = processMapPlanRotorFilteredByDepth.RopMax;
|
2024-06-21 09:53:45 +05:00
|
|
|
|
}
|
|
|
|
|
if (processMapPlanFilteredByDepth is ProcessMapPlanSlideDto processMapPlanSlideFilteredByDepth)
|
|
|
|
|
{
|
2024-06-21 17:22:29 +05:00
|
|
|
|
result.PressureDiff.SetpointPlan = processMapPlanSlideFilteredByDepth.DifferentialPressure;
|
2024-06-30 11:11:09 +05:00
|
|
|
|
result.PressureDiff.Limit = processMapPlanSlideFilteredByDepth.DifferentialPressureMax;
|
2024-06-21 17:22:29 +05:00
|
|
|
|
result.AxialLoad.SetpointPlan = processMapPlanSlideFilteredByDepth.WeightOnBit;
|
2024-06-30 11:11:09 +05:00
|
|
|
|
result.AxialLoad.Limit = processMapPlanSlideFilteredByDepth.WeightOnBitMax;
|
|
|
|
|
result.SpeedLimit.SetpointPlan = processMapPlanSlideFilteredByDepth.RopMax;
|
2024-06-21 17:22:29 +05:00
|
|
|
|
result.Flow.SetpointPlan = processMapPlanSlideFilteredByDepth.FlowRate;
|
2024-06-30 11:11:09 +05:00
|
|
|
|
result.Flow.Limit = processMapPlanSlideFilteredByDepth.FlowRateMax;
|
|
|
|
|
result.Rop.Plan = processMapPlanSlideFilteredByDepth.RopMax;
|
2024-06-21 09:53:45 +05:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-15 15:59:34 +05:00
|
|
|
|
return result;
|
2024-02-14 13:43:19 +05:00
|
|
|
|
}
|
2024-02-12 16:55:50 +05:00
|
|
|
|
|
2024-02-15 12:09:33 +05:00
|
|
|
|
private static (
|
2024-02-14 13:43:19 +05:00
|
|
|
|
double Pressure,
|
|
|
|
|
double AxialLoadSp,
|
|
|
|
|
double AxialLoad,
|
|
|
|
|
double RotorTorqueSp,
|
|
|
|
|
double RotorTorque,
|
|
|
|
|
double RotorTorqueMax,
|
|
|
|
|
double BlockSpeedSp,
|
|
|
|
|
double RotorSpeed,
|
|
|
|
|
double RotorSpeedMax,
|
|
|
|
|
double MaxFlow,
|
|
|
|
|
double SetpointUsagePressure,
|
|
|
|
|
double SetpointUsageAxialLoad,
|
|
|
|
|
double SetpointUsageRotorTorque,
|
|
|
|
|
double SetpointUsageRopPlan,
|
|
|
|
|
double DrilledTime
|
|
|
|
|
) CalcAggregate(Span<DataSaubStatDto> span)
|
|
|
|
|
{
|
|
|
|
|
var sumPressure = 0.0;
|
|
|
|
|
var sumAxialLoadSp = 0.0;
|
|
|
|
|
var sumAxialLoad = 0.0;
|
|
|
|
|
var sumRotorTorqueSp = 0.0;
|
|
|
|
|
var sumRotorTorque = 0.0;
|
|
|
|
|
var sumBlockSpeedSp = 0.0;
|
|
|
|
|
var sumRotorSpeed = 0.0;
|
|
|
|
|
var maxFlow = 0.0;
|
|
|
|
|
var maxRotorTorque = 0.0;
|
|
|
|
|
var maxRotorSpeed = 0.0;
|
|
|
|
|
var sumDiffDepthByPressure = 0.0;
|
|
|
|
|
var sumDiffDepthByAxialLoad = 0.0;
|
|
|
|
|
var sumDiffDepthByRotorTorque = 0.0;
|
|
|
|
|
var sumDiffDepthByRopPlan = 0.0;
|
|
|
|
|
|
|
|
|
|
var diffDepthTotal = 0.0;
|
|
|
|
|
var drilledTime = 0.0;
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < span.Length; i++)
|
2024-02-12 16:55:50 +05:00
|
|
|
|
{
|
2024-02-14 13:43:19 +05:00
|
|
|
|
var diffDepth = span[i].DepthEnd - span[i].DepthStart;
|
|
|
|
|
|
|
|
|
|
sumPressure += diffDepth * (span[i].Pressure - (span[i].PressureIdle ?? 0.0));
|
|
|
|
|
sumAxialLoadSp += diffDepth * (span[i].AxialLoadSp ?? 0);
|
|
|
|
|
sumAxialLoad += diffDepth * span[i].AxialLoad;
|
|
|
|
|
sumRotorTorqueSp += diffDepth * (span[i].RotorTorqueSp ?? 0);
|
|
|
|
|
sumRotorTorque += diffDepth * span[i].RotorTorque;
|
|
|
|
|
sumBlockSpeedSp += diffDepth * (span[i].BlockSpeedSp ?? 0);
|
|
|
|
|
sumRotorSpeed += diffDepth * span[i].RotorSpeed;
|
|
|
|
|
maxFlow = span[i].Flow > maxFlow ? span[i].Flow : maxFlow;
|
|
|
|
|
maxRotorTorque = span[i].RotorTorque > maxRotorTorque ? span[i].RotorTorque : maxRotorTorque;
|
|
|
|
|
maxRotorSpeed = span[i].RotorSpeed > maxRotorSpeed ? span[i].RotorSpeed : maxRotorSpeed;
|
|
|
|
|
|
|
|
|
|
if (span[i].IdFeedRegulator == LimitingParameterDto.Pressure)
|
|
|
|
|
sumDiffDepthByPressure += diffDepth;
|
|
|
|
|
if (span[i].IdFeedRegulator == LimitingParameterDto.AxialLoad)
|
|
|
|
|
sumDiffDepthByAxialLoad += diffDepth;
|
|
|
|
|
if (span[i].IdFeedRegulator == LimitingParameterDto.RotorTorque)
|
|
|
|
|
sumDiffDepthByRotorTorque += diffDepth;
|
|
|
|
|
if (span[i].IdFeedRegulator == LimitingParameterDto.RopPlan)
|
|
|
|
|
sumDiffDepthByRopPlan += diffDepth;
|
|
|
|
|
|
|
|
|
|
diffDepthTotal += diffDepth;
|
|
|
|
|
drilledTime += (span[i].DateEnd - span[i].DateStart).TotalHours;
|
2024-02-12 16:55:50 +05:00
|
|
|
|
}
|
2024-02-14 13:43:19 +05:00
|
|
|
|
return (
|
|
|
|
|
Pressure: sumPressure / diffDepthTotal,
|
|
|
|
|
AxialLoadSp: sumAxialLoadSp / diffDepthTotal,
|
|
|
|
|
AxialLoad: sumAxialLoad / diffDepthTotal,
|
|
|
|
|
RotorTorqueSp: sumRotorTorqueSp / diffDepthTotal,
|
|
|
|
|
RotorTorque: sumRotorTorque / diffDepthTotal,
|
|
|
|
|
RotorTorqueMax: maxRotorTorque,
|
|
|
|
|
BlockSpeedSp: sumBlockSpeedSp / diffDepthTotal,
|
|
|
|
|
RotorSpeed: sumRotorSpeed / diffDepthTotal,
|
|
|
|
|
RotorSpeedMax: maxRotorSpeed,
|
|
|
|
|
MaxFlow: maxFlow,
|
2024-02-19 12:35:48 +05:00
|
|
|
|
SetpointUsagePressure: sumDiffDepthByPressure * 100 / diffDepthTotal,
|
|
|
|
|
SetpointUsageAxialLoad: sumDiffDepthByAxialLoad * 100 / diffDepthTotal,
|
|
|
|
|
SetpointUsageRotorTorque: sumDiffDepthByRotorTorque * 100 / diffDepthTotal,
|
2024-06-05 12:08:38 +05:00
|
|
|
|
SetpointUsageRopPlan: sumDiffDepthByRopPlan * 100 / diffDepthTotal,
|
2024-02-14 13:43:19 +05:00
|
|
|
|
DrilledTime: drilledTime
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-02-12 16:55:50 +05:00
|
|
|
|
|
2024-02-15 12:09:33 +05:00
|
|
|
|
private static bool IsNewInterval(DataSaubStatDto currentElem, DataSaubStatDto firstElem, DataSaubStatRequest request)
|
2024-02-14 13:43:19 +05:00
|
|
|
|
{
|
2024-02-15 12:09:33 +05:00
|
|
|
|
static bool IsNewElemBySpeed(double currentSpeed, double firstSpeed)
|
2024-02-12 16:55:50 +05:00
|
|
|
|
{
|
2024-02-14 13:43:19 +05:00
|
|
|
|
//2. Изменение уставки скорости подачи от первого значения в начале интервала при условии:
|
|
|
|
|
//скорость > 80 м/ч => изменение уставки на ± 20 м/ч;
|
|
|
|
|
//скорость > 30 м/ч => изменение уставки на ± 15 м/ч;
|
|
|
|
|
//скорость <= 30 м/ч => изменение уставки на ± 5 м/ч;
|
|
|
|
|
if (firstSpeed > 80)
|
|
|
|
|
return Math.Abs(currentSpeed - firstSpeed) >= 20;
|
|
|
|
|
else if (firstSpeed > 30)
|
|
|
|
|
return Math.Abs(currentSpeed - firstSpeed) >= 15;
|
|
|
|
|
else
|
|
|
|
|
return Math.Abs(currentSpeed - firstSpeed) >= 5;
|
2024-02-12 16:55:50 +05:00
|
|
|
|
}
|
2024-02-14 13:43:19 +05:00
|
|
|
|
|
|
|
|
|
var isNewElem = (currentElem.IdCategory != firstElem.IdCategory)
|
|
|
|
|
|| (Math.Abs(currentElem.Pressure - firstElem.Pressure) >= request.DeltaPressure)
|
|
|
|
|
|| (Math.Abs(currentElem.AxialLoad - firstElem.AxialLoad) >= request.DeltaAxialLoad)
|
|
|
|
|
|| (Math.Abs(currentElem.RotorTorque - firstElem.RotorTorque) >= request.DeltaRotorTorque)
|
|
|
|
|
|| (Math.Abs((currentElem.AxialLoadSp ?? 0) - (firstElem.AxialLoadSp ?? 0)) >= request.DeltaAxialLoadSp)
|
|
|
|
|
|| (Math.Abs((currentElem.RotorTorqueSp ?? 0) - (firstElem.RotorTorqueSp ?? 0)) >= request.DeltaRotorTorqueSp)
|
2024-02-15 12:09:33 +05:00
|
|
|
|
|| (IsNewElemBySpeed(currentElem.Speed, firstElem.Speed));
|
2024-02-14 13:43:19 +05:00
|
|
|
|
return isNewElem;
|
2024-02-12 16:55:50 +05:00
|
|
|
|
}
|
|
|
|
|
}
|