CS2-53: Added model for 'TVD' chart

This commit is contained in:
KharchenkoVV 2021-08-13 15:37:33 +05:00
parent 12a73a4e21
commit fa63d18fa3
3 changed files with 77 additions and 21 deletions

View File

@ -27,13 +27,14 @@ namespace AsbCloudDb.Model
public virtual DbSet<TelemetryEvent> TelemetryEvents { get; set; }
public virtual DbSet<TelemetryMessage> TelemetryMessages { get; set; }
public virtual DbSet<TelemetryUser> TelemetryUsers { get; set; }
public virtual DbSet<TelemetryOperation> TelemetryOperations { get; set; }
public virtual DbSet<Operation> TelemetryOperations { get; set; }
public virtual DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; }
public virtual DbSet<WellSection> WellSections { get; set; }
public virtual DbSet<WellSectionType> WellSectionTypes { get; set; }
public virtual DbSet<WellOperation> WellOperations { get; set; }
public virtual DbSet<WellType> WellTypes { get; set; }
public virtual DbSet<LastData> LastData { get; set; }
public virtual DbSet<TvdData> TvdData { get; set; }
//var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
// .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
@ -163,6 +164,12 @@ namespace AsbCloudDb.Model
.HasConstraintName("t_relation_company_well_t_company_id_fk");
});
modelBuilder.Entity<TvdData>(entity =>
{
entity.HasIndex(d => d.Depth);
entity.HasIndex(d => d.Date);
});
FillData(modelBuilder);
FillDemoData(modelBuilder);
}
@ -198,26 +205,26 @@ namespace AsbCloudDb.Model
});
});
modelBuilder.Entity<TelemetryOperation>(entity =>
modelBuilder.Entity<Operation>(entity =>
{
entity.HasData(new List<TelemetryOperation> {
new TelemetryOperation {Id = 1, OperationType = 0, Name = "Невозможно определить операцию"},
new TelemetryOperation {Id = 2, OperationType = 0, Name = "Роторное бурение" },
new TelemetryOperation {Id = 3, OperationType = 0, Name = "Слайдирование" },
new TelemetryOperation {Id = 4, OperationType = 0, Name = "Подъем с проработкой" },
new TelemetryOperation {Id = 5, OperationType = 0, Name = "Спуск с проработкой" },
new TelemetryOperation {Id = 6, OperationType = 0, Name = "Подъем с промывкой" },
new TelemetryOperation {Id = 7, OperationType = 0, Name = "Спуск с промывкой" },
new TelemetryOperation {Id = 8, OperationType = 0, Name = "Спуск в скважину" },
new TelemetryOperation {Id = 9, OperationType = 0, Name = "Спуск с вращением" },
new TelemetryOperation {Id = 10, OperationType = 0, Name = "Подъем из скважины" },
new TelemetryOperation {Id = 11, OperationType = 0, Name = "Подъем с вращением" },
new TelemetryOperation {Id = 12, OperationType = 0, Name = "Промывка в покое" },
new TelemetryOperation {Id = 13, OperationType = 0, Name = "Промывка с вращением" },
new TelemetryOperation {Id = 14, OperationType = 0, Name = "Удержание в клиньях" },
new TelemetryOperation {Id = 15, OperationType = 0, Name = "Неподвижное состояние" },
new TelemetryOperation {Id = 16, OperationType = 0, Name = "Вращение без циркуляции" },
new TelemetryOperation {Id = 17, OperationType = 0, Name = "На поверхности" }
entity.HasData(new List<Operation> {
new Operation {Id = 1, OperationType = 0, Name = "Невозможно определить операцию"},
new Operation {Id = 2, OperationType = 0, Name = "Роторное бурение" },
new Operation {Id = 3, OperationType = 0, Name = "Слайдирование" },
new Operation {Id = 4, OperationType = 0, Name = "Подъем с проработкой" },
new Operation {Id = 5, OperationType = 0, Name = "Спуск с проработкой" },
new Operation {Id = 6, OperationType = 0, Name = "Подъем с промывкой" },
new Operation {Id = 7, OperationType = 0, Name = "Спуск с промывкой" },
new Operation {Id = 8, OperationType = 0, Name = "Спуск в скважину" },
new Operation {Id = 9, OperationType = 0, Name = "Спуск с вращением" },
new Operation {Id = 10, OperationType = 0, Name = "Подъем из скважины" },
new Operation {Id = 11, OperationType = 0, Name = "Подъем с вращением" },
new Operation {Id = 12, OperationType = 0, Name = "Промывка в покое" },
new Operation {Id = 13, OperationType = 0, Name = "Промывка с вращением" },
new Operation {Id = 14, OperationType = 0, Name = "Удержание в клиньях" },
new Operation {Id = 15, OperationType = 0, Name = "Неподвижное состояние" },
new Operation {Id = 16, OperationType = 0, Name = "Вращение без циркуляции" },
new Operation {Id = 17, OperationType = 0, Name = "На поверхности" }
});
});

View File

@ -22,7 +22,7 @@ namespace AsbCloudDb.Model
DbSet<FileCategory> FileCategories { get; set; }
DbSet<Telemetry> Telemetries { get; set; }
DbSet<TelemetryUser> TelemetryUsers { get; set; }
DbSet<TelemetryOperation> TelemetryOperations { get; set; }
DbSet<Operation> TelemetryOperations { get; set; }
DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; }
DbSet<Well> Wells { get; set; }
DbSet<WellSection> WellSections { get; set; }
@ -30,6 +30,7 @@ namespace AsbCloudDb.Model
DbSet<WellOperation> WellOperations { get; set; }
DbSet<WellType> WellTypes { get; set; }
DbSet<LastData> LastData { get; set; }
DbSet<TvdData> TvdData { get; set; }
int SaveChanges();
int SaveChanges(bool acceptAllChangesOnSuccess);

View File

@ -0,0 +1,48 @@
using System;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace AsbCloudDb.Model
{
[Table("t_tvd_data"), Comment("Данные для графика глубина-день")]
public class TvdData
{
[Key]
[Column("id")]
public int Id { get; set; }
[Column("id_section"), Comment("Id секции скважины")]
public int IdSection { get; set; }
[Column("id_category"), Comment("Id категории операции")]
public int IdCategory { get; set; }
[Column("type"), Comment("План или Факт")]
public string Type { get; set; }
[Column("depth"), Comment("Глубина, на которой производилась операция")]
public string Depth { get; set; }
[Column("date"), Comment("Дата операции")]
public DateTime Date { get; set; }
[Column("duration_hours"), Comment("Продолжительность в часах")]
public double Duration { get; set; }
[Column("data"), Comment("Данные по операции")]
public string Data { get; set; }
[Column("comment"), Comment("Комментарий")]
public string Comment { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdSection))]
public virtual WellSection WellSection { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdCategory))]
public virtual Operation Operation { get; set; }
}
}