using DeviceRepair.Models.Attr;
using DeviceRepair.Models.Enum;
using Newtonsoft.Json;
using System.Linq;
using TsSFCDevice.Client.Biz.Base.Utils;

namespace TsSFCDevice.Client.Biz.His
{
    public class DevDataHistory
    {
        [JsonProperty("Operator", NullValueHandling = NullValueHandling.Ignore)]
        public int Operator
        {
            get;
            set;
        }

        /// <summary>
        /// 名称
        /// </summary>
        [HistoryFilterField(Code = "EquipmentID", CtlType = HistoryFilterCtlType.TextBox, DefaultValue = "", Description = "设备编号", ShowSequence = 1)]
        [HistoryGridField(Description = "设备编号", ShowSequence = 1)]
        [JsonProperty("EquipmentID", NullValueHandling = NullValueHandling.Ignore)]
        public string EquipmentID { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [HistoryGridField(Description = "设备名称", ShowSequence = 2)]
        [HistoryFilterField(Code = "EquipmentName", CtlType = HistoryFilterCtlType.TextBox, DefaultValue = "", Description = "设备名称", ShowSequence = 2)]
        [JsonProperty("EquipmentName", NullValueHandling = NullValueHandling.Ignore)]
        public string EquipmentName { get; set; }


        [HistoryGridField(Description = "操作类型", ShowSequence = 3)]
        [JsonProperty("OperationType", NullValueHandling = NullValueHandling.Ignore)]
        public string OperationType
        {
            get;
            set;
        } = "修改";

        [HistoryGridField(Description = "操作人", ShowSequence = 4)]
        [JsonProperty("OperatorName", NullValueHandling = NullValueHandling.Ignore)]
        public string OperatorName
        {
            get
            {
                var us = Utility.SystemRuntimeInfo.CurrentUsersCaches.FirstOrDefault(x => x.Id == Operator);
                return (us?.UserCode) ?? "N/A";
            }
        }

        [HistoryGridField(Description = "操作时间", ShowSequence = 5)]
        [JsonProperty("OperationDate", NullValueHandling = NullValueHandling.Ignore)]
        public string OperationDate
        {
            get;
            set;
        }


        [HistoryGridField(Description = "操作客户端", ShowSequence = 6)]
        [JsonProperty("OperationComputer", NullValueHandling = NullValueHandling.Ignore)]
        public string OperationComputer
        {
            get;
            set;

        }
        /// <summary>
        /// 设备型号规格
        /// </summary>
        [HistoryGridField(Description = "设备型号规格", ShowSequence = 7)]
        [JsonProperty("Specification", NullValueHandling = NullValueHandling.Ignore)]
        public string Specification { get; set; }

        /// <summary>
        /// 制造厂家
        /// </summary>
        [HistoryGridField(Description = "制造厂家", ShowSequence = 8)]
        [JsonProperty("Manufacturer", NullValueHandling = NullValueHandling.Ignore)]
        public string Manufacturer { get; set; }

        /// <summary>
        /// 出厂编号
        /// </summary>
        [HistoryGridField(Description = "出厂编号", ShowSequence = 9)]
        [JsonProperty("SerialNumber", NullValueHandling = NullValueHandling.Ignore)]
        public string SerialNumber { get; set; }

        /// <summary>
        /// 投产年月
        /// </summary>
        [HistoryGridField(Description = "投产年月", ShowSequence = 10)]
        [JsonProperty("UsingDate", NullValueHandling = NullValueHandling.Ignore)]
        public string UsingDate { get; set; }

        /// <summary>
        /// 设备总容量(KW)
        /// </summary>
        [HistoryGridField(Description = "设备总容量(KW)", ShowSequence = 11)]
        [JsonProperty("Totalcapacity", NullValueHandling = NullValueHandling.Ignore)]
        public double Totalcapacity { get; set; }

        /// <summary>
        /// 设备重量(吨)
        /// </summary>
        [HistoryGridField(Description = "设备重量(吨)", ShowSequence = 12)]
        [JsonProperty("Weight", NullValueHandling = NullValueHandling.Ignore)]
        public double Weight { get; set; }

        /// <summary>
        /// 设备类别
        /// </summary>
        [HistoryGridField(Description = "设备类别", ShowSequence = 13)]
        [JsonProperty("EquipmentCategory", NullValueHandling = NullValueHandling.Ignore)]
        public string EquipmentCategory { get; set; }

        /// <summary>
        /// 设备原值(万元)
        /// </summary>
        [HistoryGridField(Description = "设备原值(万元)", ShowSequence = 14)]
        [JsonProperty("EquipmentOriginalvalue", NullValueHandling = NullValueHandling.Ignore)]
        public decimal EquipmentOriginalvalue { get; set; }

        /// <summary>
        /// 设备状态
        /// </summary>
        [JsonProperty("EquipmentStatus", NullValueHandling = NullValueHandling.Ignore)]
        public int EquipmentStatus { get; set; }

        [HistoryGridField(Description = "设备状态", ShowSequence = 15)]
        [JsonProperty("EquipmentStatus", NullValueHandling = NullValueHandling.Ignore)]
        public string vEquipmentStatus
        {
            get
            {
                return EquipmentStatus == 1 ? "启用" : "禁用";
            }
        }

        /// <summary>
        /// 质保期
        /// </summary>
        [HistoryGridField(Description = "质保期", ShowSequence = 16)]
        [JsonProperty("WarrantyPeriod", NullValueHandling = NullValueHandling.Ignore)]
        public string WarrantyPeriod { get; set; }

        /// <summary>
        /// 安装地点
        /// </summary>
        [HistoryGridField(Description = "安装地点", ShowSequence = 17)]
        [JsonProperty("InstallationLocation", NullValueHandling = NullValueHandling.Ignore)]
        public string InstallationLocation { get; set; }

        /// <summary>
        /// 所属单元
        /// </summary>
        [HistoryGridField(Description = "所属单元", ShowSequence = 18)]
        [JsonProperty("OwningUnit", NullValueHandling = NullValueHandling.Ignore)]
        public string OwningUnit { get; set; }

        /// <summary>
        /// 运行参数
        /// </summary>
        [HistoryGridField(Description = "运行参数", ShowSequence = 19)]
        [JsonProperty("OperatingParameters", NullValueHandling = NullValueHandling.Ignore)]
        public string OperatingParameters { get; set; }

        /// <summary>
        /// 保养使用的表单
        /// </summary>
        [HistoryGridField(Description = "PM保养使用的表单", ShowSequence = 20)]
        [JsonProperty("MaintenanceFormVersion", NullValueHandling = NullValueHandling.Ignore)]
        public string MaintenanceFormVersion { get; set; }

        /// <summary>
        /// AM保养使用的表单
        /// </summary>
        [HistoryGridField(Description = "AM保养使用的表单", ShowSequence = 21)]
        [JsonProperty("MaintenanceAMFormVersion", NullValueHandling = NullValueHandling.Ignore)]
        public string MaintenanceAMFormVersion { get; set; }

        /// <summary>
        /// 路径
        /// </summary>
        [HistoryGridField(Description = "父级分类字段", ShowSequence = 22)]
        [JsonProperty("Route", NullValueHandling = NullValueHandling.Ignore)]
        public string Route { get; set; }

        /// <summary>
        /// 说明
        /// </summary>
        [HistoryGridField(Description = "说明", ShowSequence = 23)]
        [JsonProperty("Remarks", NullValueHandling = NullValueHandling.Ignore)]
        public string Remarks { get; set; }
    }
}
