|
|
@@ -93,13 +93,18 @@ def _build_record_view(record: RecognitionRecord, db: Session = None):
|
|
|
if db and display_labels:
|
|
|
try:
|
|
|
from models.scene import SecondScene, ThirdScene
|
|
|
+ from utils.label_translator import translate_scenes_for_query
|
|
|
|
|
|
for label in display_labels:
|
|
|
- # Find matching secondary scene
|
|
|
+ # Translate sub-secondary scene to secondary scene for database query
|
|
|
+ # e.g., "加油机" -> "加油设施_附属场地"
|
|
|
+ query_label = translate_scenes_for_query([label])[0] if label else label
|
|
|
+
|
|
|
+ # Find matching secondary scene using translated name
|
|
|
second_scene = (
|
|
|
db.query(SecondScene)
|
|
|
.filter(
|
|
|
- SecondScene.second_scene_name == label,
|
|
|
+ SecondScene.second_scene_name == query_label,
|
|
|
SecondScene.is_deleted == 0,
|
|
|
)
|
|
|
.first()
|
|
|
@@ -117,6 +122,7 @@ def _build_record_view(record: RecognitionRecord, db: Session = None):
|
|
|
)
|
|
|
|
|
|
if third_scene_records:
|
|
|
+ # Use original label as key for frontend matching
|
|
|
element_hazards[label] = [
|
|
|
ts.third_scene_name for ts in third_scene_records
|
|
|
]
|