package com.qaup.collision.common.model;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import lombok.experimental.SuperBuilder;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * 航空器模型
 * 
 * @author AI Assistant
 * @version 1.0
 * @since 2025-01-17
 */
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@SuperBuilder
@JsonIgnoreProperties(ignoreUnknown = true)
public class Aircraft extends MovingObject {

    /**
     * 航班号
     */
    private String flightNumber;
    
    /**
     * 进港跑道编号
     */
    private String inRunway;
    
    /**
     * 出港跑道编号
     */
    private String outRunway;
    
    /**
     * 联络道口
     */
    private String contactCross;
    
    /**
     * 目的机位
     */
    private String seat;
    
    /**
     * 航班状态
     */
    private FlightStatus flightStatus;
    
    /**
     * 当前进港路由信息
     */
    private AircraftRoute arrivalRoute;
    
    /**
     * 当前出港路由信息
     */
    private AircraftRoute departureRoute;
    
    /**
     * 当前激活的路由 (指向arrivalRoute或departureRoute)
     */
    private AircraftRoute currentRoute;
    
    /**
     * 路由状态时间戳
     */
    private Long routeTimestamp;
    
    /**
     * 航班状态枚举
     */
    public enum FlightStatus {
        SCHEDULED,      // 计划
        TAXIING,        // 滑行
        TAKEOFF,        // 起飞
        AIRBORNE,       // 空中
        LANDING,        // 降落
        ARRIVED,        // 进港
        DEPARTURE,      // 出港
        CANCELLED       // 取消
    }
    
    /**
     * 检查是否有激活的路由
     */
    public boolean hasActiveRoute() {
        return currentRoute != null && currentRoute.isValid();
    }
    
    /**
     * 获取当前路由类型
     */
    public String getCurrentRouteType() {
        return currentRoute != null ? currentRoute.getType() : null;
    }
    
    /**
     * 设置进港路由为当前激活路由
     */
    public void activateArrivalRoute() {
        if (arrivalRoute != null) {
            this.currentRoute = arrivalRoute;
            this.routeTimestamp = System.currentTimeMillis();
        }
    }
    
    /**
     * 设置出港路由为当前激活路由
     */
    public void activateDepartureRoute() {
        if (departureRoute != null) {
            this.currentRoute = departureRoute;
            this.routeTimestamp = System.currentTimeMillis();
        }
    }
    
    /**
     * 清除当前激活路由
     */
    public void clearCurrentRoute() {
        this.currentRoute = null;
        this.routeTimestamp = null;
    }
}
