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_maintenance")]
[Index("idx_{tablename}_01", nameof(TenantId) + "," + nameof(EquipmentId) + "," + nameof(MaintenanceDate))]
[Index("idx_{tablename}_02", nameof(TenantId) + "," + nameof(MaintenanceType))]
[Index("idx_{tablename}_03", nameof(TenantId) + "," + nameof(Status))]
public partial class EquipmentMaintenanceEntity : 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 MaintenanceType { get; set; }

    /// <summary>
    /// 维修日期
    /// </summary>
    public DateTime MaintenanceDate { get; set; }

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

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

    /// <summary>
    /// 维修时长（小时）
    /// </summary>
    public decimal? MaintenanceHours { get; set; }

    /// <summary>
    /// 维修人员ID
    /// </summary>
    public long? MaintenancePersonId { get; set; }

    /// <summary>
    /// 维修人员姓名
    /// </summary>
    [Column(StringLength = 50)]
    public string MaintenancePersonName { get; set; }

    /// <summary>
    /// 维修内容
    /// </summary>
    [Column(StringLength = 1000)]
    public string MaintenanceContent { get; set; }

    /// <summary>
    /// 维修结果
    /// </summary>
    [Column(StringLength = 500)]
    public string MaintenanceResult { get; set; }

    /// <summary>
    /// 维修费用
    /// </summary>
    public decimal? MaintenanceCost { 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 = 500)]
    public string MaintenanceTools { get; set; }

    /// <summary>
    /// 维修材料
    /// </summary>
    [Column(StringLength = 500)]
    public string MaintenanceMaterials { get; set; }

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

/// <summary>
/// 维修类型枚举
/// </summary>
public static class MaintenanceType
{
    /// <summary>
    /// 预防性维护
    /// </summary>
    public const string Preventive = "Preventive";

    /// <summary>
    /// 故障维修
    /// </summary>
    public const string Corrective = "Corrective";

    /// <summary>
    /// 紧急维修
    /// </summary>
    public const string Emergency = "Emergency";

    /// <summary>
    /// 定期保养
    /// </summary>
    public const string Regular = "Regular";

    /// <summary>
    /// 升级改造
    /// </summary>
    public const string Upgrade = "Upgrade";
}

/// <summary>
/// 维修状态枚举
/// </summary>
public static class MaintenanceStatus
{
    /// <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;
}