报告对√
parent
a83bde2ceb
commit
c73d347e01
|
|
@ -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})
|
||||
|
|
|
|||
Loading…
Reference in New Issue