certflow.services.report_migration.report_fill_engine module¶
质保书系列报告的 xlsx 填充引擎(openpyxl,保格式 + 分页 + 以下空白)。
设计依据(提取自 VBA 模块 Mod_制作质保书在用.txt + 真实模板几何): - 单工作表内按「页」堆叠:每页 = 标题/表头(静态) + K 个产品行 + 材质段(每产品 p 行) + 落款(仅末页)。 - 行高/列宽/边框来自模板母行,原样保留 -> 打印按行高精准分页不偏。 - 末页数据不足 K 条时:首个空产品槽合并 A:C 写「以下空白」,其余空行纯留空(仅边框)。
材质段同理:首个空零件组写「以下空白」,后续空行清内容、复制格式。
分页:每页末行加 row_break;表头行(1:4)设 print_title_rows 重复。
模块泛型化:模板差异由 ZhiBaoShuSpec 描述,引擎本身不硬编码列号。 (独立于 certflow PySide GUI 包,便于无头环境测试与迁移工具复用。)
- class certflow.services.report_migration.report_fill_engine.ProductRecord(序号=0, 产品名称='', 产品型号='', 规格='', 数量='', 产品编号='', 试验标准='', 壳体压力='', 壳体时间='', 上密封压力='', 上密封时间='', 密封压力='', 密封时间='', 结果='合格', 适用温度='', 生产令号='', parts=None, 待核对明细=None)[源代码]¶
基类:
object一条产品记录(写入质保书产品行 + 驱动材质解析)。
字段与 VBA 产品行列映射一一对应;parts 为材质块主要零件列表。
- 参数:
- parts: list[MaterialPart] | None = None¶
- certflow.services.report_migration.report_fill_engine.copy_block_styles(src_ws, dst_ws, src_top, src_bottom, dst_top, ncols, src_left=1)[源代码]¶
把 [src_top..src_bottom] 行的样式(单元格样式+行高+合并) 整体偏移复制到 dst_top。
src_ws 为模板源(始终读模板母行),dst_ws 为输出表。
- class certflow.services.report_migration.report_fill_engine.ZhiBaoShuSpec(name: 'str', k: 'int', 单条行数: 'int', page_row_count: 'int', page_col_count: 'int', title_rows: 'tuple[int, int]'=(1, 4), product_start: 'int' = 5, material_header_rows: 'tuple[int, int]'=(11, 13), material_start: 'int' = 14, footer_rows: 'tuple[int, int]'=(27, 29), has_material: 'bool' = True, date_row: 'int' = 2, date_col: 'int' = 8, number_row: 'int' = 2, number_col: 'int' = 15, number_prefix: 'str' = 'C/1 编号:', report_code: 'str' = '9.1-13', date_label: 'str' = '日期:', date_fmt: 'str' = '%Y.%m.%d', product_row_span: 'int' = 1, product_block: 'bool' = True, caizhi: 'bool' = False, product_cols: 'dict[str, int]'=<factory>, product_merges: 'dict[str, tuple[int, int]]'=<factory>, material_cols: 'dict[str, int]'=<factory>)[源代码]¶
基类:
object- 参数:
name (str)
k (int)
单条行数 (int)
page_row_count (int)
page_col_count (int)
product_start (int)
material_start (int)
has_material (bool)
date_row (int)
date_col (int)
number_row (int)
number_col (int)
number_prefix (str)
report_code (str)
date_label (str)
date_fmt (str)
product_row_span (int)
product_block (bool)
caizhi (bool)
- class certflow.services.report_migration.report_fill_engine.ReportFillEngine(provider, material_annotation=False)[源代码]¶
基类:
object- 参数:
provider (MaterialProvider)
material_annotation (bool)