feat: Из dal перенесены все модели в Domain. Из dal переименованы service в repository, вынесены в Core.
This commit is contained in:
98
PARR.Domain/Entities/Unit/Unit.cs
Normal file
98
PARR.Domain/Entities/Unit/Unit.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.Domain.Constants;
|
||||
using PARR.Domain.Entities.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.Domain.Entities.Unit
|
||||
{
|
||||
[Table("Units", Schema = DatabaseSchemas.Unit)]
|
||||
[Comment("Таблица с ЭК")]
|
||||
[Index(nameof(Name), IsUnique = true)]
|
||||
public class Unit : IBaseEntity
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ЭК
|
||||
/// </summary>
|
||||
public required string Name { get; set; }
|
||||
|
||||
public DateTimeOffset? LastLogon { get; set; }
|
||||
|
||||
|
||||
[NotMapped]
|
||||
public BaseFields? BaseFields
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
if (UnitValues.Any())
|
||||
{
|
||||
var result = new BaseFields();
|
||||
|
||||
result.IP = UnitValues.FirstOrDefault(t => t.Field?.AihitName == "IP_АДРЕС")?.Value?.Value;
|
||||
result.ResponseArea = UnitValues.FirstOrDefault(t => t.Field?.AihitName == "ЗО_РГ")?.Value?.Value;
|
||||
result.WorkGroup = UnitValues.FirstOrDefault(t => t.Field?.AihitName == "РАБОЧАЯ_ГР_ОТВ_ЗА_ЭК")?.Value?.Value;
|
||||
result.Status = UnitValues.FirstOrDefault(t => t.Field?.AihitName == "СТАТУС")?.Value?.Value;
|
||||
result.NotUnique = UnitValues.FirstOrDefault(t => t.Field?.AihitName == "НЕУНИКАЛЬНЫЙ_ЭК")?.Value?.Value;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ICollection<UnitInField> UnitFields { get; set; } = new HashSet<UnitInField>();
|
||||
|
||||
public ICollection<UnitInValue> UnitValues { get; set; } = new HashSet<UnitInValue>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить всех родителей
|
||||
/// </summary>
|
||||
[InverseProperty(nameof(UnitInUnit.ChildUnit))]
|
||||
public ICollection<UnitInUnit> ParentUnits { get; set; } = new HashSet<UnitInUnit>();
|
||||
|
||||
/// <summary>
|
||||
/// Получить детей
|
||||
/// </summary>
|
||||
[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>();
|
||||
|
||||
|
||||
public UnitKiiUnit? UnitKii { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class BaseFields
|
||||
{
|
||||
public string? IP { get; set; }
|
||||
|
||||
public string? ResponseArea { get; set; }
|
||||
|
||||
public string? WorkGroup { get; set; }
|
||||
|
||||
public string? Status { get; set; }
|
||||
|
||||
public string? NotUnique { get; set; }
|
||||
}
|
||||
}
|
||||
70
PARR.Domain/Entities/Unit/UnitField.cs
Normal file
70
PARR.Domain/Entities/Unit/UnitField.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.Domain.Constants;
|
||||
using PARR.Domain.Entities.Base;
|
||||
using PARR.Domain.Entities.Job;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.Domain.Entities.Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// Справочник полей ЭК (компонентный состав, ответствтвенные, любые поля)
|
||||
/// </summary>
|
||||
[Table("Fields", Schema = DatabaseSchemas.Unit)]
|
||||
[Comment("Справочник полей ЭК")]
|
||||
[Index(nameof(AihitName))]
|
||||
[Index(nameof(EsppName))]
|
||||
public class UnitField : IBaseEntity
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Имя поля в АИХ ИТ, заполняется при синхронизации
|
||||
/// </summary>
|
||||
public required string AihitName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Название поля в ЕСПП, возможно в дальнейшем для синхронизации
|
||||
/// </summary>
|
||||
public string? EsppName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Название поля для отображения в ГУИ
|
||||
/// </summary>
|
||||
public string? DisplayName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Код поля, используется в GUI
|
||||
/// </summary>
|
||||
public string? Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Могут ли принимать несколько значений. Из АИХ ИТ приходят значения разделённые запятой
|
||||
/// </summary>
|
||||
public bool? IsMultipleValue { get; set; }
|
||||
|
||||
|
||||
public ICollection<UnitInField> Units { get; set; } = new HashSet<UnitInField>();
|
||||
|
||||
public ICollection<UnitInValue> UnitInValues { get; set; } = new HashSet<UnitInValue>();
|
||||
|
||||
|
||||
public ICollection<UnitFieldInUnitFieldValue> UnitFieldValues { get; set; } = new HashSet<UnitFieldInUnitFieldValue>();
|
||||
|
||||
public ICollection<JobRelationshipFilter> RelationshipFilters { get; set; } = new HashSet<JobRelationshipFilter>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// JobGroup которые группируются по этому полю (!!!отключено каскадное удаление!!!)
|
||||
/// </summary>
|
||||
public ICollection<JobGroup> JobGroupWithGrouping { get; set; } = new HashSet<JobGroup>();
|
||||
}
|
||||
}
|
||||
28
PARR.Domain/Entities/Unit/UnitFieldInUnitFieldValue.cs
Normal file
28
PARR.Domain/Entities/Unit/UnitFieldInUnitFieldValue.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.Domain.Constants;
|
||||
using PARR.Domain.Entities.Base;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.Domain.Entities.Unit
|
||||
{
|
||||
[Table("FieldInFieldValues", Schema = DatabaseSchemas.Unit)]
|
||||
[Comment("Значения полей ЭК")]
|
||||
[PrimaryKey(nameof(FieldId), nameof(FieldValueId))]
|
||||
public class UnitFieldInUnitFieldValue : IBaseEntityDateCreated
|
||||
{
|
||||
public Guid FieldId { get; set; }
|
||||
|
||||
public Guid FieldValueId { get; set; }
|
||||
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
|
||||
|
||||
[ForeignKey(nameof(FieldId))]
|
||||
public UnitField? Field { get; set; }
|
||||
|
||||
|
||||
[ForeignKey(nameof(FieldValueId))]
|
||||
public UnitFieldValue? FieldValue { get; set; }
|
||||
}
|
||||
}
|
||||
31
PARR.Domain/Entities/Unit/UnitFieldValue.cs
Normal file
31
PARR.Domain/Entities/Unit/UnitFieldValue.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.Domain.Constants;
|
||||
using PARR.Domain.Entities.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.Domain.Entities.Unit
|
||||
{
|
||||
[Table("FieldValues", Schema = DatabaseSchemas.Unit)]
|
||||
[Comment("Значения полей ЭК")]
|
||||
[Index(nameof(Value), IsUnique = true)]
|
||||
public class UnitFieldValue : IBaseEntity
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
|
||||
public string? Value { get; set; }
|
||||
|
||||
|
||||
public ICollection<UnitInValue> UnitInValues { get; set; } = new HashSet<UnitInValue>();
|
||||
|
||||
public ICollection<UnitFieldInUnitFieldValue> FieldValues { get; set; } = new HashSet<UnitFieldInUnitFieldValue>();
|
||||
|
||||
public UnitRegionalEkPtkGroup? RegionalEkPtkGroup { get; set; }
|
||||
}
|
||||
}
|
||||
29
PARR.Domain/Entities/Unit/UnitInField.cs
Normal file
29
PARR.Domain/Entities/Unit/UnitInField.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.Domain.Constants;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.Domain.Entities.Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// Связь Unit in Field
|
||||
/// </summary>
|
||||
///
|
||||
[Table("UnitInFields", Schema = DatabaseSchemas.Unit)]
|
||||
[Comment("Справочник полей ЭК")]
|
||||
[PrimaryKey(nameof(UnitId), nameof(FieldId))]
|
||||
public class UnitInField
|
||||
{
|
||||
public Guid UnitId { get; set; }
|
||||
|
||||
public Guid FieldId { get; set; }
|
||||
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
|
||||
[ForeignKey(nameof(UnitId))]
|
||||
public Unit? Unit { get; set; }
|
||||
|
||||
[ForeignKey(nameof(FieldId))]
|
||||
public UnitField? UnitField { get; set; }
|
||||
}
|
||||
}
|
||||
30
PARR.Domain/Entities/Unit/UnitInUnit.cs
Normal file
30
PARR.Domain/Entities/Unit/UnitInUnit.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.Domain.Constants;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.Domain.Entities.Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// Связи иерархии между ЭК
|
||||
/// </summary>
|
||||
[Table("UnitInUnits", Schema = DatabaseSchemas.Unit)]
|
||||
[Comment("Таблица связей иерархии между ЭК")]
|
||||
[PrimaryKey(nameof(ParentUnitId), nameof(ChildUnitId))]
|
||||
public class UnitInUnit
|
||||
{
|
||||
public Guid ParentUnitId { get; set; }
|
||||
|
||||
public Guid ChildUnitId { get; set; }
|
||||
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
public DateTimeOffset? DateSynced { get; set; }
|
||||
|
||||
|
||||
[ForeignKey(nameof(ParentUnitId))]
|
||||
public Unit? ParentUnit { get; set; }
|
||||
|
||||
[ForeignKey(nameof(ChildUnitId))]
|
||||
public Unit? ChildUnit { get; set; }
|
||||
}
|
||||
}
|
||||
37
PARR.Domain/Entities/Unit/UnitInValue.cs
Normal file
37
PARR.Domain/Entities/Unit/UnitInValue.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.Domain.Constants;
|
||||
using PARR.Domain.Entities.Base;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.Domain.Entities.Unit
|
||||
{
|
||||
|
||||
[Table("UnitInValues", Schema = DatabaseSchemas.Unit)]
|
||||
[Comment("Таблица связи ЭК с полями и со значениями")]
|
||||
[PrimaryKey(nameof(UnitId), nameof(FieldId), nameof(ValueId))]
|
||||
[Index(nameof(FieldId), nameof(ValueId))]
|
||||
[Index(nameof(UnitId), nameof(FieldId))]
|
||||
[Index(nameof(FieldId), nameof(UnitId))]
|
||||
public class UnitInValue : IBaseEntityDateModified, IBaseEntityDateCreated
|
||||
{
|
||||
public Guid UnitId { get; set; }
|
||||
|
||||
public Guid FieldId { get; set; }
|
||||
|
||||
public Guid ValueId { get; set; }
|
||||
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
|
||||
|
||||
[ForeignKey(nameof(UnitId))]
|
||||
public Unit? Unit { get; set; }
|
||||
|
||||
[ForeignKey(nameof(FieldId))]
|
||||
public UnitField? Field { get; set; }
|
||||
|
||||
[ForeignKey(nameof(ValueId))]
|
||||
public UnitFieldValue? Value { get; set; }
|
||||
}
|
||||
}
|
||||
23
PARR.Domain/Entities/Unit/UnitKiiUnit.cs
Normal file
23
PARR.Domain/Entities/Unit/UnitKiiUnit.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.Domain.Constants;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.Domain.Entities.Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// Список ЭК КИИ, которые учавствуют в групповых работах. Создавалась как временная
|
||||
/// </summary>
|
||||
[Table("KiiUnits", Schema = DatabaseSchemas.Unit)]
|
||||
[Comment("Таблица - Список ЭК КИИ, которые учавствуют в групповых работах. Создавалась как временная")]
|
||||
public class UnitKiiUnit
|
||||
{
|
||||
//TODO: создавалась как временная таблица
|
||||
|
||||
[Key]
|
||||
public Guid UnitId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(UnitId))]
|
||||
public Unit? Unit { get; set; }
|
||||
}
|
||||
}
|
||||
18
PARR.Domain/Entities/Unit/UnitRegionalEkPtkGroup.cs
Normal file
18
PARR.Domain/Entities/Unit/UnitRegionalEkPtkGroup.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.Domain.Constants;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.Domain.Entities.Unit
|
||||
{
|
||||
[Table("RegionalEkPtkGroups", Schema = DatabaseSchemas.Unit)]
|
||||
[Comment("Таблица - региональные группы ПТК")]
|
||||
public class UnitRegionalEkPtkGroup
|
||||
{
|
||||
[Key]
|
||||
public Guid FieldValueId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(FieldValueId))]
|
||||
public UnitFieldValue? FieldValue { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user