diff --git a/AsbCloudApp/Data/GTR/WitsRecordDto.cs b/AsbCloudApp/Data/GTR/WitsRecordDto.cs
index 28e6ba81..763b439b 100644
--- a/AsbCloudApp/Data/GTR/WitsRecordDto.cs
+++ b/AsbCloudApp/Data/GTR/WitsRecordDto.cs
@@ -13,6 +13,11 @@ namespace AsbCloudApp.Data.GTR
///
public int Id { get; set; }
+ ///
+ /// Id телеметрии
+ ///
+ public int IdTelemetry { get; set; }
+
///
/// Дата создания записи
///
diff --git a/AsbCloudApp/Services/WITS/IGtrService.cs b/AsbCloudApp/Services/WITS/IGtrService.cs
new file mode 100644
index 00000000..c66831cf
--- /dev/null
+++ b/AsbCloudApp/Services/WITS/IGtrService.cs
@@ -0,0 +1,41 @@
+using AsbCloudApp.Data.GTR;
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace AsbCloudApp.Services.WITS
+{
+#nullable enable
+ ///
+ /// данные ГТИ
+ ///
+ public interface IGtrService
+
+ {
+ ///
+ /// добавить/изменить данные (для панели бурильщика)
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task UpdateAsync(string uid, IEnumerable dtos, CancellationToken token);
+
+ ///
+ /// получить данные для клиента
+ ///
+ ///
+ ///
+ ///
+ /// кол-во элементов до которых эти данные прореживаются
+ ///
+ ///
+ Task> GetAsync(int idWell,
+ DateTime dateBegin = default, double intervalSec = 600d,
+ int approxPointsCount = 1024, CancellationToken token = default);
+
+
+ }
+#nullable disable
+}
diff --git a/AsbCloudDb/Model/AsbCloudDbContext.cs b/AsbCloudDb/Model/AsbCloudDbContext.cs
index d749ceb7..4d94b290 100644
--- a/AsbCloudDb/Model/AsbCloudDbContext.cs
+++ b/AsbCloudDb/Model/AsbCloudDbContext.cs
@@ -57,9 +57,9 @@ namespace AsbCloudDb.Model
public virtual DbSet TelemetryWirelineRunOut => Set();
// GTR WITS
- public DbSet WitsFloat => Set();
- public DbSet WitsInt => Set();
- public DbSet WitsStr => Set();
+ public DbSet WitsItemFloat => Set();
+ public DbSet WitsItemInt => Set();
+ public DbSet WitsItemString => Set();
// WITS
public DbSet Record1 => Set();
@@ -340,21 +340,21 @@ namespace AsbCloudDb.Model
.HasJsonConversion();
});
- modelBuilder.Entity(entity =>
- {
+ modelBuilder.Entity(entity =>
+ {
entity.HasKey(
nameof(ITelemetryData.IdTelemetry),
nameof(WitsItemBase.IdRecord),
nameof(WitsItemBase.IdItem));
});
- modelBuilder.Entity(entity =>
+ modelBuilder.Entity(entity =>
{
entity.HasKey(
nameof(ITelemetryData.IdTelemetry),
nameof(WitsItemBase.IdRecord),
nameof(WitsItemBase.IdItem));
});
- modelBuilder.Entity(entity =>
+ modelBuilder.Entity(entity =>
{
entity.HasKey(
nameof(ITelemetryData.IdTelemetry),
diff --git a/AsbCloudDb/Model/GTR/WitsFloat.cs b/AsbCloudDb/Model/GTR/WitsFloat.cs
deleted file mode 100644
index e993b6f6..00000000
--- a/AsbCloudDb/Model/GTR/WitsFloat.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using System.ComponentModel.DataAnnotations.Schema;
-namespace AsbCloudDb.Model.GTR
-{
- [Table("t_wits_float"), Comment("таблица данных ГТИ с типом значения float")]
- public class WitsFloat : WitsItemBase { }
-}
diff --git a/AsbCloudDb/Model/GTR/WitsInt.cs b/AsbCloudDb/Model/GTR/WitsInt.cs
deleted file mode 100644
index 22922688..00000000
--- a/AsbCloudDb/Model/GTR/WitsInt.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using System.ComponentModel.DataAnnotations.Schema;
-
-namespace AsbCloudDb.Model.GTR
-{
- [Table("t_wits_int"), Comment("таблица данных ГТИ с типом значения int16 int32")]
- public class WitsInt : WitsItemBase, ITelemetryData { }
-}
diff --git a/AsbCloudDb/Model/GTR/WitsItemBase.cs b/AsbCloudDb/Model/GTR/WitsItemBase.cs
index 0127997d..c81d26b9 100644
--- a/AsbCloudDb/Model/GTR/WitsItemBase.cs
+++ b/AsbCloudDb/Model/GTR/WitsItemBase.cs
@@ -1,4 +1,5 @@
-using System;
+using Microsoft.EntityFrameworkCore;
+using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model.GTR
@@ -24,7 +25,12 @@ namespace AsbCloudDb.Model.GTR
public virtual Telemetry? Telemetry { get; set; }
}
+ [Table("t_wits_string"), Comment("таблица данных ГТИ с типом значения string")]
public class WitsItemString : WitsItemBase { }
+
+ [Table("t_wits_float"), Comment("таблица данных ГТИ с типом значения ")]
public class WitsItemFloat : WitsItemBase { }
+
+ [Table("t_wits_int"), Comment("таблица данных ГТИ с типом значения int16 int32")]
public class WitsItemInt : WitsItemBase { }
}
diff --git a/AsbCloudDb/Model/GTR/WitsStr.cs b/AsbCloudDb/Model/GTR/WitsStr.cs
deleted file mode 100644
index 97ff2dc9..00000000
--- a/AsbCloudDb/Model/GTR/WitsStr.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using System.ComponentModel.DataAnnotations.Schema;
-
-namespace AsbCloudDb.Model.GTR
-{
- [Table("t_wits_string"), Comment("таблица данных ГТИ с типом значения string")]
- public class WitsStr: WitsItemBase { }
-}
diff --git a/AsbCloudDb/Model/IAsbCloudDbContext.cs b/AsbCloudDb/Model/IAsbCloudDbContext.cs
index 980ef455..55a21b7c 100644
--- a/AsbCloudDb/Model/IAsbCloudDbContext.cs
+++ b/AsbCloudDb/Model/IAsbCloudDbContext.cs
@@ -48,9 +48,9 @@ namespace AsbCloudDb.Model
DbSet WellOperationCategories { get; }
DbSet WellSectionTypes { get; }
DbSet WellTypes { get; }
- DbSet WitsFloat { get; }
- DbSet WitsInt { get; }
- DbSet WitsStr { get; }
+ DbSet WitsItemFloat { get; }
+ DbSet WitsItemInt { get; }
+ DbSet WitsItemString { get; }
DbSet Drillers { get; }
DbSet Schedule { get; }
DbSet OperationValues { get; }
diff --git a/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs b/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs
new file mode 100644
index 00000000..4e16f277
--- /dev/null
+++ b/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs
@@ -0,0 +1,66 @@
+using AsbCloudApp.Data.GTR;
+using AsbCloudApp.Services;
+using AsbCloudApp.Services.WITS;
+using AsbCloudDb.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace AsbCloudInfrastructure.Repository
+{
+#nullable enable
+ public class GtrWitsRepository: IGtrService
+
+ {
+
+ private readonly IAsbCloudDbContext db;
+ private readonly ITelemetryService telemetryService;
+
+ public GtrWitsRepository(
+ IAsbCloudDbContext db,
+ ITelemetryService telemetryService)
+ {
+ this.db = db;
+ this.telemetryService = telemetryService;
+ }
+
+ public async Task> GetAsync(int idWell, DateTime dateBegin = default, double intervalSec = 600, int approxPointsCount = 1024, CancellationToken token = default)
+ {
+ var telemetry = telemetryService.GetOrDefaultTelemetryByIdWell(idWell);
+ if (telemetry is null)
+ return Enumerable.Empty();
+ var timezone = telemetryService.GetTimezone(telemetry.Id);
+
+ var filterByDateEnd = dateBegin != default;
+ DateTimeOffset dateBeginUtc;
+ if (dateBegin == default)
+ {
+ dateBeginUtc = telemetryService.GetLastTelemetryDate(telemetry.Id)
+ .ToUtcDateTimeOffset(timezone.Hours);
+ if (dateBeginUtc != default)
+ dateBeginUtc = dateBeginUtc.AddSeconds(-intervalSec);
+ }
+ else
+ {
+ dateBeginUtc = dateBegin.ToUtcDateTimeOffset(timezone.Hours);
+ }
+
+ if (dateBeginUtc == default)
+ dateBeginUtc = DateTime.UtcNow.AddSeconds(-intervalSec);
+ var dateEnd = dateBeginUtc.AddSeconds(intervalSec);
+
+ //временная заглушка(для билда без ошибок)
+ return Enumerable.Empty();
+ }
+
+
+
+ public Task UpdateAsync(string uid, IEnumerable dtos, CancellationToken token)
+ {
+ throw new NotImplementedException();
+ }
+ }
+#nullable disable
+}