Equipment.cs 4.61 KB
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Collections.Generic;
using TableAttribute = System.ComponentModel.DataAnnotations.Schema.TableAttribute;
using ColumnAttribute = System.ComponentModel.DataAnnotations.Schema.ColumnAttribute;
using System;

namespace HHECS.Model.Entities
{
    /// <summary>
    /// 设备
    /// </summary>
    [Table("equipment")]
    public class Equipment : BaseEntityCU<int>
    {
        private string code;

        /// <summary>
        /// 设备编码,唯一且有规律易识别
        /// </summary>
        [Column(Order = 2)]
        [MaxLength(50)]
        [Required]
        public string Code
        {
            get { return code; }
            set { code = value; }
        }

        private string name;

        /// <summary>
        /// 设备名
        /// </summary>
        [Column(Order = 3)]
        [MaxLength(50)]
        [Required]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        private int equipmentTypeId;

        /// <summary>
        /// 关联到设备类型Id
        /// </summary>
        [Column(Order = 4)]
        [Required]
        public int EquipmentTypeId
        {
            get { return equipmentTypeId; }
            set { equipmentTypeId = value; }
        }

        private string ip;

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

        /// <summary>
        /// 出厂日期
        /// </summary>
        public DateTime? ProdTime { get; set; }

        /// <summary>
        /// 保养起始时间
        /// </summary>
        public DateTime? MaintainStartTime {  get; set; }

        //todo:更多属性待讨论

        /// <summary>
        /// 所在区域,出于调度目的或其他划分,比如:为兼容转轨堆垛机设定,正常情况下与巷道相同,转轨情况下对应虚拟划分巷道
        /// </summary>
        [Column(Order = 8)]
        [MaxLength(50)]
        public string DestinationArea { get; set; }

        private string description;

        /// <summary>
        /// 图片文件名称
        /// </summary>
        public string ImageName { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        [Column(Order = 22)]
        [MaxLength(200)]
        public string Description
        {
            get { return description; }
            set { description = value; }
        }

        /// <summary>
        /// 维护规则Id
        /// </summary>
        [Column(Order = 27)]
        public int? EquipmentMaintainRuleId { get; set; }



        private bool disable;

        /// <summary>
        /// 是否启用
        /// </summary>
        [Column(Order = 45)]
        [Required]
        public bool Disable
        {
            get { return disable; }
            set { disable = value; }
        }

        /// <summary>
        /// 仓库编码
        /// </summary>
        [MaxLength(50)]
        public string WarehouseCode { get; set; }

        /// <summary>
        /// 温度
        /// </summary>
        public double Temperature { get; set; }

        /// <summary>
        /// 震动
        /// </summary>
        public double Shake { get; set; }

        #region 外键
        /// <summary>
        /// 逻辑外键实体-设备保养规格
        /// </summary>
        public EquipmentMaintainRule EquipmentMaintainRule { get; set; }

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

        private List<EquipmentProp> equipmentProps = new List<EquipmentProp>();

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


        /// <summary>
        /// 获取设备属性
        /// </summary>
        /// <param name="key">设备属性code </param>
        /// <returns></returns>
        [NotMapped]
        public EquipmentProp this[string key]
        {
            get
            {
                return equipmentProps?.Find(t => t.EquipmentTypePropTemplateCode == key);
            }
        }

        [NotMapped]
        public string WarehouseCodeExt { get; set; }

        #endregion

    }
}