MapNode.cs 3.7 KB
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Rcs.Domain.Attributes;

namespace Rcs.Domain.Entities;

[Table("map_nodes")]
public partial class MapNode : Entity
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.None)]
    [Column("node_id")]
    public Guid NodeId { get; set; }

    /// <summary>
    /// 地图ID(外键)
    /// </summary>
    [Column("map_id")]
    public Guid MapId { get; set; }

    [Required]
    [Column("node_code")]
    [MaxLength(50)]
    public string NodeCode { get; set; }

    [Column("node_name")]
    [MaxLength(100)]
    public string? NodeName { get; set; }

    [Column("description")]
    public string? Description { get; set; }

    [Column("x")]
    public double X { get; set; }

    [Column("y")]
    public double Y { get; set; }

    [Column("theta")]
    public double? Theta { get; set; }
        
    /// <summary>
    /// 是否倒车进入
    /// </summary>
    [Column("is_reverse_parking")]
    public bool IsReverseParking { get; set; }
        
    /// <summary>
    /// 是否旋转
    /// </summary>
    [Column("allow_rotate")]
    public bool AllowRotate { get; set; }

    /// <summary>
    /// 最大坐标偏移值 (单位:米)
    /// </summary>
    [Column("max_coordinate_offset")]
    public double? MaxCoordinateOffset { get; set; }

    [Column("type")]
    public MapNodeTYPE Type { get; set; }

    [Column("metadata", TypeName = "jsonb")]
    public Dictionary<string, object>? Metadata { get; set; }

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

    [Column("active")]
    public bool Active { get; set; }

    /// <summary>
    /// 储位类型ID(外键,可为空)
    /// </summary>
    [Column("storage_location_type_id")]
    public Guid? StorageLocationTypeId { get; set; }

    #region 外键 => 导航属性,ManyToOne/OneToOne

    [ForeignKey(nameof(MapId))]
    public virtual Map Map { get; set; }

    /// <summary>
    /// 储位类型(导航属性)
    /// </summary>
    [ForeignKey(nameof(StorageLocationTypeId))]
    public virtual StorageLocationType? StorageLocationType { get; set; }

    #endregion

    #region 外键 => 导航属性,OneToMany

    public virtual ICollection<MapEdge> MapEdgesFromNodes { get; set; } = new List<MapEdge>();

    public virtual ICollection<MapEdge> MapEdgesToNodes { get; set; } = new List<MapEdge>();

    public virtual ICollection<MapResource> MapResourcess { get; set; } = new List<MapResource>();

    /// <summary>
    /// 关联库位集合
    /// @author zzy
    /// </summary>
    public virtual ICollection<StorageLocation> StorageLocations { get; set; } = new List<StorageLocation>();

    #endregion

    #region 外键 => 导航属性,OneToOne

    [Column("robot_id")]
    public Guid? RobotId { get; set; }

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

    #endregion

    /// <summary>
    /// 是否为斑马线点
    /// </summary>
    [NotMapped]
    public bool ZebraCrossing { get; set; }
}

public enum MapNodeTYPE
{
    [EnumDescription("高速点", "High Speed")]
    speediness = 1,

    [EnumDescription("储位", "Storage")]
    store,

    [EnumDescription("充电位", "Charger")]
    charger,

    [EnumDescription("停车位", "Parking")]
    parking,

    [EnumDescription("其他", "Other")]
    other
}

/// <summary>
/// 节点使用状态枚举
/// @author zzy
/// </summary>
public enum MapNodeUseStatus
{
    [EnumDescription("空闲", "Free")]
    free = 0,

    [EnumDescription("占用/已放货", "In Use")]
    use = 1,

    [EnumDescription("预占用/放货中", "Pre Use")]
    pre_use = 2
}