Renamed 'TelemetryOperation' model to 'Operation'

This commit is contained in:
KharchenkoVV 2021-08-13 15:35:03 +05:00
parent 5951953cb6
commit 12a73a4e21
5 changed files with 14 additions and 11 deletions

View File

@ -5,8 +5,8 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model
{
[Table("t_telemetry_operation"), Comment("Справочник операций на скважине")]
public class TelemetryOperation
[Table("t_operations"), Comment("Справочник операций на скважине")]
public class Operation
{
[Key]
[Column("id")]
@ -18,6 +18,9 @@ namespace AsbCloudDb.Model
[Column("name"), Comment("Название операции")]
public string Name { get; set; }
[Column("code"), Comment("Код операции")]
public int Code { get; set; }
[InverseProperty(nameof(TelemetryAnalysis.Operation))]
public virtual ICollection<TelemetryAnalysis> Analysis { get; set; }
}

View File

@ -28,8 +28,8 @@ namespace AsbCloudDb.Model
[JsonIgnore]
[ForeignKey(nameof(IdOperation))]
[InverseProperty(nameof(Model.TelemetryOperation.Analysis))]
public virtual TelemetryOperation Operation { get; set; }
[InverseProperty(nameof(Model.Operation.Analysis))]
public virtual Operation Operation { get; set; }
[Column("unix_date", TypeName = "bigint"), Comment("Unix timestamp для Linq запросов с вычислением дат")]

View File

@ -17,9 +17,9 @@ namespace AsbCloudInfrastructure.Services
private readonly IAsbCloudDbContext db;
private readonly ITelemetryService telemetryService;
private readonly ISaubDataCache saubDataCache;
private readonly CacheTable<TelemetryOperation> cacheOperations;
private readonly CacheTable<Operation> cacheOperations;
private readonly TelemetryOperationDetectorService operationDetectorService;
private readonly IEnumerable<TelemetryOperation> operations;
private readonly IEnumerable<Operation> operations;
public AnalyticsService(IAsbCloudDbContext db, ITelemetryService telemetryService,
ISaubDataCache saubDataCache, CacheDb cacheDb)
@ -27,7 +27,7 @@ namespace AsbCloudInfrastructure.Services
this.db = db;
this.telemetryService = telemetryService;
this.saubDataCache = saubDataCache;
cacheOperations = cacheDb.GetCachedTable<TelemetryOperation>((AsbCloudDbContext)db);
cacheOperations = cacheDb.GetCachedTable<Operation>((AsbCloudDbContext)db);
operations = cacheOperations.Select(c => true);
operationDetectorService = new TelemetryOperationDetectorService(operations);
}

View File

@ -7,7 +7,7 @@ namespace AsbCloudInfrastructure.Services
public class TelemetryOperationDetector
{
public int Order { get; set; }
public TelemetryOperation Operation { get; set; }
public Operation Operation { get; set; }
public Func<TelemetryAnalysisDto, bool> Detect { get; set; }
}
}

View File

@ -9,7 +9,7 @@ namespace AsbCloudInfrastructure.Services
{
private readonly IEnumerable<TelemetryOperationDetector> detectors;
public TelemetryOperationDetectorService(IEnumerable<TelemetryOperation> operations)
public TelemetryOperationDetectorService(IEnumerable<Operation> operations)
{
detectors = new List<TelemetryOperationDetector>()
{
@ -180,8 +180,8 @@ namespace AsbCloudInfrastructure.Services
};
}
public TelemetryOperation DetectOperation(TelemetryAnalysisDto data) =>
public Operation DetectOperation(TelemetryAnalysisDto data) =>
detectors.OrderBy(d => d.Order).First(o => o.Detect(data)).Operation
?? new TelemetryOperation { Id = 1, Name = "Невозможно определить операцию" };
?? new Operation { Id = 1, Name = "Невозможно определить операцию" };
}
}