ChargingPile.cs 2.33 KB
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Rcs.Domain.Entities;

/// <summary>
/// 充电桩实体。
/// </summary>
[Table("charging_piles")]
public class ChargingPile : Entity
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.None)]
    [Column("pile_id")]
    public Guid PileId { get; set; }

    [Required]
    [Column("pile_code")]
    [MaxLength(50)]
    public string PileCode { get; set; } = string.Empty;

    [Required]
    [Column("pile_name")]
    [MaxLength(100)]
    public string PileName { get; set; } = string.Empty;

    [Column("ip_address")]
    [MaxLength(45)]
    public string IpAddress { get; set; } = string.Empty;

    [Column("port")]
    public int Port { get; set; } = 0;

    [Column("min_charging_minutes")]
    public int MinChargingMinutes { get; set; } = 10;

    [Column("full_charge_threshold")]
    public decimal FullChargeThreshold { get; set; } = 90m;

    [Column("supported_robot_models")]
    [MaxLength(200)]
    public List<string> SupportedRobotModels { get; set; } = new();

    [Column("bound_robot_ids")]
    [MaxLength(500)]
    public List<Guid> BoundRobotIds { get; set; } = new();

    [Column("current_charging_robot_id")]
    public Guid? CurrentChargingRobotId { get; set; }

    [Column("map_node_id")]
    public Guid? MapNodeId { get; set; }

    [Column("auto_start_threshold")]
    public decimal AutoStartThreshold { get; set; } = 30m;

    [Column("resume_threshold")]
    public decimal ResumeThreshold { get; set; } = 60m;

    [Column("max_charging_minutes")]
    public int MaxChargingMinutes { get; set; } = 120;

    [Column("queue_timeout_minutes")]
    public int QueueTimeoutMinutes { get; set; } = 30;

    [Column("priority")]
    public int Priority { get; set; } = 100;

    [Column("allow_task_interrupt")]
    public bool AllowTaskInterrupt { get; set; } = true;

    [Column("is_active")]
    public bool IsActive { get; set; } = true;

    [Column("created_at", TypeName = "timestamp")]
    public DateTime CreatedAt { get; set; }

    [Column("updated_at", TypeName = "timestamp")]
    public DateTime? UpdatedAt { get; set; }

    [ForeignKey(nameof(MapNodeId))]
    public virtual MapNode? MapNode { get; set; }

    [ForeignKey(nameof(CurrentChargingRobotId))]
    public virtual Robot? CurrentChargingRobot { get; set; }
}