feat(dal): Переделал модели для новой концепции управления роботами

This commit is contained in:
Mikhail Trubnikov
2023-10-05 12:28:31 +10:00
parent 10fe67a3bb
commit 4679994600
22 changed files with 2681 additions and 14 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,174 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class TblsRobotConfigurations : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Robots",
columns: table => new
{
Code = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Robots", x => x.Code);
});
migrationBuilder.CreateTable(
name: "RobotConfigurations",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
TemplateId = table.Column<Guid>(type: "uuid", nullable: false),
RobotCode = table.Column<int>(type: "integer", nullable: false),
TaskStatusCode = table.Column<int>(type: "integer", nullable: false),
RobotStatusCode = table.Column<int>(type: "integer", nullable: false),
AttemptsNumber = table.Column<int>(type: "integer", nullable: false),
LastStatusUpdated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RobotConfigurations", x => x.Id);
table.ForeignKey(
name: "FK_RobotConfigurations_RobotStatuses_RobotStatusCode",
column: x => x.RobotStatusCode,
principalTable: "RobotStatuses",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RobotConfigurations_Robots_RobotCode",
column: x => x.RobotCode,
principalTable: "Robots",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RobotConfigurations_StatusTemplates_TaskStatusCode",
column: x => x.TaskStatusCode,
principalTable: "StatusTemplates",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RobotConfigurations_Templates_TemplateId",
column: x => x.TemplateId,
principalTable: "Templates",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "RobotHistories",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
HistoryLevel = table.Column<int>(type: "integer", nullable: false),
RobotMessage = table.Column<string>(type: "text", nullable: true),
EsppMessage = table.Column<string>(type: "text", nullable: true),
TaskStatusCode = table.Column<int>(type: "integer", nullable: false),
RobotConfigurationId = table.Column<Guid>(type: "uuid", nullable: false),
IdSeries = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RobotHistories", x => x.Id);
table.ForeignKey(
name: "FK_RobotHistories_RobotConfigurations_RobotConfigurationId",
column: x => x.RobotConfigurationId,
principalTable: "RobotConfigurations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RobotHistories_RobotHistoryLevels_HistoryLevel",
column: x => x.HistoryLevel,
principalTable: "RobotHistoryLevels",
principalColumn: "Level",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RobotHistories_StatusTemplates_TaskStatusCode",
column: x => x.TaskStatusCode,
principalTable: "StatusTemplates",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "Robots",
columns: new[] { "Code", "Description", "Name" },
values: new object[,]
{
{ 1, "Робот по созданию/изменению шаблона наряда ЕСПП", "TemplateOrder" },
{ 2, "Робот по созданию/изменению расписания шаблона наряда в ЕСПП", "ScheduleOrder" }
});
migrationBuilder.CreateIndex(
name: "IX_RobotConfigurations_RobotCode",
table: "RobotConfigurations",
column: "RobotCode");
migrationBuilder.CreateIndex(
name: "IX_RobotConfigurations_RobotStatusCode",
table: "RobotConfigurations",
column: "RobotStatusCode");
migrationBuilder.CreateIndex(
name: "IX_RobotConfigurations_TaskStatusCode",
table: "RobotConfigurations",
column: "TaskStatusCode");
migrationBuilder.CreateIndex(
name: "IX_RobotConfigurations_TemplateId_RobotCode",
table: "RobotConfigurations",
columns: new[] { "TemplateId", "RobotCode" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_RobotHistories_HistoryLevel",
table: "RobotHistories",
column: "HistoryLevel");
migrationBuilder.CreateIndex(
name: "IX_RobotHistories_RobotConfigurationId",
table: "RobotHistories",
column: "RobotConfigurationId");
migrationBuilder.CreateIndex(
name: "IX_RobotHistories_TaskStatusCode",
table: "RobotHistories",
column: "TaskStatusCode");
migrationBuilder.CreateIndex(
name: "IX_Robots_Name",
table: "Robots",
column: "Name",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "RobotHistories");
migrationBuilder.DropTable(
name: "RobotConfigurations");
migrationBuilder.DropTable(
name: "Robots");
}
}
}

View File

@@ -738,6 +738,123 @@ namespace PARR.DAL.Migrations
});
});
modelBuilder.Entity("PARR.DAL.Models.Robot", b =>
{
b.Property<int>("Code")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Code"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Code");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Robots");
b.HasData(
new
{
Code = 1,
Description = "Робот по созданию/изменению шаблона наряда ЕСПП",
Name = "TemplateOrder"
},
new
{
Code = 2,
Description = "Робот по созданию/изменению расписания шаблона наряда в ЕСПП",
Name = "ScheduleOrder"
});
});
modelBuilder.Entity("PARR.DAL.Models.RobotConfiguration", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AttemptsNumber")
.HasColumnType("integer");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("LastStatusUpdated")
.HasColumnType("timestamp with time zone");
b.Property<int>("RobotCode")
.HasColumnType("integer");
b.Property<int>("RobotStatusCode")
.HasColumnType("integer");
b.Property<int>("TaskStatusCode")
.HasColumnType("integer");
b.Property<Guid>("TemplateId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RobotCode");
b.HasIndex("RobotStatusCode");
b.HasIndex("TaskStatusCode");
b.HasIndex("TemplateId", "RobotCode")
.IsUnique();
b.ToTable("RobotConfigurations");
});
modelBuilder.Entity("PARR.DAL.Models.RobotHistory", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<string>("EsppMessage")
.HasColumnType("text");
b.Property<int>("HistoryLevel")
.HasColumnType("integer");
b.Property<Guid>("IdSeries")
.HasColumnType("uuid");
b.Property<Guid>("RobotConfigurationId")
.HasColumnType("uuid");
b.Property<string>("RobotMessage")
.HasColumnType("text");
b.Property<int>("TaskStatusCode")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("HistoryLevel");
b.HasIndex("RobotConfigurationId");
b.HasIndex("TaskStatusCode");
b.ToTable("RobotHistories");
});
modelBuilder.Entity("PARR.DAL.Models.RobotHistoryLevel", b =>
{
b.Property<int>("Level")
@@ -932,7 +1049,7 @@ namespace PARR.DAL.Migrations
});
});
modelBuilder.Entity("PARR.DAL.Models.StatusTemplate", b =>
modelBuilder.Entity("PARR.DAL.Models.StatusTask", b =>
{
b.Property<int>("Code")
.ValueGeneratedOnAdd()
@@ -1528,6 +1645,68 @@ namespace PARR.DAL.Migrations
b.Navigation("ResponseArea");
});
modelBuilder.Entity("PARR.DAL.Models.RobotConfiguration", b =>
{
b.HasOne("PARR.DAL.Models.Robot", "Robot")
.WithMany("RobotConfigurations")
.HasForeignKey("RobotCode")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.RobotStatus", "RobotStatus")
.WithMany()
.HasForeignKey("RobotStatusCode")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.StatusTask", "StatusTask")
.WithMany()
.HasForeignKey("TaskStatusCode")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.Template", "Template")
.WithMany("RobotConfigurations")
.HasForeignKey("TemplateId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Robot");
b.Navigation("RobotStatus");
b.Navigation("StatusTask");
b.Navigation("Template");
});
modelBuilder.Entity("PARR.DAL.Models.RobotHistory", b =>
{
b.HasOne("PARR.DAL.Models.RobotHistoryLevel", "RobotHistoryLevel")
.WithMany("RobotHistories")
.HasForeignKey("HistoryLevel")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.RobotConfiguration", "RobotConfiguration")
.WithMany("RobotHistories")
.HasForeignKey("RobotConfigurationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.StatusTask", "StatusTask")
.WithMany()
.HasForeignKey("TaskStatusCode")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("RobotConfiguration");
b.Navigation("RobotHistoryLevel");
b.Navigation("StatusTask");
});
modelBuilder.Entity("PARR.DAL.Models.RobotTemplateHistory", b =>
{
b.HasOne("PARR.DAL.Models.RobotHistoryLevel", "RobotHistoryLevel")
@@ -1542,7 +1721,7 @@ namespace PARR.DAL.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.StatusTemplate", "StatusTemplate")
b.HasOne("PARR.DAL.Models.StatusTask", "StatusTemplate")
.WithMany("RobotTemplateHistories")
.HasForeignKey("TemplateStatusCode")
.OnDelete(DeleteBehavior.Cascade)
@@ -1586,7 +1765,7 @@ namespace PARR.DAL.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.StatusTemplate", "StatusTemplate")
b.HasOne("PARR.DAL.Models.StatusTask", "StatusTask")
.WithMany("Templates")
.HasForeignKey("StatusCode")
.OnDelete(DeleteBehavior.Cascade)
@@ -1598,7 +1777,7 @@ namespace PARR.DAL.Migrations
b.Navigation("RobotStatus");
b.Navigation("StatusTemplate");
b.Navigation("StatusTask");
});
modelBuilder.Entity("PARR.DAL.Models.Tnk", b =>
@@ -1761,8 +1940,20 @@ namespace PARR.DAL.Migrations
b.Navigation("Hosts");
});
modelBuilder.Entity("PARR.DAL.Models.Robot", b =>
{
b.Navigation("RobotConfigurations");
});
modelBuilder.Entity("PARR.DAL.Models.RobotConfiguration", b =>
{
b.Navigation("RobotHistories");
});
modelBuilder.Entity("PARR.DAL.Models.RobotHistoryLevel", b =>
{
b.Navigation("RobotHistories");
b.Navigation("robotTemplateHistories");
});
@@ -1771,7 +1962,7 @@ namespace PARR.DAL.Migrations
b.Navigation("Templates");
});
modelBuilder.Entity("PARR.DAL.Models.StatusTemplate", b =>
modelBuilder.Entity("PARR.DAL.Models.StatusTask", b =>
{
b.Navigation("RobotTemplateHistories");
@@ -1785,6 +1976,8 @@ namespace PARR.DAL.Migrations
modelBuilder.Entity("PARR.DAL.Models.Template", b =>
{
b.Navigation("RobotConfigurations");
b.Navigation("RobotTemplateHistories");
});