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_calibration")]
[Index("idx_{tablename}_01", nameof(TenantId) + "," + nameof(EquipmentId) + "," + nameof(CalibrationDate))]
[Index("idx_{tablename}_02", nameof(TenantId) + "," + nameof(CalibrationType))]
[Index("idx_{tablename}_03", nameof(TenantId) + "," + nameof(Status))]
public partial class EquipmentCalibrationEntity : EntityTenant
{
    /// <summary>
    /// 设备ID
    /// </summary>
    public long EquipmentId { get; set; }

    /// <summary>
    /// 设备名称
    /// </summary>
    [Column(StringLength = 100)]
    public string EquipmentName { get; set; }

    /// <summary>
    /// 校验类型
    /// </summary>
    [Column(StringLength = 50)]
    public string CalibrationType { get; set; }

    /// <summary>
    /// 校验日期
    /// </summary>
    public DateTime CalibrationDate { get; set; }

    /// <summary>
    /// 校验开始时间
    /// </summary>
    public DateTime? StartTime { get; set; }

    /// <summary>
    /// 校验结束时间
    /// </summary>
    public DateTime? EndTime { get; set; }

    /// <summary>
    /// 校验时长（小时）
    /// </summary>
    public decimal? CalibrationHours { get; set; }

    /// <summary>
    /// 校验人员ID
    /// </summary>
    public long? CalibrationPersonId { get; set; }

    /// <summary>
    /// 校验人员姓名
    /// </summary>
    [Column(StringLength = 50)]
    public string CalibrationPersonName { get; set; }

    /// <summary>
    /// 校验机构
    /// </summary>
    [Column(StringLength = 200)]
    public string CalibrationInstitution { get; set; }

    /// <summary>
    /// 校验证书编号
    /// </summary>
    [Column(StringLength = 100)]
    public string CertificateNumber { get; set; }

    /// <summary>
    /// 校验结果
    /// </summary>
    [Column(StringLength = 50)]
    public string CalibrationResult { get; set; }

    /// <summary>
    /// 校验精度
    /// </summary>
    [Column(StringLength = 100)]
    public string CalibrationAccuracy { get; set; }

    /// <summary>
    /// 校验费用
    /// </summary>
    public decimal? CalibrationCost { get; set; }

    /// <summary>
    /// 状态（0-计划中，1-进行中，2-已完成，3-已取消）
    /// </summary>
    public int Status { get; set; } = 0;

    /// <summary>
    /// 是否计划校验
    /// </summary>
    public bool IsPlanned { get; set; } = false;

    /// <summary>
    /// 计划校验周期（天）
    /// </summary>
    public int? PlannedCycle { get; set; }

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

    /// <summary>
    /// 校验标准
    /// </summary>
    [Column(StringLength = 200)]
    public string CalibrationStandard { get; set; }

    /// <summary>
    /// 校验方法
    /// </summary>
    [Column(StringLength = 500)]
    public string CalibrationMethod { get; set; }

    /// <summary>
    /// 校验环境要求
    /// </summary>
    [Column(StringLength = 500)]
    public string EnvironmentalRequirements { get; set; }

    /// <summary>
    /// 校验报告路径
    /// </summary>
    [Column(StringLength = 500)]
    public string ReportPath { get; set; }

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

/// <summary>
/// 校验类型枚举
/// </summary>
public static class CalibrationType
{
    /// <summary>
    /// 定期校验
    /// </summary>
    public const string Regular = "Regular";

    /// <summary>
    /// 首次校验
    /// </summary>
    public const string Initial = "Initial";

    /// <summary>
    /// 重新校验
    /// </summary>
    public const string Recalibration = "Recalibration";

    /// <summary>
    /// 临时校验
    /// </summary>
    public const string Temporary = "Temporary";

    /// <summary>
    /// 强制校验
    /// </summary>
    public const string Mandatory = "Mandatory";
}

/// <summary>
/// 校验结果枚举
/// </summary>
public static class CalibrationResult
{
    /// <summary>
    /// 合格
    /// </summary>
    public const string Pass = "Pass";

    /// <summary>
    /// 不合格
    /// </summary>
    public const string Fail = "Fail";

    /// <summary>
    /// 部分合格
    /// </summary>
    public const string Partial = "Partial";

    /// <summary>
    /// 待定
    /// </summary>
    public const string Pending = "Pending";
}

/// <summary>
/// 校验状态枚举
/// </summary>
public static class CalibrationStatus
{
    /// <summary>
    /// 计划中
    /// </summary>
    public const int Planned = 0;

    /// <summary>
    /// 进行中
    /// </summary>
    public const int InProgress = 1;

    /// <summary>
    /// 已完成
    /// </summary>
    public const int Completed = 2;

    /// <summary>
    /// 已取消
    /// </summary>
    public const int Cancelled = 3;
}