refactor: centralize configuration management with type-safe schema
Major changes: - Add dataclass-based configuration schema with validation (config/schema.py) - Create centralized config loader and default values (config/defaults.py, config/loader.py) - Remove duplicate database_config.py, merge into unified structure - Consolidate browser settings into ERP config - Add batch_size parameter support to extractor Bug fixes: - Fix settings save error by updating config paths (browser.* → erp.*) - Fix batch_size not being applied in data extraction Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@ from typing import Callable, Optional
|
||||
class DiscreteMaterialPlanExtractor:
|
||||
"""离散备料计划维护数据提取器"""
|
||||
|
||||
def __init__(self, username, password, headless=False, verbose=True, progress_callback=None):
|
||||
def __init__(self, username, password, headless=False, verbose=True, batch_size=100):
|
||||
"""
|
||||
初始化提取器
|
||||
|
||||
@@ -23,13 +23,14 @@ class DiscreteMaterialPlanExtractor:
|
||||
password: 登录密码
|
||||
headless: 是否无头模式运行
|
||||
verbose: 是否打印详细日志
|
||||
progress_callback: 进度回调函数,接收 ProgressInfo 对象
|
||||
batch_size: 批次大小
|
||||
"""
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.headless = headless
|
||||
self.verbose = verbose
|
||||
self.progress_callback = progress_callback
|
||||
self.batch_size = batch_size
|
||||
self.progress_callback = None
|
||||
self.converter = ExcelConverter(verbose=verbose)
|
||||
|
||||
def _print(self, *args, **kwargs):
|
||||
@@ -302,9 +303,9 @@ class DiscreteMaterialPlanExtractor:
|
||||
# 按批次下载
|
||||
downloaded_files = []
|
||||
# 计算总批次数
|
||||
total_batches = sum(1 for _ in self.group_order_ids(order_ids, 100))
|
||||
total_batches = sum(1 for _ in self.group_order_ids(order_ids, self.batch_size))
|
||||
|
||||
for batch_index, order_ids_batch in enumerate(self.group_order_ids(order_ids, 100)):
|
||||
for batch_index, order_ids_batch in enumerate(self.group_order_ids(order_ids, self.batch_size)):
|
||||
self._print(f"\n=== 开始处理第 {batch_index + 1} 批,共 {len(order_ids_batch)} 个订单号 ===")
|
||||
|
||||
# 报告开始下载批次
|
||||
|
||||
Reference in New Issue
Block a user