Правка алгоритма формирования записей в кеш-таблицу Data_Saub_Stat

This commit is contained in:
Olga Nemt 2024-03-14 14:57:00 +05:00
parent 63638219a2
commit 8b761779fd

View File

@ -34,7 +34,7 @@ namespace AsbCloudInfrastructure.Background.PeriodicWorks
var cacheRequest = new TelemetryDataRequest()
{
GeDate = DateTime.UtcNow.AddDays(-Gap)
GeDate = DateTime.UtcNow.AddDays(-100)
};
var idTelemetries = telemetryDataCache.GetIds(cacheRequest).ToArray();
@ -49,6 +49,10 @@ namespace AsbCloudInfrastructure.Background.PeriodicWorks
for( var i =0; i < idTelemetries.Length; i++)
{
var idTelemetry = idTelemetries[i];
if(idTelemetry == 783)
{
;
}
var lastDate = stats.FirstOrDefault(s => s.IdTelemetry == idTelemetry)?.DateEnd.ToUniversalTime() ?? DateTimeOffset.UnixEpoch;
var statsCount = await CreateStatForTelemetryFromDate(idTelemetry, lastDate, dataSaubService, dataSaubStatRepo, detectedOperationRepository, token);
onProgressCallback($"Calculate stat for telemetry: {idTelemetry}; from {lastDate}; results count: {statsCount};", 100*i / idTelemetries.Length);
@ -154,13 +158,19 @@ namespace AsbCloudInfrastructure.Background.PeriodicWorks
var hasOscillation = EnabledSubsystemsFlags.AutoOscillation.HasEnabledSubsystems(operation.EnabledSubsystems);
var aggregatedValues = CalcAggregate(span);
var dateStart = span[0].DateTime;
var dateEnd = span[^1].DateTime;
var depthStart = span[0].WellDepth;
var depthEnd = span[^1].WellDepth;
var speed = ((depthEnd - depthStart) / (dateEnd - dateStart).TotalHours);
var processMapDrillingCacheItem = new DataSaubStatDto
{
DateStart = operation.DateStart,
DateEnd = operation.DateEnd,
DepthStart = operation.DepthStart,
DepthEnd = operation.DepthEnd,
Speed = (operation.DepthEnd - operation.DepthStart) / ((operation.DateEnd - operation.DateStart).TotalHours),
DateStart = dateStart,
DateEnd = dateEnd,
DepthStart = depthStart,
DepthEnd = depthEnd,
Speed = speed,
BlockSpeedSp = span[0].BlockSpeedSp,
Pressure = aggregatedValues.Pressure,
PressureIdle = span[0].PressureIdle,