合并代码
This commit is contained in:
parent
d5eeb77f4f
commit
74a20ea351
@ -19,7 +19,7 @@ path = D:/BodyCheck/file/
|
||||
|
||||
[CAMERA1]
|
||||
enabled = True
|
||||
device_index = 0
|
||||
device_index = 1
|
||||
width = 1280
|
||||
height = 720
|
||||
fps = 30
|
||||
@ -50,12 +50,12 @@ synchronized_images_only = False
|
||||
|
||||
[DEVICES]
|
||||
imu_enabled = True
|
||||
imu_device_type = mock
|
||||
imu_device_type = ble
|
||||
imu_port = COM9
|
||||
imu_mac_address = ef:3c:1a:0a:fe:02
|
||||
imu_baudrate = 9600
|
||||
pressure_enabled = True
|
||||
pressure_device_type = mock
|
||||
pressure_device_type = real
|
||||
pressure_use_mock = False
|
||||
pressure_port = COM5
|
||||
pressure_baudrate = 115200
|
||||
|
||||
@ -233,6 +233,7 @@ class DatabaseManager:
|
||||
remark_info TEXT, -- 备注信息
|
||||
detection_report TEXT, -- 生成检测报告的存储路径
|
||||
status TEXT DEFAULT 'checking', -- 会话状态(checking/checked/diagnosed/reported)
|
||||
data_ids TEXT, -- 关联的检测数据ID(逗号分隔)
|
||||
created_at TIMESTAMP, -- 记录创建时间
|
||||
FOREIGN KEY (patient_id) REFERENCES patients (id), -- 患者表外键约束
|
||||
FOREIGN KEY (creator_id) REFERENCES users (id) -- 用户表外键约束
|
||||
@ -764,7 +765,7 @@ class DatabaseManager:
|
||||
try:
|
||||
offset = (page - 1) * size
|
||||
cursor.execute('''
|
||||
SELECT s.id, s.status, s.start_time, u.name as creator_name,s.detection_report as detection_report
|
||||
SELECT s.id, s.status, s.start_time, u.name as creator_name,s.detection_report as detection_report,s.data_ids as data_ids
|
||||
FROM detection_sessions s
|
||||
LEFT JOIN users u ON s.creator_id = u.id
|
||||
WHERE s.patient_id = ?
|
||||
@ -785,6 +786,7 @@ class DatabaseManager:
|
||||
'start_time': r[2],
|
||||
'creator_name': r[3],
|
||||
'detection_report': r[4],
|
||||
'data_ids': r[5]
|
||||
}
|
||||
sessions.append({
|
||||
'id': item.get('id'),
|
||||
@ -792,6 +794,7 @@ class DatabaseManager:
|
||||
'start_time': item.get('start_time'),
|
||||
'creator_name': item.get('creator_name'),
|
||||
'detection_report': item.get('detection_report'),
|
||||
'data_ids': item.get('data_ids')
|
||||
})
|
||||
return sessions
|
||||
|
||||
@ -897,14 +900,14 @@ class DatabaseManager:
|
||||
except Exception as e:
|
||||
logger.error(f'获取会话数据失败: {e}')
|
||||
return None
|
||||
def update_session_report_path(self, session_id: str, report_path: str) -> 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
|
||||
|
||||
@ -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:
|
||||
# 全屏截图
|
||||
|
||||
@ -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}')
|
||||
|
||||
@ -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'
|
||||
|
||||
@ -133,7 +133,7 @@
|
||||
<span class="currencytext2">{{ headlist.rotation }}°</span>
|
||||
</div>
|
||||
<div style="width: 100%;height: 80%;">
|
||||
<Model :rotation="Number(headlist.rotation)" :tilt="Number(headlist.tilt)" :pitch="Number(headlist.pitch)" :gender="patientInfo.gender || '男'" />
|
||||
<Model :rotation="Number(headlist.rotation)" :tilt="Number(headlist.tilt)" :pitch="Number(headlist.pitch)*(-1)" :gender="patientInfo.gender || '男'" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user