Enable nullable on Relation*, ReportProperty, SetpointRequest, WellFinalDocument.

This commit is contained in:
ngfrolov 2023-02-20 14:21:52 +05:00
parent 942b2bca74
commit 02a8db1a58
Signed by untrusted user who does not match committer: ng.frolov
GPG Key ID: E99907A0357B29A7
17 changed files with 7106 additions and 56 deletions

View File

@ -2,6 +2,7 @@
namespace AsbCloudApp.Data
{
#nullable enable
/// <summary>
/// DTO формирования рапорта
/// </summary>
@ -16,12 +17,12 @@ namespace AsbCloudApp.Data
/// <summary>
/// название
/// </summary>
public string Name { get; set; }
public string Name { get; set; } = null!;
/// <summary>
/// <see cref="FileInfoDto"/>
/// </summary>
public FileInfoDto File { get; set; }
public FileInfoDto File { get; set; } = null!;
/// <summary>
/// Дата формирования
@ -46,6 +47,6 @@ namespace AsbCloudApp.Data
/// <summary>
/// формат файла
/// </summary>
public string Format { get; set; }
public string Format { get; set; } = string.Empty;
}
}

View File

@ -1,5 +1,6 @@
namespace AsbCloudApp.Data.SAUB
{
#nullable enable
/// <summary>
/// DTO рекомендации уставок передаваемых на панель оператора
/// </summary>
@ -8,31 +9,31 @@
/// <summary>
/// отображаемое название уставки
/// </summary>
public string DisplayName { get; set; }
public string DisplayName { get; set; } = string.Empty;
/// <summary>
/// настоящее название уставки (имя переменной в панели оператора)
/// </summary>
public string Name { get; set; }
public string Name { get; set; } = null!;
/// <summary>
/// единицы измерения
/// </summary>
public string Units { get; set; }
public string? Units { get; set; }
/// <summary>
/// комментарий
/// </summary>
public string Comment { get; set; }
public string? Comment { get; set; }
/// <summary>
/// макс. значение
/// </summary>
public double Max { get; set; }
public double Max { get; set; } = double.MaxValue;
/// <summary>
/// мин значение
/// </summary>
public double Min { get; set; }
public double Min { get; set; } = double.MinValue;
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
namespace AsbCloudApp.Data.SAUB
{
#nullable enable
/// <summary>
/// DTO запроса для предложения по изменению уставок на панели оператора
/// </summary>
@ -27,7 +28,7 @@ namespace AsbCloudApp.Data.SAUB
/// <summary>
/// отметка времени создания запроса
/// </summary>
public DateTime UploadDate { get; set; }
public DateTime UploadDate { get; set; } = DateTime.Now;
/// <summary>
/// время в секундах актуальности этого запроса
@ -37,21 +38,21 @@ namespace AsbCloudApp.Data.SAUB
/// <summary>
/// набор уставок: {"название переменной панели"; "рекомендуемое значение"}
/// </summary>
public Dictionary<string, double> Setpoints { get; set; }
public Dictionary<string, double> Setpoints { get; set; } = new();
/// <summary>
/// Комментарий для оператора панели
/// </summary>
public string Comment { get; set; }
public string? Comment { get; set; }
/// <summary>
/// DTO скважины
/// </summary>
public WellDto Well { get; set; }
public WellDto? Well { get; set; }
/// <summary>
/// DTO автора
/// </summary>
public UserDto Author { get; set; }
public UserDto? Author { get; set; }
}
}

View File

@ -5,6 +5,7 @@ using System.Threading.Tasks;
namespace AsbCloudApp.Services
{
#nullable enable
/// <summary>
/// Сервис рекомендаций новых уставок для панели оператора САУБ
/// </summary>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Enable_nullable_on_setpoints_finalDocs : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("update t_setpoints_rquest set setpoint_set = '{}' where setpoint_set is null;");
migrationBuilder.AlterColumn<string>(
name: "setpoint_set",
table: "t_setpoints_rquest",
type: "jsonb",
nullable: false,
defaultValue: "{}",
comment: "Набор уставок",
oldClrType: typeof(string),
oldType: "jsonb",
oldNullable: true,
oldComment: "Набор уставок");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "setpoint_set",
table: "t_setpoints_rquest",
type: "jsonb",
nullable: true,
comment: "Набор уставок",
oldClrType: typeof(string),
oldType: "jsonb",
oldComment: "Набор уставок");
}
}
}

View File

@ -3168,6 +3168,7 @@ namespace AsbCloudDb.Migrations
.HasComment("сек. до устаревания");
b.Property<string>("Setpoints")
.IsRequired()
.HasColumnType("jsonb")
.HasColumnName("setpoint_set")
.HasComment("Набор уставок");

View File

@ -1,8 +1,6 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
namespace AsbCloudDb.Model
{
[Table("t_relation_company_well"), Comment("отношение скважин и компаний")]
@ -16,10 +14,10 @@ namespace AsbCloudDb.Model
[ForeignKey(nameof(IdWell))]
[InverseProperty(nameof(Model.Well.RelationCompaniesWells))]
public virtual Well Well { get; set; }
public virtual Well Well { get; set; } = null!;
[ForeignKey(nameof(IdCompany))]
[InverseProperty(nameof(Model.Company.RelationCompaniesWells))]
public virtual Company Company { get; set; }
public virtual Company Company { get; set; } = null!;
}
}

View File

@ -3,7 +3,6 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model
{
#nullable disable
[Table("t_relation_user_drilling_program_part"), Comment("Отношение пользователей и частей ПБ")]
public class RelationUserDrillingProgramPart
{
@ -18,11 +17,9 @@ namespace AsbCloudDb.Model
[ForeignKey(nameof(IdDrillingProgramPart))]
[InverseProperty(nameof(Model.DrillingProgramPart.RelatedUsers))]
public virtual DrillingProgramPart DrillingProgramPart { get; set; }
public virtual DrillingProgramPart DrillingProgramPart { get; set; } = null!;
[ForeignKey(nameof(IdUser))]
public virtual User User { get; set; }
public virtual User User { get; set; } = null!;
}
}

View File

@ -3,7 +3,6 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model
{
#nullable disable
[Table("t_relation_user_role_permission"), Comment("Отношение ролей пользователей и разрешений доступа")]
public class RelationUserRolePermission
{
@ -15,11 +14,10 @@ namespace AsbCloudDb.Model
[ForeignKey(nameof(IdUserRole))]
[InverseProperty(nameof(Model.UserRole.RelationUserRolePermissions))]
public virtual UserRole UserRole { get; set; }
public virtual UserRole UserRole { get; set; } = null!;
[ForeignKey(nameof(IdPermission))]
[InverseProperty(nameof(Model.Permission.RelationUserRolePermissions))]
public virtual Permission Permission { get; set; }
public virtual Permission Permission { get; set; } = null!;
}
}

View File

@ -3,7 +3,6 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model
{
#nullable disable
[Table("t_relation_user_role_user_role"), Comment("Отношение ролей к ролям")]
public class RelationUserRoleUserRole
{
@ -15,11 +14,9 @@ namespace AsbCloudDb.Model
[ForeignKey(nameof(Id))]
[InverseProperty(nameof(UserRole.RelationUserRoleUserRoles))]
public virtual UserRole Role { get; set; }
public virtual UserRole Role { get; set; } = null!;
[ForeignKey(nameof(IdInclude))]
public virtual UserRole IncludeRole { get; set; }
public virtual UserRole IncludeRole { get; set; } = null!;
}
}

View File

@ -3,7 +3,6 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model
{
#nullable disable
[Table("t_relation_user_user_role"), Comment("Отношение пользователей и ролей")]
public class RelationUserUserRole
{
@ -15,11 +14,10 @@ namespace AsbCloudDb.Model
[ForeignKey(nameof(IdUser))]
[InverseProperty(nameof(Model.User.RelationUsersUserRoles))]
public virtual User User { get; set; }
public virtual User User { get; set; } = null!;
[ForeignKey(nameof(IdUserRole))]
[InverseProperty(nameof(Model.UserRole.RelationUsersUserRoles))]
public virtual UserRole UserRole { get; set; }
public virtual UserRole UserRole { get; set; } = null!;
}
}

View File

@ -5,7 +5,6 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model
{
#nullable disable
[Table("t_report_property"), Comment("Отчеты с данными по буровым")]
public class ReportProperty : IId, IWellRelated
{
@ -32,10 +31,10 @@ namespace AsbCloudDb.Model
public int Format { get; set; }
[ForeignKey(nameof(IdWell))]
public virtual Well Well { get; set; }
public virtual Well Well { get; set; } = null!;
[ForeignKey(nameof(IdFile))]
public virtual FileInfo File { get; set; }
public virtual FileInfo File { get; set; } = null!;
}
}

View File

@ -6,7 +6,6 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model
{
#nullable disable
[Table("t_setpoints_rquest"), Comment("Запросы на изменение уставок панели оператора")]
public class SetpointsRequest : IId, IWellRelated
{
@ -30,16 +29,16 @@ namespace AsbCloudDb.Model
public int ObsolescenceSec { get; set; }
[Column("setpoint_set", TypeName = "jsonb"), Comment("Набор уставок")]
public Dictionary<string, double> Setpoints { get; set; }
public Dictionary<string, double> Setpoints { get; set; } = new();
[Column("comment"), Comment("комментарий для оператора")]
public string Comment { get; set; }
public string? Comment { get; set; }
[ForeignKey(nameof(IdWell))]
public virtual Well Well { get; set; }
public virtual Well Well { get; set; } = null!;
[ForeignKey(nameof(IdAuthor))]
public virtual User Author { get; set; }
public virtual User Author { get; set; } = null!;
}
}

View File

@ -6,5 +6,4 @@ namespace AsbCloudDb.Model
public string? TimezoneId { get; set; }
public bool IsOverride { get; set; }
}
}

View File

@ -1,10 +1,8 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model
{
#nullable disable
[Table("t_well_final_documents"), Comment("Дело скважины")]
public class WellFinalDocument : IWellRelated
{
@ -18,12 +16,12 @@ namespace AsbCloudDb.Model
public int IdCategory { get; set; }
[ForeignKey(nameof(IdWell))]
public virtual Well Well { get; set; }
public virtual Well Well { get; set; } = null!;
[ForeignKey(nameof(IdUser))]
public virtual User User { get; set; }
public virtual User User { get; set; } = null!;
[ForeignKey(nameof(IdCategory))]
public virtual FileCategory Category { get; set; }
public virtual FileCategory Category { get; set; } = null!;
}
}

View File

@ -12,6 +12,7 @@ using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services.SAUB
{
#nullable enable
public class SetpointsService : ISetpointsService
{
// ## Инфо от АПГ от 26.11.2021, дополнения ШОВ от 26.11.2021
@ -57,7 +58,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
var idWell = telemetryService.GetIdWellByTelemetryUid(uid) ?? -1;
if (idWell < 0)
return null;
return Enumerable.Empty<SetpointsRequestDto>();
var all = await setpointsRepository.GetAllAsync(token);
var filtered = all.Where(s =>
s.IdWell == idWell &&
@ -66,7 +67,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
.ToList();
if (!filtered.Any())
return null;
return Enumerable.Empty<SetpointsRequestDto>();
foreach (var item in filtered)
{
@ -92,7 +93,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
var entity = await setpointsRepository.GetOrDefaultAsync(setpointsRequestDto.Id, token);
if (entity.IdWell != setpointsRequestDto.IdWell)
if (entity?.IdWell != setpointsRequestDto.IdWell)
return 0;
if (entity is null)