feat(dal): Созданы таблицы JobGroupTypes+UnitsInTemplates, обновлен ключ уникального индекса шаблонов

This commit is contained in:
Mikhail Kuznetsov
2025-11-14 14:48:56 +10:00
parent 334595e81c
commit 48c8741395
19 changed files with 12199 additions and 16 deletions

View File

@@ -44,7 +44,7 @@ namespace PARR.DAL.Models.Job
/// true - диапазон связей относится к родительским связям<br/>
/// false, null - диапазон относится к дочерним связям
/// </value>
public bool? isParentRelationships { get; set; }
public bool? IsParentRelationships { get; set; }
/// <summary>
/// Маска для динамического формирования имени шаблона

View File

@@ -27,7 +27,7 @@ namespace PARR.DAL.Models.Job
/// Связана ли работа с групповыми ЭК(зонтами)
/// </summary>
public bool? IsUmbrella { get; set; }
/// <summary>
/// Поле Короткое описания шаблона АСУ ЕСПП
/// </summary>
@@ -114,6 +114,11 @@ namespace PARR.DAL.Models.Job
/// </summary>
public string? AgentScript { get; set; }
public Guid GroupTypeId { get; set; }
[ForeignKey(nameof(GroupTypeId))]
public JobGroupType? GroupType { get; set; }
public ICollection<Job> Jobs { get; set; } = new HashSet<Job>();
public ICollection<EsppSchValue> EsppSchValues { get; set; } = new HashSet<EsppSchValue>();

View File

@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Contracts;
using PARR.DAL.Models.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Job
{
[Table("GroupTypes", Schema = DataContextSettings.Job)]
[Comment("Таблица типов групп работ")]
public class JobGroupType : IBase
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
public required JobGroupTypesEnum Code { get; set; }
public required string Name { get; set; }
public ICollection<JobGroup> JobGroups { get; set; } = new HashSet<JobGroup>();
}
}

View File

@@ -46,9 +46,5 @@ namespace PARR.DAL.Models.Job
[ForeignKey(nameof(FieldId))]
public UnitField? UnitField { get; set; }
}
}

View File

@@ -11,7 +11,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("Templates")]
[Index(nameof(Name), IsUnique = true)]
[Index(nameof(Name), nameof(Index), IsUnique = true)]
public class Template : IBase, ITemplateGeneralProps, IHistoryInitiator, IMyHistory<TemplateHistory>
{
[Key]
@@ -23,10 +23,20 @@ namespace PARR.DAL.Models
public required string Name { get; set; }
/// <summary>
/// Индекс, используется в групповых шаблонах
/// </summary>
public int? Index { get; set; }
public bool IsActiveTemplate { get; set; }
public bool IsActiveSchedule { get; set; }
/// <summary>
/// Шаблон не используется : перестал подходить условиям Job'а
/// </summary>
public bool IsUnused { get; set; } = false;
/// <summary>
/// Номер расписания еспп
/// </summary>
@@ -76,7 +86,7 @@ namespace PARR.DAL.Models
[ForeignKey(nameof(UnitId))]
public Unit.Unit? Unit { get; set; }
public ICollection<RobotConfiguration> RobotConfigurations { get; set; } = new HashSet<RobotConfiguration>();
public ICollection<AgentHistory> AgentHistories { get; set; } = new HashSet<AgentHistory>();
@@ -84,5 +94,7 @@ namespace PARR.DAL.Models
public ICollection<Order> Orders { get; set; } = new HashSet<Order>();
public ICollection<TemplateHistory> TemplateHistories { get; set; } = new HashSet<TemplateHistory>();
public ICollection<UnitsInTemplate> UnitsInTemplate { get; set; } = new HashSet<UnitsInTemplate>();
}
}

View File

@@ -67,7 +67,16 @@ namespace PARR.DAL.Models.Unit
[InverseProperty(nameof(UnitInUnit.ParentUnit))]
public ICollection<UnitInUnit> ChildUnits { get; set; } = new HashSet<UnitInUnit>();
/// <summary>
/// Связь с шаблонами. Один ко многим
/// </summary>
public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
/// <summary>
/// К одному шаблону привязано несколько ЭК(Груповой тип работы). Многие ко многим
/// </summary>
public ICollection<UnitsInTemplate> TemplatesInUnit { get; set; } = new HashSet<UnitsInTemplate>();
}

View File

@@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using System.ComponentModel.DataAnnotations.Schema;
using System.Xml.Linq;
namespace PARR.DAL.Models
{
[Table("UnitsInTemplates", Schema = DataContextSettings.Job)]
[Comment("Таблица связи ЭК в шаблонах")]
public class UnitsInTemplate
{
public Guid TemplateId { get; set; }
public Guid UnitId { get; set; }
public DateTimeOffset DateCreated { get; set; }
[ForeignKey(nameof(TemplateId))]
public Template? Template { get; set; }
[ForeignKey(nameof(UnitId))]
public Unit.Unit? Unit { get; set; }
}
}