From c91f1d74813603965a902ec9eb83bca55f4a24db Mon Sep 17 00:00:00 2001 From: root <13910913995@163.com> Date: Fri, 9 Jan 2026 18:36:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/main.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/backend/main.py b/backend/main.py index e92c7a17..982e8550 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1319,6 +1319,45 @@ class AppServer: self.logger.error(f'检查会话检测数据存在失败: {e}') return jsonify({'success': False, 'error': str(e)}), 500 + @self.app.route('/api/detection//get_data', methods=['GET']) + def get_session_detection_data(session_id: str): + try: + if not self.db_manager: + return jsonify({'success': False, 'error': '数据库管理器未初始化'}), 500 + + # 获取检测数据和视频数据 + session_data = self.db_manager.get_session_data(session_id) + if not session_data: + return jsonify({'success': False, 'error': '会话不存在'}), 404 + + result_data = [] + + # 处理检测数据 + if 'data' in session_data: + for item in session_data['data']: + item_copy = item.copy() + item_copy['type'] = 'data' + result_data.append(item_copy) + + # 处理视频数据 + if 'videos' in session_data: + for item in session_data['videos']: + item_copy = item.copy() + item_copy['type'] = 'video' + result_data.append(item_copy) + + # 按时间戳排序 + result_data.sort(key=lambda x: x.get('timestamp', ''), reverse=False) + + return jsonify({ + 'success': True, + 'session_id': session_id, + 'data': result_data + }) + except Exception as e: + self.logger.error(f'获取会话检测数据失败: {e}') + return jsonify({'success': False, 'error': str(e)}), 500 + @self.app.route('/api/detection//stop', methods=['POST']) def stop_detection(session_id): """停止检测"""