forked from ddrilling/AsbCloudServer
Deleted link to AsbCloudDb from AsbCloudApp + codefix
This commit is contained in:
parent
433900a1ee
commit
91da4fa9c2
@ -4,12 +4,4 @@
|
|||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\AsbCloudDb\AsbCloudDb.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -23,6 +23,11 @@ namespace AsbCloudApp.Data
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int? Mode { get; set; }
|
public int? Mode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// telemetry id
|
||||||
|
/// </summary>
|
||||||
|
public int IdTelemetry { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// telemetry user
|
/// telemetry user
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
26
AsbCloudApp/Data/TelemetryAnalysisDto.cs
Normal file
26
AsbCloudApp/Data/TelemetryAnalysisDto.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
namespace AsbCloudApp.Data
|
||||||
|
{
|
||||||
|
public class TelemetryAnalysisDto
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int IdTelemetry { get; set; }
|
||||||
|
public int IdOperation { get; set; }
|
||||||
|
public long UnixDate { get; set; }
|
||||||
|
public int DurationSec { get; set; }
|
||||||
|
public double? OperationStartDepth { get; set; }
|
||||||
|
public double? OperationEndDepth { get; set; }
|
||||||
|
public bool IsWellDepthIncreasing { get; set; }
|
||||||
|
public bool IsWellDepthDecreasing { get; set; }
|
||||||
|
public bool IsBitPositionIncreasing { get; set; }
|
||||||
|
public bool IsBitPositionDecreasing { get; set; }
|
||||||
|
public bool IsBitPositionLt20 { get; set; }
|
||||||
|
public bool IsBlockPositionIncreasing { get; set; }
|
||||||
|
public bool IsBlockPositionDecreasing { get; set; }
|
||||||
|
public bool IsRotorSpeedLt3 { get; set; }
|
||||||
|
public bool IsRotorSpeedGt3 { get; set; }
|
||||||
|
public bool IsPressureLt20 { get; set; }
|
||||||
|
public bool IsPressureGt20 { get; set; }
|
||||||
|
public bool IsHookWeightNotChanges { get; set; }
|
||||||
|
public bool IsHookWeightLt3 { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudDb.Model;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
@ -17,6 +16,6 @@ namespace AsbCloudApp.Services
|
|||||||
DateTime begin = default, DateTime end = default);
|
DateTime begin = default, DateTime end = default);
|
||||||
IEnumerable<TelemetryOperationInfoDto> GetOperationsToInterval(int idWell,
|
IEnumerable<TelemetryOperationInfoDto> GetOperationsToInterval(int idWell,
|
||||||
int intervalHoursTimestamp, int workBeginTimestamp);
|
int intervalHoursTimestamp, int workBeginTimestamp);
|
||||||
void SaveAnalytics(DataSaubBase dataSaub);
|
void SaveAnalytics(DataSaubBaseDto dataSaub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
using AsbCloudDb.Model;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
using AsbCloudApp.Data;
|
||||||
|
|
||||||
namespace AsbCloudApp.Services
|
namespace AsbCloudApp.Services
|
||||||
{
|
{
|
||||||
public interface ISaubDataCache
|
public interface ISaubDataCache
|
||||||
{
|
{
|
||||||
TelemetryAnalysis CurrentAnalysis { get; set; }
|
TelemetryAnalysisDto CurrentAnalysis { get; set; }
|
||||||
IEnumerable<DataSaubBase> GetOrCreateCache(int telemetryId);
|
IEnumerable<DataSaubBaseDto> GetOrCreateCache(int telemetryId);
|
||||||
void AddData(DataSaubBase data);
|
void AddData(DataSaubBaseDto data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudDb.Model;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Services
|
namespace AsbCloudApp.Services
|
||||||
{
|
{
|
||||||
@ -9,6 +8,6 @@ namespace AsbCloudApp.Services
|
|||||||
int GetOrCreateTemetryIdByUid(string uid);
|
int GetOrCreateTemetryIdByUid(string uid);
|
||||||
double GetTimezoneOffsetByTelemetryId(int idTelemetry);
|
double GetTimezoneOffsetByTelemetryId(int idTelemetry);
|
||||||
void UpdateInfo(string uid, TelemetryInfoDto info);
|
void UpdateInfo(string uid, TelemetryInfoDto info);
|
||||||
Telemetry GetTelemetryByidWell(int idWell);
|
int? GetIdTelemetryByIdWell(int idWell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
@ -6,6 +6,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Mapster;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
@ -31,13 +32,13 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
public IEnumerable<WellDepthToDayDto> GetWellDepthToDay(int idWell)
|
public IEnumerable<WellDepthToDayDto> GetWellDepthToDay(int idWell)
|
||||||
{
|
{
|
||||||
var telemetry = telemetryService.GetTelemetryByidWell(idWell);
|
var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||||
|
|
||||||
if (telemetry is null)
|
if (telemetryId is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var depthToTimeData = (from d in db.DataSaubBases
|
var depthToTimeData = (from d in db.DataSaubBases
|
||||||
where d.IdTelemetry == telemetry.Id
|
where d.IdTelemetry == telemetryId
|
||||||
select new
|
select new
|
||||||
{
|
{
|
||||||
d.Id,
|
d.Id,
|
||||||
@ -64,14 +65,14 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
{
|
{
|
||||||
intervalSeconds = intervalSeconds == 0 ? 86400 : intervalSeconds;
|
intervalSeconds = intervalSeconds == 0 ? 86400 : intervalSeconds;
|
||||||
|
|
||||||
var telemetry = telemetryService.GetTelemetryByidWell(idWell);
|
var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||||
|
|
||||||
if (telemetry is null)
|
if (telemetryId is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var timezoneOffset = telemetryService.GetTimezoneOffsetByTelemetryId(telemetry.Id);
|
var timezoneOffset = telemetryService.GetTimezoneOffsetByTelemetryId((int)telemetryId);
|
||||||
|
|
||||||
var drillingPeriodsInfo = db.GetDepthToInterval(telemetry.Id, intervalSeconds,
|
var drillingPeriodsInfo = db.GetDepthToInterval((int)telemetryId, intervalSeconds,
|
||||||
workBeginSeconds, timezoneOffset);
|
workBeginSeconds, timezoneOffset);
|
||||||
|
|
||||||
var wellDepthToIntervalData = drillingPeriodsInfo.Select(d => new WellDepthToIntervalDto
|
var wellDepthToIntervalData = drillingPeriodsInfo.Select(d => new WellDepthToIntervalDto
|
||||||
@ -87,14 +88,14 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
IEnumerable<int> categoryIds = default, DateTime begin = default,
|
IEnumerable<int> categoryIds = default, DateTime begin = default,
|
||||||
DateTime end = default, int skip = 0, int take = 32)
|
DateTime end = default, int skip = 0, int take = 32)
|
||||||
{
|
{
|
||||||
var telemetry = telemetryService.GetTelemetryByidWell(idWell);
|
var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||||
|
|
||||||
if (telemetry is null)
|
if (telemetryId is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var operations = from a in db.TelemetryAnalysis.Include(t => t.Operation)
|
var operations = from a in db.TelemetryAnalysis.Include(t => t.Operation)
|
||||||
where a.IdTelemetry == telemetry.Id
|
where a.IdTelemetry == telemetryId
|
||||||
select a;
|
select a;
|
||||||
|
|
||||||
if ((categoryIds != default) && (categoryIds.Any()))
|
if ((categoryIds != default) && (categoryIds.Any()))
|
||||||
operations = operations.Where(o => categoryIds.Contains(o.IdOperation));
|
operations = operations.Where(o => categoryIds.Contains(o.IdOperation));
|
||||||
@ -150,16 +151,16 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
public IEnumerable<TelemetryOperationDurationDto> GetOperationsSummary(int idWell,
|
public IEnumerable<TelemetryOperationDurationDto> GetOperationsSummary(int idWell,
|
||||||
DateTime begin = default, DateTime end = default)
|
DateTime begin = default, DateTime end = default)
|
||||||
{
|
{
|
||||||
var telemetry = telemetryService.GetTelemetryByidWell(idWell);
|
var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||||
|
|
||||||
if (telemetry is null)
|
if (telemetryId is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var unixBegin = (begin - new DateTime(1970, 1, 1)).TotalSeconds;
|
var unixBegin = (begin - new DateTime(1970, 1, 1)).TotalSeconds;
|
||||||
var unixEnd = (end - new DateTime(1970, 1, 1)).TotalSeconds;
|
var unixEnd = (end - new DateTime(1970, 1, 1)).TotalSeconds;
|
||||||
|
|
||||||
var operations = (from a in db.TelemetryAnalysis
|
var operations = (from a in db.TelemetryAnalysis
|
||||||
where a.IdTelemetry == telemetry.Id &&
|
where a.IdTelemetry == telemetryId &&
|
||||||
a.UnixDate > unixBegin && a.UnixDate < unixEnd
|
a.UnixDate > unixBegin && a.UnixDate < unixEnd
|
||||||
join o in db.Operations on a.IdOperation equals o.Id
|
join o in db.Operations on a.IdOperation equals o.Id
|
||||||
group a by new { a.IdOperation, o.Name } into g
|
group a by new { a.IdOperation, o.Name } into g
|
||||||
@ -178,15 +179,15 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
{
|
{
|
||||||
intervalSeconds = intervalSeconds == 0 ? 86400 : intervalSeconds;
|
intervalSeconds = intervalSeconds == 0 ? 86400 : intervalSeconds;
|
||||||
|
|
||||||
var telemetry = telemetryService.GetTelemetryByidWell(idWell);
|
var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||||
|
|
||||||
if (telemetry is null)
|
if (telemetryId is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var timezoneOffset = telemetryService.GetTimezoneOffsetByTelemetryId(telemetry.Id);
|
var timezoneOffset = telemetryService.GetTimezoneOffsetByTelemetryId((int)telemetryId);
|
||||||
|
|
||||||
var operations = (from a in db.TelemetryAnalysis
|
var operations = (from a in db.TelemetryAnalysis
|
||||||
where a.IdTelemetry == telemetry.Id
|
where a.IdTelemetry == telemetryId
|
||||||
join o in db.Operations on a.IdOperation equals o.Id
|
join o in db.Operations on a.IdOperation equals o.Id
|
||||||
group a by new
|
group a by new
|
||||||
{
|
{
|
||||||
@ -216,36 +217,36 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
return operationsGroupedByInterval;
|
return operationsGroupedByInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveAnalytics(DataSaubBase dataSaub)
|
public void SaveAnalytics(DataSaubBaseDto dataSaubDto)
|
||||||
{
|
{
|
||||||
saubDataCache.AddData(dataSaub);
|
saubDataCache.AddData(dataSaubDto);
|
||||||
|
|
||||||
if (saubDataCache.GetOrCreateCache(dataSaub.IdTelemetry).Count() > 1)
|
if (saubDataCache.GetOrCreateCache(dataSaubDto.IdTelemetry).Count() > 1)
|
||||||
{
|
{
|
||||||
var dataSaubs = saubDataCache.GetOrCreateCache(dataSaub.IdTelemetry)
|
var dataSaubs = saubDataCache.GetOrCreateCache(dataSaubDto.IdTelemetry)
|
||||||
.OrderBy(d => d.Date);
|
.OrderBy(d => d.Date);
|
||||||
|
|
||||||
var telemetryAnalysis = GetDrillingAnalysis(dataSaubs);
|
var telemetryAnalysisDto = GetDrillingAnalysis(dataSaubs);
|
||||||
|
|
||||||
if (saubDataCache.CurrentAnalysis is null)
|
if (saubDataCache.CurrentAnalysis is null)
|
||||||
saubDataCache.CurrentAnalysis = telemetryAnalysis;
|
saubDataCache.CurrentAnalysis = telemetryAnalysisDto;
|
||||||
|
|
||||||
if (saubDataCache.CurrentAnalysis.IdOperation == telemetryAnalysis.IdOperation)
|
if (saubDataCache.CurrentAnalysis.IdOperation == telemetryAnalysisDto.IdOperation)
|
||||||
{
|
{
|
||||||
saubDataCache.CurrentAnalysis.DurationSec +=
|
saubDataCache.CurrentAnalysis.DurationSec +=
|
||||||
telemetryAnalysis.DurationSec;
|
telemetryAnalysisDto.DurationSec;
|
||||||
saubDataCache.CurrentAnalysis.OperationEndDepth = dataSaub.WellDepth;
|
saubDataCache.CurrentAnalysis.OperationEndDepth = dataSaubDto.WellDepth;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
db.TelemetryAnalysis.Add(saubDataCache.CurrentAnalysis);
|
db.TelemetryAnalysis.Add(saubDataCache.CurrentAnalysis.Adapt<TelemetryAnalysis>());
|
||||||
saubDataCache.CurrentAnalysis = telemetryAnalysis;
|
saubDataCache.CurrentAnalysis = telemetryAnalysisDto;
|
||||||
saubDataCache.CurrentAnalysis.OperationStartDepth = dataSaub.WellDepth;
|
saubDataCache.CurrentAnalysis.OperationStartDepth = dataSaubDto.WellDepth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TelemetryAnalysis GetDrillingAnalysis(IEnumerable<DataSaubBase> dataSaubBases)
|
private TelemetryAnalysisDto GetDrillingAnalysis(IEnumerable<DataSaubBaseDto> dataSaubBases)
|
||||||
{
|
{
|
||||||
var lastSaubDate = dataSaubBases.Last().Date;
|
var lastSaubDate = dataSaubBases.Last().Date;
|
||||||
|
|
||||||
@ -279,7 +280,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
var IsBlockGoesDown = InterpolationLine.IsValueIncreases(blockPositionChangingIndex, 0.0001);
|
var IsBlockGoesDown = InterpolationLine.IsValueIncreases(blockPositionChangingIndex, 0.0001);
|
||||||
var IsBlockStandsStill = InterpolationLine.IsValueNotChanges(blockPositionChangingIndex, (0.0001, -0.0001));
|
var IsBlockStandsStill = InterpolationLine.IsValueNotChanges(blockPositionChangingIndex, (0.0001, -0.0001));
|
||||||
|
|
||||||
var drillingAnalysis = new TelemetryAnalysis
|
var drillingAnalysis = new TelemetryAnalysisDto
|
||||||
{
|
{
|
||||||
IdTelemetry = dataSaubBases.First().IdTelemetry,
|
IdTelemetry = dataSaubBases.First().IdTelemetry,
|
||||||
UnixDate = (long)(lastSaubDate - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds,
|
UnixDate = (long)(lastSaubDate - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds,
|
||||||
|
@ -4,7 +4,6 @@ using AsbCloudDb.Model;
|
|||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
@ -22,12 +21,12 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
dbSet = context.Set<TModel>();
|
dbSet = context.Set<TModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Tdto> GetAll(System.Linq.Expressions.Expression<System.Func<TModel, bool>> predicate = null)
|
public IEnumerable<Tdto> GetAll(System.Linq.Expressions.Expression<System.Func<object, bool>> predicate = null)
|
||||||
{
|
{
|
||||||
IQueryable<TModel> entities = dbSet;
|
IQueryable<TModel> entities = dbSet;
|
||||||
|
|
||||||
if (predicate is not null)
|
if (predicate is not null)
|
||||||
entities = entities.Where(predicate);
|
entities = entities.Where(predicate).Cast<TModel>();
|
||||||
|
|
||||||
var dto = entities.Adapt<Tdto>();
|
var dto = entities.Adapt<Tdto>();
|
||||||
return dto;
|
return dto;
|
||||||
|
@ -85,13 +85,14 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
db.DataSaubBases.RemoveRange(oldDataSaubBase);
|
db.DataSaubBases.RemoveRange(oldDataSaubBase);
|
||||||
|
|
||||||
|
|
||||||
foreach (var item in dtos)
|
foreach (var dto in dtos)
|
||||||
{
|
{
|
||||||
var dataSaub = item.Adapt<DataSaubBase>();
|
var dataSaub = dto.Adapt<DataSaubBase>();
|
||||||
dataSaub.IdTelemetry = telemetryId;
|
dataSaub.IdTelemetry = telemetryId;
|
||||||
db.DataSaubBases.Add(dataSaub);
|
db.DataSaubBases.Add(dataSaub);
|
||||||
|
|
||||||
analyticsService.SaveAnalytics(dataSaub);
|
dto.IdTelemetry = telemetryId;
|
||||||
|
analyticsService.SaveAnalytics(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
@ -99,11 +100,11 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
public DatesRangeDto GetDataDatesRange(int idWell)
|
public DatesRangeDto GetDataDatesRange(int idWell)
|
||||||
{
|
{
|
||||||
var telemetry = telemetryService.GetTelemetryByidWell(idWell);
|
var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||||
if (telemetry is null)
|
if (telemetryId is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var (From, To) = db.GetDatesRange<DataSaubBase>(telemetry.Id);
|
var (From, To) = db.GetDatesRange<DataSaubBase>((int)telemetryId);
|
||||||
|
|
||||||
return new DatesRangeDto { From = From, To = To };
|
return new DatesRangeDto { From = From, To = To };
|
||||||
}
|
}
|
||||||
|
@ -49,10 +49,6 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
int idCategory, DateTime begin = default, DateTime end = default,
|
int idCategory, DateTime begin = default, DateTime end = default,
|
||||||
int skip = 0, int take = 32)
|
int skip = 0, int take = 32)
|
||||||
{
|
{
|
||||||
var telemetry = telemetryService.GetTelemetryByidWell(idWell);
|
|
||||||
if (telemetry is null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var filesInfoQuery = db.Files.Include(f => f.User)
|
var filesInfoQuery = db.Files.Include(f => f.User)
|
||||||
.Where(f => f.IdWell == idWell &&
|
.Where(f => f.IdWell == idWell &&
|
||||||
f.IdCategory == idCategory);
|
f.IdCategory == idCategory);
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Linq;
|
||||||
using System.Linq;
|
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
|
@ -27,17 +27,17 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
public PaginationContainer<MessageDto> GetMessages(int idWell, IEnumerable<int> categoryids = default, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32)
|
public PaginationContainer<MessageDto> GetMessages(int idWell, IEnumerable<int> categoryids = default, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32)
|
||||||
{
|
{
|
||||||
var telemetry = telemetryService.GetTelemetryByidWell(idWell);
|
var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||||
if (telemetry is null)
|
if (telemetryId is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var events = cacheEvents.Select(e => e.IdTelemetry == telemetry.Id);
|
var events = cacheEvents.Select(e => e.IdTelemetry == telemetryId);
|
||||||
|
|
||||||
if (!events.Any())
|
if (!events.Any())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var messages = from m in db.Messages
|
var messages = from m in db.Messages
|
||||||
where m.IdTelemetry == telemetry.Id
|
where m.IdTelemetry == telemetryId
|
||||||
select m;
|
select m;
|
||||||
|
|
||||||
if ((categoryids != default) && (categoryids.Any()))
|
if ((categoryids != default) && (categoryids.Any()))
|
||||||
@ -72,7 +72,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
if (messagesList.Count == 0)
|
if (messagesList.Count == 0)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
var users = cacheTUsers.Select(u => u.IdTelemetry == telemetry.Id);
|
var users = cacheTUsers.Select(u => u.IdTelemetry == telemetryId);
|
||||||
|
|
||||||
foreach (var message in messagesList)
|
foreach (var message in messagesList)
|
||||||
{
|
{
|
||||||
@ -98,11 +98,11 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
public DatesRangeDto GetMessagesDatesRange(int idWell)
|
public DatesRangeDto GetMessagesDatesRange(int idWell)
|
||||||
{
|
{
|
||||||
var telemetry = telemetryService.GetTelemetryByidWell(idWell);
|
var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||||
if (telemetry is null)
|
if (telemetryId is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var (From, To) = db.GetDatesRange<Message>(telemetry.Id);
|
var (From, To) = db.GetDatesRange<Message>((int)telemetryId);
|
||||||
|
|
||||||
return new DatesRangeDto { From = From, To = To };
|
return new DatesRangeDto { From = From, To = To };
|
||||||
}
|
}
|
||||||
|
@ -111,16 +111,16 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
public DatesRangeDto GetReportsDatesRange(int idWell)
|
public DatesRangeDto GetReportsDatesRange(int idWell)
|
||||||
{
|
{
|
||||||
var telemetry = telemetryService.GetTelemetryByidWell(idWell);
|
var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||||
|
|
||||||
if (telemetry is null)
|
if (telemetryId is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var datesRange = (from d in db.DataSaubBases
|
var datesRange = (from d in db.DataSaubBases
|
||||||
where d.IdTelemetry == telemetry.Id
|
where d.IdTelemetry == telemetryId
|
||||||
select d.Date).Union(
|
select d.Date).Union(
|
||||||
from m in db.Messages
|
from m in db.Messages
|
||||||
where m.IdTelemetry == telemetry.Id
|
where m.IdTelemetry == telemetryId
|
||||||
select m.Date).DefaultIfEmpty().GroupBy(g => true)
|
select m.Date).DefaultIfEmpty().GroupBy(g => true)
|
||||||
.Select(g => new
|
.Select(g => new
|
||||||
{
|
{
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudApp.Services;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
public class SaubDataCache : ISaubDataCache
|
public class SaubDataCache : ISaubDataCache
|
||||||
{
|
{
|
||||||
public TelemetryAnalysis CurrentAnalysis { get; set; }
|
public TelemetryAnalysisDto CurrentAnalysis { get; set; }
|
||||||
|
|
||||||
private readonly Dictionary<int, List<DataSaubBase>> saubData =
|
private readonly Dictionary<int, List<DataSaubBaseDto>> saubData =
|
||||||
new Dictionary<int, List<DataSaubBase>>();
|
new Dictionary<int, List<DataSaubBaseDto>>();
|
||||||
|
|
||||||
public IEnumerable<DataSaubBase> GetOrCreateCache(int telemetryId)
|
public IEnumerable<DataSaubBaseDto> GetOrCreateCache(int telemetryId)
|
||||||
{
|
{
|
||||||
if (!saubData.ContainsKey(telemetryId))
|
if (!saubData.ContainsKey(telemetryId))
|
||||||
saubData[telemetryId] = new List<DataSaubBase>();
|
saubData[telemetryId] = new List<DataSaubBaseDto>();
|
||||||
|
|
||||||
return saubData[telemetryId];
|
return saubData[telemetryId];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddData(DataSaubBase data)
|
public void AddData(DataSaubBaseDto data)
|
||||||
{
|
{
|
||||||
GetOrCreateCache(data.IdTelemetry);
|
GetOrCreateCache(data.IdTelemetry);
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
|
using AsbCloudApp.Data;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
@ -7,6 +8,6 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
{
|
{
|
||||||
public int Order { get; set; }
|
public int Order { get; set; }
|
||||||
public TelemetryOperation Operation { get; set; }
|
public TelemetryOperation Operation { get; set; }
|
||||||
public Func<TelemetryAnalysis, bool> Detect { get; set; }
|
public Func<TelemetryAnalysisDto, bool> Detect { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
|
using AsbCloudApp.Data;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
@ -179,7 +180,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public TelemetryOperation DetectOperation(TelemetryAnalysis data) =>
|
public TelemetryOperation DetectOperation(TelemetryAnalysisDto data) =>
|
||||||
detectors.OrderBy(d => d.Order).First(o => o.Detect(data)).Operation
|
detectors.OrderBy(d => d.Order).First(o => o.Detect(data)).Operation
|
||||||
?? new TelemetryOperation { Id = 1, Name = "Невозможно определить операцию" };
|
?? new TelemetryOperation { Id = 1, Name = "Невозможно определить операцию" };
|
||||||
}
|
}
|
||||||
|
@ -33,17 +33,13 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
cacheTelemetry.Upsert(telemetry);
|
cacheTelemetry.Upsert(telemetry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Telemetry GetTelemetryByidWell(int idWell)
|
public int? GetIdTelemetryByIdWell(int idWell)
|
||||||
{
|
{
|
||||||
var well = cacheWells.FirstOrDefault(w => w.Id == idWell);
|
var well = cacheWells.FirstOrDefault(w => w.Id == idWell);
|
||||||
if (well is null)
|
if (well is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var telemetry = cacheTelemetry.FirstOrDefault(t => t.Id == well.Id);
|
return well.IdTelemetry;
|
||||||
if (telemetry is null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return telemetry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Well GetWellByTelemetryUid(string uid)
|
private Well GetWellByTelemetryUid(string uid)
|
||||||
|
Loading…
Reference in New Issue
Block a user