2021-07-21 15:22:58 +05:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2021-05-17 12:53:30 +05:00
|
|
|
|
using System;
|
2021-04-02 17:28:07 +05:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2021-04-07 18:01:56 +05:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2021-08-11 12:11:21 +05:00
|
|
|
|
using System.Data.Common;
|
2021-04-02 17:28:07 +05:00
|
|
|
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudDb.Model
|
|
|
|
|
{
|
|
|
|
|
//Scaffold-DbContext "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True" Npgsql.EntityFrameworkCore.PostgreSQL -OutputDir Model -DataAnnotations
|
|
|
|
|
public partial class AsbCloudDbContext : DbContext, IAsbCloudDbContext
|
|
|
|
|
{
|
|
|
|
|
public virtual DbSet<Cluster> Clusters { get; set; }
|
2021-07-21 12:30:51 +05:00
|
|
|
|
public virtual DbSet<Company> Companies { get; set; }
|
2021-04-02 17:28:07 +05:00
|
|
|
|
public virtual DbSet<DataSaubBase> DataSaubBases { get; set; }
|
|
|
|
|
public virtual DbSet<Deposit> Deposits { get; set; }
|
2021-07-23 17:40:31 +05:00
|
|
|
|
public virtual DbSet<FileCategory> FileCategories { get; set; }
|
2021-08-28 20:00:04 +05:00
|
|
|
|
public virtual DbSet<FileInfo> Files { get; set; }
|
|
|
|
|
public virtual DbSet<Measure> Measures { get; set; }
|
|
|
|
|
public virtual DbSet<MeasureCategory> MeasureCategories { get; set; }
|
|
|
|
|
public virtual DbSet<ReportProperty> ReportProperties { get; set; }
|
2021-07-27 14:43:30 +05:00
|
|
|
|
public virtual DbSet<Telemetry> Telemetries { get; set; }
|
2021-08-28 20:00:04 +05:00
|
|
|
|
public virtual DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; }
|
2021-08-10 15:53:11 +05:00
|
|
|
|
public virtual DbSet<TelemetryEvent> TelemetryEvents { get; set; }
|
|
|
|
|
public virtual DbSet<TelemetryMessage> TelemetryMessages { get; set; }
|
2021-07-27 14:43:30 +05:00
|
|
|
|
public virtual DbSet<TelemetryUser> TelemetryUsers { get; set; }
|
2021-08-28 20:00:04 +05:00
|
|
|
|
public virtual DbSet<User> Users { get; set; }
|
|
|
|
|
public virtual DbSet<UserRole> UserRoles { get; set; }
|
|
|
|
|
public virtual DbSet<Well> Wells { get; set; }
|
|
|
|
|
public virtual DbSet<WellOperation> WellOperations { get; set; }
|
2021-08-16 14:19:43 +05:00
|
|
|
|
public virtual DbSet<WellOperationCategory> TelemetryOperations { get; set; }
|
2021-08-13 12:33:05 +05:00
|
|
|
|
public virtual DbSet<WellSectionType> WellSectionTypes { get; set; }
|
2021-07-21 15:22:58 +05:00
|
|
|
|
public virtual DbSet<WellType> WellTypes { get; set; }
|
2021-04-02 17:28:07 +05:00
|
|
|
|
|
2021-07-28 09:46:58 +05:00
|
|
|
|
//var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
|
|
|
|
|
// .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
|
|
|
|
|
// .Options;
|
|
|
|
|
//var context = new AsbCloudDbContext(options);
|
2021-04-02 17:28:07 +05:00
|
|
|
|
|
|
|
|
|
public AsbCloudDbContext(DbContextOptions<AsbCloudDbContext> options)
|
|
|
|
|
: base(options)
|
|
|
|
|
{
|
|
|
|
|
Database.EnsureCreated();
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-23 10:21:25 +05:00
|
|
|
|
//protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
|
|
|
//{
|
|
|
|
|
// if (!optionsBuilder.IsConfigured)
|
|
|
|
|
// {
|
|
|
|
|
// optionsBuilder.UseNpgsql(connectionString);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
2021-04-02 17:28:07 +05:00
|
|
|
|
|
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
modelBuilder.HasPostgresExtension("adminpack")
|
|
|
|
|
.HasAnnotation("Relational:Collation", "Russian_Russia.1251");
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<Cluster>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasOne(d => d.Deposit)
|
|
|
|
|
.WithMany(p => p.Clusters)
|
|
|
|
|
.HasForeignKey(d => d.IdDeposit)
|
|
|
|
|
.HasConstraintName("t_cluster_t_deposit_id_fk");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<DataSaubBase>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasOne(d => d.Telemetry)
|
|
|
|
|
.WithMany(p => p.DataSaubBases)
|
|
|
|
|
.HasForeignKey(d => d.IdTelemetry)
|
|
|
|
|
.OnDelete(DeleteBehavior.ClientSetNull)
|
|
|
|
|
.HasConstraintName("t_data_saub_base_t_telemetry_id_fk");
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-10 15:53:11 +05:00
|
|
|
|
modelBuilder.Entity<TelemetryMessage>(entity =>
|
2021-04-02 17:28:07 +05:00
|
|
|
|
{
|
|
|
|
|
entity.HasOne(d => d.Telemetry)
|
|
|
|
|
.WithMany(p => p.Messages)
|
|
|
|
|
.HasForeignKey(d => d.IdTelemetry)
|
|
|
|
|
.HasConstraintName("t_messages_t_telemetry_id_fk");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<TelemetryUser>(entity =>
|
|
|
|
|
{
|
2021-04-23 10:21:25 +05:00
|
|
|
|
entity.HasKey(nameof(TelemetryUser.IdTelemetry), nameof(TelemetryUser.IdUser));
|
2021-04-02 17:28:07 +05:00
|
|
|
|
entity.HasOne(d => d.Telemetry)
|
2021-04-23 10:21:25 +05:00
|
|
|
|
.WithMany(p => p.Users)
|
2021-04-02 17:28:07 +05:00
|
|
|
|
.HasForeignKey(d => d.IdTelemetry)
|
|
|
|
|
.OnDelete(DeleteBehavior.ClientSetNull)
|
|
|
|
|
.HasConstraintName("t_telemetry_user_t_telemetry_id_fk");
|
|
|
|
|
});
|
|
|
|
|
|
2021-07-19 15:31:50 +05:00
|
|
|
|
modelBuilder.Entity<TelemetryAnalysis>(entity =>
|
2021-06-24 13:02:31 +05:00
|
|
|
|
{
|
|
|
|
|
entity.HasOne(d => d.Telemetry)
|
|
|
|
|
.WithMany(p => p.Analysis)
|
|
|
|
|
.HasForeignKey(d => d.IdTelemetry)
|
|
|
|
|
.HasConstraintName("t_analysis_t_telemetry_id_fk");
|
|
|
|
|
|
|
|
|
|
entity.HasOne(d => d.Operation)
|
|
|
|
|
.WithMany(p => p.Analysis)
|
|
|
|
|
.HasForeignKey(d => d.IdOperation)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull)
|
|
|
|
|
.HasConstraintName("t_analysis_t_operation_id_fk");
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-10 15:53:11 +05:00
|
|
|
|
modelBuilder.Entity<TelemetryEvent>(entity =>
|
2021-04-23 10:21:25 +05:00
|
|
|
|
{
|
2021-08-10 15:53:11 +05:00
|
|
|
|
entity.HasKey(nameof(TelemetryEvent.IdTelemetry), nameof(TelemetryEvent.IdEvent));
|
2021-04-23 10:21:25 +05:00
|
|
|
|
entity.HasOne(d => d.Telemetry)
|
|
|
|
|
.WithMany(p => p.Events)
|
|
|
|
|
.HasForeignKey(d => d.IdTelemetry)
|
|
|
|
|
.HasConstraintName("t_event_t_telemetry_id_fk");
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-02 17:28:07 +05:00
|
|
|
|
modelBuilder.Entity<User>(entity =>
|
|
|
|
|
{
|
2021-07-21 12:30:51 +05:00
|
|
|
|
entity.HasOne(d => d.Company)
|
2021-04-02 17:28:07 +05:00
|
|
|
|
.WithMany(p => p.Users)
|
2021-07-21 12:30:51 +05:00
|
|
|
|
.HasForeignKey(d => d.IdCompany)
|
2021-07-21 15:22:58 +05:00
|
|
|
|
.HasConstraintName("t_user_t_company_id_fk");
|
2021-04-02 17:28:07 +05:00
|
|
|
|
|
|
|
|
|
entity.HasIndex(d => d.Login)
|
|
|
|
|
.IsUnique();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<Well>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasOne(d => d.Cluster)
|
|
|
|
|
.WithMany(p => p.Wells)
|
|
|
|
|
.HasForeignKey(d => d.IdCluster)
|
|
|
|
|
.HasConstraintName("t_well_t_cluster_id_fk");
|
|
|
|
|
|
|
|
|
|
entity.HasOne(d => d.Telemetry)
|
|
|
|
|
.WithOne(p => p.Well)
|
|
|
|
|
.HasForeignKey<Well>(d => d.IdTelemetry)
|
|
|
|
|
.HasConstraintName("t_well_t_telemetry_id_fk");
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-09 15:41:42 +05:00
|
|
|
|
modelBuilder.Entity<RelationCompanyWell>(entity =>
|
|
|
|
|
{
|
2021-07-21 16:30:57 +05:00
|
|
|
|
|
|
|
|
|
entity.HasKey(nameof(RelationCompanyWell.IdCompany), nameof(RelationCompanyWell.IdWell));
|
|
|
|
|
|
|
|
|
|
entity.HasOne(r => r.Well)
|
|
|
|
|
.WithMany(w => w.RelationCompaniesWells)
|
|
|
|
|
.HasForeignKey(r => r.IdWell)
|
|
|
|
|
.HasConstraintName("t_relation_company_well_t_well_id_fk");
|
|
|
|
|
|
|
|
|
|
entity.HasOne(r => r.Company)
|
|
|
|
|
.WithMany(w => w.RelationCompaniesWells)
|
|
|
|
|
.HasForeignKey(r => r.IdCompany)
|
|
|
|
|
.HasConstraintName("t_relation_company_well_t_company_id_fk");
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-13 17:25:06 +05:00
|
|
|
|
modelBuilder.Entity<WellOperation>(entity =>
|
2021-08-13 15:37:33 +05:00
|
|
|
|
{
|
2021-08-13 17:25:06 +05:00
|
|
|
|
entity.HasIndex(d => d.WellDepth);
|
|
|
|
|
entity.HasIndex(d => d.StartDate);
|
2021-08-13 15:37:33 +05:00
|
|
|
|
});
|
|
|
|
|
|
2021-04-09 17:59:07 +05:00
|
|
|
|
FillData(modelBuilder);
|
2021-09-07 09:58:48 +05:00
|
|
|
|
#if DEBUG
|
2021-07-21 17:59:18 +05:00
|
|
|
|
FillDemoData(modelBuilder);
|
2021-09-07 09:58:48 +05:00
|
|
|
|
#endif
|
2021-04-02 17:28:07 +05:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-19 15:21:19 +05:00
|
|
|
|
private static void FillData(ModelBuilder modelBuilder)
|
2021-04-09 17:59:07 +05:00
|
|
|
|
{
|
2021-07-21 17:59:18 +05:00
|
|
|
|
modelBuilder.Entity<UserRole>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasData(new List<UserRole>{
|
|
|
|
|
new UserRole{ Id = 1, Caption = "Администратор", },
|
2021-09-07 09:58:48 +05:00
|
|
|
|
new UserRole{ Id = 2, Caption = "Пользователь", },
|
2021-07-21 17:59:18 +05:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<User>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasData(new List<User>{
|
|
|
|
|
new User{
|
|
|
|
|
Id = 1,
|
|
|
|
|
IdCompany = 1,
|
|
|
|
|
IdRole = 1,
|
|
|
|
|
Level = int.MaxValue,
|
|
|
|
|
Login = "dev",
|
|
|
|
|
PasswordHash = "Vlcj|4fa529103dde7ff72cfe76185f344d4aa87931f8e1b2044e8a7739947c3d18923464eaad93843e4f809c5e126d013072", // dev
|
|
|
|
|
Name = "Разработчик",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<Company>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasData(new List<Company>{
|
2021-07-22 14:23:47 +05:00
|
|
|
|
new Company{ Id = 1, Caption = "ООО \"АСБ\"", IdCompanyType = 3},
|
2021-07-21 17:59:18 +05:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-16 14:19:43 +05:00
|
|
|
|
modelBuilder.Entity<WellOperationCategory>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasData(new List<WellOperationCategory> {
|
2021-08-18 16:26:06 +05:00
|
|
|
|
// Автоматически опеределяемые операции
|
2021-08-16 14:19:43 +05:00
|
|
|
|
new WellOperationCategory {Id = 1, Name = "Невозможно определить операцию", Code = 0},
|
|
|
|
|
new WellOperationCategory {Id = 2, Name = "Роторное бурение", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 3, Name = "Слайдирование", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 4, Name = "Подъем с проработкой", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 5, Name = "Спуск с проработкой", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 6, Name = "Подъем с промывкой", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 7, Name = "Спуск с промывкой", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 8, Name = "Спуск в скважину", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 9, Name = "Спуск с вращением", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 10, Name = "Подъем из скважины", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 11, Name = "Подъем с вращением", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 12, Name = "Промывка в покое", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 13, Name = "Промывка с вращением", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 14, Name = "Удержание в клиньях", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 15, Name = "Неподвижное состояние", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 16, Name = "Вращение без циркуляции", Code = 0 },
|
2021-08-18 16:26:06 +05:00
|
|
|
|
new WellOperationCategory {Id = 17, Name = "На поверхности", Code = 0 },
|
|
|
|
|
// Операции ручного ввода
|
2021-08-19 14:31:02 +05:00
|
|
|
|
new WellOperationCategory {Id = 1001, Name = "Бурение в интервале", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1002, Name = "ГИС", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1003, Name = "ГФР", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1004, Name = "Монтаж ПВО", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1005, Name = "Демонтаж ПВО", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1006, Name = "Установка ФА", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1007, Name = "Оборудование устья", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1008, Name = "ОЗЦ", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1009, Name = "Оборудование устья", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1010, Name = "ОЗЦ", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1011, Name = "Начало цикла строительства скважины", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1012, Name = "Окончание цикла строительства скважины", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1013, Name = "Опрессовка ПВО", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1014, Name = "Опресовка Ц.К.", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1015, Name = "Опрессовка ВЗД", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1016, Name = "Перевод скв на другой тип промывочной жидкости", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1017, Name = "Перезапись каротажа", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1018, Name = "Перетяжка талевого каната", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1019, Name = "Перетяжка тальканата", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1020, Name = "Подъем инструмента", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1021, Name = "Подъем инструмента с промывкой", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1022, Name = "Обратная проработка", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1023, Name = "Сборка инструмента", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1024, Name = "Подготовительные работы", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1025, Name = "Сборка КНБК", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1026, Name = "Разборка КНБК", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1027, Name = "Промывка", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1028, Name = "Промежуточная промывка", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1029, Name = "Прокачка пачек", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1030, Name = "Разбуривание тех.оснастки", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1031, Name = "Ремонт", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1032, Name = "Спуск инструмента", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1033, Name = "Спуск инструмента с промывкой", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1034, Name = "Прямая проработка", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1035, Name = "Принудительная проработка", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1036, Name = "Спуск обсадной колонны", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1037, Name = "Тех СПО-подъем", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1038, Name = "Тех СПО-спуск", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1039, Name = "Техническое обслуживание", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1040, Name = "Цементаж", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1041, Name = "Шаблонировка ствола", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1042, Name = "Геологическое осложнение", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1043, Name = "НПВ", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1044, Name = "ВМР", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1045, Name = "Прочее", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1046, Name = "Спуск КНБК", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1047, Name = "Подъем КНБК", Code = 0 },
|
|
|
|
|
new WellOperationCategory {Id = 1048, Name = "Спуск ОК", Code = 0 }
|
2021-07-21 17:59:18 +05:00
|
|
|
|
});
|
|
|
|
|
});
|
2021-07-23 17:40:31 +05:00
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<FileCategory>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasData(new List<FileCategory> {
|
2021-08-02 18:35:36 +05:00
|
|
|
|
new FileCategory {Id = 1, Name = "Растворный сервис", ShortName = "fluidService"},
|
|
|
|
|
new FileCategory {Id = 2, Name = "Цементирование", ShortName = "cement"},
|
|
|
|
|
new FileCategory {Id = 3, Name = "ННБ", ShortName = "nnb"},
|
|
|
|
|
new FileCategory {Id = 4, Name = "ГТИ", ShortName = "gti"},
|
|
|
|
|
new FileCategory {Id = 5, Name = "Документы по скважине", ShortName = "wellDocuments"},
|
|
|
|
|
new FileCategory {Id = 6, Name = "Супервайзер", ShortName = "supervisor"},
|
|
|
|
|
new FileCategory {Id = 7, Name = "Мастер", ShortName = "master"},
|
|
|
|
|
new FileCategory {Id = 8, Name = "Последний замер бурового раствора ПЛАН", ShortName = "fluidPlanLastData"},
|
|
|
|
|
new FileCategory {Id = 9, Name = "Последний замер бурового раствора ФАКТ", ShortName = "fluidFactLastData"},
|
|
|
|
|
new FileCategory {Id = 10, Name = "Последние данные Шламограммы", ShortName = "mudLastData"},
|
|
|
|
|
new FileCategory {Id = 11, Name = "Последние данные ННБ", ShortName = "nnbLastData"},
|
2021-08-29 17:25:16 +05:00
|
|
|
|
new FileCategory {Id = 12, Name = "Рапорт", ShortName = "report"},
|
2021-08-31 09:52:32 +05:00
|
|
|
|
new FileCategory {Id = 13, Name = "Программа бурения, части", ShortName = "ПБч"},
|
|
|
|
|
new FileCategory {Id = 14, Name = "Программа бурения", ShortName = "ПБ"},
|
2021-07-23 17:40:31 +05:00
|
|
|
|
});
|
|
|
|
|
});
|
2021-08-10 15:48:06 +05:00
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<WellSectionType>(entity => {
|
|
|
|
|
entity.HasData(new List<WellSectionType>{
|
2021-08-25 15:17:24 +05:00
|
|
|
|
new WellSectionType{ Id = 1, Caption = "Пилотный ствол"},
|
|
|
|
|
new WellSectionType{ Id = 2, Caption = "Направление"},
|
|
|
|
|
new WellSectionType{ Id = 3, Caption = "Кондуктор"},
|
|
|
|
|
new WellSectionType{ Id = 4, Caption = "Эксплуатационная колонна"},
|
|
|
|
|
new WellSectionType{ Id = 5, Caption = "Транспортный ствол"},
|
|
|
|
|
new WellSectionType{ Id = 6, Caption = "Хвостовик"},
|
2021-08-10 15:48:06 +05:00
|
|
|
|
});
|
|
|
|
|
});
|
2021-08-25 17:58:35 +05:00
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<WellType>(entity => {
|
|
|
|
|
entity.HasData(new List<WellType> {
|
|
|
|
|
new WellType{ Id = 1, Caption = "Наклонно-направленная"},
|
|
|
|
|
new WellType{ Id = 2, Caption = "Горизонтальная"},
|
|
|
|
|
});
|
|
|
|
|
});
|
2021-08-28 20:00:04 +05:00
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<MeasureCategory>(entity => {
|
|
|
|
|
entity.HasData(new List<MeasureCategory> {
|
|
|
|
|
new MeasureCategory{ Id = 1, Name = "Показатели бурового раствора", ShortName = "Раствор"},
|
|
|
|
|
new MeasureCategory{ Id = 2, Name = "Шламограмма", ShortName = "Шламограмма"},
|
|
|
|
|
new MeasureCategory{ Id = 3, Name = "ННБ", ShortName = "ННБ"},
|
|
|
|
|
});
|
|
|
|
|
});
|
2021-07-21 17:59:18 +05:00
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<CompanyType>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasData(new List<CompanyType>{
|
|
|
|
|
new CompanyType{ Id = 1, Caption = "Недрапользователь", },
|
|
|
|
|
new CompanyType{ Id = 2, Caption = "Буровой подрядчик", },
|
|
|
|
|
new CompanyType{ Id = 3, Caption = "Сервис автоматизации бурения", },
|
|
|
|
|
});
|
|
|
|
|
});
|
2021-09-07 09:58:48 +05:00
|
|
|
|
}
|
2021-07-21 17:59:18 +05:00
|
|
|
|
|
2021-09-07 09:58:48 +05:00
|
|
|
|
// Эти данные не должны быть в релизе
|
|
|
|
|
private static void FillDemoData(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
2021-04-09 17:59:07 +05:00
|
|
|
|
modelBuilder.Entity<Deposit>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasData(new List<Deposit> {
|
2021-07-19 15:57:51 +05:00
|
|
|
|
new Deposit{Id = 1, Caption = "м/р 1", Latitude = 60.8705722222222, Longitude = 70.3811888888889 },
|
2021-04-09 17:59:07 +05:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<Cluster>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasData(new List<Cluster> {
|
2021-07-21 17:59:18 +05:00
|
|
|
|
new Cluster{Id = 1, Caption = "к39.1", IdDeposit = 1, Latitude = 60.8705722222222, Longitude = 70.3811888888889},
|
2021-07-19 15:57:51 +05:00
|
|
|
|
new Cluster{Id = 2, Caption = "к151", IdDeposit = 1, Latitude = 60.8205750000000, Longitude = 70.1343833333334},
|
|
|
|
|
new Cluster{Id = 3, Caption = "к611", IdDeposit = 1, Latitude = 60.8100666666667, Longitude = 69.7778388888889},
|
|
|
|
|
new Cluster{Id = 4, Caption = "к203", IdDeposit = 1, Latitude = 60.8928805555556, Longitude = 70.3272055555556},
|
2021-07-21 17:59:18 +05:00
|
|
|
|
new Cluster{Id = 5, Caption = "к221", IdDeposit = 1, Latitude = 60.6672055555556, Longitude = 69.6603861111111},
|
2021-04-09 17:59:07 +05:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-28 20:00:04 +05:00
|
|
|
|
modelBuilder.Entity<Measure>(entity => {
|
|
|
|
|
entity.HasData(new List<Measure> {
|
|
|
|
|
new Measure{ Id = 1, IdCategory = 1, IdWell = 1, Timestamp = DateTime.Now.AddHours(1), Data = new Dictionary<string, object>{ {"a", 1 }}},
|
|
|
|
|
new Measure{ Id = 2, IdCategory = 1, IdWell = 1, Timestamp = DateTime.Now.AddHours(2), Data = new Dictionary<string, object>{ {"a", 2 }}},
|
|
|
|
|
new Measure{ Id = 3, IdCategory = 2, IdWell = 1, Timestamp = DateTime.Now.AddHours(3), Data = new Dictionary<string, object>{ {"a", 3 }}},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2021-07-21 17:59:18 +05:00
|
|
|
|
modelBuilder.Entity<Telemetry>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasData(new List<Telemetry>{
|
|
|
|
|
new Telemetry{
|
|
|
|
|
Id = 1,
|
|
|
|
|
RemoteUid = "123",
|
|
|
|
|
Info = new TelemetryInfo
|
|
|
|
|
{
|
|
|
|
|
Well = "1",
|
|
|
|
|
Cluster = "1",
|
|
|
|
|
Comment = "",
|
|
|
|
|
Deposit = "1",
|
|
|
|
|
Customer = "1",
|
|
|
|
|
HmiVersion = "1",
|
|
|
|
|
PlcVersion = "1",
|
|
|
|
|
TimeZoneId = "1",
|
|
|
|
|
DrillingStartDate = DateTime.Parse("2021-06-29T12:01:19.000000"),
|
|
|
|
|
TimeZoneOffsetTotalHours = 5.0
|
|
|
|
|
},
|
|
|
|
|
}
|
2021-04-09 17:59:07 +05:00
|
|
|
|
});
|
|
|
|
|
});
|
2021-06-24 13:02:31 +05:00
|
|
|
|
|
2021-07-23 17:40:31 +05:00
|
|
|
|
modelBuilder.Entity<Well>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasData(new List<Well> {
|
2021-08-25 17:58:35 +05:00
|
|
|
|
new Well{Id = 1, IdCluster = 1, IdWellType = 1, Caption = "скв 16314", Latitude = 60.8705722222222, Longitude = 70.3811888888889, IdTelemetry = 1, },
|
|
|
|
|
new Well{Id = 2, IdCluster = 1, IdWellType = 2, Caption = "скв 16311", Latitude = 60.8705722222222, Longitude = 70.3811888888889},
|
|
|
|
|
new Well{Id = 3, IdCluster = 2, IdWellType = 1, Caption = "скв 16315", Latitude = 60.8205750000000, Longitude = 70.1343833333334},
|
|
|
|
|
new Well{Id = 4, IdCluster = 2, IdWellType = 1, Caption = "скв 16318", Latitude = 60.8205750000000, Longitude = 70.1343833333334},
|
|
|
|
|
new Well{Id = 5, IdCluster = 3, IdWellType = 1, Caption = "скв 16310", Latitude = 60.8100666666667, Longitude = 69.7778388888889},
|
|
|
|
|
new Well{Id = 6, IdCluster = 4, IdWellType = 1, Caption = "скв 16316", Latitude = 60.8928805555556, Longitude = 70.3272055555556},
|
|
|
|
|
new Well{Id = 7, IdCluster = 5, IdWellType = 1, Caption = "скв 16312", Latitude = 60.6672055555556, Longitude = 69.6603861111111},
|
|
|
|
|
new Well{Id = 8, IdCluster = 5, IdWellType = 1, Caption = "скв 16313", Latitude = 60.6672055555556, Longitude = 69.6603861111111},
|
|
|
|
|
new Well{Id = 9, IdCluster = 5, IdWellType = 1, Caption = "скв 42669", Latitude = 60.6672055555556, Longitude = 69.6603861111111},
|
2021-07-23 17:40:31 +05:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-09 15:41:42 +05:00
|
|
|
|
modelBuilder.Entity<RelationCompanyWell>(entity =>
|
|
|
|
|
{
|
2021-07-21 16:30:57 +05:00
|
|
|
|
entity.HasData(new List<RelationCompanyWell> {
|
|
|
|
|
new RelationCompanyWell{ IdWell = 1, IdCompany = 1},
|
|
|
|
|
new RelationCompanyWell{ IdWell = 2, IdCompany = 1},
|
|
|
|
|
new RelationCompanyWell{ IdWell = 3, IdCompany = 1},
|
|
|
|
|
new RelationCompanyWell{ IdWell = 4, IdCompany = 1},
|
|
|
|
|
new RelationCompanyWell{ IdWell = 5, IdCompany = 1},
|
|
|
|
|
new RelationCompanyWell{ IdWell = 6, IdCompany = 1},
|
|
|
|
|
new RelationCompanyWell{ IdWell = 7, IdCompany = 1},
|
|
|
|
|
new RelationCompanyWell{ IdWell = 8, IdCompany = 1},
|
|
|
|
|
new RelationCompanyWell{ IdWell = 9, IdCompany = 1},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-18 16:51:41 +05:00
|
|
|
|
modelBuilder.Entity<WellOperation>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasData(new List<WellOperation> {
|
2021-08-29 11:59:20 +05:00
|
|
|
|
new WellOperation{ Id = 64049, IdWell = 1, IdWellSectionType = 2, IdCategory = 1025, IdType = 0, WellDepth = 1400, StartDate = DateTime.Parse("2021-09-02 15:30"), DurationHours = 3.5},
|
2021-08-29 17:25:16 +05:00
|
|
|
|
new WellOperation{ Id = 31502, IdWell = 1, IdWellSectionType = 1, IdCategory = 1027, IdType = 0, WellDepth = 800, StartDate = DateTime.Parse("2021-08-24 07:00"), DurationHours = 1.16666666666667},
|
|
|
|
|
new WellOperation{ Id = 1531, IdWell = 5, IdWellSectionType = 2, IdCategory = 1025, IdType = 1, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 00:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 44572, IdWell = 1, IdWellSectionType = 1, IdCategory = 1047, IdType = 0, WellDepth = 1400, StartDate = DateTime.Parse("2021-08-27 05:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 44514, IdWell = 1, IdWellSectionType = 2, IdCategory = 1046, IdType = 0, WellDepth = 1400, StartDate = DateTime.Parse("2021-09-02 19:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 53383, IdWell = 2, IdWellSectionType = 2, IdCategory = 1027, IdType = 1, WellDepth = 800, StartDate = DateTime.Parse("2021-08-24 07:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 3431, IdWell = 1, IdWellSectionType = 1, IdCategory = 1047, IdType = 1, WellDepth = 1300, StartDate = DateTime.Parse("2021-08-25 15:40"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 21460, IdWell = 1, IdWellSectionType = 1, IdCategory = 1025, IdType = 1, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 01:10"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 30464, IdWell = 1, IdWellSectionType = 2, IdCategory = 1026, IdType = 0, WellDepth = 1500, StartDate = DateTime.Parse("2021-09-03 12:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 73111, IdWell = 1, IdWellSectionType = 2, IdCategory = 1026, IdType = 1, WellDepth = 1500, StartDate = DateTime.Parse("2021-09-04 13:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 81351, IdWell = 1, IdWellSectionType = 1, IdCategory = 1001, IdType = 1, WellDepth = 1110, StartDate = DateTime.Parse("2021-08-25 05:10"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 24480, IdWell = 1, IdWellSectionType = 2, IdCategory = 1027, IdType = 0, WellDepth = 1400, StartDate = DateTime.Parse("2021-09-02 22:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 19101, IdWell = 1, IdWellSectionType = 1, IdCategory = 1026, IdType = 0, WellDepth = 1250, StartDate = DateTime.Parse("2021-08-25 21:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 34738, IdWell = 1, IdWellSectionType = 2, IdCategory = 1046, IdType = 1, WellDepth = 1400, StartDate = DateTime.Parse("2021-09-04 02:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 37606, IdWell = 5, IdWellSectionType = 2, IdCategory = 1027, IdType = 1, WellDepth = 800, StartDate = DateTime.Parse("2021-08-24 07:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 71293, IdWell = 1, IdWellSectionType = 1, IdCategory = 1033, IdType = 1, WellDepth = 1300, StartDate = DateTime.Parse("2021-08-25 22:40"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 91696, IdWell = 1, IdWellSectionType = 1, IdCategory = 1025, IdType = 0, WellDepth = 1250, StartDate = DateTime.Parse("2021-08-26 18:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 77916, IdWell = 1, IdWellSectionType = 1, IdCategory = 1047, IdType = 0, WellDepth = 1250, StartDate = DateTime.Parse("2021-08-25 11:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 93585, IdWell = 1, IdWellSectionType = 1, IdCategory = 1046, IdType = 0, WellDepth = 800, StartDate = DateTime.Parse("2021-08-24 10:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 42016, IdWell = 4, IdWellSectionType = 2, IdCategory = 1046, IdType = 0, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 03:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 90466, IdWell = 1, IdWellSectionType = 1, IdCategory = 1048, IdType = 1, WellDepth = 1300, StartDate = DateTime.Parse("2021-08-26 09:10"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 15914, IdWell = 1, IdWellSectionType = 1, IdCategory = 1001, IdType = 0, WellDepth = 1250, StartDate = DateTime.Parse("2021-08-27 01:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 63469, IdWell = 4, IdWellSectionType = 2, IdCategory = 1026, IdType = 0, WellDepth = 1100, StartDate = DateTime.Parse("2021-08-27 08:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 23659, IdWell = 1, IdWellSectionType = 2, IdCategory = 1001, IdType = 1, WellDepth = 1400, StartDate = DateTime.Parse("2021-09-04 06:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 93508, IdWell = 1, IdWellSectionType = 2, IdCategory = 1027, IdType = 1, WellDepth = 1400, StartDate = DateTime.Parse("2021-09-03 23:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 74346, IdWell = 2, IdWellSectionType = 2, IdCategory = 1026, IdType = 0, WellDepth = 1100, StartDate = DateTime.Parse("2021-08-27 08:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 3139, IdWell = 1, IdWellSectionType = 1, IdCategory = 1047, IdType = 1, WellDepth = 1110, StartDate = DateTime.Parse("2021-08-24 22:10"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 11429, IdWell = 2, IdWellSectionType = 2, IdCategory = 1046, IdType = 1, WellDepth = 800, StartDate = DateTime.Parse("2021-08-24 10:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 14542, IdWell = 1, IdWellSectionType = 1, IdCategory = 1046, IdType = 0, WellDepth = 1100, StartDate = DateTime.Parse("2021-08-24 21:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 70906, IdWell = 4, IdWellSectionType = 2, IdCategory = 1046, IdType = 0, WellDepth = 800, StartDate = DateTime.Parse("2021-08-24 10:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 82194, IdWell = 1, IdWellSectionType = 2, IdCategory = 1046, IdType = 0, WellDepth = 1400, StartDate = DateTime.Parse("2021-09-03 02:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 13578, IdWell = 1, IdWellSectionType = 1, IdCategory = 1046, IdType = 0, WellDepth = 1250, StartDate = DateTime.Parse("2021-08-26 08:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 57798, IdWell = 1, IdWellSectionType = 1, IdCategory = 1033, IdType = 0, WellDepth = 1250, StartDate = DateTime.Parse("2021-08-25 14:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 37277, IdWell = 1, IdWellSectionType = 1, IdCategory = 1001, IdType = 0, WellDepth = 1100, StartDate = DateTime.Parse("2021-08-25 00:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 23233, IdWell = 1, IdWellSectionType = 1, IdCategory = 1045, IdType = 0, WellDepth = 1250, StartDate = DateTime.Parse("2021-08-25 07:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 26075, IdWell = 2, IdWellSectionType = 2, IdCategory = 1046, IdType = 0, WellDepth = 800, StartDate = DateTime.Parse("2021-08-24 10:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 8230, IdWell = 1, IdWellSectionType = 1, IdCategory = 1027, IdType = 1, WellDepth = 800, StartDate = DateTime.Parse("2021-08-26 12:40"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 26414, IdWell = 1, IdWellSectionType = 1, IdCategory = 1026, IdType = 0, WellDepth = 1250, StartDate = DateTime.Parse("2021-08-26 15:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 92747, IdWell = 1, IdWellSectionType = 1, IdCategory = 1046, IdType = 0, WellDepth = 1250, StartDate = DateTime.Parse("2021-08-26 22:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 89559, IdWell = 1, IdWellSectionType = 1, IdCategory = 1027, IdType = 1, WellDepth = 800, StartDate = DateTime.Parse("2021-08-25 19:10"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 99336, IdWell = 1, IdWellSectionType = 1, IdCategory = 1027, IdType = 1, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 08:10"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 80943, IdWell = 1, IdWellSectionType = 1, IdCategory = 1047, IdType = 0, WellDepth = 1250, StartDate = DateTime.Parse("2021-08-25 04:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 11934, IdWell = 1, IdWellSectionType = 1, IdCategory = 1006, IdType = 0, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 08:10"), DurationHours = 2.33333333333333},
|
|
|
|
|
new WellOperation{ Id = 88089, IdWell = 1, IdWellSectionType = 1, IdCategory = 1046, IdType = 1, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 11:40"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 57116, IdWell = 1, IdWellSectionType = 1, IdCategory = 1047, IdType = 0, WellDepth = 1250, StartDate = DateTime.Parse("2021-08-25 18:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 57561, IdWell = 5, IdWellSectionType = 2, IdCategory = 1046, IdType = 1, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 03:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 72783, IdWell = 1, IdWellSectionType = 1, IdCategory = 1046, IdType = 1, WellDepth = 1110, StartDate = DateTime.Parse("2021-08-25 01:40"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 75549, IdWell = 1, IdWellSectionType = 1, IdCategory = 1046, IdType = 0, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 03:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 60717, IdWell = 2, IdWellSectionType = 2, IdCategory = 1025, IdType = 1, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 00:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 21171, IdWell = 1, IdWellSectionType = 1, IdCategory = 1025, IdType = 0, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 00:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 13547, IdWell = 2, IdWellSectionType = 2, IdCategory = 1047, IdType = 1, WellDepth = 1100, StartDate = DateTime.Parse("2021-08-24 17:30"), DurationHours = 15},
|
|
|
|
|
new WellOperation{ Id = 83361, IdWell = 5, IdWellSectionType = 2, IdCategory = 1026, IdType = 1, WellDepth = 1100, StartDate = DateTime.Parse("2021-08-27 08:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 58676, IdWell = 2, IdWellSectionType = 2, IdCategory = 1001, IdType = 1, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 14:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 46864, IdWell = 1, IdWellSectionType = 2, IdCategory = 1025, IdType = 1, WellDepth = 1400, StartDate = DateTime.Parse("2021-09-03 16:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 95276, IdWell = 1, IdWellSectionType = 1, IdCategory = 1027, IdType = 1, WellDepth = 800, StartDate = DateTime.Parse("2021-08-24 18:40"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 33478, IdWell = 1, IdWellSectionType = 1, IdCategory = 1047, IdType = 0, WellDepth = 1100, StartDate = DateTime.Parse("2021-08-24 17:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 85086, IdWell = 1, IdWellSectionType = 2, IdCategory = 1047, IdType = 1, WellDepth = 1500, StartDate = DateTime.Parse("2021-09-04 09:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 38808, IdWell = 1, IdWellSectionType = 2, IdCategory = 1001, IdType = 0, WellDepth = 1400, StartDate = DateTime.Parse("2021-09-03 05:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 60045, IdWell = 5, IdWellSectionType = 2, IdCategory = 1001, IdType = 1, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 14:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 82773, IdWell = 2, IdWellSectionType = 2, IdCategory = 1027, IdType = 0, WellDepth = 800, StartDate = DateTime.Parse("2021-08-24 07:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 38025, IdWell = 1, IdWellSectionType = 1, IdCategory = 1047, IdType = 1, WellDepth = 1300, StartDate = DateTime.Parse("2021-08-25 08:40"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 8312, IdWell = 1, IdWellSectionType = 1, IdCategory = 1047, IdType = 1, WellDepth = 1300, StartDate = DateTime.Parse("2021-08-26 02:10"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 84440, IdWell = 1, IdWellSectionType = 2, IdCategory = 1046, IdType = 1, WellDepth = 1400, StartDate = DateTime.Parse("2021-09-03 19:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 78963, IdWell = 1, IdWellSectionType = 1, IdCategory = 1026, IdType = 1, WellDepth = 1300, StartDate = DateTime.Parse("2021-08-26 05:40"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 39690, IdWell = 2, IdWellSectionType = 2, IdCategory = 1046, IdType = 1, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 03:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 88719, IdWell = 2, IdWellSectionType = 2, IdCategory = 1001, IdType = 0, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 14:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 64890, IdWell = 1, IdWellSectionType = 1, IdCategory = 1001, IdType = 1, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 15:10"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 95476, IdWell = 1, IdWellSectionType = 1, IdCategory = 1025, IdType = 0, WellDepth = 1250, StartDate = DateTime.Parse("2021-08-26 04:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 78257, IdWell = 4, IdWellSectionType = 2, IdCategory = 1027, IdType = 0, WellDepth = 800, StartDate = DateTime.Parse("2021-08-24 07:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 41260, IdWell = 1, IdWellSectionType = 2, IdCategory = 1047, IdType = 0, WellDepth = 1500, StartDate = DateTime.Parse("2021-09-03 09:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 41055, IdWell = 5, IdWellSectionType = 2, IdCategory = 1047, IdType = 1, WellDepth = 1100, StartDate = DateTime.Parse("2021-08-24 17:30"), DurationHours = 15},
|
|
|
|
|
new WellOperation{ Id = 47051, IdWell = 1, IdWellSectionType = 1, IdCategory = 1046, IdType = 1, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 04:40"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 14068, IdWell = 1, IdWellSectionType = 1, IdCategory = 1045, IdType = 1, WellDepth = 1300, StartDate = DateTime.Parse("2021-08-25 12:10"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 96039, IdWell = 4, IdWellSectionType = 2, IdCategory = 1047, IdType = 0, WellDepth = 1100, StartDate = DateTime.Parse("2021-08-24 17:30"), DurationHours = 15},
|
|
|
|
|
new WellOperation{ Id = 34668, IdWell = 1, IdWellSectionType = 1, IdCategory = 1001, IdType = 0, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 14:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 43146, IdWell = 2, IdWellSectionType = 2, IdCategory = 1026, IdType = 1, WellDepth = 1100, StartDate = DateTime.Parse("2021-08-27 08:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 15263, IdWell = 2, IdWellSectionType = 2, IdCategory = 1046, IdType = 0, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 03:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 20802, IdWell = 2, IdWellSectionType = 2, IdCategory = 1025, IdType = 0, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 00:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 81320, IdWell = 4, IdWellSectionType = 2, IdCategory = 1001, IdType = 0, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 14:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 43902, IdWell = 2, IdWellSectionType = 2, IdCategory = 1047, IdType = 0, WellDepth = 1100, StartDate = DateTime.Parse("2021-08-24 17:30"), DurationHours = 15},
|
|
|
|
|
new WellOperation{ Id = 62958, IdWell = 4, IdWellSectionType = 2, IdCategory = 1025, IdType = 0, WellDepth = 1000, StartDate = DateTime.Parse("2021-08-24 00:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 74174, IdWell = 5, IdWellSectionType = 2, IdCategory = 1046, IdType = 1, WellDepth = 800, StartDate = DateTime.Parse("2021-08-24 10:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 76347, IdWell = 1, IdWellSectionType = 1, IdCategory = 1048, IdType = 0, WellDepth = 1250, StartDate = DateTime.Parse("2021-08-26 01:00"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 51329, IdWell = 1, IdWellSectionType = 1, IdCategory = 1026, IdType = 0, WellDepth = 1400, StartDate = DateTime.Parse("2021-08-27 08:30"), DurationHours = 3.5},
|
|
|
|
|
new WellOperation{ Id = 76341, IdWell = 1, IdWellSectionType = 1, IdCategory = 1047, IdType = 0, WellDepth = 1250, StartDate = DateTime.Parse("2021-08-26 11:30"), DurationHours = 3.5},
|
2021-08-18 16:51:41 +05:00
|
|
|
|
});
|
|
|
|
|
});
|
2021-08-25 15:17:24 +05:00
|
|
|
|
|
2021-07-21 17:59:18 +05:00
|
|
|
|
modelBuilder.Entity<TelemetryAnalysis>(entity =>
|
2021-06-24 13:02:31 +05:00
|
|
|
|
{
|
2021-07-21 17:59:18 +05:00
|
|
|
|
entity.HasData(new List<TelemetryAnalysis>{
|
|
|
|
|
new TelemetryAnalysis
|
|
|
|
|
{
|
|
|
|
|
Id = 1,
|
|
|
|
|
IdTelemetry = 1,
|
|
|
|
|
IdOperation = 17,
|
|
|
|
|
UnixDate = 1626870355,
|
|
|
|
|
DurationSec = 10,
|
|
|
|
|
OperationStartDepth = null,
|
|
|
|
|
OperationEndDepth = 206,
|
|
|
|
|
IsWellDepthIncreasing = false,
|
|
|
|
|
IsWellDepthDecreasing = false,
|
|
|
|
|
IsBitPositionIncreasing = false,
|
|
|
|
|
IsBitPositionDecreasing = false,
|
|
|
|
|
IsBitPositionLt20 = true,
|
|
|
|
|
IsBlockPositionIncreasing = false,
|
|
|
|
|
IsBlockPositionDecreasing = false,
|
|
|
|
|
IsRotorSpeedLt3 = true,
|
|
|
|
|
IsRotorSpeedGt3 = false,
|
|
|
|
|
IsPressureLt20 = true,
|
|
|
|
|
IsPressureGt20 = false,
|
|
|
|
|
IsHookWeightNotChanges = true,
|
|
|
|
|
IsHookWeightLt3 = true
|
|
|
|
|
},
|
|
|
|
|
new TelemetryAnalysis
|
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
IdTelemetry = 1,
|
|
|
|
|
IdOperation = 8,
|
|
|
|
|
UnixDate = 1626870364,
|
|
|
|
|
DurationSec = 6,
|
|
|
|
|
OperationStartDepth = 206,
|
|
|
|
|
OperationEndDepth = 206,
|
|
|
|
|
IsWellDepthIncreasing = false,
|
|
|
|
|
IsWellDepthDecreasing = false,
|
|
|
|
|
IsBitPositionIncreasing = true,
|
|
|
|
|
IsBitPositionDecreasing = false,
|
|
|
|
|
IsBitPositionLt20 = true,
|
|
|
|
|
IsBlockPositionIncreasing = true,
|
|
|
|
|
IsBlockPositionDecreasing = false,
|
|
|
|
|
IsRotorSpeedLt3 = true,
|
|
|
|
|
IsRotorSpeedGt3 = false,
|
|
|
|
|
IsPressureLt20 = true,
|
|
|
|
|
IsPressureGt20 = false,
|
|
|
|
|
IsHookWeightNotChanges = true,
|
|
|
|
|
IsHookWeightLt3 = true
|
|
|
|
|
},
|
|
|
|
|
new TelemetryAnalysis
|
|
|
|
|
{
|
|
|
|
|
Id = 3,
|
|
|
|
|
IdTelemetry = 1,
|
|
|
|
|
IdOperation = 10,
|
|
|
|
|
UnixDate = 1626870370,
|
|
|
|
|
DurationSec = 2,
|
2021-08-02 12:23:18 +05:00
|
|
|
|
OperationStartDepth = 206,
|
2021-07-21 17:59:18 +05:00
|
|
|
|
OperationEndDepth = 206,
|
|
|
|
|
IsWellDepthIncreasing = false,
|
|
|
|
|
IsWellDepthDecreasing = false,
|
|
|
|
|
IsBitPositionIncreasing = false,
|
|
|
|
|
IsBitPositionDecreasing = true,
|
|
|
|
|
IsBitPositionLt20 = true,
|
|
|
|
|
IsBlockPositionIncreasing = false,
|
|
|
|
|
IsBlockPositionDecreasing = true,
|
|
|
|
|
IsRotorSpeedLt3 = true,
|
|
|
|
|
IsRotorSpeedGt3 = false,
|
|
|
|
|
IsPressureLt20 = true,
|
|
|
|
|
IsPressureGt20 = false,
|
|
|
|
|
IsHookWeightNotChanges = true,
|
|
|
|
|
IsHookWeightLt3 = true
|
|
|
|
|
},
|
|
|
|
|
new TelemetryAnalysis
|
|
|
|
|
{
|
|
|
|
|
Id = 4,
|
|
|
|
|
IdTelemetry = 1,
|
|
|
|
|
IdOperation = 17,
|
|
|
|
|
UnixDate = 1626870372,
|
|
|
|
|
DurationSec = 7,
|
|
|
|
|
OperationStartDepth = 206,
|
|
|
|
|
OperationEndDepth = 206,
|
|
|
|
|
IsWellDepthIncreasing = false,
|
|
|
|
|
IsWellDepthDecreasing = false,
|
|
|
|
|
IsBitPositionIncreasing = false,
|
|
|
|
|
IsBitPositionDecreasing = false,
|
|
|
|
|
IsBitPositionLt20 = true,
|
|
|
|
|
IsBlockPositionIncreasing = false,
|
|
|
|
|
IsBlockPositionDecreasing = false,
|
|
|
|
|
IsRotorSpeedLt3 = true,
|
|
|
|
|
IsRotorSpeedGt3 = false,
|
|
|
|
|
IsPressureLt20 = true,
|
|
|
|
|
IsPressureGt20 = false,
|
|
|
|
|
IsHookWeightNotChanges = true,
|
|
|
|
|
IsHookWeightLt3 = true
|
|
|
|
|
},
|
|
|
|
|
new TelemetryAnalysis
|
|
|
|
|
{
|
|
|
|
|
Id = 5,
|
|
|
|
|
IdTelemetry = 1,
|
|
|
|
|
IdOperation = 8,
|
|
|
|
|
UnixDate = 1626870379,
|
|
|
|
|
DurationSec = 7,
|
|
|
|
|
OperationStartDepth = 206,
|
|
|
|
|
OperationEndDepth = 206,
|
|
|
|
|
IsWellDepthIncreasing = false,
|
|
|
|
|
IsWellDepthDecreasing = false,
|
|
|
|
|
IsBitPositionIncreasing = true,
|
|
|
|
|
IsBitPositionDecreasing = false,
|
|
|
|
|
IsBitPositionLt20 = true,
|
|
|
|
|
IsBlockPositionIncreasing = true,
|
|
|
|
|
IsBlockPositionDecreasing = false,
|
|
|
|
|
IsRotorSpeedLt3 = true,
|
|
|
|
|
IsRotorSpeedGt3 = false,
|
|
|
|
|
IsPressureLt20 = true,
|
|
|
|
|
IsPressureGt20 = false,
|
|
|
|
|
IsHookWeightNotChanges = true,
|
|
|
|
|
IsHookWeightLt3 = true
|
|
|
|
|
}
|
2021-06-24 13:02:31 +05:00
|
|
|
|
});
|
|
|
|
|
});
|
2021-04-09 17:59:07 +05:00
|
|
|
|
}
|
2021-04-02 17:28:07 +05:00
|
|
|
|
|
2021-07-21 12:30:51 +05:00
|
|
|
|
public IQueryable<Well> GetWellsForCompany(int idCompany)
|
2021-04-02 17:28:07 +05:00
|
|
|
|
{
|
|
|
|
|
return from well in Wells
|
2021-07-21 16:30:57 +05:00
|
|
|
|
.Include(w => w.RelationCompaniesWells)
|
|
|
|
|
.ThenInclude(r => r.Company)
|
2021-04-02 17:28:07 +05:00
|
|
|
|
.Include(w => w.Cluster)
|
|
|
|
|
.ThenInclude(c => c.Deposit)
|
2021-07-21 16:30:57 +05:00
|
|
|
|
where well.RelationCompaniesWells.Any(c => c.IdCompany == idCompany)
|
2021-04-02 17:28:07 +05:00
|
|
|
|
select well;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IQueryable<User> GetUsersByLogin(string login)
|
|
|
|
|
=> Users
|
|
|
|
|
.Include(e => e.Role)
|
2021-07-21 12:30:51 +05:00
|
|
|
|
.Include(e => e.Company)
|
2021-04-02 17:28:07 +05:00
|
|
|
|
.Where(e => e.Login == login);
|
2021-04-07 18:01:56 +05:00
|
|
|
|
|
2021-08-11 16:54:42 +05:00
|
|
|
|
public async Task<(DateTime From, DateTime To)> GetDatesRangeAsync<TEntity>(int idTelemetry,
|
|
|
|
|
CancellationToken token = default)
|
2021-05-17 14:04:33 +05:00
|
|
|
|
where TEntity : class, IIdTelemetryDate
|
2021-05-17 12:53:30 +05:00
|
|
|
|
{
|
2021-05-17 14:04:33 +05:00
|
|
|
|
var dbSet = Set<TEntity>();
|
|
|
|
|
|
2021-08-11 16:54:42 +05:00
|
|
|
|
var datesRange = await (from m in dbSet
|
|
|
|
|
where m.IdTelemetry == idTelemetry
|
|
|
|
|
group m by m.IdTelemetry into g
|
|
|
|
|
select new
|
|
|
|
|
{
|
|
|
|
|
From = g.Min(d => d.Date),
|
|
|
|
|
To = g.Max(d => d.Date)
|
|
|
|
|
}).AsNoTracking().FirstOrDefaultAsync(token);
|
2021-05-17 12:53:30 +05:00
|
|
|
|
|
|
|
|
|
if (datesRange is null)
|
2021-05-19 15:21:19 +05:00
|
|
|
|
return (DateTime.MinValue, DateTime.MaxValue);
|
2021-05-17 12:53:30 +05:00
|
|
|
|
|
2021-05-19 15:21:19 +05:00
|
|
|
|
return (datesRange.From, datesRange.To);
|
2021-05-17 12:53:30 +05:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-11 12:11:21 +05:00
|
|
|
|
public async Task<IEnumerable<(double? MinDepth, double? MaxDepth, DateTime BeginPeriodDate)>> GetDepthToIntervalAsync(int telemetryId,
|
2021-08-11 16:54:42 +05:00
|
|
|
|
int intervalHoursTimestamp, int workStartTimestamp, double timezoneOffset, CancellationToken token)
|
2021-06-22 09:49:53 +05:00
|
|
|
|
{
|
|
|
|
|
//TODO: Сменить на LINQ группирование
|
|
|
|
|
using var command = Database.GetDbConnection().CreateCommand();
|
|
|
|
|
|
|
|
|
|
command.CommandText = $@"SELECT Min(t.bit_depth) AS MinDepth, Max(t.bit_depth) AS MaxDepth, Min(t.Date) AS dateStart
|
|
|
|
|
FROM t_data_saub_base AS t
|
|
|
|
|
WHERE id_telemetry = {telemetryId} AND t.Id % 10 = 0
|
|
|
|
|
GROUP BY floor((extract(epoch from t.date) - {workStartTimestamp} + {timezoneOffset}) / {intervalHoursTimestamp});";
|
|
|
|
|
|
|
|
|
|
Database.OpenConnection();
|
2021-08-11 16:54:42 +05:00
|
|
|
|
using var reader = await command.ExecuteReaderAsync(token);
|
2021-08-11 12:11:21 +05:00
|
|
|
|
|
|
|
|
|
IEnumerable<(double? MinDepth, double? MaxDepth, DateTime BeginPeriodDate)> GetResult(DbDataReader rd)
|
2021-06-22 09:49:53 +05:00
|
|
|
|
{
|
2021-08-11 12:11:21 +05:00
|
|
|
|
if (rd.HasRows)
|
2021-06-22 09:49:53 +05:00
|
|
|
|
{
|
2021-08-11 12:11:21 +05:00
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
yield return
|
|
|
|
|
(
|
|
|
|
|
(double?)reader.GetValue(0),
|
|
|
|
|
(double?)reader.GetValue(1),
|
|
|
|
|
(DateTime)reader.GetValue(2)
|
|
|
|
|
);
|
|
|
|
|
}
|
2021-06-22 09:49:53 +05:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-11 12:11:21 +05:00
|
|
|
|
|
|
|
|
|
return GetResult(reader);
|
2021-06-22 09:49:53 +05:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-07 18:01:56 +05:00
|
|
|
|
public async Task<int> CreatePartitionAsync<TEntity>(string propertyName, int id, CancellationToken token = default)
|
2021-04-23 10:21:25 +05:00
|
|
|
|
where TEntity : class
|
2021-04-07 18:01:56 +05:00
|
|
|
|
{
|
|
|
|
|
var dbSet = Set<TEntity>();
|
|
|
|
|
var baseTableName = dbSet.EntityType.GetTableName();
|
|
|
|
|
var schema = dbSet.EntityType.GetSchema();
|
|
|
|
|
var tableObject = Microsoft.EntityFrameworkCore.Metadata.StoreObjectIdentifier.Table(baseTableName, schema);
|
2021-04-23 10:21:25 +05:00
|
|
|
|
var tableName = baseTableName.Replace("_base", "");
|
2021-04-07 18:01:56 +05:00
|
|
|
|
var property = dbSet.EntityType.GetProperty(propertyName).GetColumnName(tableObject);
|
|
|
|
|
|
|
|
|
|
var query = $"CREATE TABLE {tableName}_{id} (like {baseTableName} including all, constraint partitioning_check check ({property} = 1)) INHERITS ({baseTableName});";
|
2021-04-23 10:21:25 +05:00
|
|
|
|
|
2021-04-07 18:01:56 +05:00
|
|
|
|
return await Database.ExecuteSqlRawAsync(query, token).ConfigureAwait(false);
|
|
|
|
|
}
|
2021-04-02 17:28:07 +05:00
|
|
|
|
}
|
|
|
|
|
}
|