diff --git a/AsbCloudApp/Data/ClusterDto.cs b/AsbCloudApp/Data/ClusterDto.cs index 683cd445..800d61a6 100644 --- a/AsbCloudApp/Data/ClusterDto.cs +++ b/AsbCloudApp/Data/ClusterDto.cs @@ -34,6 +34,6 @@ namespace AsbCloudApp.Data /// /// Список скважин куста /// - public IEnumerable Wells { get; set; } = Enumerable.Empty(); + public IEnumerable Wells { get; set; } = Enumerable.Empty(); } } diff --git a/AsbCloudDb/Model/IAsbCloudDbContext.cs b/AsbCloudDb/Model/IAsbCloudDbContext.cs index 82e87c7a..a839a43c 100644 --- a/AsbCloudDb/Model/IAsbCloudDbContext.cs +++ b/AsbCloudDb/Model/IAsbCloudDbContext.cs @@ -2,6 +2,7 @@ using AsbCloudDb.Model.Subsystems; using AsbCloudDb.Model.WITS; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Infrastructure; using System; using System.Threading; @@ -73,7 +74,10 @@ namespace AsbCloudDb.Model Task RefreshMaterializedViewAsync(CancellationToken token) where TEntity : class; int SaveChanges(); int SaveChanges(bool acceptAllChangesOnSuccess); - Task SaveChangesAsync(CancellationToken cancellationToken); - DbSet Set() where TEntity : class; + Task SaveChangesAsync(CancellationToken cancellationToken); + DbSet Set() where TEntity : class; + + EntityEntry Entry(TEntity entity) + where TEntity : class; } } \ No newline at end of file diff --git a/AsbCloudInfrastructure/DateTimeExtentions.cs b/AsbCloudInfrastructure/DateTimeExtensions.cs similarity index 97% rename from AsbCloudInfrastructure/DateTimeExtentions.cs rename to AsbCloudInfrastructure/DateTimeExtensions.cs index 0beb0b3e..2e355356 100644 --- a/AsbCloudInfrastructure/DateTimeExtentions.cs +++ b/AsbCloudInfrastructure/DateTimeExtensions.cs @@ -1,9 +1,10 @@ -using System; +// Ignore Spelling: Linq + +using System; namespace AsbCloudInfrastructure { - - public static class DateTimeExtentions + public static class DateTimeExtensions { /// /// Приветсти к UTC из времени куста @@ -78,5 +79,4 @@ namespace AsbCloudInfrastructure return indexOfMiddle; } } - } diff --git a/AsbCloudInfrastructure/Services/SAUB/TelemetryService.cs b/AsbCloudInfrastructure/Services/SAUB/TelemetryService.cs index 811f9beb..7aa4f6c5 100644 --- a/AsbCloudInfrastructure/Services/SAUB/TelemetryService.cs +++ b/AsbCloudInfrastructure/Services/SAUB/TelemetryService.cs @@ -95,7 +95,8 @@ namespace AsbCloudInfrastructure.Services.SAUB { var entity = GetTelemetryCache() .FirstOrDefault(t => t.Well?.Id == idWell); - if (entity.Well?.Timezone is not null && entity.TimeZone.Hours != entity.Well.Timezone.Hours) + + if (entity?.Well?.Timezone is not null && entity.TimeZone.Hours != entity.Well.Timezone.Hours) { entity.TimeZone = entity.Well.Timezone; //TODO: выдаем предупреждение! diff --git a/AsbCloudInfrastructure/Services/WellInfoService.cs b/AsbCloudInfrastructure/Services/WellInfoService.cs index 7a99a767..5032d474 100644 --- a/AsbCloudInfrastructure/Services/WellInfoService.cs +++ b/AsbCloudInfrastructure/Services/WellInfoService.cs @@ -34,20 +34,22 @@ namespace AsbCloudInfrastructure.Services private readonly TelemetryDataCache telemetryDataSpinCache; private readonly IWitsRecordRepository witsRecord7Repository; private readonly IWitsRecordRepository witsRecord1Repository; - + private readonly IGtrRepository gtrRepository; private static IEnumerable WellMapInfo = Enumerable.Empty(); public WellInfoService( TelemetryDataCache telemetryDataSaubCache, TelemetryDataCache telemetryDataSpinCache, IWitsRecordRepository witsRecord7Repository, - IWitsRecordRepository witsRecord1Repository) + IWitsRecordRepository witsRecord1Repository, + IGtrRepository gtrRepository) { this.telemetryDataSaubCache = telemetryDataSaubCache; this.telemetryDataSpinCache = telemetryDataSpinCache; this.witsRecord7Repository = witsRecord7Repository; this.witsRecord1Repository = witsRecord1Repository; + this.gtrRepository = gtrRepository; } public static WorkPeriodic MakeWork() @@ -173,10 +175,12 @@ namespace AsbCloudInfrastructure.Services var result = wellInfo.Adapt(); if (wellInfo.IdTelemetry.HasValue) { - result.LastDataSaub = telemetryDataSaubCache.GetLastOrDefault(wellInfo.IdTelemetry.Value); - result.LastDataSpin = telemetryDataSpinCache.GetLastOrDefault(wellInfo.IdTelemetry.Value); - result.LastDataDdsDate = GetLastOrDefaultDdsTelemetry(wellInfo.IdTelemetry.Value); - result.LastDataGtrDate = null; + var idTelemetry = wellInfo.IdTelemetry.Value; + result.LastDataSaub = telemetryDataSaubCache.GetLastOrDefault(idTelemetry); + result.LastDataSpin = telemetryDataSpinCache.GetLastOrDefault(idTelemetry); + result.LastDataDdsDate = GetLastOrDefaultDdsTelemetry(idTelemetry); + result.LastDataGtrDate = gtrRepository.GetLastData(wellInfo.Id) + .MaxOrDefault(item => item.Date); result.LastDataDpcsDate = null; result.LastDataDpcsDate = null; } diff --git a/AsbCloudWebApi/Rest/Gtr.http b/AsbCloudWebApi/Rest/Gtr.http index 32f6a474..6658edb2 100644 --- a/AsbCloudWebApi/Rest/Gtr.http +++ b/AsbCloudWebApi/Rest/Gtr.http @@ -2,7 +2,7 @@ @contentType = application/json @auth = Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImN0eSI6IkpXVCJ9.eyJpZCI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiZGV2IiwiaWRDb21wYW55IjoiMSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6InJvb3QiLCJuYmYiOjE2NjI1NDgxNjIsImV4cCI6MTY5NDEwNTc2MiwiaXNzIjoiYSIsImF1ZCI6ImEifQ.OEAlNzxi7Jat6pzDBTAjTbChskc-tdJthJexyWwwUKE -@uid = 20210910_012752700 +@uid = 20210101_000000000 @idCluster = 1 @idWell = 1 @@ -20,7 +20,7 @@ Content-Type: {{contentType}} accept: */* Authorization: {{auth}} -{ +[{ "id":1, "date": "2023-04-18T08:41:49.332Z", "items": { @@ -28,4 +28,4 @@ Authorization: {{auth}} "2": 1.1, "3": "string1" } -} \ No newline at end of file +}] \ No newline at end of file diff --git a/AsbCloudWebApi/Rest/TelemetryDataSaub.http b/AsbCloudWebApi/Rest/TelemetryDataSaub.http index 54786c9e..1d90787f 100644 --- a/AsbCloudWebApi/Rest/TelemetryDataSaub.http +++ b/AsbCloudWebApi/Rest/TelemetryDataSaub.http @@ -2,7 +2,7 @@ @contentType = application/json @auth = Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImN0eSI6IkpXVCJ9.eyJpZCI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiZGV2IiwiaWRDb21wYW55IjoiMSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6InJvb3QiLCJuYmYiOjE2NjI1NDgxNjIsImV4cCI6MTY5NDEwNTc2MiwiaXNzIjoiYSIsImF1ZCI6ImEifQ.OEAlNzxi7Jat6pzDBTAjTbChskc-tdJthJexyWwwUKE -@uid = 20210917_165407777 +@uid = 20210101_000000000 # https://marketplace.visualstudio.com/items?itemName=humao.rest-client diff --git a/AsbCloudWebApi/Rest/Wits.http b/AsbCloudWebApi/Rest/Wits.http new file mode 100644 index 00000000..83813e07 --- /dev/null +++ b/AsbCloudWebApi/Rest/Wits.http @@ -0,0 +1,66 @@ +@baseUrl = http://127.0.0.1:5000 +@contentType = application/json +@auth = Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImN0eSI6IkpXVCJ9.eyJpZCI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiZGV2IiwiaWRDb21wYW55IjoiMSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6InJvb3QiLCJuYmYiOjE2NjI1NDgxNjIsImV4cCI6MTY5NDEwNTc2MiwiaXNzIjoiYSIsImF1ZCI6ImEifQ.OEAlNzxi7Jat6pzDBTAjTbChskc-tdJthJexyWwwUKE + +@uid = 20210101_000000000 + +# https://marketplace.visualstudio.com/items?itemName=humao.rest-client + +### +POST {{baseUrl}}/api/WitsRecord1/{{uid}} +Content-Type: {{contentType}} +accept: */* + +[ + { + "id": 0, + "idTelemetry": 0, + "dateTime": "2023-06-30T05:05:05.000Z", + "timeStamp": 0, + "wellid": "string", + "stknum": 0, + "recid": 0, + "seqid": 0, + "date_": 0, + "time": 0, + "actcod": 0, + "deptbitm": 0, + "deptbitv": 0, + "deptmeas": 0, + "deptvert": 0, + "blkpos": 0, + "ropa": 0, + "hkla": 0, + "hklx": 0, + "woba": 0, + "wobx": 0, + "torqa": 0, + "torqx": 0, + "rpma": 0, + "sppa": 0, + "chkp": 0, + "spm1": 0, + "spm2": 0, + "spm3": 0, + "tvolact": 0, + "tvolcact": 0, + "mfop": 0, + "mfoa": 0, + "mfia": 0, + "mdoa": 0, + "mdia": 0, + "mtoa": 0, + "mtia": 0, + "mcoa": 0, + "mcia": 0, + "stkc": 0, + "lagstks": 0, + "deptretm": 0, + "gasa": 0, + "spare1": 0, + "spare2": 0, + "spare3": 0, + "spare4": 0, + "spare5": 0 + } +] \ No newline at end of file