32 lines
885 B
Python
32 lines
885 B
Python
|
|
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 {
|
||
|
|
"id": row[0],
|
||
|
|
"name": row[1] or "",
|
||
|
|
"event_type": row[2] or "",
|
||
|
|
"occurred_time": row[3],
|
||
|
|
"condition": row[4] if isinstance(row[4], dict) else {},
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
qgis_repository = QgisRepository()
|