using SqlSugar;
using System;
using System.Collections.Generic;

namespace Intend
{
    [SugarTable("DeviceWarrantyRequestForm")]
    public class MainModel : ModelContext
    {
        /// <summary>
        /// 主键编号 (原则：300000000 - 399999999)
        ///</summary>
        [SugarColumn(ColumnName = "AutoID", IsPrimaryKey = true, IsIdentity = true)]
        public int AutoID { get; set; }
        /// <summary>
        /// 唯一编号 
        ///</summary>
        [SugarColumn(ColumnName = "GUID")]
        public Guid GUID { get; set; }
        /// <summary>
        /// 设备表主键编号 
        ///</summary>
        [SugarColumn(ColumnName = "EquipmentPK")]
        public int EquipmentPK { get; set; }
        /// <summary>
        /// 设备编号 
        ///</summary>
        [SugarColumn(ColumnName = "EquipmentID", Length = 50)]
        public string EquipmentID { get; set; }
        /// <summary>
        /// 设备名称 
        ///</summary>
        [SugarColumn(ColumnName = "EquipmentName", Length = 200, ColumnDataType = "nvarchar")]
        public string EquipmentName { get; set; }
        /// <summary>
        /// 发生地点 
        ///</summary>
        [SugarColumn(ColumnName = "Location")]
        public int Location { get; set; }
        /// <summary>
        /// 发生地点 
        ///</summary>
        [SugarColumn(ColumnName = "LocationName")]
        public string LocationName { get; set; }
        /// <summary>
        /// 是否有在途生产单 
        ///</summary>
        [SugarColumn(ColumnName = "InProduction")]
        public bool InProduction { get; set; }
        /// <summary>
        /// 批次号 
        ///</summary>
        [SugarColumn(ColumnName = "Batch", Length = 30)]
        public string Batch { get; set; }
        /// <summary>
        /// 故障现象
        /// </summary>
        [SugarColumn(ColumnName = "FaultSymptoms")]
        public string FaultSymptoms { get; set; }
        /// <summary>
        /// 设备设施部
        /// </summary>
        [SugarColumn(ColumnName = "ReceivingDep")]
        public string ReceivingDep { get; set; }
        /// <summary>
        /// 停机状态（是、否）
        /// </summary>
        [SugarColumn(ColumnName = "IsDown")]
        public bool IsDown { get; set; }
        /// <summary>
        /// 文档版本
        /// </summary>
        [SugarColumn(ColumnName = "FormVer")]
        public int FormVer { get; set; }
        /// <summary>
        /// 申请时间 
        ///</summary>
        [SugarColumn(ColumnName = "CreatOn")]
        public DateTime? CreatOn { get; set; }
        /// <summary>
        /// 申请人 
        ///</summary>
        [SugarColumn(ColumnName = "CreatBy")]
        public int? CreatBy { get; set; }
        /// <summary>
        /// 申请人姓名
        /// </summary>
        [SugarColumn(ColumnName = "CreatorName")]
        public string CreatorName { get; set; }
        /// <summary>
        /// 申请部门 
        ///</summary>
        [SugarColumn(ColumnName = "CreatDept")]
        public int? CreatDept { get; set; }
        /// <summary>
        /// 申请部门名称
        /// </summary>
        public string CreatDeptName { get; set; }
        /// <summary>
        /// 修改时间 
        ///</summary>
        [SugarColumn(ColumnName = "ModifyOn")]
        public DateTime? ModifyOn { get; set; }
        /// <summary>
        /// 修改人 
        ///</summary>
        [SugarColumn(ColumnName = "ModifyBy")]
        public int? ModifyBy { get; set; }

        [SugarColumn(IsIgnore = true)]
        public List<MainItemModel> MaintaionItems
        {
            get
            {
                return base.CreateMapping<MainItemModel>().Where(x => x.FormID == this.AutoID).ToList();
            }
        }

        [SugarColumn(IsIgnore = true)]
        public List<EvaluatorItemModel> EvaluatorItems
        {
            get
            {
                return base.CreateMapping<EvaluatorItemModel>().Where(x => x.FormID == this.AutoID).ToList();
            }
        }
    }
}
