using System;
using FreeSql.DataAnnotations;
using ZhonTai.Admin.Core.Entities;
using NPP.SmartSchedue.Api.Contracts.Core.Consts;

namespace NPP.SmartSchedue.Api.Contracts.Domain.Equipment;

/// <summary>
/// 设备基本信息实体
/// </summary>
[Table(Name = DbConsts.AEMTableNamePrefix + "equipment")]
[Index("idx_{tablename}_01", nameof(TenantId) + "," + nameof(InternalNumber), true)]
[Index("idx_{tablename}_02", nameof(TenantId) + "," + nameof(EquipmentType))]
[Index("idx_{tablename}_03", nameof(TenantId) + "," + nameof(Status))]
public partial class EquipmentEntity : EntityTenant
{
    /// <summary>
    /// 设备名称
    /// </summary>
    [Column(StringLength = 100)]
    public string Name { get; set; }

    /// <summary>
    /// 设备型号
    /// </summary>
    [Column(StringLength = 100)]
    public string Model { get; set; }

    /// <summary>
    /// 内部编号
    /// </summary>
    [Column(StringLength = 50)]
    public string InternalNumber { get; set; }

    /// <summary>
    /// 房间号
    /// </summary>
    [Column(StringLength = 50)]
    public string RoomNumber { get; set; }

    /// <summary>
    /// 设备类型
    /// </summary>
    [Column(StringLength = 50)]
    public string EquipmentType { get; set; }

    /// <summary>
    /// 设备状态（0-正常，1-维护，2-校验，3-故障，4-报废）
    /// </summary>
    public int Status { get; set; } = 0;

    /// <summary>
    /// 适配工序
    /// </summary>
    public long ProcessID { get; set; }

    /// <summary>
    /// 固资编号
    /// </summary>
    [Column(StringLength = 50)]
    public string FixedAssetNumber { get; set; }

    /// <summary>
    /// 设备负责人ID
    /// </summary>
    public long? ResponsiblePersonId { get; set; }

    /// <summary>
    /// 设备负责人姓名
    /// </summary>
    [Column(StringLength = 50)]
    public string ResponsiblePersonName { get; set; }

    /// <summary>
    /// 最大流速
    /// </summary>
    public decimal? MaxFlowRate { get; set; }

    /// <summary>
    /// 流速单位
    /// </summary>
    [Column(StringLength = 20)]
    public string FlowRateUnit { get; set; }

    /// <summary>
    /// 设备规格
    /// </summary>
    [Column(StringLength = 500)]
    public string Specifications { get; set; }

    /// <summary>
    /// 制造商
    /// </summary>
    [Column(StringLength = 100)]
    public string Manufacturer { get; set; }

    /// <summary>
    /// 购买日期
    /// </summary>
    public DateTime? PurchaseDate { get; set; }

    /// <summary>
    /// 保修期（月）
    /// </summary>
    public int? WarrantyMonths { get; set; }

    /// <summary>
    /// 最后维护日期
    /// </summary>
    public DateTime? LastMaintenanceDate { get; set; }

    /// <summary>
    /// 下次维护日期
    /// </summary>
    public DateTime? NextMaintenanceDate { get; set; }

    /// <summary>
    /// 最后校验日期
    /// </summary>
    public DateTime? LastCalibrationDate { get; set; }

    /// <summary>
    /// 下次校验日期
    /// </summary>
    public DateTime? NextCalibrationDate { get; set; }

    /// <summary>
    /// 设备位置
    /// </summary>
    [Column(StringLength = 200)]
    public string Location { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    [Column(StringLength = 500)]
    public string Remark { get; set; }
}

/// <summary>
/// 设备状态枚举
/// </summary>
public static class EquipmentStatus
{
    /// <summary>
    /// 正常
    /// </summary>
    public const int Normal = 0;

    /// <summary>
    /// 维护
    /// </summary>
    public const int Maintenance = 1;

    /// <summary>
    /// 校验
    /// </summary>
    public const int Calibration = 2;

    /// <summary>
    /// 故障
    /// </summary>
    public const int Fault = 3;

    /// <summary>
    /// 报废
    /// </summary>
    public const int Scrapped = 4;
}

/// <summary>
/// 设备类型枚举
/// </summary>
public static class EquipmentType
{
    /// <summary>
    /// 生产设备
    /// </summary>
    public const string Production = "Production";

    /// <summary>
    /// 检测设备
    /// </summary>
    public const string Testing = "Testing";

    /// <summary>
    /// 实验室设备
    /// </summary>
    public const string Laboratory = "Laboratory";

    /// <summary>
    /// 办公设备
    /// </summary>
    public const string Office = "Office";

    /// <summary>
    /// 其他设备
    /// </summary>
    public const string Other = "Other";
}