forked from ddrilling/AsbCloudServer
CS2-33: Сохранение аналитики целой операцией с продолжительностью.
This commit is contained in:
parent
c4b2c548f9
commit
faaa4bedda
@ -5,6 +5,7 @@ namespace AsbCloudApp.Services
|
||||
{
|
||||
public interface ISaubDataCache
|
||||
{
|
||||
TelemetryAnalysis CurrentAnalysis { get; set; }
|
||||
IEnumerable<DataSaubBase> GetOrCreateCache(int telemetryId);
|
||||
void AddData(DataSaubBase data);
|
||||
}
|
||||
|
@ -38,8 +38,11 @@ namespace AsbCloudDb.Model
|
||||
[Column("duration_sec"), Comment("Кол-во секунд после предыдущей операции")]
|
||||
public int Duration { get; set; }
|
||||
|
||||
[Column("well_depth"), Comment("Глубина, на которой закончилась операция")]
|
||||
public double WellDepth { get; set; }
|
||||
[Column("operation_start_depth"), Comment("Глубина, на которой началась операция")]
|
||||
public double? OperationStartDepth { get; set; }
|
||||
|
||||
[Column("operation_end_depth"), Comment("Глубина, на которой закончилась операция")]
|
||||
public double? OperationEndDepth { get; set; }
|
||||
|
||||
[Column("is_well_depth_increasing"), Comment("Глубина забоя увеличивается")]
|
||||
public bool IsWellDepthIncreasing { get; set; }
|
||||
|
@ -185,7 +185,8 @@ namespace AsbCloudInfrastructure.Services
|
||||
IdTelemetry = dataSaubBases.First().IdTelemetry,
|
||||
UnixDate = (long)(lastSaubDate - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds,
|
||||
Duration = (int)(dataSaubBases.Last().Date - dataSaubBases.ElementAt(dataSaubBases.Count() - 2).Date).TotalSeconds,
|
||||
WellDepth = (double)dataSaubBases.Last().WellDepth,
|
||||
OperationStartDepth = null,
|
||||
OperationEndDepth = null,
|
||||
IsWellDepthDecreasing = LinearFunctionCalculator.IsValueGoesDown(wellDepthChangingIndex, -0.0001),
|
||||
IsWellDepthIncreasing = LinearFunctionCalculator.IsValueGoesUp(wellDepthChangingIndex, 0.0001),
|
||||
IsBitPositionDecreasing = LinearFunctionCalculator.IsValueGoesDown(bitPositionChangingIndex, -0.0001),
|
||||
|
@ -106,9 +106,23 @@ namespace AsbCloudInfrastructure.Services
|
||||
var dataSaubs = saubDataCache.GetOrCreateCache(dataSaub.IdTelemetry)
|
||||
.OrderBy(d => d.Date);
|
||||
|
||||
var drillingAnalysis = analyticsService.GetDrillingAnalysis(dataSaubs);
|
||||
var telemetryAnalysis = analyticsService.GetDrillingAnalysis(dataSaubs);
|
||||
|
||||
db.TelemetryAnalysis.Add(drillingAnalysis);
|
||||
if(saubDataCache.CurrentAnalysis is null)
|
||||
saubDataCache.CurrentAnalysis = telemetryAnalysis;
|
||||
|
||||
if (saubDataCache.CurrentAnalysis.IdOperation == telemetryAnalysis.IdOperation)
|
||||
{
|
||||
saubDataCache.CurrentAnalysis.Duration +=
|
||||
telemetryAnalysis.Duration;
|
||||
saubDataCache.CurrentAnalysis.OperationEndDepth = item.WellDepth;
|
||||
}
|
||||
else
|
||||
{
|
||||
db.TelemetryAnalysis.Add(saubDataCache.CurrentAnalysis);
|
||||
saubDataCache.CurrentAnalysis = telemetryAnalysis;
|
||||
saubDataCache.CurrentAnalysis.OperationStartDepth = item.WellDepth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,9 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
public class SaubDataCache : ISaubDataCache
|
||||
{
|
||||
private readonly Dictionary<int, List<DataSaubBase>> saubData =
|
||||
public TelemetryAnalysis CurrentAnalysis { get; set; }
|
||||
|
||||
private readonly Dictionary<int, List<DataSaubBase>> saubData =
|
||||
new Dictionary<int, List<DataSaubBase>>();
|
||||
|
||||
public IEnumerable<DataSaubBase> GetOrCreateCache(int telemetryId)
|
||||
|
Loading…
Reference in New Issue
Block a user