Убран лишний код

This commit is contained in:
Olga Nemt 2024-10-07 11:26:41 +05:00
parent 73d60d1464
commit d5a4b3d7fe
4 changed files with 20 additions and 23 deletions

View File

@ -20,7 +20,7 @@ public interface IDataSaubStatDrillingQualityRepository : ITelemetryDataEditorSe
/// <param name="leDate">конечная дата</param>
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<DataSaubStatDto>> GetAsync(int idTelemetry, DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken token);
Task<IEnumerable<DataSaubStatDrillingQualityDto>> GetAsync(int idTelemetry, DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken token);
/// <summary>
/// Получение последних по дате окончания бурения записей качества в разрезе телеметрий

View File

@ -22,7 +22,6 @@ public class DataSaubStatDrillingQualityRepository : IDataSaubStatDrillingQualit
{
db = dbContext;
this.telemetryService = telemetryService;
}
public async Task<IEnumerable<DataSaubStatDrillingQualityDto>> GetLastsAsync(int[] idTelemetries, CancellationToken token)
@ -41,22 +40,21 @@ public class DataSaubStatDrillingQualityRepository : IDataSaubStatDrillingQualit
return result;
}
public async Task<IEnumerable<DataSaubStatDto>> GetAsync(int idTelemetry, DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken token)
public async Task<IEnumerable<DataSaubStatDrillingQualityDto>> GetAsync(int idTelemetry, DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken token)
{
var timeSpan = TimeSpan.FromHours(telemetryService.GetTimezone(idTelemetry).Hours);
var geDateUtc = geDate.ToUniversalTime();
var leDateUtc = leDate.ToUniversalTime();
var stats = await db.Set<DataSaubStat>()
var stats = await db.Set<DataSaubStatDrillingQuality>()
.Where(s => s.IdTelemetry == idTelemetry)
.Where(s => s.DateStart >= geDateUtc)
.Where(s => s.DateEnd <= leDateUtc)
.ToArrayAsync(token);
//todo
//var result = stats.Select(s => ConvertToDto(s, timeSpan));
//return result;
return null;
var result = stats.Select(s => ConvertToDto(s, timeSpan));
return result;
}
public async Task<int> InsertRangeAsync(IEnumerable<DataSaubStatDrillingQualityDto> dataSaubStats, CancellationToken token)
@ -84,9 +82,9 @@ public class DataSaubStatDrillingQualityRepository : IDataSaubStatDrillingQualit
return entity;
}
private IQueryable<DataSaubStat> BuildQuery(TelemetryPartDeleteRequest request)
private IQueryable<DataSaubStatDrillingQuality> BuildQuery(TelemetryPartDeleteRequest request)
{
var query = db.Set<DataSaubStat>()
var query = db.Set<DataSaubStatDrillingQuality>()
.Where(o => o.IdTelemetry == request.IdTelemetry);
if (request.LeDate is not null)
@ -107,7 +105,7 @@ public class DataSaubStatDrillingQualityRepository : IDataSaubStatDrillingQualit
public async Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
{
var query = BuildQuery(request);
db.Set<DataSaubStat>().RemoveRange(query);
db.Set<DataSaubStatDrillingQuality>().RemoveRange(query);
return await db.SaveChangesAsync(token);
}
}

View File

@ -3,6 +3,7 @@ using AsbCloudApp.Data.SAUB;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using AsbCloudInfrastructure.Services.SAUB;
using System;
using System.Collections.Generic;
using System.Linq;
@ -15,8 +16,8 @@ namespace AsbCloudInfrastructure.Services;
public class DataSaubStatDrillingQualityService : IDataSaubStatService
{
private IDataSaubStatDrillingQualityRepository dataSaubStatDrillingQualityRepository;
private ITelemetryDataCache<TelemetryDataSaubDto> telemetryDataCache;
private ITelemetryDataSaubService dataSaubService;
private ITelemetryDataCache<TelemetryDataSaubDto> telemetryDataCache;
public Dictionary<int, Predicate<TelemetryDataSaubDto>> QualitySettingsForFeedRegulators { get; }
@ -26,8 +27,8 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatService
ITelemetryDataSaubService dataSaubService)
{
this.dataSaubStatDrillingQualityRepository = dataSaubStatDrillingQualityRepository;
this.telemetryDataCache = telemetryDataCache;
this.dataSaubService = dataSaubService;
this.telemetryDataCache = telemetryDataCache;
Predicate<TelemetryDataSaubDto> hasQualityWithIdFeedRegulator1 = (TelemetryDataSaubDto spanItem)
=> (spanItem.BlockSpeed >= spanItem.BlockSpeedSp * 0.95
@ -55,13 +56,11 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatService
public async Task CreateStatAsync(int lastDaysFilter, Action<string, double?> onProgressCallback, CancellationToken token)
{
//to do
var cacheRequest = new TelemetryDataRequest()
{
GeDate = DateTime.UtcNow.AddDays(-5000)
GeDate = DateTime.UtcNow.AddDays(-lastDaysFilter)
};
var idTelemetries = new int[119];
//telemetryDataCache.GetIds(cacheRequest).ToArray();
var idTelemetries = telemetryDataCache.GetIds(cacheRequest).ToArray();
if (!idTelemetries.Any())
return;
@ -116,7 +115,7 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatService
var indexStart = 0;
var indexEnd = 0;
while (indexEnd < dataSaub.Count()-1)
while (indexEnd < dataSaub.Count())
{
indexStart = Array.FindIndex(dataSaub, indexEnd, t => t.IdFeedRegulator == idFeedRegulator);
if (indexStart < 0)
@ -134,7 +133,7 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatService
var subset = dataSaub.AsSpan(indexStart, length);
if (length <= 2 || (subset[^1].WellDepth - subset[0].WellDepth) < 0.3)
if (length <= 2 || (subset[^1].WellDepth - subset[0].WellDepth) < 0.15)
continue; // мелкие выборки не учитываем.

View File

@ -7,10 +7,10 @@
}
},
"ConnectionStrings": {
"DefaultConnection": "Host=192.168.0.10;Database=postgres;Username=postgres;Password=q;Persist Security Info=True",
"DebugConnection": "Host=192.168.0.10;Database=postgres;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True",
"TestConnection": "Host=192.168.0.10;Database=test;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True",
"LocalConnection": "Host=192.168.0.10;Database=postgres;Username=postgres;Password=q;Persist Security Info=True"
"DefaultConnection": "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True",
"DebugConnection": "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True",
"TestConnection": "Host=localhost;Database=test;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True",
"LocalConnection": "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True"
},
"AllowedHosts": "*",
"ContentPath": "../data",