package com.qaup.system.domain;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.qaup.common.annotation.Excel;
import com.qaup.common.core.domain.BaseEntity;

/**
 * 车辆类型（路径编码模式）对象 sys_vehicle_type
 *
 * @author qaup
 * @date 2025-07-14
 */
public class SysVehicleType extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 代理主键ID */
    private Long id;

    /** 路径编码（如UV.PT表示无人车.巡逻车） */
    @Excel(name = "路径编码")
    private String typeCode;

    /** 类型名称 */
    @Excel(name = "类型名称")
    private String typeName;

    /** 中文显示名称 */
    @Excel(name = "中文显示名称")
    private String displayNameCn;

    /** 英文显示名称 */
    @Excel(name = "英文显示名称")
    private String displayNameEn;

    /** 路径层级（1=一级分类，2=二级分类） */
    @Excel(name = "路径层级")
    private Integer pathLevel;

    /** 父路径编码 */
    @Excel(name = "父路径编码")
    private String parentCode;

    /** 完整路径描述 */
    @Excel(name = "完整路径描述")
    private String fullPath;

    /** 是否叶子节点 */
    @Excel(name = "是否叶子节点")
    private Boolean isLeaf;

    /** 排序序号 */
    @Excel(name = "排序序号")
    private Integer sortOrder;

    /** 是否启用 */
    @Excel(name = "是否启用")
    private Boolean enabled;

    /** 描述信息 */
    @Excel(name = "描述信息")
    private String description;

    /** 扩展属性JSON（权限、速度限制等） */
    private String attributes;

    /** 乐观锁版本号 */
    private Long version;

    public void setId(Long id) 
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }

    public void setTypeCode(String typeCode) 
    {
        this.typeCode = typeCode;
    }

    public String getTypeCode() 
    {
        return typeCode;
    }

    public void setTypeName(String typeName) 
    {
        this.typeName = typeName;
    }

    public String getTypeName() 
    {
        return typeName;
    }

    public void setDisplayNameCn(String displayNameCn) 
    {
        this.displayNameCn = displayNameCn;
    }

    public String getDisplayNameCn() 
    {
        return displayNameCn;
    }

    public void setDisplayNameEn(String displayNameEn) 
    {
        this.displayNameEn = displayNameEn;
    }

    public String getDisplayNameEn() 
    {
        return displayNameEn;
    }

    public void setPathLevel(Integer pathLevel) 
    {
        this.pathLevel = pathLevel;
    }

    public Integer getPathLevel() 
    {
        return pathLevel;
    }

    public void setParentCode(String parentCode) 
    {
        this.parentCode = parentCode;
    }

    public String getParentCode() 
    {
        return parentCode;
    }

    public void setFullPath(String fullPath) 
    {
        this.fullPath = fullPath;
    }

    public String getFullPath() 
    {
        return fullPath;
    }

    public void setIsLeaf(Boolean isLeaf) 
    {
        this.isLeaf = isLeaf;
    }

    public Boolean getIsLeaf() 
    {
        return isLeaf;
    }

    public void setSortOrder(Integer sortOrder) 
    {
        this.sortOrder = sortOrder;
    }

    public Integer getSortOrder() 
    {
        return sortOrder;
    }

    public void setEnabled(Boolean enabled) 
    {
        this.enabled = enabled;
    }

    public Boolean getEnabled() 
    {
        return enabled;
    }

    public void setDescription(String description) 
    {
        this.description = description;
    }

    public String getDescription() 
    {
        return description;
    }

    public void setAttributes(String attributes) 
    {
        this.attributes = attributes;
    }

    public String getAttributes() 
    {
        return attributes;
    }

    public void setVersion(Long version) 
    {
        this.version = version;
    }

    public Long getVersion() 
    {
        return version;
    }

    // ========== 向后兼容的方法 ==========

    /** 
     * @deprecated 使用getId()代替
     */
    @Deprecated
    public Long getTypeId() {
        return getId();
    }

    /** 
     * @deprecated 使用setId()代替
     */
    @Deprecated
    public void setTypeId(Long typeId) {
        setId(typeId);
    }

    /** 
     * @deprecated 使用getPathLevel()代替
     */
    @Deprecated
    public Integer getLevel() {
        return getPathLevel();
    }

    /** 
     * @deprecated 使用setPathLevel()代替
     */
    @Deprecated
    public void setLevel(Integer level) {
        setPathLevel(level);
    }

    // ========== 业务方法 ==========

    /**
     * 获取一级分类编码
     */
    public String getTopLevelCode() {
        if (typeCode == null || typeCode.trim().isEmpty()) {
            return null;
        }
        
        int dotIndex = typeCode.indexOf('.');
        if (dotIndex > 0) {
            return typeCode.substring(0, dotIndex);
        }
        return typeCode;
    }

    /**
     * 判断是否为无人车
     */
    public boolean isUnmannedVehicle() {
        return "UV".equals(getTopLevelCode());
    }

    /**
     * 判断是否为特勤车
     */
    public boolean isSpecialVehicle() {
        return "SP".equals(getTopLevelCode());
    }

    /**
     * 判断是否为普通车
     */
    public boolean isNormalVehicle() {
        return "NM".equals(getTopLevelCode());
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("typeCode", getTypeCode())
            .append("typeName", getTypeName())
            .append("displayNameCn", getDisplayNameCn())
            .append("displayNameEn", getDisplayNameEn())
            .append("pathLevel", getPathLevel())
            .append("parentCode", getParentCode())
            .append("fullPath", getFullPath())
            .append("isLeaf", getIsLeaf())
            .append("sortOrder", getSortOrder())
            .append("enabled", getEnabled())
            .append("description", getDescription())
            .append("attributes", getAttributes())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .append("updateBy", getUpdateBy())
            .append("updateTime", getUpdateTime())
            .append("version", getVersion())
            .toString();
    }
}