forked from ddrilling/AsbCloudServer
ProcessMapService calculations draft
This commit is contained in:
parent
f5becebbeb
commit
ac1c9aedb2
@ -15,12 +15,12 @@ namespace AsbCloudApp.Data.ProcessMap
|
||||
/// <summary>
|
||||
/// Уставка план
|
||||
/// </summary>
|
||||
public double SetPointPlan { get; set; }
|
||||
public double? SetpointPlan { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Уставка факт
|
||||
/// </summary>
|
||||
public double? SetPointFact { get; set; }
|
||||
public double? SetpointFact { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Факт
|
||||
@ -35,7 +35,7 @@ namespace AsbCloudApp.Data.ProcessMap
|
||||
/// <summary>
|
||||
/// Процент бурения по уставке ,%
|
||||
/// </summary>
|
||||
public double? PercDrillingSetPoint { get; set; }
|
||||
public double? PercDrillingSetpoint { get; set; }
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudApp.Data.ProcessMap
|
||||
namespace AsbCloudApp.Data.ProcessMap
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
@ -20,22 +14,22 @@ namespace AsbCloudApp.Data.ProcessMap
|
||||
/// <summary>
|
||||
/// Перепад давления, атм
|
||||
/// </summary>
|
||||
public ProcessMapReportParamsDto PressureDiff { get; set; } = null!;
|
||||
public ProcessMapReportParamsDto PressureDiff { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Нагрузка, т
|
||||
/// </summary>
|
||||
public ProcessMapReportParamsDto AxialLoad { get; set; } = null!;
|
||||
public ProcessMapReportParamsDto AxialLoad { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Момент на ВСП, кНхМ
|
||||
/// </summary>
|
||||
public ProcessMapReportParamsDto TopDriveTorque { get; set; } = null!;
|
||||
public ProcessMapReportParamsDto TopDriveTorque { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Ограничение скорости, м/ч
|
||||
/// </summary>
|
||||
public ProcessMapReportParamsDto SpeedLimit { get; set; } = null!;
|
||||
public ProcessMapReportParamsDto SpeedLimit { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Процент использования системы АПД, %
|
||||
|
@ -49,14 +49,14 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
||||
var processMapDtos = (await processMapRepository.GetByIdWellAsync(idWell, token))!;
|
||||
|
||||
var idTelemetry = telemetryService.GetOrDefaultIdTelemetryByIdWell(idWell)!.Value;
|
||||
IEnumerable<ProcessTelemetrySaubStat> telemetryStat = await GetTelemetryDataAsync(idTelemetry, token);
|
||||
IEnumerable<ProcessTelemetrySaubStat> telemetryDataStat = await GetTelemetryDataAsync(idTelemetry, token);
|
||||
|
||||
var result = allFactDrillingOperations
|
||||
.GroupBy(o => o.IdWellSectionType)
|
||||
.SelectMany(sectionOperations =>
|
||||
{
|
||||
var sectionProcessMap = processMapDtos.Where(p => p.IdWellSectionType == sectionOperations.Key);
|
||||
return HandleSections(sectionOperations, sectionProcessMap);
|
||||
return HandleSections(sectionOperations, sectionProcessMap, telemetryDataStat);
|
||||
})
|
||||
.ToList();
|
||||
|
||||
@ -114,7 +114,8 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
||||
|
||||
private static IEnumerable<ProcessMapReportDto> HandleSections(
|
||||
IEnumerable<WellOperationDto> sectionOperations,
|
||||
IEnumerable<ProcessMapDto> sectionProcessMap )
|
||||
IEnumerable<ProcessMapDto> sectionProcessMap,
|
||||
IEnumerable<ProcessTelemetrySaubStat> telemetryDataStat)
|
||||
{
|
||||
var minDepth = sectionOperations.Min(o => o.DepthStart);
|
||||
var maxDepth = sectionOperations.Max(o => o.DepthEnd);
|
||||
@ -123,7 +124,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
||||
var result = new ProcessMapReportDto[depthIntervals.Length];
|
||||
|
||||
for (var i = 0; i < depthIntervals.Length; i++ )
|
||||
result[i] = MakeProcessMapReportDto(depthIntervals[i], sectionOperations, sectionProcessMap);
|
||||
result[i] = MakeProcessMapReportDto(depthIntervals[i], sectionOperations, sectionProcessMap, telemetryDataStat);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -131,7 +132,8 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
||||
private static ProcessMapReportDto MakeProcessMapReportDto(
|
||||
(double min, double max) depthInterval,
|
||||
IEnumerable<WellOperationDto> sectionOperations,
|
||||
IEnumerable<ProcessMapDto> sectionProcessMap)
|
||||
IEnumerable<ProcessMapDto> sectionProcessMap,
|
||||
IEnumerable<ProcessTelemetrySaubStat> telemetryDataStat)
|
||||
{
|
||||
var dto = new ProcessMapReportDto{
|
||||
DepthStart = depthInterval.min
|
||||
@ -139,6 +141,8 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
||||
|
||||
var intervalOperations = sectionOperations.Where(o => o.DepthEnd >= depthInterval.min && o.DepthStart <= depthInterval.max);
|
||||
var intervalProcessMap = sectionProcessMap.Where(map => map.DepthEnd >= depthInterval.min && map.DepthStart <= depthInterval.max);
|
||||
var intervalTelemetryDataStat = CalcIntervalTelemetryDataStat(depthInterval, telemetryDataStat);
|
||||
|
||||
if (intervalOperations.Any())
|
||||
{
|
||||
var firstIntervalOperation = intervalOperations.First();
|
||||
@ -151,40 +155,98 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
||||
dto.IdWellSectionType = firstIntervalOperation.IdWellSectionType;
|
||||
dto.WellSectionTypeName = firstIntervalOperation.WellSectionTypeName;
|
||||
dto.MechDrillingHours = CalcHours(depthInterval, sectionOperations);
|
||||
dto.Slide = CalcDrillStat(depthInterval, slideOperations, intervalProcessMap);
|
||||
dto.Rotor = CalcDrillStat(depthInterval, rotorOperations, intervalProcessMap);
|
||||
dto.Slide = CalcDrillModeStat(depthInterval, slideOperations, intervalProcessMap, intervalTelemetryDataStat);
|
||||
dto.Rotor = CalcDrillModeStat(depthInterval, rotorOperations, intervalProcessMap, intervalTelemetryDataStat);
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
private static ProcessMapReportRowDto CalcDrillStat(
|
||||
private static ProcessTelemetrySaubStat? CalcIntervalTelemetryDataStat((double min, double max) depthInterval, IEnumerable<ProcessTelemetrySaubStat> telemetryDataStat)
|
||||
{
|
||||
ProcessTelemetrySaubStat[] data = telemetryDataStat
|
||||
.Where(d => d.WellDepthMin <= depthInterval.max && d.WellDepthMax >= depthInterval.min)
|
||||
.ToArray();
|
||||
|
||||
if (!data.Any())
|
||||
return null;
|
||||
|
||||
if (data.Length == 1)
|
||||
return data.First();
|
||||
|
||||
|
||||
var result = new ProcessTelemetrySaubStat
|
||||
{
|
||||
WellDepthMin = data.Min(d => d.WellDepthMin),
|
||||
WellDepthMax = data.Max(d => d.WellDepthMax),
|
||||
DateMin = data.Min(d => d.DateMin),
|
||||
DateMax = data.Max(d => d.DateMax),
|
||||
};
|
||||
|
||||
var intervalDeltaDepth = result.WellDepthMax - result.WellDepthMin;
|
||||
|
||||
foreach (var item in data)
|
||||
{
|
||||
var itemWeight = (item.WellDepthMax - item.WellDepthMin) / intervalDeltaDepth;
|
||||
|
||||
result.Pressure += item.Pressure * itemWeight;
|
||||
result.PressureSp += item.PressureSp * itemWeight;
|
||||
result.PressureSpRotor += item.PressureSpSlide * itemWeight;
|
||||
result.PressureIdle += item.PressureIdle * itemWeight;
|
||||
|
||||
result.AxialLoad += item.AxialLoad * itemWeight;
|
||||
result.AxialLoadSp += item.AxialLoadSp * itemWeight;
|
||||
result.AxialLoadLimitMax += item.AxialLoadLimitMax * itemWeight;
|
||||
|
||||
result.RotorTorque += item.RotorTorque * itemWeight;
|
||||
result.RotorTorqueSp += item.RotorTorqueSp * itemWeight;
|
||||
result.RotorTorqueLimitMax += item.RotorTorqueLimitMax * itemWeight;
|
||||
|
||||
result.BlockSpeed += item.BlockSpeed * itemWeight;
|
||||
result.BlockSpeedSp += item.BlockSpeedSp * itemWeight;
|
||||
result.BlockSpeedSpRotor += item.BlockSpeedSpRotor * itemWeight;
|
||||
result.BlockSpeedSpSlide += item.BlockSpeedSpSlide * itemWeight;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static ProcessMapReportRowDto CalcDrillModeStat(
|
||||
(double min, double max) depthInterval,
|
||||
IEnumerable<WellOperationDto> intervalModeOperations,
|
||||
IEnumerable<ProcessMapDto> intervalProcessMap)
|
||||
IEnumerable<ProcessMapDto> intervalProcessMap,
|
||||
ProcessTelemetrySaubStat? telemetryDataStat)
|
||||
{
|
||||
var dto = new ProcessMapReportRowDto();
|
||||
if(intervalModeOperations.Any())
|
||||
if (intervalModeOperations.Any())
|
||||
{
|
||||
var deltaDepth = CalcDeltaDepth(depthInterval, intervalModeOperations);
|
||||
dto.DeltaDepth = deltaDepth;
|
||||
dto.Rop = deltaDepth / CalcHours(depthInterval, intervalModeOperations);
|
||||
|
||||
dto.PressureDiff = CalcPressureDiff(depthInterval, intervalProcessMap);
|
||||
var processMapFirst = intervalProcessMap.First();
|
||||
|
||||
dto.PressureDiff.SetpointPlan = processMapFirst.Pressure.Plan;
|
||||
dto.AxialLoad.SetpointPlan = processMapFirst.AxialLoad.Plan;
|
||||
dto.TopDriveTorque.SetpointPlan = processMapFirst.TopDriveTorque.Plan;
|
||||
dto.SpeedLimit.SetpointPlan = double.NaN;
|
||||
};
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
private static ProcessMapReportParamsDto CalcPressureDiff(
|
||||
(double min, double max) depthInterval,
|
||||
IEnumerable<ProcessMapDto> intervalProcessMap)
|
||||
{
|
||||
var dto = new ProcessMapReportParamsDto();
|
||||
if (intervalProcessMap.Any())
|
||||
if (telemetryDataStat is not null)
|
||||
{
|
||||
dto.SetPointPlan = intervalProcessMap.First().Pressure.Plan;
|
||||
dto.PressureDiff.SetpointFact = telemetryDataStat.PressureSp;
|
||||
dto.PressureDiff.Fact = telemetryDataStat.Pressure;
|
||||
dto.PressureDiff.Limit = telemetryDataStat.PressureDeltaLimitMax;
|
||||
|
||||
dto.AxialLoad.SetpointFact = telemetryDataStat.AxialLoadSp;
|
||||
dto.AxialLoad.Fact = telemetryDataStat.AxialLoad;
|
||||
dto.AxialLoad.Limit = telemetryDataStat.AxialLoadLimitMax;
|
||||
|
||||
dto.TopDriveTorque.SetpointFact = telemetryDataStat.RotorTorqueSp;
|
||||
dto.TopDriveTorque.Fact = telemetryDataStat.RotorTorque;
|
||||
dto.TopDriveTorque.Limit = telemetryDataStat.RotorTorqueLimitMax;
|
||||
}
|
||||
throw new NotImplementedException();
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
private static double CalcDeltaDepth((double min, double max) depthInterval, IEnumerable<WellOperationDto> intervalOperations)
|
||||
|
Loading…
Reference in New Issue
Block a user