diff --git a/README.md b/README.md index 3fa0ca2..c038208 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # HIS_Sur_Data_Deal -网页端检测数据处理工具。上传 `待处理检测数据.zip` 后,服务会自动识别 V1/V2 数据结构,调用原处理脚本生成 Excel,并在网页中展示结果摘要、工作表统计和数据预览;用户可调整每个工作表的预览行数,并按需导出单个 Excel 或全部 Excel 压缩包。 +网页端检测数据处理工具。上传 `待处理检测数据.zip` 后,服务会自动识别 V1/V2 数据结构,调用原处理脚本生成 Excel,并在网页中展示结果摘要、工作表统计和数据预览;用户可调整每个工作表的预览行数,并按需导出单个 Excel。 ## 本地运行 @@ -33,7 +33,7 @@ V2:zip 解压后包含 `Patients_info.csv`,并按患者目录分别保存检 患者编号类型可选择自动识别。自动识别会读取 `Patients_info.csv` 中的 `pat_no`,并与 `Tests_List` 文件名或患者目录名比对:若更匹配 10 位补零编号,则使用 `pat_no`;若更匹配原始编号,则使用 `zhuyuanhao`。 -导出的压缩包默认只包含 Excel 结果,不包含处理日志。系统默认输出完整结果;处理完成后可在结果页选择导出时是否保留: +系统默认输出完整结果;处理完成后可在结果页通过“内容选择”立即切换预览内容,并同步影响右侧“导出此 Excel”的文件内容。可选择是否保留: - 基本工作表 - 未匹配检测内容项 diff --git a/app/main.py b/app/main.py index 942f364..b5c66d0 100644 --- a/app/main.py +++ b/app/main.py @@ -111,14 +111,32 @@ async def process( @app.get("/result/{job_id}", response_class=HTMLResponse) -def result_page(job_id: str, preview_rows: int = Query(20, ge=5, le=200)) -> str: +def result_page( + job_id: str, + preview_rows: int = Query(20, ge=5, le=200), + include_basic_sheets: bool = Query(True), + include_unmatched_items: bool = Query(True), + include_summary_sheet: bool = Query(True), +) -> str: job_dir = _get_job_dir(job_id) try: rows = _clean_preview_rows(preview_rows) - result = summarize_job(job_dir, rows) + result = summarize_job( + job_dir, + rows, + include_basic_sheets=include_basic_sheets, + include_unmatched_items=include_unmatched_items, + include_summary_sheet=include_summary_sheet, + ) except ProcessingError as exc: raise HTTPException(status_code=404, detail=str(exc)) from exc - return _render_result(result, preview_rows=rows) + return _render_result( + result, + preview_rows=rows, + include_basic_sheets=include_basic_sheets, + include_unmatched_items=include_unmatched_items, + include_summary_sheet=include_summary_sheet, + ) @app.get("/download/all/{job_id}") @@ -185,7 +203,17 @@ def _clean_preview_rows(preview_rows: int) -> int: return max(5, min(int(preview_rows or 20), 200)) -def _render_result(result: ProcessingResult, preview_rows: int = 20) -> str: +def _checked(value: bool) -> str: + return "checked" if value else "" + + +def _render_result( + result: ProcessingResult, + preview_rows: int = 20, + include_basic_sheets: bool = True, + include_unmatched_items: bool = True, + include_summary_sheet: bool = True, +) -> str: total_sheets = sum(len(file.sheets) for file in result.files) total_rows = sum(max(sheet.rows - 1, 0) for file in result.files for sheet in file.sheets) file_items = "\n".join(_render_file(file, result.job_id) for file in result.files) @@ -197,15 +225,11 @@ def _render_result(result: ProcessingResult, preview_rows: int = 20) -> str: