feat(dal): добавлены таблицы JobAutoControls, JobAutoCOntrolInEkStatuses, JobEkMasks. Сервисы.

This commit is contained in:
Mikhail Trubnikov
2024-09-09 10:08:07 +10:00
parent 2a774bc413
commit c74086412b
14 changed files with 3507 additions and 11 deletions

View File

@@ -28,6 +28,9 @@ namespace PARR.DAL.Context
public DbSet<Work> Works { get; set; }
public DbSet<ApplicationsInWork> ApplicationsInWorks { get; set; }
public DbSet<JobAutoControl> JobAutoControls { get; set; }
public DbSet<JobEkMask> JobEkMasks { get; set; }
public DbSet<JobAutoControlInEkStatus> JobAutoControlInEkStatuses { get; set; }
public DbSet<Models.Setting> Setting { get; set; }

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,115 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblJobAutoControlAndRel : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "JobAutoControls",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
ApplicationInWorkId = table.Column<Guid>(type: "uuid", nullable: false),
CreateNew = table.Column<bool>(type: "boolean", nullable: false),
Deactivate = table.Column<bool>(type: "boolean", nullable: false),
Activate = table.Column<bool>(type: "boolean", nullable: false),
OnTemplateIsActive = table.Column<bool>(type: "boolean", nullable: false),
OnScheduleIsActive = table.Column<bool>(type: "boolean", nullable: false),
OffTemplateIsActive = table.Column<bool>(type: "boolean", nullable: false),
OffScheduleIsActive = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_JobAutoControls", x => x.Id);
table.ForeignKey(
name: "FK_JobAutoControls_ApplicationsInWorks_ApplicationInWorkId",
column: x => x.ApplicationInWorkId,
principalTable: "ApplicationsInWorks",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "JobAutoControlInEkStatus",
columns: table => new
{
JobAutoControlId = table.Column<Guid>(type: "uuid", nullable: false),
EkStatusCode = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_JobAutoControlInEkStatus", x => new { x.JobAutoControlId, x.EkStatusCode });
table.ForeignKey(
name: "FK_JobAutoControlInEkStatus_EkStatuses_EkStatusCode",
column: x => x.EkStatusCode,
principalTable: "EkStatuses",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_JobAutoControlInEkStatus_JobAutoControls_JobAutoControlId",
column: x => x.JobAutoControlId,
principalTable: "JobAutoControls",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "JobEkMasks",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
JobAutoControlId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_JobEkMasks", x => x.Id);
table.ForeignKey(
name: "FK_JobEkMasks_JobAutoControls_JobAutoControlId",
column: x => x.JobAutoControlId,
principalTable: "JobAutoControls",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_JobAutoControlInEkStatus_EkStatusCode",
table: "JobAutoControlInEkStatus",
column: "EkStatusCode");
migrationBuilder.CreateIndex(
name: "IX_JobAutoControls_ApplicationInWorkId",
table: "JobAutoControls",
column: "ApplicationInWorkId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_JobEkMasks_JobAutoControlId",
table: "JobEkMasks",
column: "JobAutoControlId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "JobAutoControlInEkStatus");
migrationBuilder.DropTable(
name: "JobEkMasks");
migrationBuilder.DropTable(
name: "JobAutoControls");
}
}
}

View File

@@ -1542,6 +1542,88 @@ namespace PARR.DAL.Migrations
b.ToTable("Hosts");
});
modelBuilder.Entity("PARR.DAL.Models.JobAutoControl", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<bool>("Activate")
.HasColumnType("boolean");
b.Property<Guid>("ApplicationInWorkId")
.HasColumnType("uuid");
b.Property<bool>("CreateNew")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("DateModified")
.HasColumnType("timestamp with time zone");
b.Property<bool>("Deactivate")
.HasColumnType("boolean");
b.Property<bool>("OffScheduleIsActive")
.HasColumnType("boolean");
b.Property<bool>("OffTemplateIsActive")
.HasColumnType("boolean");
b.Property<bool>("OnScheduleIsActive")
.HasColumnType("boolean");
b.Property<bool>("OnTemplateIsActive")
.HasColumnType("boolean");
b.HasKey("Id");
b.HasIndex("ApplicationInWorkId")
.IsUnique();
b.ToTable("JobAutoControls");
});
modelBuilder.Entity("PARR.DAL.Models.JobAutoControlInEkStatus", b =>
{
b.Property<Guid>("JobAutoControlId")
.HasColumnType("uuid");
b.Property<int>("EkStatusCode")
.HasColumnType("integer");
b.HasKey("JobAutoControlId", "EkStatusCode");
b.HasIndex("EkStatusCode");
b.ToTable("JobAutoControlInEkStatus");
});
modelBuilder.Entity("PARR.DAL.Models.JobEkMask", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("JobAutoControlId")
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("JobAutoControlId");
b.ToTable("JobEkMasks");
});
modelBuilder.Entity("PARR.DAL.Models.Order", b =>
{
b.Property<Guid>("Id")
@@ -2592,6 +2674,47 @@ namespace PARR.DAL.Migrations
b.Navigation("WorkGroup");
});
modelBuilder.Entity("PARR.DAL.Models.JobAutoControl", b =>
{
b.HasOne("PARR.DAL.Models.ApplicationsInWork", "ApplicationsInWork")
.WithOne("JobAutoControl")
.HasForeignKey("PARR.DAL.Models.JobAutoControl", "ApplicationInWorkId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ApplicationsInWork");
});
modelBuilder.Entity("PARR.DAL.Models.JobAutoControlInEkStatus", b =>
{
b.HasOne("PARR.DAL.Models.EkStatus", "EkStatus")
.WithMany("JobAutoControlInEkStatuses")
.HasForeignKey("EkStatusCode")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.JobAutoControl", "JobAutoControl")
.WithMany("JobAutoControlInEkStatuses")
.HasForeignKey("JobAutoControlId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("EkStatus");
b.Navigation("JobAutoControl");
});
modelBuilder.Entity("PARR.DAL.Models.JobEkMask", b =>
{
b.HasOne("PARR.DAL.Models.JobAutoControl", "JobAutoControl")
.WithMany("JobEkMasks")
.HasForeignKey("JobAutoControlId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("JobAutoControl");
});
modelBuilder.Entity("PARR.DAL.Models.Order", b =>
{
b.HasOne("PARR.DAL.Models.OrderStatus", "NextStatus")
@@ -2780,6 +2903,8 @@ namespace PARR.DAL.Migrations
{
b.Navigation("EsppSchValues");
b.Navigation("JobAutoControl");
b.Navigation("Templates");
b.Navigation("WorkGroups");
@@ -2798,6 +2923,8 @@ namespace PARR.DAL.Migrations
modelBuilder.Entity("PARR.DAL.Models.EkStatus", b =>
{
b.Navigation("Hosts");
b.Navigation("JobAutoControlInEkStatuses");
});
modelBuilder.Entity("PARR.DAL.Models.EsppSchType", b =>
@@ -2829,6 +2956,13 @@ namespace PARR.DAL.Migrations
b.Navigation("Templates");
});
modelBuilder.Entity("PARR.DAL.Models.JobAutoControl", b =>
{
b.Navigation("JobAutoControlInEkStatuses");
b.Navigation("JobEkMasks");
});
modelBuilder.Entity("PARR.DAL.Models.Order", b =>
{
b.Navigation("AgentHistories");

View File

@@ -47,9 +47,11 @@ namespace PARR.DAL.Models
}
}
/// <summary>
/// Краткое описание
/// </summary>
public required string ShortDescription { get; set; }
//public required string FullDescription { get; set; }
private string _fullDescription = string.Empty;
public required string FullDescription
@@ -67,17 +69,11 @@ namespace PARR.DAL.Models
}
}
/// <summary>
/// Решение
/// </summary>
public required string Solution { get; set; }
///// <summary>
///// Время последнего запуска скрипта/генерации наряда
///// </summary>
//public DateTimeOffset? LastRun { get; set; }
///// <summary>
///// Время следующего запуска скрипта/генерации наряда
///// </summary>
//public DateTimeOffset NextRun { get; set; }
/// <summary>
/// Включить автораспределение
@@ -120,5 +116,7 @@ namespace PARR.DAL.Models
public ICollection<EsppSchValue> EsppSchValues { get; set; } = new HashSet<EsppSchValue>();
public ICollection<AppInWorkInWorkGroup> WorkGroups { get; set; } = new HashSet<AppInWorkInWorkGroup>();
public JobAutoControl? JobAutoControl { get; set; }
}
}

View File

@@ -13,5 +13,7 @@ namespace PARR.DAL.Models
public string Name { get; set; } = string.Empty;
public ICollection<Host> Hosts { get; set; } = new HashSet<Host>();
public ICollection<JobAutoControlInEkStatus> JobAutoControlInEkStatuses { get; set; } = new HashSet<JobAutoControlInEkStatus>();
}
}

View File

@@ -0,0 +1,71 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Models.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("JobAutoControls")]
[Index(nameof(ApplicationInWorkId), IsUnique = true)]
public class JobAutoControl : IBase
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public Guid ApplicationInWorkId { get; set; }
[ForeignKey(nameof(ApplicationInWorkId))]
public ApplicationsInWork? ApplicationsInWork { get; set; }
/// <summary>
/// Создавать новые РР (из настроке РР)
/// </summary>
public bool CreateNew { get; set; }
/// <summary>
/// Деактивировать не актуальные согласно ЭК (обратные статусы ЭК)
/// </summary>
public bool Deactivate { get; set; }
/// <summary>
/// Активировать РР после смены ЭК (согласно настройкам статусов ЭК)
/// </summary>
public bool Activate { get; set; }
/// <summary>
/// Состояние для активированных РР, шаблоны
/// </summary>
public bool OnTemplateIsActive { get; set; }
/// <summary>
/// Состояние для активированных РР, расписания
/// </summary>
public bool OnScheduleIsActive { get; set; }
/// <summary>
/// Состояние для деактивированных РР, шаблоны
/// </summary>
public bool OffTemplateIsActive { get; set; }
/// <summary>
/// Состояние для деактивированных РР, расписания
/// </summary>
public bool OffScheduleIsActive { get; set; }
/// <summary>
/// Список масок ЭК, или ЭК
/// </summary>
public ICollection<JobEkMask> JobEkMasks { get; set; } = new HashSet<JobEkMask>();
/// <summary>
/// Список статусов ЭК для которых создавать/активировать шаблоны/расписания
/// </summary>
public ICollection<JobAutoControlInEkStatus> JobAutoControlInEkStatuses { get; set; } = new HashSet<JobAutoControlInEkStatus>();
}
}

View File

@@ -0,0 +1,20 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("JobAutoControlInEkStatus")]
[PrimaryKey(nameof(JobAutoControlId), nameof(EkStatusCode))]
public class JobAutoControlInEkStatus
{
public Guid JobAutoControlId { get; set; }
public int EkStatusCode { get; set; }
[ForeignKey(nameof(EkStatusCode))]
public EkStatus? EkStatus { get; set; }
[ForeignKey(nameof(JobAutoControlId))]
public JobAutoControl? JobAutoControl { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
using PARR.DAL.Models.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("JobEkMasks")]
public class JobEkMask : IBase
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
public required string Name { get; set; }
public Guid JobAutoControlId { get; set; }
[ForeignKey(nameof(JobAutoControlId))]
public JobAutoControl? JobAutoControl { get; set; }
}
}

View File

@@ -84,7 +84,8 @@ namespace PARR.DAL
services.AddTransient<IDistributionPeriodService, DistributionPeriodService>();
services.AddTransient<IEsppSchTypeValueService, EsppSchTypeValueService>();
services.AddTransient<IResponseAreaService, ResponseAreaService>();
services.AddTransient<IJobAutoControlService, JobAutoControlService>();
services.AddTransient<IJobEkMaskService, JobEkMaskService>();
// TransformServices

View 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 JobAutoControlService : BaseService<JobAutoControl>, IJobAutoControlService
{
private readonly DataContext dataContext;
protected override DbSet<JobAutoControl> EntitySet => dataContext.JobAutoControls;
protected override DataContext EntitiContext => dataContext;
public JobAutoControlService(DataContext dataContext, ILogger<JobAutoControlService> logger) : base(logger)
{
this.dataContext = dataContext;
}
}
}

View 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 JobEkMaskService : BaseService<JobEkMask>, IJobEkMaskService
{
private readonly DataContext dataContext;
protected override DbSet<JobEkMask> EntitySet => dataContext.JobEkMasks;
protected override DataContext EntitiContext => dataContext;
public JobEkMaskService(DataContext dataContext, ILogger<JobEkMaskService> logger) : base(logger)
{
this.dataContext = dataContext;
}
}
}

View File

@@ -0,0 +1,9 @@
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces.Base;
namespace PARR.DAL.Services.Interfaces
{
public interface IJobAutoControlService : IBaseService<JobAutoControl>
{
}
}

View File

@@ -0,0 +1,9 @@
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces.Base;
namespace PARR.DAL.Services.Interfaces
{
public interface IJobEkMaskService : IBaseService<JobEkMask>
{
}
}