forked from ddrilling/AsbCloudServer
Operation rename to TelemetryOperation
This commit is contained in:
parent
05cf7244ef
commit
96730aeecb
@ -2,7 +2,7 @@
|
||||
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
public class OperationDto
|
||||
public class TelemetryOperationDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
@ -7,7 +7,7 @@ namespace AsbCloudApp.Services
|
||||
{
|
||||
public interface IAnalyticsService
|
||||
{
|
||||
PaginationContainer<OperationDto> GetOperationsByWell(int wellId,
|
||||
PaginationContainer<TelemetryOperationDto> GetOperationsByWell(int wellId,
|
||||
IEnumerable<int> categoryids = default, DateTime begin = default,
|
||||
DateTime end = default, int skip = 0, int take = 32);
|
||||
IEnumerable<WellDepthToDayDto> GetWellDepthToDay(int wellId);
|
||||
|
@ -27,7 +27,7 @@ namespace AsbCloudDb.Model
|
||||
public virtual DbSet<Report> Reports { get; set; }
|
||||
public virtual DbSet<File> Files { get; set; }
|
||||
public virtual DbSet<FileCategory> FileCategories { get; set; }
|
||||
public virtual DbSet<Operation> Operations { get; set; }
|
||||
public virtual DbSet<TelemetryOperation> Operations { get; set; }
|
||||
public virtual DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; }
|
||||
public virtual DbSet<WellSection> SectionAnalysis { get; set; }
|
||||
public virtual DbSet<WellType> WellTypes { get; set; }
|
||||
@ -189,26 +189,26 @@ namespace AsbCloudDb.Model
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Operation>(entity =>
|
||||
modelBuilder.Entity<TelemetryOperation>(entity =>
|
||||
{
|
||||
entity.HasData(new List<Operation> {
|
||||
new Operation {Id = 1, Name = "Невозможно определить операцию"},
|
||||
new Operation {Id = 2, Name = "Роторное бурение" },
|
||||
new Operation {Id = 3, Name = "Слайдирование" },
|
||||
new Operation {Id = 4, Name = "Подъем с проработкой" },
|
||||
new Operation {Id = 5, Name = "Спуск с проработкой" },
|
||||
new Operation {Id = 6, Name = "Подъем с промывкой" },
|
||||
new Operation {Id = 7, Name = "Спуск с промывкой" },
|
||||
new Operation {Id = 8, Name = "Спуск в скважину" },
|
||||
new Operation {Id = 9, Name = "Спуск с вращением" },
|
||||
new Operation {Id = 10, Name = "Подъем из скважины" },
|
||||
new Operation {Id = 11, Name = "Подъем с вращением" },
|
||||
new Operation {Id = 12, Name = "Промывка в покое" },
|
||||
new Operation {Id = 13, Name = "Промывка с вращением" },
|
||||
new Operation {Id = 14, Name = "Удержание в клиньях" },
|
||||
new Operation {Id = 15, Name = "Неподвижное состояние" },
|
||||
new Operation {Id = 16, Name = "Вращение без циркуляции" },
|
||||
new Operation {Id = 17, Name = "На поверхности" }
|
||||
entity.HasData(new List<TelemetryOperation> {
|
||||
new TelemetryOperation {Id = 1, Name = "Невозможно определить операцию"},
|
||||
new TelemetryOperation {Id = 2, Name = "Роторное бурение" },
|
||||
new TelemetryOperation {Id = 3, Name = "Слайдирование" },
|
||||
new TelemetryOperation {Id = 4, Name = "Подъем с проработкой" },
|
||||
new TelemetryOperation {Id = 5, Name = "Спуск с проработкой" },
|
||||
new TelemetryOperation {Id = 6, Name = "Подъем с промывкой" },
|
||||
new TelemetryOperation {Id = 7, Name = "Спуск с промывкой" },
|
||||
new TelemetryOperation {Id = 8, Name = "Спуск в скважину" },
|
||||
new TelemetryOperation {Id = 9, Name = "Спуск с вращением" },
|
||||
new TelemetryOperation {Id = 10, Name = "Подъем из скважины" },
|
||||
new TelemetryOperation {Id = 11, Name = "Подъем с вращением" },
|
||||
new TelemetryOperation {Id = 12, Name = "Промывка в покое" },
|
||||
new TelemetryOperation {Id = 13, Name = "Промывка с вращением" },
|
||||
new TelemetryOperation {Id = 14, Name = "Удержание в клиньях" },
|
||||
new TelemetryOperation {Id = 15, Name = "Неподвижное состояние" },
|
||||
new TelemetryOperation {Id = 16, Name = "Вращение без циркуляции" },
|
||||
new TelemetryOperation {Id = 17, Name = "На поверхности" }
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace AsbCloudDb.Model
|
||||
DbSet<Report> Reports { get; set; }
|
||||
DbSet<File> Files { get; set; }
|
||||
DbSet<FileCategory> FileCategories { get; set; }
|
||||
DbSet<Operation> Operations { get; set; }
|
||||
DbSet<TelemetryOperation> Operations { get; set; }
|
||||
DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; }
|
||||
|
||||
int SaveChanges();
|
||||
|
@ -28,8 +28,8 @@ namespace AsbCloudDb.Model
|
||||
|
||||
[JsonIgnore]
|
||||
[ForeignKey(nameof(IdOperation))]
|
||||
[InverseProperty(nameof(Model.Operation.Analysis))]
|
||||
public virtual Operation Operation { get; set; }
|
||||
[InverseProperty(nameof(Model.TelemetryOperation.Analysis))]
|
||||
public virtual TelemetryOperation Operation { get; set; }
|
||||
|
||||
|
||||
[Column("unix_date", TypeName = "bigint"), Comment("Unix timestamp для Linq запросов с вычислением дат")]
|
||||
|
@ -5,8 +5,8 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace AsbCloudDb.Model
|
||||
{
|
||||
[Table("t_operation"), Comment("Справочник операций на скважине")]
|
||||
public class Operation
|
||||
[Table("t_telemetry_operation"), Comment("Справочник операций на скважине")]
|
||||
public class TelemetryOperation
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
@ -14,9 +14,9 @@ namespace AsbCloudInfrastructure.Services
|
||||
private readonly IAsbCloudDbContext db;
|
||||
private readonly ITelemetryService telemetryService;
|
||||
private readonly ISaubDataCache saubDataCache;
|
||||
private readonly CacheTable<Operation> cacheOperations;
|
||||
private readonly OperationDetectorService operationDetectorService;
|
||||
private readonly IEnumerable<Operation> operations;
|
||||
private readonly CacheTable<TelemetryOperation> cacheOperations;
|
||||
private readonly TelemetryOperationDetectorService operationDetectorService;
|
||||
private readonly IEnumerable<TelemetryOperation> operations;
|
||||
|
||||
public AnalyticsService(IAsbCloudDbContext db, ITelemetryService telemetryService,
|
||||
ISaubDataCache saubDataCache, CacheDb cacheDb)
|
||||
@ -24,9 +24,9 @@ namespace AsbCloudInfrastructure.Services
|
||||
this.db = db;
|
||||
this.telemetryService = telemetryService;
|
||||
this.saubDataCache = saubDataCache;
|
||||
cacheOperations = cacheDb.GetCachedTable<Operation>((AsbCloudDbContext)db);
|
||||
cacheOperations = cacheDb.GetCachedTable<TelemetryOperation>((AsbCloudDbContext)db);
|
||||
operations = cacheOperations.Select(c => true);
|
||||
operationDetectorService = new OperationDetectorService(operations);
|
||||
operationDetectorService = new TelemetryOperationDetectorService(operations);
|
||||
}
|
||||
|
||||
public IEnumerable<WellDepthToDayDto> GetWellDepthToDay(int wellId)
|
||||
@ -83,7 +83,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
return wellDepthToIntervalData;
|
||||
}
|
||||
|
||||
public PaginationContainer<OperationDto> GetOperationsByWell(int wellId,
|
||||
public PaginationContainer<TelemetryOperationDto> GetOperationsByWell(int wellId,
|
||||
IEnumerable<int> categoryIds = default, DateTime begin = default,
|
||||
DateTime end = default, int skip = 0, int take = 32)
|
||||
{
|
||||
@ -99,7 +99,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
if ((categoryIds != default) && (categoryIds.Any()))
|
||||
operations = operations.Where(o => categoryIds.Contains(o.IdOperation));
|
||||
|
||||
var result = new PaginationContainer<OperationDto>
|
||||
var result = new PaginationContainer<TelemetryOperationDto>
|
||||
{
|
||||
Skip = skip,
|
||||
Take = take
|
||||
@ -131,7 +131,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
foreach(var operation in operations)
|
||||
{
|
||||
var operationDto = new OperationDto
|
||||
var operationDto = new TelemetryOperationDto
|
||||
{
|
||||
Id = operation.Id,
|
||||
Name = operation.Operation.Name,
|
||||
|
@ -3,10 +3,10 @@ using System;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
public class OperationDetector
|
||||
public class TelemetryOperationDetector
|
||||
{
|
||||
public int Order { get; set; }
|
||||
public Operation Operation { get; set; }
|
||||
public TelemetryOperation Operation { get; set; }
|
||||
public Func<TelemetryAnalysis, bool> Detect { get; set; }
|
||||
}
|
||||
}
|
@ -4,15 +4,15 @@ using System.Linq;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
public class OperationDetectorService
|
||||
public class TelemetryOperationDetectorService
|
||||
{
|
||||
private readonly IEnumerable<OperationDetector> detectors;
|
||||
private readonly IEnumerable<TelemetryOperationDetector> detectors;
|
||||
|
||||
public OperationDetectorService(IEnumerable<Operation> operations)
|
||||
public TelemetryOperationDetectorService(IEnumerable<TelemetryOperation> operations)
|
||||
{
|
||||
detectors = new List<OperationDetector>()
|
||||
detectors = new List<TelemetryOperationDetector>()
|
||||
{
|
||||
new OperationDetector
|
||||
new TelemetryOperationDetector
|
||||
{
|
||||
Order = 1,
|
||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("На поверхности")),
|
||||
@ -22,7 +22,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
&& data.IsBitPositionLt20 && data.IsHookWeightLt3;
|
||||
}
|
||||
},
|
||||
new OperationDetector
|
||||
new TelemetryOperationDetector
|
||||
{
|
||||
Order = 2,
|
||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("Удержание в клиньях")),
|
||||
@ -34,7 +34,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
data.IsHookWeightLt3;
|
||||
}
|
||||
},
|
||||
new OperationDetector
|
||||
new TelemetryOperationDetector
|
||||
{
|
||||
Order = 3,
|
||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("Подъем с проработкой")),
|
||||
@ -45,7 +45,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
data.IsRotorSpeedGt3 && data.IsPressureGt20;
|
||||
}
|
||||
},
|
||||
new OperationDetector
|
||||
new TelemetryOperationDetector
|
||||
{
|
||||
Order = 4,
|
||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("Спуск с проработкой")),
|
||||
@ -56,7 +56,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
data.IsRotorSpeedGt3 && data.IsPressureGt20;
|
||||
}
|
||||
},
|
||||
new OperationDetector
|
||||
new TelemetryOperationDetector
|
||||
{
|
||||
Order = 5,
|
||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("Подъем с промывкой")),
|
||||
@ -67,7 +67,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
data.IsRotorSpeedLt3 && data.IsPressureGt20;
|
||||
}
|
||||
},
|
||||
new OperationDetector
|
||||
new TelemetryOperationDetector
|
||||
{
|
||||
Order = 6,
|
||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("Спуск с промывкой")),
|
||||
@ -78,7 +78,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
data.IsRotorSpeedLt3 && data.IsPressureGt20;
|
||||
}
|
||||
},
|
||||
new OperationDetector
|
||||
new TelemetryOperationDetector
|
||||
{
|
||||
Order = 7,
|
||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("Спуск в скважину")),
|
||||
@ -89,7 +89,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
data.IsRotorSpeedLt3 && data.IsPressureLt20;
|
||||
}
|
||||
},
|
||||
new OperationDetector
|
||||
new TelemetryOperationDetector
|
||||
{
|
||||
Order = 8,
|
||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("Спуск с вращением")),
|
||||
@ -100,7 +100,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
data.IsRotorSpeedGt3 && data.IsPressureLt20;
|
||||
}
|
||||
},
|
||||
new OperationDetector
|
||||
new TelemetryOperationDetector
|
||||
{
|
||||
Order = 9,
|
||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("Подъем из скважины")),
|
||||
@ -111,7 +111,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
data.IsRotorSpeedLt3 && data.IsPressureLt20;
|
||||
}
|
||||
},
|
||||
new OperationDetector
|
||||
new TelemetryOperationDetector
|
||||
{
|
||||
Order = 10,
|
||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("Подъем с вращением")),
|
||||
@ -122,7 +122,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
data.IsRotorSpeedGt3 && data.IsPressureLt20;
|
||||
}
|
||||
},
|
||||
new OperationDetector
|
||||
new TelemetryOperationDetector
|
||||
{
|
||||
Order = 11,
|
||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("Промывка в покое")),
|
||||
@ -134,7 +134,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
data.IsRotorSpeedLt3 && data.IsPressureGt20;
|
||||
}
|
||||
},
|
||||
new OperationDetector
|
||||
new TelemetryOperationDetector
|
||||
{
|
||||
Order = 12,
|
||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("Промывка с вращением")),
|
||||
@ -146,7 +146,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
data.IsRotorSpeedGt3 && data.IsPressureGt20;
|
||||
}
|
||||
},
|
||||
new OperationDetector
|
||||
new TelemetryOperationDetector
|
||||
{
|
||||
Order = 13,
|
||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("Неподвижное состояние")),
|
||||
@ -158,7 +158,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
data.IsRotorSpeedLt3 && data.IsPressureLt20 && data.IsHookWeightNotChanges;
|
||||
}
|
||||
},
|
||||
new OperationDetector
|
||||
new TelemetryOperationDetector
|
||||
{
|
||||
Order = 14,
|
||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("Вращение без циркуляции")),
|
||||
@ -170,7 +170,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
data.IsRotorSpeedGt3 && data.IsPressureLt20;
|
||||
}
|
||||
},
|
||||
new OperationDetector
|
||||
new TelemetryOperationDetector
|
||||
{
|
||||
Order = 15,
|
||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("Невозможно определить операцию")),
|
||||
@ -179,8 +179,8 @@ namespace AsbCloudInfrastructure.Services
|
||||
};
|
||||
}
|
||||
|
||||
public Operation DetectOperation(TelemetryAnalysis data) =>
|
||||
public TelemetryOperation DetectOperation(TelemetryAnalysis data) =>
|
||||
detectors.OrderBy(d => d.Order).First(o => o.Detect(data)).Operation
|
||||
?? new Operation { Id = 1, Name = "Невозможно определить операцию" };
|
||||
?? new TelemetryOperation { Id = 1, Name = "Невозможно определить операцию" };
|
||||
}
|
||||
}
|
@ -56,9 +56,14 @@ namespace AsbCloudInfrastructure.Services
|
||||
return wellDto;
|
||||
}
|
||||
|
||||
public IEnumerable<WellSectionDto> GetStat(int wellId, int idCompany)
|
||||
public IEnumerable<WellSectionDto> GetSections(int wellId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public object GetOperations(int wellId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// <returns>Список операций на скважине за все время</returns>
|
||||
[HttpGet]
|
||||
[Route("{wellId}/operationsByWell")]
|
||||
[ProducesResponseType(typeof(PaginationContainer<OperationDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(PaginationContainer<TelemetryOperationDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public IActionResult GetOperationsByWell(int wellId, int skip = 0, int take = 32,
|
||||
[FromQuery] IEnumerable<int> categoryIds = default, DateTime begin = default, DateTime end = default)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user