feat(dal,aihitloader): Создали таблицы схемы Units и сервисы к ним.

This commit is contained in:
Mikhail Kuznetsov
2025-05-14 15:13:30 +10:00
parent a89e7f7b86
commit b03af638f6
27 changed files with 4361 additions and 6 deletions

View File

@@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Unit
{
[Table("Units", Schema = DataContextSettings.Unit)]
[Comment("Таблица с ЭК")]
[Index(nameof(Name), IsUnique = true)]
public class Unit : IBase
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
/// <summary>
/// ЭК
/// </summary>
public required string Name { get; set; }
//статус ЭК
// todo: добавить еще поля??? (которые есть у всех ЭК)
public ICollection<UnitInField> UnitFields { get; set; } = new HashSet<UnitInField>();
public ICollection<UnitInValue> UnitInValues { get; set; } = new HashSet<UnitInValue>();
}
}

View File

@@ -0,0 +1,53 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Unit
{
/// <summary>
/// Справочник полей ЭК (компонентный состав, ответствтвенные, любые поля)
/// </summary>
[Table("Fields", Schema = DataContextSettings.Unit)]
[Comment("Справочник полей ЭК")]
[Index(nameof(AihitName))]
[Index(nameof(EsppName))]
public class UnitField : IBase
{
[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; }
public ICollection<UnitInField> Units { get; set; } = new HashSet<UnitInField>();
public ICollection<UnitInValue> UnitInValues { get; set; } = new HashSet<UnitInValue>();
public ICollection<UnitFieldInUnitFieldValue> FieldValues { get; set; } = new HashSet<UnitFieldInUnitFieldValue>();
}
}

View File

@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Base;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Unit
{
[Table("FieldInFieldValues", Schema = DataContextSettings.Unit)]
[Comment("Значения полей ЭК")]
[PrimaryKey(nameof(FieldId), nameof(FieldValueId))]
public class UnitFieldInUnitFieldValue : IBaseDateCreated
{
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; }
}
}

View File

@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Unit
{
[Table("FieldValues", Schema = DataContextSettings.Unit)]
[Comment("Значения полей ЭК")]
[Index(nameof(Value))]
public class UnitFieldValue : IBase
{
[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>();
}
}

View File

@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Unit
{
/// <summary>
/// Связь Unit in Field
/// </summary>
///
[Table("UnitInFields", Schema = DataContextSettings.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; }
}
}

View File

@@ -0,0 +1,34 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Base;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Unit
{
[Table("UnitInValues", Schema = DataContextSettings.Unit)]
[Comment("Таблица связи ЭК с полями и со значениями")]
[PrimaryKey(nameof(UnitId), nameof(FieldId))]
public class UnitInValue : IBaseDateModified, IBaseDateCreated
{
public Guid UnitId { get; set; }
public Guid FieldId { get; set; }
public Guid VlaueId { 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(VlaueId))]
public UnitFieldValue? Value { get; set; }
}
}