From 5fb58a6f7b58d64c3c9c60cfcac028c6bf58351a Mon Sep 17 00:00:00 2001 From: root <13910913995@163.com> Date: Thu, 11 Dec 2025 12:04:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/Log/OrbbecSDK.log.txt | Bin 18731 -> 22147 bytes backend/config.ini | 6 +++--- backend/database.py | 11 +++++++---- backend/devices/screen_recorder.py | 9 +++++---- backend/main.py | 5 +++-- frontend/src/renderer/main/preload.js | 8 ++------ frontend/src/renderer/src/views/Detection.vue | 4 ++-- 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/backend/Log/OrbbecSDK.log.txt b/backend/Log/OrbbecSDK.log.txt index 8512bbae1fca351a19aec33b00170ac1c771f8a8..cdf03d3a13bb79c275635ca9f451c5c11a80f3b3 100644 GIT binary patch delta 1409 zcmZXU&1zIZ5QT{e0XKqZMq|{BphJj|ba!=kbx$DVsteue!cB%j5P!%4Mm(0POL349X4>bZYaJ^PPyPMv%D{`k6b{&VH>@r!hMXKkqUP^&Tcv4uTw7+jc6 z-o1bO<>PdsO#qYT>u>H$D7ff3lwNJ=0*MN>K)!DsZ%dV^m6}dYK7IJyI?b*ohY;wvu0~2UNZ;0q;NB`H+!omUXh-^406|fv zKd^sK_*rnSs9=zW&mWeQU#4E(*eObgI*6H&;n6yU;*O}aqB^?^iJ2X=jpNv;Js*O% zeQ*<^QF*qlP79&#XON*(?bB`-^Y0MoN3cLnpB|S;Zn92OJF(feG9jPE8JcZ-dc#CI ztLw2AdT`i&|Biu@VZ&WOXq_|t+G-&hu5inc?~88SRu3iQW3=*mmDp};J5=E5NjA@| zR-)bVju4fLl1abJlLGOY{vo`g>dMVLT$u?KF4R delta 9 QcmZo(%eZ bool: + def update_session_report_path(self, session_id: str, report_path: str, data_ids: str) -> bool: """更新检测会话的报告路径并将状态置为 reported""" conn = self.get_connection() cursor = conn.cursor() try: cursor.execute( - 'UPDATE detection_sessions SET detection_report = ?, status = COALESCE(status, "reported") WHERE id = ?', - (report_path, session_id) + 'UPDATE detection_sessions SET detection_report = ?, data_ids = ?, status = COALESCE(status, "reported") WHERE id = ?', + (report_path, data_ids, session_id) ) conn.commit() return cursor.rowcount > 0 diff --git a/backend/devices/screen_recorder.py b/backend/devices/screen_recorder.py index bc7eb6c9..0483a68c 100644 --- a/backend/devices/screen_recorder.py +++ b/backend/devices/screen_recorder.py @@ -881,6 +881,7 @@ class RecordingManager: data = { 'session_id': session_id, 'head_pose': detection_data.get('head_pose'), + 'screen_location': detection_data.get('screen_location'), 'body_pose': None, 'body_image': None, 'foot_data': detection_data.get('foot_data'), @@ -927,7 +928,7 @@ class RecordingManager: except Exception as e: self.logger.error(f'保存{field}失败: {e}') # 屏幕截图 - screen_image = self._capture_screen_image(data_dir,timestamp) + screen_image = self._capture_screen_image(data_dir, data.get('screen_location'), timestamp=timestamp) if screen_image: data['screen_image'] = str(os.path.join( patient_id, session_id, f"image_{timestamp}", screen_image)) @@ -940,7 +941,7 @@ class RecordingManager: - def _capture_screen_image(self, data_dir,timestamp) -> Optional[str]: + def _capture_screen_image(self, data_dir, screen_location, timestamp) -> Optional[str]: """ 采集屏幕截图,根据screen_region 进行截图 @@ -952,9 +953,9 @@ class RecordingManager: """ try: # 截取屏幕 - if self.screen_region: + if screen_location: # 使用指定区域截图 - x, y, width, height = self.screen_region + x, y, width, height = screen_location screenshot = pyautogui.screenshot(region=(x, y, width, height)) else: # 全屏截图 diff --git a/backend/main.py b/backend/main.py index 663d4906..d39ce6e0 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1452,6 +1452,7 @@ class AppServer: if not self.db_manager: return jsonify({'success': False, 'error': '数据库管理器未初始化'}), 500 file = flask_request.files.get('file') + data_ids = flask_request.form.get('data_ids') if not file: return jsonify({'success': False, 'error': '缺少文件'}), 400 # 获取会话信息以得到 patient_id @@ -1484,7 +1485,7 @@ class AppServer: # 生成相对路径存入数据库 rel_path = os.path.join(db_base_path, filename).replace('\\', '/') - self.db_manager.update_session_report_path(session_id, rel_path) + self.db_manager.update_session_report_path(session_id, rel_path,data_ids) return jsonify({'success': True, 'path': rel_path}) except Exception as e: self.logger.error(f'上传报告失败: {e}') @@ -1568,7 +1569,7 @@ class AppServer: # 调用录制管理器保存检测截图到文件 collected_data = self.recording_manager.save_detection_images( session_id=session_id, - patient_id=patient_id, + patient_id=patient_id, detection_data=data ) diff --git a/frontend/src/renderer/main/preload.js b/frontend/src/renderer/main/preload.js index 222465b0..bb9679a1 100644 --- a/frontend/src/renderer/main/preload.js +++ b/frontend/src/renderer/main/preload.js @@ -1,11 +1,7 @@ -const { contextBridge } = require('electron'); +const { contextBridge, ipcRenderer } = require('electron'); contextBridge.exposeInMainWorld('electronAPI', { - generateReportPdf: (payload) => { - try { - return window?.electron?.ipcRenderer?.invoke('generate-report-pdf', payload) - } catch {} - }, + generateReportPdf: (payload) => ipcRenderer.invoke('generate-report-pdf', payload), getBackendUrl: () => process.env.BACKEND_URL || 'http://localhost:5000', getSocketTransports: () => { const allowPolling = process.env.ALLOW_POLLING === '1' diff --git a/frontend/src/renderer/src/views/Detection.vue b/frontend/src/renderer/src/views/Detection.vue index 1ab2c1de..2f8da51d 100644 --- a/frontend/src/renderer/src/views/Detection.vue +++ b/frontend/src/renderer/src/views/Detection.vue @@ -133,7 +133,7 @@ {{ headlist.rotation }}°
- +
@@ -1623,7 +1623,7 @@ async function saveDetectionData() { session_id: patientInfo.value.sessionId, patient_id: patientInfo.value.id, - + screen_location:screen_location, head_pose:head_pose, body_pose:null, body_image: body_image,