Initial commit: Robot ökoszisztéma v2.0 - Stabilizált jármű és szerviz robotok

This commit is contained in:
Kincses
2026-03-04 02:03:03 +01:00
commit 250f4f4b8f
7942 changed files with 449625 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
from sqlalchemy import Column, Integer, String, Date, ForeignKey, DateTime
from sqlalchemy.sql import func
from app.db.base import Base
class Vehicle(Base):
__tablename__ = "vehicles"
__table_args__ = {"schema": "data"}
id = Column(Integer, primary_key=True, index=True)
user_id = Column(Integer, ForeignKey("data.users.id"), nullable=False, index=True)
# Alapadatok
license_plate = Column(String, index=True, nullable=False) # Rendszám (változhat)
vin = Column(String, unique=True, index=True, nullable=True) # Alvázszám (Opcionális létrehozáskor)
make = Column(String, nullable=False) # Márka (pl. BMW)
model = Column(String, nullable=False) # Típus (pl. E46 320d)
year = Column(Integer, nullable=False) # Évjárat
fuel_type = Column(String, nullable=True) # Benzin, Dízel, EV, Hybrid
# Szervizkönyv Kritikus Adatok
initial_odometer = Column(Integer, default=0) # Kezdő km állás rögzítéskor
current_odometer = Column(Integer, default=0) # Mindig a legfrissebb ismert állás
# Lejáratok (Értesítésekhez)
mot_expiry_date = Column(Date, nullable=True) # Műszaki vizsga
insurance_expiry_date = Column(Date, nullable=True) # Kötelező biztosítás
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), onupdate=func.now())

View File

@@ -0,0 +1 @@
{"version":1,"resource":"vscode-remote://192.168.100.43:8443/home/coder/project/backend/app/models/vehicle.py","entries":[{"id":"roVG.py","timestamp":1769025580452},{"id":"6EB5.py","timestamp":1769038049778}]}

View File

@@ -0,0 +1,53 @@
from datetime import datetime
from sqlalchemy import Column, Integer, String, Boolean, ForeignKey, DateTime, Date
from sqlalchemy.orm import relationship
from app.db.base import Base
class VehicleModel(Base):
"""Reference table for Make/Model (e.g., Toyota Corolla)"""
__tablename__ = "vehicle_models"
__table_args__ = {"schema": "ref"}
id = Column(Integer, primary_key=True, index=True)
make = Column(String, nullable=False)
model_name = Column(String, nullable=False)
category = Column(String) # sedan, truck, van
class Vehicle(Base):
"""The physical asset"""
__tablename__ = "vehicles"
__table_args__ = {"schema": "data"}
id = Column(Integer, primary_key=True, index=True)
model_id = Column(Integer, ForeignKey("ref.vehicle_models.id"))
vin = Column(String, unique=True, index=True, nullable=False)
license_plate = Column(String, unique=True, index=True, nullable=False)
production_year = Column(Integer)
status = Column(String, default="active") # active, maintenance, sold
created_at = Column(DateTime, default=datetime.utcnow)
# Relationships
history = relationship("VehicleHistory", back_populates="vehicle")
class VehicleHistory(Base):
"""
Defines who is driving what and when.
CRITICAL: This is the source of truth for 'Can User X see Vehicle Y?'
"""
__tablename__ = "vehicle_history"
__table_args__ = {"schema": "data"}
id = Column(Integer, primary_key=True, index=True)
vehicle_id = Column(Integer, ForeignKey("data.vehicles.id"), nullable=False)
user_id = Column(Integer, ForeignKey("data.users.id"), nullable=False)
role = Column(String, nullable=False) # owner, driver, fleet_manager
start_date = Column(Date, nullable=False)
end_date = Column(Date, nullable=True) # If NULL, the assignment is current
is_active = Column(Boolean, default=True)
vehicle = relationship("Vehicle", back_populates="history")