Equipment.cs 2.81 KB
using FreeSql.DataAnnotations;
using System.ComponentModel.DataAnnotations;

namespace HHECS.DAQShared.Models
{
    [Table(Name = "daq_equipment")]
    [Index($"uk_{nameof(Code)}", $"{nameof(Code)}", true)]
    public class Equipment : BaseEntityCU<int>
    {
        /// <summary>
        /// 设备编码,唯一且有规律易识别
        /// </summary>
        [Column(IsNullable = false, Position = 2)]
        [MaxLength(50)]
        public string Code { get; set; } = null!;

        /// <summary>
        /// 设备名
        /// </summary>
        [Column(IsNullable = false, Position = 3)]
        [MaxLength(50)]
        public string Name { get; set; } = null!;

        /// <summary>
        /// 关联到设备类型Id
        /// </summary>
        [Column(IsNullable = false, Position = 4)]
        public int EquipmentTypeId { get; set; }

        /// <summary>
        /// 此处写到这台设备对应的IP,一般为PLC的IP
        /// </summary>
        [Column(IsNullable = false, Position = 5)]
        [MaxLength(20)]
        public string IP { get; set; } = null!;

        /// <summary>
        /// 标定设备所在区域,他可能在一个仓库,也可能在一条产线上
        /// </summary>
        [Column(Position = 8)]
        [MaxLength(50)]
        public string DestinationArea { get; set; } = null!;

        /// <summary>
        /// 连接名
        /// </summary>
        public string ConnectName { get; set; } = null!;

        /// <summary>
        /// 描述
        /// </summary>
        [Column(Position = 29)]
        [MaxLength(200)]
        public string Description { get; set; } = null!;

        /// <summary>
        /// 是否禁用
        /// </summary>
        [Column(Position = 33)]
        [Required]
        public bool Disable { get; set; }

        /// <summary>
        /// 逻辑外键实体-设备类型
        /// </summary>
        public EquipmentType EquipmentType { get; set; } = null!;

        /// <summary>
        ///  逻辑外键实体-设备属性
        /// </summary>
        public List<EquipmentProp> EquipmentProps { get; set; } = new List<EquipmentProp>();

        /// <summary>
        /// 获取设备属性
        /// </summary>
        /// <param name="key">设备属性Code</param>
        /// <returns></returns>
        [Column(IsIgnore = true)]
        public EquipmentProp this[string key]
        {
            get
            {
                string key2 = key;
                return EquipmentProps?.Find((EquipmentProp t) => t.Code == key2) ?? new EquipmentProp();
            }
        }

        /// <summary>
        /// 项目编号
        /// </summary>
        public string ProjectCode { get; set; } = null!;

        /// <summary>
        /// 仓库编号
        /// </summary>
        public string FactoryCode { get; set; } = null!;
    }
}