Enable nullable for ef models: Deposit, Cluster, Well, WellOperation, WellOperationCategory, Company, and corresponding dtos.

This commit is contained in:
ngfrolov 2023-02-17 15:30:17 +05:00
parent 3510af3628
commit 61bee21ad9
Signed by: ng.frolov
GPG Key ID: E99907A0357B29A7
23 changed files with 7507 additions and 155 deletions

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
namespace AsbCloudApp.Data
{
@ -11,7 +12,7 @@ namespace AsbCloudApp.Data
/// <summary>
/// ИД месторождения, необязательный
/// </summary>
public int? IdDeposit { get; set; }
public int IdDeposit { get; set; }
/// <summary>
/// DTO месторождения
@ -21,7 +22,7 @@ namespace AsbCloudApp.Data
/// <summary>
/// Список скважин куста
/// </summary>
public IEnumerable<WellDto>? Wells { get; set; } = null!;
public IEnumerable<WellDto> Wells { get; set; } = Enumerable.Empty<WellDto>();
}
/// <summary>
@ -32,7 +33,6 @@ namespace AsbCloudApp.Data
/// <summary>
/// Список скважин куста
/// </summary>
public IEnumerable<WellMapInfoDto>? Wells { get; set; } = null!;
public IEnumerable<WellMapInfoDto> Wells { get; set; } = Enumerable.Empty<WellMapInfoDto>();
}
#nullable disable
}

View File

@ -1,5 +1,8 @@
namespace AsbCloudApp.Data
using System.ComponentModel.DataAnnotations;
namespace AsbCloudApp.Data
{
#nullable enable
/// <summary>
/// DTO компании
/// </summary>
@ -11,7 +14,8 @@
/// <summary>
/// Название
/// </summary>
public string Caption { get; set; }
[Required]
public string Caption { get; set; } = null!;
/// <summary>
/// ИД типа компании
@ -21,6 +25,6 @@
/// <summary>
/// Название типа компании
/// </summary>
public string CompanyTypeCaption { get; set; }
public string CompanyTypeCaption { get; set; } = null!;
}
}

View File

@ -1,7 +1,11 @@
using System.Collections.Generic;
using System.Linq;
namespace AsbCloudApp.Data
{
#nullable enable
/// <summary>
/// DTO Месторождения
/// </summary>
@ -17,7 +21,7 @@ namespace AsbCloudApp.Data
/// <summary>
/// Кусты месторождения
/// </summary>
public IEnumerable<ClusterDto> Clusters { get; set; }
public IEnumerable<ClusterDto> Clusters { get; set; } = Enumerable.Empty<ClusterDto>();
}
/// <summary>
@ -28,6 +32,6 @@ namespace AsbCloudApp.Data
/// <summary>
/// Кусты месторождения
/// </summary>
public IEnumerable<ClusterBranchDto> Clusters { get; set; }
public IEnumerable<ClusterBranchDto> Clusters { get; set; } = Enumerable.Empty<ClusterBranchDto>();
}
}

View File

@ -1,5 +1,6 @@
namespace AsbCloudApp.Data
{
#nullable enable
/// <summary>
/// Интерфейс данных с Id
/// </summary>

View File

@ -1,5 +1,6 @@
namespace AsbCloudApp.Data
{
#nullable enable
/// <summary>
/// точка на карте
/// </summary>

View File

@ -1,5 +1,6 @@
namespace AsbCloudApp.Data
{
#nullable enable
/// <summary>
/// âðåìåííàÿ çîíà
/// </summary>
@ -13,7 +14,7 @@ namespace AsbCloudApp.Data
/// <summary>
/// èäåíòèôèêàòîð ÷àñîâîé çîíû
/// </summary>
public string TimezoneId { get; set; }
public string? TimezoneId { get; set; }
/// <summary>
/// çàïðåò íà ïåðåîïðåäåëåíèå
@ -21,7 +22,7 @@ namespace AsbCloudApp.Data
public bool IsOverride { get; set; }
/// <inheritdoc/>
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (obj is SimpleTimezoneDto tTimeZone
&& tTimeZone.Hours == Hours
@ -34,7 +35,7 @@ namespace AsbCloudApp.Data
/// <inheritdoc/>
public override int GetHashCode()
=> Hours.GetHashCode()
| TimezoneId.GetHashCode()
| TimezoneId?.GetHashCode()??-1
| IsOverride.GetHashCode();
/// <inheritdoc/>

View File

@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
namespace AsbCloudApp.Data
{
#nullable enable
/// <summary>
/// Скважина
/// </summary>
@ -15,22 +18,23 @@ namespace AsbCloudApp.Data
public double? Longitude { get; set; }
/// <inheritdoc/>
public SimpleTimezoneDto Timezone { get; set; }
[Required]
public SimpleTimezoneDto Timezone { get; set; } = null!;
/// <summary>
/// Название типа скважины
/// </summary>
public string WellType { get; set; }
public string WellType { get; set; } = null!;
/// <summary>
/// ID типа скважины
/// </summary>
public int? IdWellType { get; set; }
public int IdWellType { get; set; }
/// <summary>
/// ID куста
/// </summary>
public int? IdCluster { get; set; }
public int IdCluster { get; set; }
/// <summary>
/// 0 - неизвестно,
@ -57,11 +61,11 @@ namespace AsbCloudApp.Data
/// <summary>
/// Объект телеметрии (инфо от панели оператора)
/// </summary>
public TelemetryBaseDto Telemetry { get; set; }
public TelemetryBaseDto? Telemetry { get; set; }
/// <summary>
/// Компании участвующие в работах на скважине
/// </summary>
public IEnumerable<CompanyDto> Companies { get; set; }
public IEnumerable<CompanyDto> Companies { get; set; } = Enumerable.Empty<CompanyDto>();
}
}

View File

@ -1,5 +1,8 @@
namespace AsbCloudApp.Data
using System.ComponentModel.DataAnnotations;
namespace AsbCloudApp.Data
{
#nullable enable
/// <summary>
/// базовая информация о скважине
/// </summary>
@ -11,16 +14,17 @@
/// <summary>
/// Название
/// </summary>
public string Caption { get; set; }
[Required]
public string Caption { get; set; } = null!;
/// <summary>
/// Название куста
/// </summary>
public string Cluster { get; set; }
public string Cluster { get; set; } = null!;
/// <summary>
/// Название месторождения
/// </summary>
public string Deposit { get; set; }
public string Deposit { get; set; } = null!;
}
}

View File

@ -2,6 +2,7 @@
namespace AsbCloudApp.Data
{
#nullable enable
/// <summary>
/// DTO категория операции
/// </summary>
@ -13,7 +14,9 @@ namespace AsbCloudApp.Data
/// <summary>
/// название
/// </summary>
public string Name { get; set; }
[Required]
[StringLength(512)]
public string Name { get; set; } = null!;
/// <summary>
/// Идентификатор родительской категории
@ -24,12 +27,12 @@ namespace AsbCloudApp.Data
/// Название ключевого показателя операции
/// </summary>
[StringLength(32)]
public string KeyValueName { get; set; }
public string? KeyValueName { get; set; }
/// <summary>
/// Единицы измерения ключевого показателя операции
/// </summary>
[StringLength(16)]
public string KeyValueUnits { get; set; }
public string? KeyValueUnits { get; set; }
}
}

View File

@ -1,9 +1,9 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace AsbCloudApp.Data
{
//todo: добавить валидацию
#nullable enable
/// <summary>
/// Операции на скважине (заведенные пользователем)
/// </summary>
@ -13,21 +13,24 @@ namespace AsbCloudApp.Data
public int Id { get; set; }
/// <inheritdoc/>
[Required]
public int IdWell { get; set; }
/// <summary>
/// id секции скважины
/// </summary>
[Required]
public int IdWellSectionType { get; set; }
/// <summary>
/// название секции скважины
/// </summary>
public string WellSectionTypeName { get; set; }
public string WellSectionTypeName { get; set; } = null!;
/// <summary>
/// id категории операции
/// </summary>
[Required]
public int IdCategory { get; set; }
/// <summary>
@ -38,26 +41,30 @@ namespace AsbCloudApp.Data
/// <summary>
/// название категории операции
/// </summary>
public string CategoryName { get; set; }
public string CategoryName { get; set; } = null!;
/// <summary>
/// дополнительная информация по операции
/// </summary>
public string CategoryInfo { get; set; }
[StringLength(8192)]
public string? CategoryInfo { get; set; }
/// <summary>
/// 0 = план или 1 = факт или прогноз = 2
/// </summary>
[Required]
public int IdType { get; set; }
/// <summary>
/// Глубина на начало операции, м
/// </summary>
[Range(0, 50_000)]
public double DepthStart { get; set; }
/// <summary>
/// Глубина после завершения операции, м
/// </summary>
[Range(0, 50_000)]
public double DepthEnd { get; set; }
/// <summary>
@ -78,11 +85,14 @@ namespace AsbCloudApp.Data
/// <summary>
/// Продолжительность, часы
/// </summary>
[Range(0, 50)]
public double DurationHours { get; set; }
/// <summary>
/// Полезный комментарий
/// </summary>
public string Comment { get; set; }
[StringLength(8192)]
public string? Comment { get; set; }
}
#nullable disable
}

View File

@ -0,0 +1,322 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Enable_nullable_on_deposit_cluster_well_company_wellOperation : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "t_cluster_t_deposit_id_fk",
table: "t_cluster");
migrationBuilder.DropForeignKey(
name: "FK_t_well_t_well_type_id_well_type",
table: "t_well");
migrationBuilder.DropForeignKey(
name: "t_well_t_cluster_id_fk",
table: "t_well");
migrationBuilder.Sql("update t_well set timezone = '{\"Hours\": 5}' where timezone is null;");
migrationBuilder.Sql("update t_cluster set timezone = '{\"Hours\": 5}' where timezone is null;");
migrationBuilder.Sql("update t_deposit set timezone = '{\"Hours\": 5}' where timezone is null;");
migrationBuilder.AlterColumn<string>(
name: "timezone",
table: "t_well",
type: "jsonb",
nullable: false,
defaultValue: "{}",
comment: "Смещение часового пояса от UTC",
oldClrType: typeof(string),
oldType: "jsonb",
oldNullable: true,
oldComment: "Смещение часового пояса от UTC");
migrationBuilder.AlterColumn<int>(
name: "id_well_type",
table: "t_well",
type: "integer",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "integer",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "id_cluster",
table: "t_well",
type: "integer",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "integer",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_well",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "timezone",
table: "t_deposit",
type: "jsonb",
nullable: false,
defaultValue: "{}",
comment: "Смещение часового пояса от UTC",
oldClrType: typeof(string),
oldType: "jsonb",
oldNullable: true,
oldComment: "Смещение часового пояса от UTC");
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_deposit",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_company_type",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_company",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "timezone",
table: "t_cluster",
type: "jsonb",
nullable: false,
defaultValue: "{}",
comment: "Смещение часового пояса от UTC",
oldClrType: typeof(string),
oldType: "jsonb",
oldNullable: true,
oldComment: "Смещение часового пояса от UTC");
migrationBuilder.AlterColumn<int>(
name: "id_deposit",
table: "t_cluster",
type: "integer",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "integer",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_cluster",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "",
comment: "Название",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldNullable: true,
oldComment: "Название");
migrationBuilder.AddForeignKey(
name: "t_cluster_t_deposit_id_fk",
table: "t_cluster",
column: "id_deposit",
principalTable: "t_deposit",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_t_well_t_well_type_id_well_type",
table: "t_well",
column: "id_well_type",
principalTable: "t_well_type",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "t_well_t_cluster_id_fk",
table: "t_well",
column: "id_cluster",
principalTable: "t_cluster",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "t_cluster_t_deposit_id_fk",
table: "t_cluster");
migrationBuilder.DropForeignKey(
name: "FK_t_well_t_well_type_id_well_type",
table: "t_well");
migrationBuilder.DropForeignKey(
name: "t_well_t_cluster_id_fk",
table: "t_well");
migrationBuilder.AlterColumn<string>(
name: "timezone",
table: "t_well",
type: "jsonb",
nullable: true,
comment: "Смещение часового пояса от UTC",
oldClrType: typeof(string),
oldType: "jsonb",
oldComment: "Смещение часового пояса от UTC");
migrationBuilder.AlterColumn<int>(
name: "id_well_type",
table: "t_well",
type: "integer",
nullable: true,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.AlterColumn<int>(
name: "id_cluster",
table: "t_well",
type: "integer",
nullable: true,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_well",
type: "character varying(255)",
maxLength: 255,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255);
migrationBuilder.AlterColumn<string>(
name: "timezone",
table: "t_deposit",
type: "jsonb",
nullable: true,
comment: "Смещение часового пояса от UTC",
oldClrType: typeof(string),
oldType: "jsonb",
oldComment: "Смещение часового пояса от UTC");
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_deposit",
type: "character varying(255)",
maxLength: 255,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255);
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_company_type",
type: "character varying(255)",
maxLength: 255,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255);
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_company",
type: "character varying(255)",
maxLength: 255,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255);
migrationBuilder.AlterColumn<string>(
name: "timezone",
table: "t_cluster",
type: "jsonb",
nullable: true,
comment: "Смещение часового пояса от UTC",
oldClrType: typeof(string),
oldType: "jsonb",
oldComment: "Смещение часового пояса от UTC");
migrationBuilder.AlterColumn<int>(
name: "id_deposit",
table: "t_cluster",
type: "integer",
nullable: true,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_cluster",
type: "character varying(255)",
maxLength: 255,
nullable: true,
comment: "Название",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldComment: "Название");
migrationBuilder.AddForeignKey(
name: "t_cluster_t_deposit_id_fk",
table: "t_cluster",
column: "id_deposit",
principalTable: "t_deposit",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "FK_t_well_t_well_type_id_well_type",
table: "t_well",
column: "id_well_type",
principalTable: "t_well_type",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "t_well_t_cluster_id_fk",
table: "t_well",
column: "id_cluster",
principalTable: "t_cluster",
principalColumn: "id");
}
}
}

View File

@ -35,12 +35,13 @@ namespace AsbCloudDb.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Caption")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("caption")
.HasComment("Название");
b.Property<int?>("IdDeposit")
b.Property<int>("IdDeposit")
.HasColumnType("integer")
.HasColumnName("id_deposit");
@ -53,6 +54,7 @@ namespace AsbCloudDb.Migrations
.HasColumnName("longitude");
b.Property<string>("Timezone")
.IsRequired()
.HasColumnType("jsonb")
.HasColumnName("timezone")
.HasComment("Смещение часового пояса от UTC");
@ -61,7 +63,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdDeposit");
b.ToTable("t_cluster", (string)null);
b.ToTable("t_cluster");
b.HasComment("Кусты");
});
@ -76,6 +78,7 @@ namespace AsbCloudDb.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Caption")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("caption");
@ -90,7 +93,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdCompanyType");
b.ToTable("t_company", (string)null);
b.ToTable("t_company");
b.HasData(
new
@ -111,13 +114,14 @@ namespace AsbCloudDb.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Caption")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("caption");
b.HasKey("Id");
b.ToTable("t_company_type", (string)null);
b.ToTable("t_company_type");
b.HasData(
new
@ -157,7 +161,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdWell", "StartDate")
.HasName("t_id_well_date_start_pk");
b.ToTable("t_daily_report", (string)null);
b.ToTable("t_daily_report");
b.HasComment("Ежедневные отчёты");
});
@ -172,6 +176,7 @@ namespace AsbCloudDb.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Caption")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("caption");
@ -185,13 +190,14 @@ namespace AsbCloudDb.Migrations
.HasColumnName("longitude");
b.Property<string>("Timezone")
.IsRequired()
.HasColumnType("jsonb")
.HasColumnName("timezone")
.HasComment("Смещение часового пояса от UTC");
b.HasKey("Id");
b.ToTable("t_deposit", (string)null);
b.ToTable("t_deposit");
b.HasComment("Месторождение");
});
@ -255,7 +261,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdTelemetry");
b.ToTable("t_detected_operation", (string)null);
b.ToTable("t_detected_operation");
b.HasComment("автоматически определенные операции по телеметрии");
});
@ -292,7 +298,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_driller", (string)null);
b.ToTable("t_driller");
b.HasComment("Бурильщик");
});
@ -321,7 +327,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell", "IdFileCategory")
.IsUnique();
b.ToTable("t_drilling_program_part", (string)null);
b.ToTable("t_drilling_program_part");
b.HasComment("части программ бурения");
});
@ -347,7 +353,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_file_category", (string)null);
b.ToTable("t_file_category");
b.HasComment("Категории файлов");
@ -736,7 +742,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_file_info", (string)null);
b.ToTable("t_file_info");
b.HasComment("Файлы всех категорий");
});
@ -787,7 +793,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdUser");
b.ToTable("t_file_mark", (string)null);
b.ToTable("t_file_mark");
b.HasComment("Действия с файлами.");
});
@ -829,7 +835,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdTelemetry");
b.ToTable("t_limiting_parameter", (string)null);
b.ToTable("t_limiting_parameter");
b.HasComment("Ограничения по параметрам телеметрии");
});
@ -874,7 +880,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_measure", (string)null);
b.ToTable("t_measure");
b.HasComment("Таблица c данными для вкладки 'Последние данные'");
});
@ -900,7 +906,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_measure_category", (string)null);
b.ToTable("t_measure_category");
b.HasComment("Категория последних данных");
@ -971,7 +977,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_operationvalue", (string)null);
b.ToTable("t_operationvalue");
b.HasComment("Целевые/нормативные показатели операции");
});
@ -999,7 +1005,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_permission", (string)null);
b.ToTable("t_permission");
b.HasComment("Разрешения на доступ к данным");
@ -1909,7 +1915,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_planned_trajectory", (string)null);
b.ToTable("t_planned_trajectory");
b.HasComment("Загрузка плановой траектории");
});
@ -2014,7 +2020,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWellSectionType");
b.ToTable("t_process_map", (string)null);
b.ToTable("t_process_map");
b.HasComment("Операции по скважине РТК");
});
@ -2033,7 +2039,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_relation_company_well", (string)null);
b.ToTable("t_relation_company_well");
b.HasComment("отношение скважин и компаний");
});
@ -2058,7 +2064,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdDrillingProgramPart");
b.ToTable("t_relation_user_drilling_program_part", (string)null);
b.ToTable("t_relation_user_drilling_program_part");
b.HasComment("Отношение пользователей и частей ПБ");
});
@ -2077,7 +2083,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdPermission");
b.ToTable("t_relation_user_role_permission", (string)null);
b.ToTable("t_relation_user_role_permission");
b.HasComment("Отношение ролей пользователей и разрешений доступа");
@ -2719,7 +2725,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdInclude");
b.ToTable("t_relation_user_role_user_role", (string)null);
b.ToTable("t_relation_user_role_user_role");
b.HasComment("Отношение ролей к ролям");
@ -3010,7 +3016,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdUserRole");
b.ToTable("t_relation_user_user_role", (string)null);
b.ToTable("t_relation_user_user_role");
b.HasComment("Отношение пользователей и ролей");
@ -3066,7 +3072,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_report_property", (string)null);
b.ToTable("t_report_property");
b.HasComment("Отчеты с данными по буровым");
});
@ -3117,7 +3123,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_schedule", (string)null);
b.ToTable("t_schedule");
b.HasComment("График работы бурильщика");
});
@ -3171,7 +3177,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_setpoints_rquest", (string)null);
b.ToTable("t_setpoints_rquest");
b.HasComment("Запросы на изменение уставок панели оператора");
});
@ -3198,7 +3204,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_subsystem", (string)null);
b.ToTable("t_subsystem");
b.HasComment("Описание подсистем");
@ -3273,7 +3279,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdTelemetry");
b.ToTable("t_subsystem_operation_time", (string)null);
b.ToTable("t_subsystem_operation_time");
b.HasComment("наработки подсистем");
});
@ -3306,7 +3312,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex(new[] { "RemoteUid" }, "t_telemetry_remote_uid_index");
b.ToTable("t_telemetry", (string)null);
b.ToTable("t_telemetry");
b.HasComment("таблица привязки телеметрии от комплектов к конкретной скважине.");
});
@ -3509,7 +3515,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "DateTime");
b.ToTable("t_telemetry_data_saub", (string)null);
b.ToTable("t_telemetry_data_saub");
b.HasComment("набор основных данных по SAUB");
});
@ -3606,7 +3612,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "DateTime");
b.ToTable("t_telemetry_data_spin", (string)null);
b.ToTable("t_telemetry_data_spin");
b.HasComment("набор основных данных по SpinMaster");
});
@ -3631,7 +3637,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "IdEvent");
b.ToTable("t_telemetry_event", (string)null);
b.ToTable("t_telemetry_event");
b.HasComment("Справочник событий. События формируют сообщения. Разделено по версиям посылок от телеметрии.");
});
@ -3691,7 +3697,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdTelemetry");
b.ToTable("t_telemetry_message", (string)null);
b.ToTable("t_telemetry_message");
b.HasComment("Сообщения на буровых");
});
@ -3727,7 +3733,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "IdUser");
b.ToTable("t_telemetry_user", (string)null);
b.ToTable("t_telemetry_user");
b.HasComment("Пользователи панели САУБ. Для сообщений.");
});
@ -3769,7 +3775,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry");
b.ToTable("t_telemetry_wireline_run_out", (string)null);
b.ToTable("t_telemetry_wireline_run_out");
b.HasComment("Наработка талевого каната");
});
@ -3846,7 +3852,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("Login")
.IsUnique();
b.ToTable("t_user", (string)null);
b.ToTable("t_user");
b.HasComment("Пользователи облака");
@ -3883,7 +3889,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_user_role", (string)null);
b.ToTable("t_user_role");
b.HasComment("Роли пользователей в системе");
@ -4221,7 +4227,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdUser", "Key");
b.ToTable("t_user_settings", (string)null);
b.ToTable("t_user_settings");
b.HasComment("настройки интерфейса пользователя");
});
@ -4236,11 +4242,12 @@ namespace AsbCloudDb.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Caption")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("caption");
b.Property<int?>("IdCluster")
b.Property<int>("IdCluster")
.HasColumnType("integer")
.HasColumnName("id_cluster");
@ -4253,7 +4260,7 @@ namespace AsbCloudDb.Migrations
.HasColumnType("integer")
.HasColumnName("id_telemetry");
b.Property<int?>("IdWellType")
b.Property<int>("IdWellType")
.HasColumnType("integer")
.HasColumnName("id_well_type");
@ -4266,6 +4273,7 @@ namespace AsbCloudDb.Migrations
.HasColumnName("longitude");
b.Property<string>("Timezone")
.IsRequired()
.HasColumnType("jsonb")
.HasColumnName("timezone")
.HasComment("Смещение часового пояса от UTC");
@ -4279,7 +4287,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWellType");
b.ToTable("t_well", (string)null);
b.ToTable("t_well");
b.HasComment("скважины");
});
@ -4307,7 +4315,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWellSrc");
b.ToTable("t_well_composite", (string)null);
b.ToTable("t_well_composite");
b.HasComment("Композитная скважина");
});
@ -4333,7 +4341,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdUser");
b.ToTable("t_well_final_documents", (string)null);
b.ToTable("t_well_final_documents");
b.HasComment("Дело скважины");
});
@ -4416,7 +4424,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWellSectionType");
b.ToTable("t_well_operation", (string)null);
b.ToTable("t_well_operation");
b.HasComment("Данные по операциям на скважине");
});
@ -4457,7 +4465,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdParent");
b.ToTable("t_well_operation_category", (string)null);
b.ToTable("t_well_operation_category");
b.HasComment("Справочник операций на скважине");
@ -5308,7 +5316,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_well_section_type", (string)null);
b.ToTable("t_well_section_type");
b.HasComment("конструкция секции скважины");
@ -5498,7 +5506,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_well_type", (string)null);
b.ToTable("t_well_type");
b.HasComment("конструкция скважины");
@ -5555,7 +5563,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "DateTime");
b.ToTable("t_telemetry_wits_base", (string)null);
b.ToTable("t_telemetry_wits_base");
});
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record1", b =>
@ -5719,7 +5727,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
b.ToTable("t_telemetry_wits_1", (string)null);
b.ToTable("t_telemetry_wits_1");
});
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record50", b =>
@ -5807,7 +5815,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
b.ToTable("t_telemetry_wits_50", (string)null);
b.ToTable("t_telemetry_wits_50");
});
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record60", b =>
@ -5859,7 +5867,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
b.ToTable("t_telemetry_wits_60", (string)null);
b.ToTable("t_telemetry_wits_60");
});
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record61", b =>
@ -5915,7 +5923,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
b.ToTable("t_telemetry_wits_61", (string)null);
b.ToTable("t_telemetry_wits_61");
});
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record7", b =>
@ -6003,7 +6011,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
b.ToTable("t_telemetry_wits_7", (string)null);
b.ToTable("t_telemetry_wits_7");
});
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record8", b =>
@ -6207,7 +6215,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
b.ToTable("t_telemetry_wits_8", (string)null);
b.ToTable("t_telemetry_wits_8");
});
modelBuilder.Entity("AsbCloudDb.Model.Cluster", b =>
@ -6215,6 +6223,8 @@ namespace AsbCloudDb.Migrations
b.HasOne("AsbCloudDb.Model.Deposit", "Deposit")
.WithMany("Clusters")
.HasForeignKey("IdDeposit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("t_cluster_t_deposit_id_fk");
b.Navigation("Deposit");
@ -6674,6 +6684,8 @@ namespace AsbCloudDb.Migrations
b.HasOne("AsbCloudDb.Model.Cluster", "Cluster")
.WithMany("Wells")
.HasForeignKey("IdCluster")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("t_well_t_cluster_id_fk");
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
@ -6684,7 +6696,9 @@ namespace AsbCloudDb.Migrations
b.HasOne("AsbCloudDb.Model.WellType", "WellType")
.WithMany("Wells")
.HasForeignKey("IdWellType");
.HasForeignKey("IdWellType")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Cluster");

View File

@ -3,35 +3,28 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
namespace AsbCloudDb.Model
{
[Table("t_cluster"), Comment("Кусты")]
public partial class Cluster : IId, IMapPoint
{
public Cluster()
{
Wells = new HashSet<Well>();
}
[Key]
[Column("id")]
public int Id { get; set; }
[Column("caption"), Comment("Название")]
[StringLength(255)]
public string Caption { get; set; }
public string Caption { get; set; } = null!;
[Column("id_deposit")]
public int? IdDeposit { get; set; }
public int IdDeposit { get; set; }
[ForeignKey(nameof(IdDeposit))]
[InverseProperty(nameof(Model.Deposit.Clusters))]
public virtual Deposit Deposit { get; set; }
public virtual Deposit Deposit { get; set; } = null!;
[InverseProperty(nameof(Well.Cluster))]
public virtual ICollection<Well> Wells { get; set; }
public virtual ICollection<Well> Wells { get; set; } = null!;
[Column("latitude")]
public double? Latitude { get; set; }
@ -40,6 +33,6 @@ namespace AsbCloudDb.Model
public double? Longitude { get; set; }
[Column("timezone", TypeName = "jsonb"), Comment("Смещение часового пояса от UTC")]
public SimpleTimezone Timezone { get; set; }
public SimpleTimezone Timezone { get; set; } = new();
}
}

View File

@ -3,8 +3,6 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
namespace AsbCloudDb.Model
{
[Table("t_company")]
@ -16,7 +14,7 @@ namespace AsbCloudDb.Model
[Column("caption")]
[StringLength(255)]
public string Caption { get; set; }
public string Caption { get; set; } = null!;
[Column("id_company_type"), Comment("вид деятельности")]
[StringLength(255)]
@ -24,12 +22,12 @@ namespace AsbCloudDb.Model
[ForeignKey(nameof(IdCompanyType))]
[InverseProperty(nameof(Model.CompanyType.Companies))]
public virtual CompanyType CompanyType { get; set; }
public virtual CompanyType CompanyType { get; set; } = null!;
[InverseProperty(nameof(User.Company))]
public virtual ICollection<User> Users { get; set; }
public virtual ICollection<User> Users { get; set; } = null!;
[InverseProperty(nameof(RelationCompanyWell.Company))]
public virtual ICollection<RelationCompanyWell> RelationCompaniesWells { get; set; }
public virtual ICollection<RelationCompanyWell> RelationCompaniesWells { get; set; } = null!;
}
}

View File

@ -2,8 +2,6 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
namespace AsbCloudDb.Model
{
[Table("t_company_type")]
@ -15,9 +13,9 @@ namespace AsbCloudDb.Model
[Column("caption")]
[StringLength(255)]
public string Caption { get; set; }
public string Caption { get; set; } = null!;
[InverseProperty(nameof(Company.CompanyType))]
public virtual ICollection<Company> Companies { get; set; }
public virtual ICollection<Company> Companies { get; set; } = null!;
}
}

View File

@ -3,28 +3,21 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
namespace AsbCloudDb.Model
{
[Table("t_deposit"), Comment("Месторождение")]
public partial class Deposit : IId, IMapPoint
{
public Deposit()
{
Clusters = new HashSet<Cluster>();
}
[Key]
[Column("id")]
public int Id { get; set; }
[Column("caption")]
[StringLength(255)]
public string Caption { get; set; }
public string Caption { get; set; } = null!;
[InverseProperty(nameof(Cluster.Deposit))]
public virtual ICollection<Cluster> Clusters { get; set; }
public virtual ICollection<Cluster> Clusters { get; set; } = null!;
[Column("latitude")]
public double? Latitude { get; set; }
@ -33,6 +26,6 @@ namespace AsbCloudDb.Model
public double? Longitude { get; set; }
[Column("timezone", TypeName = "jsonb"), Comment("Смещение часового пояса от UTC")]
public SimpleTimezone Timezone { get; set; }
public SimpleTimezone Timezone { get; set; } = new();
}
}

View File

@ -1,10 +1,9 @@
namespace AsbCloudDb.Model
{
#nullable disable
public class SimpleTimezone
{
public double Hours { get; set; }
public string TimezoneId { get; set; }
public double Hours { get; set; } = 5d;
public string? TimezoneId { get; set; }
public bool IsOverride { get; set; }
}

View File

@ -4,8 +4,6 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
#nullable disable
namespace AsbCloudDb.Model
{
[Table("t_well"), Comment("скважины")]
@ -17,16 +15,16 @@ namespace AsbCloudDb.Model
[Column("caption")]
[StringLength(255)]
public string Caption { get; set; }
public string Caption { get; set; } = null!;
[Column("id_cluster")]
public int? IdCluster { get; set; }
public int IdCluster { get; set; }
[Column("id_telemetry")]
public int? IdTelemetry { get; set; }
[Column("id_well_type")]
public int? IdWellType { get; set; }
public int IdWellType { get; set; }
[Column("state"), Comment("0 - неизвестно, 1 - в работе, 2 - завершена")]
public int IdState { get; set; }
@ -38,37 +36,37 @@ namespace AsbCloudDb.Model
public double? Longitude { get; set; }
[Column("timezone", TypeName = "jsonb"), Comment("Смещение часового пояса от UTC")]
public SimpleTimezone Timezone { get; set; }
public SimpleTimezone Timezone { get; set; } = null!;
[ForeignKey(nameof(IdWellType))]
[InverseProperty(nameof(Model.WellType.Wells))]
public virtual WellType WellType { get; set; }
public virtual WellType WellType { get; set; } = null!;
[InverseProperty(nameof(RelationCompanyWell.Well))]
public virtual ICollection<RelationCompanyWell> RelationCompaniesWells { get; set; }
public virtual ICollection<RelationCompanyWell> RelationCompaniesWells { get; set; } = null!;
[ForeignKey(nameof(IdCluster))]
[InverseProperty(nameof(Model.Cluster.Wells))]
public virtual Cluster Cluster { get; set; }
public virtual Cluster Cluster { get; set; } = null!;
[ForeignKey(nameof(IdTelemetry))]
[InverseProperty(nameof(Model.Telemetry.Well))]
public virtual Telemetry Telemetry { get; set; }
public virtual Telemetry? Telemetry { get; set; }
[JsonIgnore]
[InverseProperty(nameof(WellOperation.Well))]
public virtual ICollection<WellOperation> WellOperations { get; set; }
public virtual ICollection<WellOperation> WellOperations { get; set; } = null!;
[InverseProperty(nameof(WellComposite.Well))]
public virtual ICollection<WellComposite> WellComposites { get; set; }
public virtual ICollection<WellComposite> WellComposites { get; set; } = null!;
[InverseProperty(nameof(WellComposite.WellSrc))]
public virtual ICollection<WellComposite> WellCompositeSrcs { get; set; }
public virtual ICollection<WellComposite> WellCompositeSrcs { get; set; } = null!;
[InverseProperty(nameof(DrillingProgramPart.Well))]
public virtual ICollection<DrillingProgramPart> DrillingProgramParts { get; set; }
public virtual ICollection<DrillingProgramPart> DrillingProgramParts { get; set; } = null!;
[InverseProperty(nameof(ProcessMap.Well))]
public virtual ICollection<ProcessMap> ProcessMaps { get; set; }
public virtual ICollection<ProcessMap> ProcessMaps { get; set; } = null!;
}
}

View File

@ -6,7 +6,6 @@ using System.Text.Json.Serialization;
namespace AsbCloudDb.Model
{
#nullable disable
[Table("t_well_operation"), Comment("Данные по операциям на скважине")]
public class WellOperation : IId
{
@ -48,26 +47,26 @@ namespace AsbCloudDb.Model
public double DurationHours { get; set; }
[Column("category_info"), Comment("Доп. информация к выбраной категории")]
public string CategoryInfo { get; set; }
public string? CategoryInfo { get; set; }
[Column("comment"), Comment("Комментарий")]
public string Comment { get; set; }
public string? Comment { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdWell))]
public virtual Well Well { get; set; }
public virtual Well Well { get; set; } = null!;
[JsonIgnore]
[ForeignKey(nameof(IdWellSectionType))]
public virtual WellSectionType WellSectionType { get; set; }
public virtual WellSectionType WellSectionType { get; set; } = null!;
[JsonIgnore]
[ForeignKey(nameof(IdCategory))]
public virtual WellOperationCategory OperationCategory { get; set; }
public virtual WellOperationCategory OperationCategory { get; set; } = null!;
[JsonIgnore]
[ForeignKey(nameof(IdPlan))]
public virtual WellOperation OperationPlan { get; set; }
public virtual WellOperation OperationPlan { get; set; } = null!;
}
}

View File

@ -5,7 +5,6 @@ using System.Text.Json.Serialization;
namespace AsbCloudDb.Model
{
#nullable enable
[Table("t_well_operation_category"), Comment("Справочник операций на скважине")]
public class WellOperationCategory : IId
{
@ -143,5 +142,4 @@ namespace AsbCloudDb.Model
[ForeignKey(nameof(IdParent))]
public virtual WellOperationCategory? Parent { get; set; } = null!;
}
#nullable disable
}

View File

@ -253,9 +253,9 @@ namespace AsbCloudInfrastructure.Services
dto.Timezone = GetTimezone(entity.Id);
dto.StartDate = wellOperationRepository.FirstOperationDate(entity.Id)?.ToRemoteDateTime(dto.Timezone.Hours);
dto.WellType = entity.WellType?.Caption;
dto.Cluster = entity.Cluster?.Caption;
dto.Deposit = entity.Cluster?.Deposit?.Caption;
dto.WellType = entity.WellType.Caption;
dto.Cluster = entity.Cluster.Caption;
dto.Deposit = entity.Cluster.Deposit.Caption;
if (entity.IdTelemetry is not null)
dto.LastTelemetryDate = telemetryService.GetLastTelemetryDate((int)entity.IdTelemetry);
dto.Companies = entity.RelationCompaniesWells
@ -347,9 +347,6 @@ namespace AsbCloudInfrastructure.Services
if (well.Latitude is not null & well.Longitude is not null)
return well;
if (well.IdCluster is null)
throw new Exception($"Can't find coordinates of well {well.Caption} id: {well.Id}");
var cluster = well.Cluster;
if (cluster.Latitude is not null & cluster.Longitude is not null)

View File

@ -8,6 +8,7 @@ using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Primitives;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp1
{
@ -27,12 +28,12 @@ namespace ConsoleApp1
public IEnumerable<IConfigurationSection> GetChildren()
{
return null;
return Enumerable.Empty<IConfigurationSection>();
}
public IChangeToken GetReloadToken()
public IChangeToken? GetReloadToken()
{
return null;
return default;
}
public IConfigurationSection GetSection(string key) => this;