Rename models;

Fix cs8618 (nullables);
Add migration.
This commit is contained in:
ngfrolov 2022-05-26 13:28:16 +05:00
parent 0d381dca78
commit 339921b968
9 changed files with 6154 additions and 34 deletions

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsbCloudApp.Data
{
@ -29,21 +25,21 @@ namespace AsbCloudApp.Data
/// <summary>
/// Начало смены
/// </summary>
public DateTimeOffset ShiftStart { get; set; }
public TimeOnly ShiftStart { get; set; }
/// <summary>
/// Конец смены
/// </summary>
public DateTimeOffset ShiftEnd { get; set; }
public TimeOnly ShiftEnd { get; set; }
/// <summary>
/// Начало бурения
/// </summary>
public DateTimeOffset DrillStart { get; set; }
public DateTime DrillStart { get; set; }
/// <summary>
/// Конец бурения
/// </summary>
public DateTimeOffset DrillEnd { get; set; }
public DateTime DrillEnd { get; set; }
}
}

View File

@ -8,6 +8,6 @@ namespace AsbCloudApp.Services
{
public interface IScheduleService : ICrudService<ScheduleDto>
{
Task<DrillerDto> GetSchedule(int idWell,DateTimeOffset workTime, CancellationToken token = default);
Task<DrillerDto> GetDrillerAsync(int idWell, DateTime workTime, CancellationToken token = default);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,132 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Add_Driller_and_Schedule : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_well_type",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "",
comment: "Название",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldNullable: true,
oldComment: "Название");
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_well_section_type",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "",
comment: "Название",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldNullable: true,
oldComment: "Название");
migrationBuilder.CreateTable(
name: "t_driller",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Имя"),
surname = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Фамилия"),
patronymic = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, comment: "Отчество")
},
constraints: table =>
{
table.PrimaryKey("PK_t_driller", x => x.id);
},
comment: "Бурильщик");
migrationBuilder.CreateTable(
name: "t_schedule",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
id_driller = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор бурильщика"),
id_well = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор скважины"),
shift_start = table.Column<TimeOnly>(type: "time without time zone", nullable: false, comment: "Начало смены"),
shift_end = table.Column<TimeOnly>(type: "time without time zone", nullable: false, comment: "Конец смены"),
drill_start = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Начало вахты"),
drill_end = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Конец вахты")
},
constraints: table =>
{
table.PrimaryKey("PK_t_schedule", x => x.id);
table.ForeignKey(
name: "FK_t_schedule_t_well_id_well",
column: x => x.id_well,
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "t_schedule_t_driller_id_driller",
column: x => x.id_driller,
principalTable: "t_driller",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
},
comment: "График работы бурильщика");
migrationBuilder.CreateIndex(
name: "IX_t_schedule_id_driller",
table: "t_schedule",
column: "id_driller");
migrationBuilder.CreateIndex(
name: "IX_t_schedule_id_well",
table: "t_schedule",
column: "id_well");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_schedule");
migrationBuilder.DropTable(
name: "t_driller");
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_well_type",
type: "character varying(255)",
maxLength: 255,
nullable: true,
comment: "Название",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldComment: "Название");
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_well_section_type",
type: "character varying(255)",
maxLength: 255,
nullable: true,
comment: "Название",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldComment: "Название");
}
}
}

View File

@ -250,6 +250,44 @@ namespace AsbCloudDb.Migrations
b.HasComment("автоматически определенные операции по телеметрии");
});
modelBuilder.Entity("AsbCloudDb.Model.Driller", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id")
.HasComment("Идентификатор");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("name")
.HasComment("Имя");
b.Property<string>("Patronymic")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("patronymic")
.HasComment("Отчество");
b.Property<string>("Surname")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("surname")
.HasComment("Фамилия");
b.HasKey("Id");
b.ToTable("t_driller");
b.HasComment("Бурильщик");
});
modelBuilder.Entity("AsbCloudDb.Model.DrillFlowChart", b =>
{
b.Property<int>("Id")
@ -2435,6 +2473,57 @@ namespace AsbCloudDb.Migrations
b.HasComment("Отчеты с данными по буровым");
});
modelBuilder.Entity("AsbCloudDb.Model.Schedule", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id")
.HasComment("Идентификатор");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTimeOffset>("DrillEnd")
.HasColumnType("timestamp with time zone")
.HasColumnName("drill_end")
.HasComment("Конец вахты");
b.Property<DateTimeOffset>("DrillStart")
.HasColumnType("timestamp with time zone")
.HasColumnName("drill_start")
.HasComment("Начало вахты");
b.Property<int>("IdDriller")
.HasColumnType("integer")
.HasColumnName("id_driller")
.HasComment("Идентификатор бурильщика");
b.Property<int>("IdWell")
.HasColumnType("integer")
.HasColumnName("id_well")
.HasComment("Идентификатор скважины");
b.Property<TimeOnly>("ShiftEnd")
.HasColumnType("time without time zone")
.HasColumnName("shift_end")
.HasComment("Конец смены");
b.Property<TimeOnly>("ShiftStart")
.HasColumnType("time without time zone")
.HasColumnName("shift_start")
.HasComment("Начало смены");
b.HasKey("Id");
b.HasIndex("IdDriller");
b.HasIndex("IdWell");
b.ToTable("t_schedule");
b.HasComment("График работы бурильщика");
});
modelBuilder.Entity("AsbCloudDb.Model.SetpointsRequest", b =>
{
b.Property<int>("Id")
@ -4223,6 +4312,7 @@ namespace AsbCloudDb.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Caption")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("caption")
@ -4397,6 +4487,7 @@ namespace AsbCloudDb.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Caption")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("caption")
@ -5398,6 +5489,26 @@ namespace AsbCloudDb.Migrations
b.Navigation("Well");
});
modelBuilder.Entity("AsbCloudDb.Model.Schedule", b =>
{
b.HasOne("AsbCloudDb.Model.Driller", "Driller")
.WithMany("Schedule")
.HasForeignKey("IdDriller")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("t_schedule_t_driller_id_driller");
b.HasOne("AsbCloudDb.Model.Well", "Well")
.WithMany()
.HasForeignKey("IdWell")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Driller");
b.Navigation("Well");
});
modelBuilder.Entity("AsbCloudDb.Model.SetpointsRequest", b =>
{
b.HasOne("AsbCloudDb.Model.User", "Author")
@ -5681,6 +5792,11 @@ namespace AsbCloudDb.Migrations
b.Navigation("Clusters");
});
modelBuilder.Entity("AsbCloudDb.Model.Driller", b =>
{
b.Navigation("Schedule");
});
modelBuilder.Entity("AsbCloudDb.Model.DrillingProgramPart", b =>
{
b.Navigation("RelatedUsers");

View File

@ -45,7 +45,7 @@ namespace AsbCloudDb.Model
public virtual DbSet<WellSectionType> WellSectionTypes => Set<WellSectionType>();
public virtual DbSet<WellType> WellTypes => Set<WellType>();
public virtual DbSet<Driller> Drillers => Set<Driller>();
public virtual DbSet<ScheduleItem> Schedule => Set<ScheduleItem>();
public virtual DbSet<Schedule> Schedule => Set<Schedule>();
// WITS
public DbSet<WITS.Record1> Record1 => Set<WITS.Record1>();
@ -285,7 +285,7 @@ namespace AsbCloudDb.Model
.ToView("mw_telemetry_datas_saub_stat");
});
modelBuilder.Entity<ScheduleItem>(entity =>
modelBuilder.Entity<Schedule>(entity =>
{
entity.HasOne(d => d.Driller)
.WithMany(p => p.Schedule)

View File

@ -1,12 +1,8 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace AsbCloudDb.Model
{
@ -19,18 +15,18 @@ namespace AsbCloudDb.Model
[Column("name"), Comment("Имя")]
[StringLength(255)]
public string Name { get; set; }
public string Name { get; set; } = null!;
[Column("surname"), Comment("Фамилия")]
[StringLength(255)]
public string Surname { get; set; }
public string Surname { get; set; } = null!;
[Column("patronymic"), Comment("Отчество")]
[StringLength(255)]
public string Patronymic { get; set; }
public string Patronymic { get; set; } = null!;
[JsonIgnore]
[InverseProperty(nameof(ScheduleItem.Driller))]
public virtual ICollection<ScheduleItem> Schedule { get; set; } = null!;
[InverseProperty(nameof(Model.Schedule.Driller))]
public virtual ICollection<Schedule> Schedule { get; set; } = null!;
}
}

View File

@ -44,7 +44,7 @@ namespace AsbCloudDb.Model
DbSet<WellSectionType> WellSectionTypes { get; }
DbSet<WellType> WellTypes { get; }
DbSet<Driller> Drillers { get; }
DbSet<ScheduleItem> Schedule { get; }
DbSet<Schedule> Schedule { get; }
DbSet<Record1> Record1 { get; }
DbSet<Record7> Record7 { get; }

View File

@ -1,16 +1,12 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsbCloudDb.Model
{
[Table("t_schedule"), Comment("График работы бурильщика")]
public class ScheduleItem: IId
public class Schedule: IId
{
[Key]
[Column("id"),Comment("Идентификатор")]
@ -22,23 +18,23 @@ namespace AsbCloudDb.Model
[Column("id_well"), Comment("Идентификатор скважины")]
public int IdWell { get; set; }
[Column("shift_start"), Comment("Начало смены")]
public DateTimeOffset ShiftStart { get; set; }
[Column("shift_start", TypeName = "time without time zone"), Comment("Начало смены")]
public TimeOnly ShiftStart { get; set; }
[Column("shift_end"), Comment("Конец смены")]
public DateTimeOffset ShiftEnd { get; set; }
[Column("shift_end", TypeName = "time without time zone"), Comment("Конец смены")]
public TimeOnly ShiftEnd { get; set; }
[Column("drill_start"), Comment("Начало бурение")]
[Column("drill_start", TypeName = "timestamp with time zone"), Comment("Начало вахты")]
public DateTimeOffset DrillStart { get; set; }
[Column("drill_end"), Comment("Конец бурения")]
[Column("drill_end", TypeName = "timestamp with time zone"), Comment("Конец вахты")]
public DateTimeOffset DrillEnd { get; set; }
[ForeignKey(nameof(IdDriller))]
[InverseProperty(nameof(Model.Driller.Schedule))]
public virtual Driller Driller { get; set; }
public virtual Driller Driller { get; set; } = null!;
[ForeignKey(nameof(IdWell))]
public virtual Well Well { get; set; }
public virtual Well Well { get; set; } = null!;
}
}