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>
|
||||||
/// Уставка план
|
/// Уставка план
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double SetPointPlan { get; set; }
|
public double? SetpointPlan { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Уставка факт
|
/// Уставка факт
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double? SetPointFact { get; set; }
|
public double? SetpointFact { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Факт
|
/// Факт
|
||||||
@ -35,7 +35,7 @@ namespace AsbCloudApp.Data.ProcessMap
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Процент бурения по уставке ,%
|
/// Процент бурения по уставке ,%
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double? PercDrillingSetPoint { get; set; }
|
public double? PercDrillingSetpoint { get; set; }
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace AsbCloudApp.Data.ProcessMap
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Data.ProcessMap
|
|
||||||
{
|
{
|
||||||
#nullable enable
|
#nullable enable
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -20,22 +14,22 @@ namespace AsbCloudApp.Data.ProcessMap
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перепад давления, атм
|
/// Перепад давления, атм
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ProcessMapReportParamsDto PressureDiff { get; set; } = null!;
|
public ProcessMapReportParamsDto PressureDiff { get; set; } = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Нагрузка, т
|
/// Нагрузка, т
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ProcessMapReportParamsDto AxialLoad { get; set; } = null!;
|
public ProcessMapReportParamsDto AxialLoad { get; set; } = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Момент на ВСП, кНхМ
|
/// Момент на ВСП, кНхМ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ProcessMapReportParamsDto TopDriveTorque { get; set; } = null!;
|
public ProcessMapReportParamsDto TopDriveTorque { get; set; } = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ограничение скорости, м/ч
|
/// Ограничение скорости, м/ч
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ProcessMapReportParamsDto SpeedLimit { get; set; } = null!;
|
public ProcessMapReportParamsDto SpeedLimit { get; set; } = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Процент использования системы АПД, %
|
/// Процент использования системы АПД, %
|
||||||
|
@ -49,14 +49,14 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
|||||||
var processMapDtos = (await processMapRepository.GetByIdWellAsync(idWell, token))!;
|
var processMapDtos = (await processMapRepository.GetByIdWellAsync(idWell, token))!;
|
||||||
|
|
||||||
var idTelemetry = telemetryService.GetOrDefaultIdTelemetryByIdWell(idWell)!.Value;
|
var idTelemetry = telemetryService.GetOrDefaultIdTelemetryByIdWell(idWell)!.Value;
|
||||||
IEnumerable<ProcessTelemetrySaubStat> telemetryStat = await GetTelemetryDataAsync(idTelemetry, token);
|
IEnumerable<ProcessTelemetrySaubStat> telemetryDataStat = await GetTelemetryDataAsync(idTelemetry, token);
|
||||||
|
|
||||||
var result = allFactDrillingOperations
|
var result = allFactDrillingOperations
|
||||||
.GroupBy(o => o.IdWellSectionType)
|
.GroupBy(o => o.IdWellSectionType)
|
||||||
.SelectMany(sectionOperations =>
|
.SelectMany(sectionOperations =>
|
||||||
{
|
{
|
||||||
var sectionProcessMap = processMapDtos.Where(p => p.IdWellSectionType == sectionOperations.Key);
|
var sectionProcessMap = processMapDtos.Where(p => p.IdWellSectionType == sectionOperations.Key);
|
||||||
return HandleSections(sectionOperations, sectionProcessMap);
|
return HandleSections(sectionOperations, sectionProcessMap, telemetryDataStat);
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
@ -114,7 +114,8 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
|||||||
|
|
||||||
private static IEnumerable<ProcessMapReportDto> HandleSections(
|
private static IEnumerable<ProcessMapReportDto> HandleSections(
|
||||||
IEnumerable<WellOperationDto> sectionOperations,
|
IEnumerable<WellOperationDto> sectionOperations,
|
||||||
IEnumerable<ProcessMapDto> sectionProcessMap )
|
IEnumerable<ProcessMapDto> sectionProcessMap,
|
||||||
|
IEnumerable<ProcessTelemetrySaubStat> telemetryDataStat)
|
||||||
{
|
{
|
||||||
var minDepth = sectionOperations.Min(o => o.DepthStart);
|
var minDepth = sectionOperations.Min(o => o.DepthStart);
|
||||||
var maxDepth = sectionOperations.Max(o => o.DepthEnd);
|
var maxDepth = sectionOperations.Max(o => o.DepthEnd);
|
||||||
@ -123,7 +124,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
|||||||
var result = new ProcessMapReportDto[depthIntervals.Length];
|
var result = new ProcessMapReportDto[depthIntervals.Length];
|
||||||
|
|
||||||
for (var i = 0; i < depthIntervals.Length; i++ )
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
@ -131,7 +132,8 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
|||||||
private static ProcessMapReportDto MakeProcessMapReportDto(
|
private static ProcessMapReportDto MakeProcessMapReportDto(
|
||||||
(double min, double max) depthInterval,
|
(double min, double max) depthInterval,
|
||||||
IEnumerable<WellOperationDto> sectionOperations,
|
IEnumerable<WellOperationDto> sectionOperations,
|
||||||
IEnumerable<ProcessMapDto> sectionProcessMap)
|
IEnumerable<ProcessMapDto> sectionProcessMap,
|
||||||
|
IEnumerable<ProcessTelemetrySaubStat> telemetryDataStat)
|
||||||
{
|
{
|
||||||
var dto = new ProcessMapReportDto{
|
var dto = new ProcessMapReportDto{
|
||||||
DepthStart = depthInterval.min
|
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 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 intervalProcessMap = sectionProcessMap.Where(map => map.DepthEnd >= depthInterval.min && map.DepthStart <= depthInterval.max);
|
||||||
|
var intervalTelemetryDataStat = CalcIntervalTelemetryDataStat(depthInterval, telemetryDataStat);
|
||||||
|
|
||||||
if (intervalOperations.Any())
|
if (intervalOperations.Any())
|
||||||
{
|
{
|
||||||
var firstIntervalOperation = intervalOperations.First();
|
var firstIntervalOperation = intervalOperations.First();
|
||||||
@ -151,40 +155,98 @@ namespace AsbCloudInfrastructure.Services.ProcessMap
|
|||||||
dto.IdWellSectionType = firstIntervalOperation.IdWellSectionType;
|
dto.IdWellSectionType = firstIntervalOperation.IdWellSectionType;
|
||||||
dto.WellSectionTypeName = firstIntervalOperation.WellSectionTypeName;
|
dto.WellSectionTypeName = firstIntervalOperation.WellSectionTypeName;
|
||||||
dto.MechDrillingHours = CalcHours(depthInterval, sectionOperations);
|
dto.MechDrillingHours = CalcHours(depthInterval, sectionOperations);
|
||||||
dto.Slide = CalcDrillStat(depthInterval, slideOperations, intervalProcessMap);
|
dto.Slide = CalcDrillModeStat(depthInterval, slideOperations, intervalProcessMap, intervalTelemetryDataStat);
|
||||||
dto.Rotor = CalcDrillStat(depthInterval, rotorOperations, intervalProcessMap);
|
dto.Rotor = CalcDrillModeStat(depthInterval, rotorOperations, intervalProcessMap, intervalTelemetryDataStat);
|
||||||
}
|
}
|
||||||
return dto;
|
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,
|
(double min, double max) depthInterval,
|
||||||
IEnumerable<WellOperationDto> intervalModeOperations,
|
IEnumerable<WellOperationDto> intervalModeOperations,
|
||||||
IEnumerable<ProcessMapDto> intervalProcessMap)
|
IEnumerable<ProcessMapDto> intervalProcessMap,
|
||||||
|
ProcessTelemetrySaubStat? telemetryDataStat)
|
||||||
{
|
{
|
||||||
var dto = new ProcessMapReportRowDto();
|
var dto = new ProcessMapReportRowDto();
|
||||||
if(intervalModeOperations.Any())
|
if (intervalModeOperations.Any())
|
||||||
{
|
{
|
||||||
var deltaDepth = CalcDeltaDepth(depthInterval, intervalModeOperations);
|
var deltaDepth = CalcDeltaDepth(depthInterval, intervalModeOperations);
|
||||||
dto.DeltaDepth = deltaDepth;
|
dto.DeltaDepth = deltaDepth;
|
||||||
dto.Rop = deltaDepth / CalcHours(depthInterval, intervalModeOperations);
|
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;
|
if (telemetryDataStat is not null)
|
||||||
}
|
|
||||||
|
|
||||||
private static ProcessMapReportParamsDto CalcPressureDiff(
|
|
||||||
(double min, double max) depthInterval,
|
|
||||||
IEnumerable<ProcessMapDto> intervalProcessMap)
|
|
||||||
{
|
|
||||||
var dto = new ProcessMapReportParamsDto();
|
|
||||||
if (intervalProcessMap.Any())
|
|
||||||
{
|
{
|
||||||
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)
|
private static double CalcDeltaDepth((double min, double max) depthInterval, IEnumerable<WellOperationDto> intervalOperations)
|
||||||
|
Loading…
Reference in New Issue
Block a user