refactor(service): 删除MQTT旧代码 + 修复边缘节点重复显示问题
**删除MQTT旧代码:** - 删除 mqtt_service.py(已废弃的空壳) - 从 config.py 删除 MQTTConfig 类和相关配置 - 从 schemas.py 删除 mqtt 字段 - 从 alert_service.py 删除 create_alert_from_mqtt 方法 - 告警上报已改为 HTTP + COS 方案,MQTT机制完全废弃 **修复边缘节点重复显示(方案A):** - 清理 edge_devices 表历史数据(删除 edge_device_001、edge_inference_device) - 禁用 DeviceService 的 handle_heartbeat 自动创建设备功能 - 边缘端未实现心跳机制,告警数从 alarm_event 表统计 - 运行时长、处理帧数字段设为 null(无心跳机制,不可用) - 添加 count_alarms_by_edge_node 方法统计边缘节点告警数 **影响范围:** - /admin-api/aiot/edge/device/page 接口返回数据调整 - /admin-api/aiot/edge/device/get 接口返回数据调整 - 确保不破坏现有功能(告警上报已改为HTTP)
This commit is contained in:
@@ -43,20 +43,6 @@ class AIModelConfig:
|
||||
api_key: str = ""
|
||||
|
||||
|
||||
@dataclass
|
||||
class MQTTConfig:
|
||||
"""MQTT 配置 (已废弃 - 告警上报已改为 HTTP + COS)"""
|
||||
broker_host: str = "localhost"
|
||||
broker_port: int = 1883
|
||||
client_id: str = "alert_platform"
|
||||
username: str = ""
|
||||
password: str = ""
|
||||
alert_topic: str = "edge/alert/#"
|
||||
heartbeat_topic: str = "edge/alert/heartbeat/#"
|
||||
qos: int = 1
|
||||
enabled: bool = False # 默认禁用
|
||||
|
||||
|
||||
@dataclass
|
||||
class RedisConfig:
|
||||
"""Redis 配置"""
|
||||
@@ -103,7 +89,6 @@ class Settings(BaseModel):
|
||||
cos: COSConfig = COSConfig()
|
||||
app: AppConfig = AppConfig()
|
||||
ai_model: AIModelConfig = AIModelConfig()
|
||||
mqtt: MQTTConfig = MQTTConfig()
|
||||
redis: RedisConfig = RedisConfig()
|
||||
camera_name: CameraNameConfig = CameraNameConfig()
|
||||
|
||||
@@ -137,17 +122,6 @@ def load_settings() -> Settings:
|
||||
endpoint=os.getenv("AI_MODEL_ENDPOINT", ""),
|
||||
api_key=os.getenv("AI_MODEL_API_KEY", ""),
|
||||
),
|
||||
mqtt=MQTTConfig(
|
||||
broker_host=os.getenv("MQTT_BROKER_HOST", "localhost"),
|
||||
broker_port=int(os.getenv("MQTT_BROKER_PORT", "1883")),
|
||||
client_id=os.getenv("MQTT_CLIENT_ID", "alert_platform"),
|
||||
username=os.getenv("MQTT_USERNAME", ""),
|
||||
password=os.getenv("MQTT_PASSWORD", ""),
|
||||
alert_topic=os.getenv("MQTT_ALERT_TOPIC", "edge/alert/#"),
|
||||
heartbeat_topic=os.getenv("MQTT_HEARTBEAT_TOPIC", "edge/alert/heartbeat/#"),
|
||||
qos=int(os.getenv("MQTT_QOS", "1")),
|
||||
enabled=os.getenv("MQTT_ENABLED", "false").lower() == "true",
|
||||
),
|
||||
redis=RedisConfig(
|
||||
host=os.getenv("REDIS_HOST", "localhost"),
|
||||
port=int(os.getenv("REDIS_PORT", "6379")),
|
||||
|
||||
Reference in New Issue
Block a user