2026-06-19 17:04:03 +08:00
|
|
|
from app.config.paths import get_logger
|
|
|
|
|
from app.utils.db_helper import db_helper
|
|
|
|
|
|
|
|
|
|
logger = get_logger("qgis")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QgisRepository:
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def query_inference_result(inference_id: int) -> dict:
|
|
|
|
|
"""根据 inferenceId 查询 xian_inference_result"""
|
|
|
|
|
sql = """
|
|
|
|
|
SELECT id, name, event_type, occurred_time, condition
|
|
|
|
|
FROM xian_inference_result
|
|
|
|
|
WHERE id = %s
|
|
|
|
|
"""
|
|
|
|
|
rows = db_helper.execute_query(sql, (inference_id,))
|
|
|
|
|
if not rows:
|
|
|
|
|
raise ValueError(f"推理结果不存在: id={inference_id}")
|
|
|
|
|
|
|
|
|
|
row = rows[0]
|
|
|
|
|
return {
|
2026-06-20 15:50:24 +08:00
|
|
|
"id": row["id"],
|
|
|
|
|
"name": row["name"] or "",
|
|
|
|
|
"event_type": row["event_type"] or "",
|
|
|
|
|
"occurred_time": row["occurred_time"],
|
|
|
|
|
"condition": row["condition"] if isinstance(row["condition"], dict) else {},
|
2026-06-19 17:04:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qgis_repository = QgisRepository()
|