获取数据

This commit is contained in:
root 2026-01-09 18:36:47 +08:00
parent a08f666306
commit c91f1d7481

View File

@ -1319,6 +1319,45 @@ class AppServer:
self.logger.error(f'检查会话检测数据存在失败: {e}')
return jsonify({'success': False, 'error': str(e)}), 500
@self.app.route('/api/detection/<session_id>/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/<session_id>/stop', methods=['POST'])
def stop_detection(session_id):
"""停止检测"""