feat(dal): Переделал модели для новой концепции управления роботами
This commit is contained in:
@@ -63,7 +63,7 @@ namespace PARR.API.MappingProfiles
|
||||
|
||||
// === Template ===
|
||||
|
||||
CreateMap<StatusTemplate, StatusTemplateResponse>();
|
||||
CreateMap<StatusTask, StatusTemplateResponse>();
|
||||
|
||||
CreateMap<Template, TemplateRobotStatusResponse>()
|
||||
.ForMember(d => d.Code, o => o.MapFrom(s => s.RobotStatus!.Code))
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace PARR.DAL.Context
|
||||
public DbSet<Models.AIHIT.Setting> Settings { get; set; }
|
||||
public DbSet<RawDataEK> RawDataEKs { get; set; }
|
||||
public DbSet<Template> Templates { get; set; }
|
||||
public DbSet<StatusTemplate> StatusTemplates { get; set; }
|
||||
public DbSet<StatusTask> StatusTasks { get; set; }
|
||||
public DbSet<RobotStatus> RobotStatuses { get; set; }
|
||||
|
||||
public DbSet<Process> Processes { get; set; }
|
||||
@@ -48,6 +48,10 @@ namespace PARR.DAL.Context
|
||||
public DbSet<RobotHistoryLevel> RobotHistoryLevels { get; set; }
|
||||
public DbSet<RobotTemplateHistory> RobotTemplateHistories { get; set; }
|
||||
|
||||
public DbSet<Robot> Robots { get; set; }
|
||||
public DbSet<RobotConfiguration> RobotConfigurations { get; set; }
|
||||
public DbSet<RobotHistory> RobotHistories { get; set; }
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
@@ -107,7 +111,7 @@ namespace PARR.DAL.Context
|
||||
});
|
||||
|
||||
|
||||
modelBuilder.Entity<StatusTemplate>(f =>
|
||||
modelBuilder.Entity<StatusTask>(f =>
|
||||
{
|
||||
f.HasData(
|
||||
|
||||
@@ -189,6 +193,14 @@ namespace PARR.DAL.Context
|
||||
);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Robot>(f =>
|
||||
{
|
||||
f.HasData(
|
||||
new { Code = (int)RobotsEnum.TemplateOrder, Name = RobotsEnum.TemplateOrder.ToString(), Description = "Робот по созданию/изменению шаблона наряда ЕСПП" },
|
||||
new { Code = (int)RobotsEnum.ScheduleOrder, Name = RobotsEnum.ScheduleOrder.ToString(), Description = "Робот по созданию/изменению расписания шаблона наряда в ЕСПП" }
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
18
PARR.DAL/Contracts/RobotsEnum.cs
Normal file
18
PARR.DAL/Contracts/RobotsEnum.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace PARR.DAL.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Список роботов
|
||||
/// </summary>
|
||||
public enum RobotsEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// Робот по созданию/изменению шаблона наряда ЕСПП
|
||||
/// </summary>
|
||||
TemplateOrder = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Робот по созданию/изменению расписания шаблона наряда в ЕСПП
|
||||
/// </summary>
|
||||
ScheduleOrder = 2
|
||||
}
|
||||
}
|
||||
2041
PARR.DAL/Migrations/20231005021105_TblsRobotConfigurations.Designer.cs
generated
Normal file
2041
PARR.DAL/Migrations/20231005021105_TblsRobotConfigurations.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
174
PARR.DAL/Migrations/20231005021105_TblsRobotConfigurations.cs
Normal file
174
PARR.DAL/Migrations/20231005021105_TblsRobotConfigurations.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
});
|
||||
|
||||
|
||||
21
PARR.DAL/Models/Robot.cs
Normal file
21
PARR.DAL/Models/Robot.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models
|
||||
{
|
||||
[Table("Robots")]
|
||||
[Index(nameof(Name), IsUnique = true)]
|
||||
public class Robot
|
||||
{
|
||||
[Key]
|
||||
public int Code { get; set; }
|
||||
|
||||
public required string Name { get; set; }
|
||||
|
||||
public required string Description { get; set; }
|
||||
|
||||
|
||||
public ICollection<RobotConfiguration> RobotConfigurations { get; set; } = new HashSet<RobotConfiguration>();
|
||||
}
|
||||
}
|
||||
61
PARR.DAL/Models/RobotConfiguration.cs
Normal file
61
PARR.DAL/Models/RobotConfiguration.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.DAL.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models
|
||||
{
|
||||
[Table("RobotConfigurations")]
|
||||
[Index(nameof(TemplateId), nameof(RobotCode), IsUnique = true)]
|
||||
public class RobotConfiguration : IBase
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
|
||||
public Guid TemplateId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Идентификатор робота
|
||||
/// </summary>
|
||||
public int RobotCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Статус. Что нужно сделать роботу
|
||||
/// </summary>
|
||||
public int TaskStatusCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Статус работы робота
|
||||
/// </summary>
|
||||
public int RobotStatusCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Количество попыток выполнения задания роботом
|
||||
/// </summary>
|
||||
public int AttemptsNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Последняя дата обновления статуса RobotStatusCode роботом
|
||||
/// </summary>
|
||||
public DateTimeOffset? LastStatusUpdated { get; set; }
|
||||
|
||||
[ForeignKey(nameof(TemplateId))]
|
||||
public Template? Template { get; set; }
|
||||
|
||||
[ForeignKey(nameof(RobotCode))]
|
||||
public Robot? Robot { get; set; }
|
||||
|
||||
[ForeignKey(nameof(TaskStatusCode))]
|
||||
public StatusTask? StatusTask { get; set; }
|
||||
|
||||
[ForeignKey(nameof(RobotStatusCode))]
|
||||
public RobotStatus? RobotStatus { get; set; }
|
||||
|
||||
public ICollection<RobotHistory> RobotHistories { get; set; } = new HashSet<RobotHistory>();
|
||||
}
|
||||
}
|
||||
44
PARR.DAL/Models/RobotHistory.cs
Normal file
44
PARR.DAL/Models/RobotHistory.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using PARR.DAL.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models
|
||||
{
|
||||
[Table("RobotHistories")]
|
||||
public class RobotHistory : IBase
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
|
||||
public int HistoryLevel { get; set; }
|
||||
|
||||
public string? RobotMessage { get; set; }
|
||||
|
||||
public string? EsppMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Статус. Что нужно было сделать роботу
|
||||
/// </summary>
|
||||
public int TaskStatusCode { get; set; }
|
||||
|
||||
public Guid RobotConfigurationId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Уникальный идентификатор серии выполнения, нужен для сопоставления истории
|
||||
/// </summary>
|
||||
public Guid IdSeries { get; set; }
|
||||
|
||||
|
||||
[ForeignKey(nameof(HistoryLevel))]
|
||||
public RobotHistoryLevel? RobotHistoryLevel { get; set; }
|
||||
|
||||
[ForeignKey(nameof(RobotConfigurationId))]
|
||||
public RobotConfiguration? RobotConfiguration { get; set; }
|
||||
|
||||
[ForeignKey(nameof(TaskStatusCode))]
|
||||
public StatusTask? StatusTask { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -19,5 +19,9 @@ namespace PARR.DAL.Models
|
||||
|
||||
public ICollection<RobotTemplateHistory> robotTemplateHistories { get; set; } = new HashSet<RobotTemplateHistory>();
|
||||
|
||||
public ICollection<RobotHistory> RobotHistories { get; set; } = new HashSet<RobotHistory>();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,6 @@ namespace PARR.DAL.Models
|
||||
public Template? Template { get; set; }
|
||||
|
||||
[ForeignKey(nameof(TemplateStatusCode))]
|
||||
public StatusTemplate? StatusTemplate { get; set; }
|
||||
public StatusTask? StatusTemplate { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace PARR.DAL.Models
|
||||
/// Статус шаблона. Что нужно сделать роботу в ЕСПП
|
||||
/// </summary>
|
||||
[Table("StatusTemplates")]
|
||||
public class StatusTemplate
|
||||
public class StatusTask
|
||||
{
|
||||
[Key]
|
||||
public int Code { get; set; }
|
||||
@@ -42,7 +42,7 @@ namespace PARR.DAL.Models
|
||||
|
||||
|
||||
[ForeignKey(nameof(StatusCode))]
|
||||
public StatusTemplate? StatusTemplate { get; set; }
|
||||
public StatusTask? StatusTask { get; set; }
|
||||
|
||||
|
||||
public Guid ApplicationInWorkId { get; set; }
|
||||
@@ -62,5 +62,7 @@ namespace PARR.DAL.Models
|
||||
|
||||
public ICollection<RobotTemplateHistory> RobotTemplateHistories { get; set; } = new HashSet<RobotTemplateHistory>();
|
||||
|
||||
public ICollection<RobotConfiguration> RobotConfigurations { get; set; } = new HashSet<RobotConfiguration>();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,9 @@ namespace PARR.DAL
|
||||
services.AddTransient<IRobotHistoryLevelService, RobotHistoryLevelService>();
|
||||
services.AddTransient<IRobotStatusService, RobotStatusService>();
|
||||
services.AddTransient<IRobotTemplateHistoryService, RobotTemplateHistoryService>();
|
||||
services.AddTransient<IRobotService, RobotService>();
|
||||
services.AddTransient<IRobotConfigurationService, RobotConfigurationService>();
|
||||
services.AddTransient<IRobotHistoryService, RobotHistoryService>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Abstracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations
|
||||
{
|
||||
internal class RobotConfigurationService : BaseService<RobotConfiguration>, IRobotConfigurationService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
|
||||
public RobotConfigurationService(DataContext dataContext, ILogger<RobotConfigurationService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
}
|
||||
|
||||
protected override DbSet<RobotConfiguration> EntitySet => dataContext.RobotConfigurations;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
}
|
||||
}
|
||||
23
PARR.DAL/Services/Implementations/RobotHistoryService.cs
Normal file
23
PARR.DAL/Services/Implementations/RobotHistoryService.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Abstracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations
|
||||
{
|
||||
internal class RobotHistoryService : BaseService<RobotHistory>, IRobotHistoryService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
|
||||
public RobotHistoryService(DataContext dataContext, ILogger<RobotHistoryService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
}
|
||||
|
||||
protected override DbSet<RobotHistory> EntitySet => dataContext.RobotHistories;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
}
|
||||
}
|
||||
21
PARR.DAL/Services/Implementations/RobotService.cs
Normal file
21
PARR.DAL/Services/Implementations/RobotService.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations
|
||||
{
|
||||
internal class RobotService : IRobotService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
|
||||
public RobotService(DataContext dataContext)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
}
|
||||
|
||||
public IQueryable<Robot> Get()
|
||||
{
|
||||
return dataContext.Robots;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,9 +13,9 @@ namespace PARR.DAL.Services.Implementations
|
||||
this.dataContext = dataContext;
|
||||
}
|
||||
|
||||
public IQueryable<StatusTemplate> Get()
|
||||
public IQueryable<StatusTask> Get()
|
||||
{
|
||||
return dataContext.StatusTemplates;
|
||||
return dataContext.StatusTasks;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IRobotConfigurationService : IBaseService<RobotConfiguration>
|
||||
{
|
||||
}
|
||||
}
|
||||
9
PARR.DAL/Services/Interfaces/IRobotHistoryService.cs
Normal file
9
PARR.DAL/Services/Interfaces/IRobotHistoryService.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IRobotHistoryService : IBaseService<RobotHistory>
|
||||
{
|
||||
}
|
||||
}
|
||||
9
PARR.DAL/Services/Interfaces/IRobotService.cs
Normal file
9
PARR.DAL/Services/Interfaces/IRobotService.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using PARR.DAL.Models;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IRobotService
|
||||
{
|
||||
IQueryable<Robot> Get();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,6 @@ namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IStatusTemplateService
|
||||
{
|
||||
IQueryable<StatusTemplate> Get();
|
||||
IQueryable<StatusTask> Get();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user