certflow.config.models module

配置数据模型

使用 Pydantic 定义配置数据结构,提供类型验证和自动补全.

class RootConfig(*, app=<factory>, paths=<factory>, sales_plan=<factory>, certificate=<factory>, import_deduplication=<factory>, database=<factory>, logging=<factory>, ui=<factory>, color_mapping=<factory>, numbering=None, duplicate_check=None, unique_key=None, priority_rules=None, export=None, sales_plan_fill=None, field_fallbacks=None, field_fill_rules=None, sales_importer=None, qualified_list=None, import_mapping=None, export_debug=None, test_report=None, printer=None, environment=None, colors=None, image_backgrounds=None, field_templates=None, print_templates=None, vba_import=None, certificate_print=None, completed_orders_backfill=None, query_page=<factory>, sync=None, print=None, background=None, print_log_empty_markers=None, grouping=None, sorting=None, **extra_data)[源代码]

基类:BaseModel

根配置模型

所有配置的顶层容器,聚合所有子配置模块. 通过 extra='allow' 保留未建模的 YAML 节点,确保 _cfg() 能读取所有配置.

参数:
app

应用基础配置

Type:

certflow.config.models.AppConfig

paths

路径配置

Type:

certflow.config.models.PathsConfig

sales_plan

销售计划配置

Type:

certflow.config.models.SalesPlanConfig

certificate

合格证配置

Type:

certflow.config.models.CertificateConfig

import_deduplication

导入去重配置

Type:

certflow.config.models.ImportDeduplicationConfig

database

数据库配置

Type:

certflow.config.models.DatabaseConfig

logging

日志配置

Type:

certflow.config.models.LoggingConfig

ui

UI配置

Type:

certflow.config.models.UIConfig

color_mapping

颜色映射配置

Type:

certflow.config.models.ColorMappingConfig

numbering

编号规则配置(V2)

Type:

certflow.config.models.NumberingConfig | None

duplicate_check

重复检查配置(V2)

Type:

certflow.config.models.DuplicateCheckConfig | None

unique_key

唯一键配置(V2)

Type:

certflow.config.models.UniqueKeyConfig | None

priority_rules

优先级规则配置(V2)

Type:

certflow.config.models.PriorityRulesConfig | None

export

导出配置(V2)

Type:

certflow.config.models.ExportConfig | None

sales_plan_fill

销售计划填充配置(V2)

Type:

dict[str, Any] | None

field_fallbacks

字段回退链配置(V2)

Type:

dict[str, list[str]] | None

field_fill_rules

字段填充规则配置(V2)

Type:

dict[str, Any] | None

sales_importer

销售计划导入器配置(V2)

Type:

certflow.config.models.SalesImporterConfig | None

import_mapping

导入列映射配置(V2)

Type:

certflow.config.models.ImportMappingConfig | None

export_debug

导出调试配置(V2)

Type:

dict[str, Any] | None

test_report

试压报告配置(V2)

Type:

certflow.config.models.TestReportConfig | None

printer

打印机配置(V2)

Type:

certflow.config.models.PrinterConfig | None

environment

环境信息配置(V2)

Type:

certflow.config.models.EnvironmentConfig | None

colors

颜色常量配置(V2)

Type:

certflow.config.models.ColorsConfig | None

image_backgrounds

图片背景配置(V2)

Type:

certflow.config.models.ImageBackgroundsConfig | None

vba_import

VBA导入配置(V2)

Type:

certflow.config.models.VBAImportConfig | None

certificate_print

合格证打印配置(V2)

Type:

certflow.config.models.CertificatePrintConfig | None

model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

app: AppConfig
paths: PathsConfig
sales_plan: SalesPlanConfig
certificate: CertificateConfig
import_deduplication: ImportDeduplicationConfig
database: DatabaseConfig
logging: LoggingConfig
ui: UIConfig
color_mapping: ColorMappingConfig
numbering: NumberingConfig | None
duplicate_check: DuplicateCheckConfig | None
unique_key: UniqueKeyConfig | None
priority_rules: PriorityRulesConfig | None
export: ExportConfig | None
sales_plan_fill: dict[str, Any] | None
field_fallbacks: dict[str, list[str]] | None
field_fill_rules: dict[str, Any] | None
sales_importer: SalesImporterConfig | None
qualified_list: dict[str, Any] | None
import_mapping: ImportMappingConfig | None
export_debug: dict[str, Any] | None
test_report: TestReportConfig | None
printer: PrinterConfig | None
environment: EnvironmentConfig | None
colors: ColorsConfig | None
image_backgrounds: ImageBackgroundsConfig | None
field_templates: dict[str, Any] | None
print_templates: dict[str, Any] | None
vba_import: VBAImportConfig | None
certificate_print: CertificatePrintConfig | None
completed_orders_backfill: CompletedOrdersBackfillConfig | None
query_page: dict[str, Any]
sync: dict[str, Any] | None
print: dict[str, Any] | None
background: dict[str, Any] | None
print_log_empty_markers: dict[str, Any] | None
grouping: GroupingConfig | None
sorting: SortingConfig | None
classmethod validate_log_level(v)[源代码]

验证日志级别是否有效

参数:

v (LoggingConfig) -- 待验证的日志配置对象

返回:

验证通过的日志配置对象

返回类型:

LoggingConfig

抛出:

ValueError -- 当日志级别不在有效值范围内时抛出

class AppConfig(*, name='CertFlow', version='2.0.0', year=2026, organization='CertFlow Team', debug=False)[源代码]

基类:BaseModel

应用基础配置模型

定义应用程序的基本信息,包括名称、版本、组织等元数据.

参数:
name

应用程序名称,默认为"CertFlow"

Type:

str

version

应用程序版本号,默认为"2.0.0"

Type:

str

year

版权年份,默认为2026

Type:

int

organization

组织名称,默认为"CertFlow Team"

Type:

str

debug

是否启用调试模式,默认为False

Type:

bool

name: str
version: str
year: int
organization: str
debug: bool
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class PathsConfig(*, database=<factory>, temp=<factory>, logs='logs', resources='resources', templates=<factory>, sales_plan=None, qualified_list=None, nameplate_db=None, quality_cert=None, transfer_docs=None, backup=None, output=None, excel_layout=None, images=None)[源代码]

基类:BaseModel

路径配置集合模型

聚合所有文件路径相关的配置,包括数据库、临时文件、日志等路径.

参数:
database

数据库路径配置

Type:

certflow.config.models.DatabasePaths

temp

临时文件路径配置

Type:

certflow.config.models.TempPaths

logs

日志文件目录,默认为"logs"

Type:

str

resources

资源文件目录,默认为"resources"

Type:

str

templates

模板文件路径配置

Type:

certflow.config.models.TemplatePaths

sales_plan

销售计划文件路径映射(V2)

Type:

dict[str, str] | None

qualified_list

合格清单文件路径映射(V2)

Type:

dict[str, str] | None

nameplate_db

铭牌数据库路径映射(V2)

Type:

dict[str, str] | None

quality_cert

质量证书路径映射(V2)

Type:

dict[str, str] | None

transfer_docs

交接文档路径映射(V2)

Type:

dict[str, str] | None

backup

备份文件路径映射(V2)

Type:

dict[str, str] | None

output

输出文件路径映射(V2)

Type:

dict[str, str] | None

excel_layout

Excel布局配置(V2)

Type:

dict[str, Any] | None

images

图片文件路径映射(V2)

Type:

dict[str, str] | None

database: DatabasePaths
temp: TempPaths
logs: str
resources: str
templates: TemplatePaths
sales_plan: dict[str, str] | None
qualified_list: dict[str, str] | None
nameplate_db: dict[str, str] | None
quality_cert: dict[str, str] | None
transfer_docs: dict[str, str] | None
backup: dict[str, str] | None
output: dict[str, str] | None
excel_layout: dict[str, Any] | None
images: dict[str, str] | None
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class TemplatePaths(*, base='data/templates/', certificate_chinese='data/templates/中文合格证模板.xlsx', certificate_bilingual='data/templates/中英文合格证模板.xlsx', certificate_russian='', test_report_small='', test_report_medium='', quality_cert_file='')[源代码]

基类:BaseModel

模板路径配置模型

定义各类模板文件的存储路径.

参数:
  • base (str)

  • certificate_chinese (str)

  • certificate_bilingual (str)

  • certificate_russian (str)

  • test_report_small (str)

  • test_report_medium (str)

  • quality_cert_file (str)

base

模板文件根目录,默认为"data/templates/"

Type:

str

certificate_chinese

中文合格证模板路径

Type:

str

certificate_bilingual

中英文合格证模板路径

Type:

str

certificate_russian

俄文合格证模板路径

Type:

str

test_report_small

试压报告模板(少)路径

Type:

str

test_report_medium

试压报告模板(中)路径

Type:

str

quality_cert_file

质保书模板路径

Type:

str

base: str
certificate_chinese: str
certificate_bilingual: str
certificate_russian: str
test_report_small: str
test_report_medium: str
quality_cert_file: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class SalesPlanConfig(*, excel_config=<factory>, column_mapping=<factory>, header_detection=None, styled_import_columns=<factory>, header_row=2, data_start_row=3, required_fields=<factory>, valid_row_check=<factory>)[源代码]

基类:BaseModel

销售计划配置模型

定义销售计划Excel文件的解析规则,包括列映射、表头位置等.

参数:
excel_config

Excel 读取配置

Type:

certflow.config.models.ExcelReadConfig

column_mapping

列映射配置

Type:

certflow.config.models.ColumnMappingConfig

header_detection

表头自动检测配置

Type:

certflow.config.models.HeaderDetectionConfig | None

styled_import_columns

带格式导入时保留的列名列表

Type:

list[str]

header_row

表头所在行号(从1开始),默认为2

Type:

int

data_start_row

数据起始行号(从1开始),默认为3

Type:

int

required_fields

必填字段列表

Type:

list[str]

valid_row_check

有效行检查配置

Type:

certflow.config.models.ValidRowCheck

excel_config: ExcelReadConfig
column_mapping: ColumnMappingConfig
header_detection: HeaderDetectionConfig | None
styled_import_columns: list[str]
header_row: int
data_start_row: int
required_fields: list[str]
valid_row_check: ValidRowCheck
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ExcelReadConfig(*, sheet_name=0, header_row=1, skip_rows=None, use_cols=None)[源代码]

基类:BaseModel

Excel 读取配置模型

定义 Excel 文件读取时的基本参数.

参数:
  • sheet_name (str | int)

  • header_row (int)

  • skip_rows (int | None)

  • use_cols (str | None)

sheet_name

工作表索引或名称,默认为 0

Type:

str | int

header_row

表头行号(0-indexed),默认为 1

Type:

int

skip_rows

跳过的行数,None 表示不跳过

Type:

int | None

use_cols

使用的列范围,None 表示全部

Type:

str | None

sheet_name: str | int
header_row: int
skip_rows: int | None
use_cols: str | None
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class HeaderDetectionConfig(*, enabled=True, keywords=<factory>, max_rows=20)[源代码]

基类:BaseModel

表头自动检测配置模型

定义表头检测的启停和匹配规则.

参数:
enabled

是否启用表头自动检测

Type:

bool

keywords

用于匹配表头的关键词列表

Type:

list[str]

max_rows

最大扫描行数

Type:

int

enabled: bool
keywords: list[str]
max_rows: int
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class SuffixRule(*, field=None, keywords, suffix, exclude=None)[源代码]

基类:BaseModel

合格证后缀规则模型

根据关键词匹配规则生成证书编号后缀.

参数:
field

可选,指定匹配的字段名

Type:

str | None

keywords

触发该后缀的关键词列表

Type:

list[str]

suffix

匹配成功时使用的后缀字符串

Type:

str

exclude

可选,排除的关键词列表,匹配时不生成后缀

Type:

list[str] | None

field: str | None
keywords: list[str]
suffix: str
exclude: list[str] | None
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class CertificateConfig(*, prefix='CERT', date_format='%Y%m%d', format_template='{prefix}{date}{seq:04d}', suffix_rules=<factory>, defaults=<factory>)[源代码]

基类:BaseModel

合格证配置模型

定义合格证编号的生成规则.

参数:
prefix

证书编号前缀,默认为"CERT"

Type:

str

date_format

日期格式字符串,默认为"%Y%m%d"

Type:

str

format_template

编号格式模板,支持{prefix}、{date}、{seq}占位符

Type:

str

suffix_rules

后缀匹配规则列表

Type:

list[certflow.config.models.SuffixRule]

defaults

默认值字典

Type:

dict[str, Any]

prefix: str
date_format: str
format_template: str
suffix_rules: list[SuffixRule]
defaults: dict[str, Any]
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ImportDeduplicationConfig(*, strategy='skip', check_within_file=True, check_against_db=True, unique_key_fields=<factory>, update_on_duplicate=True, monitored_fields=<factory>, duplicate_handling=None, unique_key_generation=None, field_normalization=None)[源代码]

基类:BaseModel

导入去重配置模型

定义数据导入时的重复检测和处理策略.

参数:
strategy

去重策略,"skip"表示跳过重复项,"overwrite"表示覆盖

Type:

str

check_within_file

是否检查文件内重复,默认为True

Type:

bool

check_against_db

是否检查与数据库重复,默认为True

Type:

bool

unique_key_fields

用于判断唯一性的字段列表

Type:

list[str]

update_on_duplicate

重复时是否检测变更并更新,默认为True

Type:

bool

monitored_fields

监控变更的字段列表

Type:

list[str]

duplicate_handling

重复处理扩展配置(V2)

Type:

dict[str, Any] | None

unique_key_generation

唯一键生成配置(V2)

Type:

dict[str, Any] | None

field_normalization

字段规范化配置(V2)

Type:

dict[str, Any] | None

strategy: str
check_within_file: bool
check_against_db: bool
unique_key_fields: list[str]
update_on_duplicate: bool
monitored_fields: list[str]
duplicate_handling: dict[str, Any] | None
unique_key_generation: dict[str, Any] | None
field_normalization: dict[str, Any] | None
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class DatabaseConfig(*, type='sqlite', echo=False, pool_size=5, max_overflow=10)[源代码]

基类:BaseModel

数据库配置模型

定义数据库连接参数和行为.

参数:
type

数据库类型,默认为"sqlite"

Type:

str

echo

是否打印SQL语句日志,默认为False

Type:

bool

pool_size

数据库连接池大小,默认为5

Type:

int

max_overflow

连接池最大溢出连接数,默认为10

Type:

int

type: str
echo: bool
pool_size: int
max_overflow: int
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class LoggingConfig(*, level='INFO', file='logs/certflow.log', format='{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {name}:{function}:{line} - {message}', rotation='10 MB', retention='30 days', compression='zip', debug_modules=<factory>, **extra_data)[源代码]

基类:BaseModel

日志配置模型

定义日志输出格式、轮转策略等参数.

参数:
level

日志级别,可选值为DEBUG、INFO、WARNING、ERROR、CRITICAL

Type:

str

file

日志文件路径,默认为"logs/certflow.log"

Type:

str

format

日志格式字符串

Type:

str

rotation

日志文件轮转条件,如"10 MB"表示10MB轮转

Type:

str

retention

日志保留时间,如"30 days"表示保留30天

Type:

str

compression

日志压缩格式,默认为"zip"

Type:

str

debug_modules

DEBUG 黑名单列表,支持模块名或"模块名:函数名"格式

Type:

list[str]

model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

level: str
file: str
format: str
rotation: str
retention: str
compression: str
debug_modules: list[str]
class UIConfig(*, window=<factory>, table=<factory>, status_bar=<factory>, query_page=<factory>)[源代码]

基类:BaseModel

UI配置集合模型

聚合所有用户界面相关的配置.

参数:
  • window (WindowConfig)

  • table (TableConfig)

  • status_bar (StatusBarConfig)

  • query_page (dict)

window

窗口配置

Type:

certflow.config.models.WindowConfig

table

表格配置

Type:

certflow.config.models.TableConfig

status_bar

状态栏配置

Type:

certflow.config.models.StatusBarConfig

query_page

查询页面配置(视图模板、操作符、字段映射等)

Type:

dict

window: WindowConfig
table: TableConfig
status_bar: StatusBarConfig
query_page: dict
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ColorMappingConfig(*, status_colors=<factory>, priority_colors=<factory>, vba_colors=None, font_color_to_shipping=None, bg_color_to_status=None, theme_font_colors=None, font_colors=None, bg_colors=None)[源代码]

基类:BaseModel

颜色映射配置模型

定义状态和优先级到颜色的映射关系.

参数:
status_colors

状态到颜色的映射字典

Type:

dict[str, str]

priority_colors

优先级到颜色的映射字典

Type:

dict[str, str]

vba_colors

VBA颜色索引到颜色的映射(V2)

Type:

dict[int, str] | None

font_color_to_shipping

字体颜色到发货状态的映射(V2)

Type:

dict[int, str] | None

bg_color_to_status

背景颜色到状态的映射(V2)

Type:

dict[int, str] | None

theme_font_colors

THEME 字体颜色到状态的映射(V3)

Type:

dict[str, str] | None

font_colors

字体颜色 hex 字符串映射

Type:

dict[str, str] | None

bg_colors

背景颜色 hex 字符串映射

Type:

dict[str, str] | None

status_colors: dict[str, str]
priority_colors: dict[str, str]
vba_colors: dict[int, str] | None
font_color_to_shipping: dict[int, str] | None
bg_color_to_status: dict[int, str] | None
theme_font_colors: dict[str, str] | None
font_colors: dict[str, str] | None
bg_colors: dict[str, str] | None
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class NumberingConfig(*, prefix='V', format='{prefix}{year}{month}{seq:03d}{suffix}', suffixes=<factory>, auto_number_mode=None, suffix_rules=<factory>)[源代码]

基类:BaseModel

编号规则配置模型(V2新增)

定义V2版本的自动编号生成规则.

参数:
prefix

编号前缀,默认为"V"

Type:

str

format

编号格式模板

Type:

str

suffixes

后缀映射字典

Type:

dict[str, str]

auto_number_mode

自动编号模式配置

Type:

dict[str, Any] | None

suffix_rules

后缀规则列表

Type:

list[certflow.config.models.NumberingSuffixRule]

prefix: str
format: str
suffixes: dict[str, str]
auto_number_mode: dict[str, Any] | None
suffix_rules: list[NumberingSuffixRule]
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class NumberingSuffixRule(*, field=None, keywords=<factory>, suffix='', exclude=None)[源代码]

基类:BaseModel

编号后缀规则模型(V2新增)

根据字段值或关键词匹配规则生成编号后缀.

参数:
field

用于匹配的字段名

Type:

str | None

keywords

触发该后缀的关键词列表

Type:

list[str]

suffix

匹配成功时使用的后缀字符串

Type:

str

exclude

排除的关键词列表,匹配时不生成后缀

Type:

list[str] | None

field: str | None
keywords: list[str]
suffix: str
exclude: list[str] | None
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class DuplicateCheckConfig(*, fields=<factory>)[源代码]

基类:BaseModel

重复检查配置模型(V2新增)

定义数据重复检查的字段列表.

参数:

fields (list[str])

fields

用于重复检查的字段名列表

Type:

list[str]

fields: list[str]
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class UniqueKeyConfig(*, separator='|', date_to_serial=True, fields=<factory>, key_field_fallbacks=None)[源代码]

基类:BaseModel

唯一标识规则配置模型(V2新增)

定义唯一键的生成规则.

参数:
separator

字段值连接符,默认为"|"

Type:

str

date_to_serial

是否将日期转换为序列号,默认为True

Type:

bool

fields

构成唯一键的字段列表

Type:

list[certflow.config.models.UniqueKeyField]

key_field_fallbacks

唯一键字段的回退映射

Type:

dict[str, list[str]] | None

separator: str
date_to_serial: bool
fields: list[UniqueKeyField]
key_field_fallbacks: dict[str, list[str]] | None
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class UniqueKeyField(*, name, required=False)[源代码]

基类:BaseModel

唯一键字段模型(V2新增)

定义构成唯一键的字段及其约束.

参数:
name

字段名称

Type:

str

required

该字段是否为必填,默认为False

Type:

bool

name: str
required: bool
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class PriorityRulesConfig(*, high_threshold=10000, medium_threshold=5000, high_label='高', medium_label='中', low_label='低', high_color='#e74c3c', medium_color='#f39c12', low_color='#27ae60')[源代码]

基类:BaseModel

优先级规则配置模型(V2新增)

定义基于金额的优先级判定规则和颜色.

参数:
  • high_threshold (int)

  • medium_threshold (int)

  • high_label (str)

  • medium_label (str)

  • low_label (str)

  • high_color (str)

  • medium_color (str)

  • low_color (str)

high_threshold

高优先级阈值,金额大于此值为高优先级,默认为10000

Type:

int

medium_threshold

中优先级阈值,金额大于此值为中优先级,默认为5000

Type:

int

high_label

高优先级标签,默认为"高"

Type:

str

medium_label

中优先级标签,默认为"中"

Type:

str

low_label

低优先级标签,默认为"低"

Type:

str

high_color

高优先级颜色(十六进制),默认为"#e74c3c"

Type:

str

medium_color

中优先级颜色(十六进制),默认为"#f39c12"

Type:

str

low_color

低优先级颜色(十六进制),默认为"#27ae60"

Type:

str

high_threshold: int
medium_threshold: int
high_label: str
medium_label: str
low_label: str
high_color: str
medium_color: str
low_color: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ExportConfig(*, hyperlink_column=44, hyperlink_ref_prefix='AR', hyperlink_width=20, summary=None)[源代码]

基类:BaseModel

导出配置模型(V2新增)

定义数据导出的格式和行为.

参数:
  • hyperlink_column (int)

  • hyperlink_ref_prefix (str)

  • hyperlink_width (int)

  • summary (dict[str, Any] | None)

超链接所在列号(从1开始),默认为44

Type:

int

超链接引用前缀,默认为"AR"

Type:

str

超链接列宽度,默认为20字符

Type:

int

summary

汇总导出配置

Type:

dict[str, Any] | None

hyperlink_column: int
hyperlink_ref_prefix: str
hyperlink_width: int
summary: dict[str, Any] | None
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class SalesImporterConfig(*, field_mapping=<factory>, color_columns=None, selection_info_columns=None)[源代码]

基类:BaseModel

销售计划导入器配置模型(V2新增)

定义销售计划Excel导入的字段映射和颜色列配置.

参数:
field_mapping

字段映射字典,键为Excel列名,值为数据字段名

Type:

dict[str, str]

color_columns

颜色列配置

Type:

dict[str, Any] | None

selection_info_columns

选择信息列列表

Type:

list[str] | None

field_mapping: dict[str, str]
color_columns: dict[str, Any] | None
selection_info_columns: list[str] | None
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class VBAImportConfig(*, sales_plan_files=None, qualified_list=None, field_mapping=<factory>, color_mapping=None, duplicate_check_fields=None)[源代码]

基类:BaseModel

VBA导入逻辑配置模型(V2新增)

定义VBA导入功能的文件路径、字段映射和重复检查规则.

参数:
sales_plan_files

销售计划文件路径映射

Type:

dict[str, str] | None

qualified_list

合格清单文件路径映射

Type:

dict[str, str] | None

field_mapping

字段映射字典

Type:

dict[str, str]

color_mapping

颜色映射配置

Type:

dict[str, Any] | None

duplicate_check_fields

重复检查字段列表

Type:

list[str] | None

sales_plan_files: dict[str, str] | None
qualified_list: dict[str, str] | None
field_mapping: dict[str, str]
color_mapping: dict[str, Any] | None
duplicate_check_fields: list[str] | None
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class CertificatePrintConfig(*, printer=None, print_area=None, batch=None, paper=None, layout=None, font=None, print_fields=None, templates=None, numbering_modes=None)[源代码]

基类:BaseModel

合格证打印配置模型(V2新增)

定义合格证打印的打印机、打印区域、批处理等配置.

参数:
printer

打印机配置

Type:

dict[str, Any] | None

print_area

打印区域配置

Type:

dict[str, str] | None

batch

批处理配置

Type:

dict[str, Any] | None

paper

纸张尺寸配置 (width/height in mm)

Type:

dict[str, float] | None

layout

打印布局配置

Type:

certflow.config.models.PrintLayoutConfig | None

font

打印字体配置

Type:

certflow.config.models.PrintFontConfig | None

print_fields

打印字段列表

Type:

list[certflow.config.models.PrintFieldConfig] | None

templates

模板配置字典

Type:

dict[str, certflow.config.models.CertificatePrintTemplateConfig] | None

numbering_modes

编号模式映射

Type:

dict[str, int] | None

printer: dict[str, Any] | None
print_area: dict[str, str] | None
batch: dict[str, Any] | None
paper: dict[str, float] | None
layout: PrintLayoutConfig | None
font: PrintFontConfig | None
print_fields: list[PrintFieldConfig] | None
templates: dict[str, CertificatePrintTemplateConfig] | None
numbering_modes: dict[str, int] | None
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class CertificatePrintTemplateConfig(*, name='', style_code=1, picture_options=None, fields=<factory>)[源代码]

基类:BaseModel

合格证打印模板配置模型(V2新增)

定义完整打印模板的配置.

参数:
name

模板名称

Type:

str

style_code

样式代码,默认为1

Type:

int

picture_options

图片选项列表

Type:

list[str] | None

fields

模板字段列表

Type:

list[certflow.config.models.CertificatePrintTemplate]

name: str
style_code: int
picture_options: list[str] | None
fields: list[CertificatePrintTemplate]
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class CertificatePrintTemplate(*, excel_row, vba_col, field_name)[源代码]

基类:BaseModel

合格证打印模板字段模型(V2新增)

定义单个字段在打印模板中的位置映射.

参数:
  • excel_row (int)

  • vba_col (int)

  • field_name (str)

excel_row

在Excel中的行号

Type:

int

vba_col

在VBA中的列索引

Type:

int

field_name

字段名称

Type:

str

excel_row: int
vba_col: int
field_name: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class PrintLayoutConfig(*, label_x=3, value_x=20, start_y=22, line_spacing=6.5, font_size=9, x_offset=14, y_offset=0)[源代码]

基类:BaseModel

打印布局配置模型

定义打印坐标、偏移和字体大小.

参数:
label_x

标签 X 坐标

Type:

float

value_x

值 X 坐标

Type:

float

start_y

起始 Y 坐标

Type:

float

line_spacing

行间距

Type:

float

font_size

字体大小

Type:

float

x_offset

打印机物理偏移修正 (mm)

Type:

float

y_offset

打印机物理偏移修正 (mm)

Type:

float

label_x: float
value_x: float
start_y: float
line_spacing: float
font_size: float
x_offset: float
y_offset: float
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class PrintFontConfig(*, name='SimSun', weight=400)[源代码]

基类:BaseModel

打印字体配置模型

参数:
name

字体名称

Type:

str

weight

字体粗细

Type:

int

name: str
weight: int
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class PrintFieldConfig(*, label, key, offset=0)[源代码]

基类:BaseModel

打印字段配置模型

参数:
label

字段标签

Type:

str

key

字段键名

Type:

str

offset

偏移量

Type:

int

label: str
key: str
offset: int
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class TestReportConfig(*, company_name='', form_code='')[源代码]

基类:BaseModel

试压报告配置模型(V2新增)

定义试压报告的相关配置.

参数:
  • company_name (str)

  • form_code (str)

company_name

公司名称

Type:

str

form_code

表单代码

Type:

str

company_name: str
form_code: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class PrinterConfig(*, default='')[源代码]

基类:BaseModel

打印机配置模型(V2新增)

定义默认打印机设置.

参数:

default (str)

default

默认打印机名称

Type:

str

default: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class EnvironmentConfig(*, computer_name='${COMPUTERNAME:Unknown}', username='${USERNAME:Unknown}')[源代码]

基类:BaseModel

环境信息配置模型(V2新增)

定义运行时环境信息,支持环境变量替换.

参数:
  • computer_name (str)

  • username (str)

computer_name

计算机名称,支持${COMPUTERNAME:Unknown}语法

Type:

str

username

用户名,支持${USERNAME:Unknown}语法

Type:

str

computer_name: str
username: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ColorsConfig(*, yellow=65535, blue=16711680, red=255, green=65280, light_blue=15773696)[源代码]

基类:BaseModel

颜色常量值配置模型(V2新增)

定义VBA中使用的颜色常量值.

参数:
yellow

黄色的RGB整数值,默认为65535

Type:

int

blue

蓝色的RGB整数值,默认为16711680

Type:

int

red

红色的RGB整数值,默认为255

Type:

int

green

绿色的RGB整数值,默认为65280

Type:

int

light_blue

浅蓝色的RGB整数值,默认为15773696

Type:

int

yellow: int
blue: int
red: int
green: int
light_blue: int
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ImageBackgroundsConfig(*, chinese='', bilingual='', russian='')[源代码]

基类:BaseModel

图片背景配置模型(V2新增)

定义不同语言版本的证书背景图片路径.

参数:
  • chinese (str)

  • bilingual (str)

  • russian (str)

chinese

中文版背景图片路径

Type:

str

bilingual

中英文双语版背景图片路径

Type:

str

russian

俄文版背景图片路径

Type:

str

chinese: str
bilingual: str
russian: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ImportMappingConfig(*, preprocessor=None, column_mapping=None, default_values=None)[源代码]

基类:BaseModel

数据导入列映射配置模型(V2新增)

定义Excel导入时的预处理、列映射和默认值.

参数:
preprocessor

预处理器配置

Type:

dict[str, Any] | None

column_mapping

列映射规则列表

Type:

list[dict[str, Any]] | None

default_values

默认值映射

Type:

dict[str, str] | None

preprocessor: dict[str, Any] | None
column_mapping: list[dict[str, Any]] | None
default_values: dict[str, str] | None
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class GroupingConfig(*, group_keys=<factory>, group_keys_no_project=<factory>, numbering=<factory>)[源代码]

基类:BaseModel

分组配置(V3新增)

第一层分组:按业务键分组,生成组内序号

参数:
group_keys: list[str]
group_keys_no_project: list[str]
numbering: GroupingNumberingConfig
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class GroupingNumberingConfig(*, use_global_prefix=True, prefix_format='G{:03d}', seq_format='{:03d}', separator='-', full_seq_field='group_seq', group_index_field='_group_index', group_key_field='_group_key')[源代码]

基类:BaseModel

分组序号配置

参数:
  • use_global_prefix (bool)

  • prefix_format (str)

  • seq_format (str)

  • separator (str)

  • full_seq_field (str)

  • group_index_field (str)

  • group_key_field (str)

use_global_prefix: bool
prefix_format: str
seq_format: str
separator: str
full_seq_field: str
group_index_field: str
group_key_field: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class SortingConfig(*, keys=<factory>)[源代码]

基类:BaseModel

排序配置(V3新增)

第二层排序:组内按产品键排序

参数:

keys (list[SortingKey])

keys: list[SortingKey]
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class SortingKey(*, field, order='asc')[源代码]

基类:BaseModel

排序键配置(V3新增)

参数:
field: str
order: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class CompletedOrdersBackfillConfig(*, file_path='temp/excel/已完成工单【202601--202612】.xlsx', match_field='生产令号', source_field='供货类型', db_match_field='production_order_no', db_target_field='supply_type', overwrite_existing=False, backup_before_update=True, backup_suffix='_before_supply_type_backfill')[源代码]

基类:BaseModel

已完成工单回填配置模型

定义从"已完成工单"Excel的月份工作表中读取"供货类型"字段并回填到数据库的规则。 核心设计:

  • 只处理月份工作表(2026-01~2026-12)

  • 按字段名称(列标题)匹配,不依赖列号/列字母

  • 通过 production_order_no 匹配(同一生产令号所有记录回填相同值)

参数:
  • file_path (str)

  • match_field (str)

  • source_field (str)

  • db_match_field (str)

  • db_target_field (str)

  • overwrite_existing (bool)

  • backup_before_update (bool)

  • backup_suffix (str)

file_path: str
match_field: str
source_field: str
db_match_field: str
db_target_field: str
overwrite_existing: bool
backup_before_update: bool
backup_suffix: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].