From c73d347e013a425a0a04deeb3206c7e52f96c98c Mon Sep 17 00:00:00 2001 From: risingLee <871066422@qq.com> Date: Wed, 11 Feb 2026 16:34:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E5=91=8A=E5=AF=B9=E2=88=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- report_generator.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/report_generator.py b/report_generator.py index d80f723..401cd0e 100644 --- a/report_generator.py +++ b/report_generator.py @@ -1916,6 +1916,28 @@ def render_report(template_path: Path, cfg: AppConfig, output_path: Path, experi logger.warning("Global parameter @%s not found", param_name) return result + # 检查数据完整性:检查脚本表格数据是否有空值 + def check_data_completeness(script_tables: Dict[str, Dict]) -> bool: + """检查脚本表格数据是否完整(无空值)""" + if not script_tables: + return False + + for table_spec in script_tables.values(): + cells = table_spec.get("cells") or table_spec.get("values") or [] + if not isinstance(cells, list): + continue + + # 检查所有单元格,如果发现空值则认为数据不完整 + for cell in cells: + if isinstance(cell, dict): + value = cell.get("value", "") + # 如果值为空字符串、None或只包含空白字符,认为数据不完整 + if not value or (isinstance(value, str) and value.strip() == ""): + logger.debug("发现空单元格: row=%s, col=%s", cell.get("row"), cell.get("col")) + return False + + return True + # 1) 文本替换(普通文本和数据库文本) text_map: Dict[str, str] = {} for k, ph in cfg.placeholders.items(): @@ -1937,6 +1959,14 @@ def render_report(template_path: Path, cfg: AppConfig, output_path: Path, experi text_map[key] = "" else: text_map[key] = "" + + # 添加数据完整性检查占位符:{isNormal} 或 {normalCheck} + # 数据完整:显示打钩符号 ☑,数据不完整:显示空框 ☐ + is_data_complete = check_data_completeness(script_tables) + text_map["isNormal"] = "☑" if is_data_complete else "☐" + text_map["normalCheck"] = "☑" if is_data_complete else "☐" + logger.info("数据完整性检查: %s (完整=%s)", "正常" if is_data_complete else "异常", is_data_complete) + _replace_texts_word(doc, constants, text_map) # 2) 表格渲染(按占位符 {tableX})