forked from ddrilling/AsbCloudServer
Renamed 'TelemetryOperation' model to 'Operation'
This commit is contained in:
parent
5951953cb6
commit
12a73a4e21
@ -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; }
|
||||
}
|
@ -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 запросов с вычислением дат")]
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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 = "Невозможно определить операцию" };
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user