2025-05-14 15:13:30 +10:00
|
|
|
|
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; }
|
|
|
|
|
|
|
2025-08-27 11:56:22 +10:00
|
|
|
|
[NotMapped]
|
2025-05-14 15:13:30 +10:00
|
|
|
|
public DateTimeOffset? DateModified { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// ЭК
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public required string Name { get; set; }
|
|
|
|
|
|
|
2025-08-26 14:04:49 +10:00
|
|
|
|
public DateTimeOffset? LastLogon { get; set; }
|
2025-05-14 15:13:30 +10:00
|
|
|
|
|
|
|
|
|
|
|
2025-06-25 14:17:34 +10:00
|
|
|
|
[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;
|
2025-08-26 14:04:49 +10:00
|
|
|
|
result.NotUnique = UnitValues.FirstOrDefault(t => t.Field?.AihitName == "НЕУНИКАЛЬНЫЙ_ЭК")?.Value?.Value;
|
2025-06-25 14:17:34 +10:00
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-14 15:13:30 +10:00
|
|
|
|
public ICollection<UnitInField> UnitFields { get; set; } = new HashSet<UnitInField>();
|
|
|
|
|
|
|
2025-05-21 11:53:07 +10:00
|
|
|
|
public ICollection<UnitInValue> UnitValues { get; set; } = new HashSet<UnitInValue>();
|
2025-05-27 11:32:05 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <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>();
|
2025-06-25 14:17:34 +10:00
|
|
|
|
|
2025-11-14 14:48:56 +10:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Связь с шаблонами. Один ко многим
|
|
|
|
|
|
/// </summary>
|
2025-06-25 14:17:34 +10:00
|
|
|
|
public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
|
2025-11-14 14:48:56 +10:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// К одному шаблону привязано несколько ЭК(Груповой тип работы). Многие ко многим
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ICollection<UnitsInTemplate> TemplatesInUnit { get; set; } = new HashSet<UnitsInTemplate>();
|
2025-12-19 09:09:22 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public UnitKiiUnit? UnitKii { get; set; }
|
2025-06-25 14:17:34 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class BaseFields
|
|
|
|
|
|
{
|
|
|
|
|
|
public string? IP { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public string? ResponseArea { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public string? WorkGroup { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public string? Status { get; set; }
|
2025-07-01 17:20:48 +10:00
|
|
|
|
|
|
|
|
|
|
public string? NotUnique { get; set; }
|
2025-05-14 15:13:30 +10:00
|
|
|
|
}
|
|
|
|
|
|
}
|