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

View File

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

View File

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

View File

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

View File

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