Refactor configuration management and remove deprecated files

- Consolidated database, file source, and field mapping configurations into dedicated modules under the `config` directory.
- Removed hardcoded database connection details from `migration.py` and replaced them with imports from the new configuration structure.
- Updated `ntfy_utils.py` and `run_incremental_sync.py` to utilize the new configuration imports for cleaner code and better maintainability.
- Deleted `update_config.py` as its contents have been integrated into the new configuration files.
- Added a new `settings.local.json` for managing permissions related to script execution.
- Enhanced the structure of the migration tasks and Excel configurations for better organization and clarity.
This commit is contained in:
Misaka_Company
2026-01-12 12:49:51 +08:00
parent ee14de0435
commit 83c90f0161
13 changed files with 501 additions and 365 deletions

115
config/app_settings.py Normal file
View File

@@ -0,0 +1,115 @@
# config/app_settings.py
# 应用设置配置
import os
# ================= 日志表配置 =================
# 从原 config.py 抽取
LOG_TABLE_CONFIG = {
'schema': 'dbo',
'table_name': 'TableChangeLog',
'col_log_id': 'LogID',
'col_table_name': 'TableName',
'col_record_id': 'RecordID',
'col_address': 'TableAddress',
'col_synced': 'Synced'
}
# ================= ntfy 配置 =================
# 从原 config.py 抽取
NTFY_CONFIG = {
'enabled': True,
'server_url': 'https://ntfy.server10086.icu',
'topic': 'bld',
'token': 'tk_eop5fs66acxtwxf6vlkiojhdvkgb0',
'priority': {
'error': 'high',
'critical': 'urgent'
}
}
# ================= 运行参数 =================
# 合并原 config.py 和 update_config.py 的配置
POLL_INTERVAL = 5 # 轮询间隔(秒)
BATCH_SIZE = 10000 # 批量处理大小
CACHE_DIR = os.path.join(os.getcwd(), "temp") # Excel 缓存目录
TEMP_DIR = os.path.join(os.getcwd(), "temp") # 临时目录(兼容 migration.py
# ================= 字段配置 =================
# 从原 update_config.py (sync_excel_to_sql.py) 抽取
EXECUTION_CARD_FIELDS = {
"合同年份": ("str", 10),
"总排号": ("str", 50),
"序号": ("int", None),
"订单号": ("str", 150),
"车间号": ("str", 20),
"销售内部号": ("str", 50),
"经办人": ("str", 20),
"签订日期": ("date", None),
"交货日期": ("date", None),
"客户名称": ("str", 200),
"产品名称": ("str", 200),
"客户型号": ("str", 200),
"选型型号": ("str", 200),
"量程": ("str", 150),
"数量": ("int", None),
"备注2": ("str", 500),
"备注1": ("str", 500),
"位号": ("str", 500),
"技术参数": ("str", 1000),
"车间": ("str", 200),
"工令号": ("str", 200),
"接单日期": ("date", None),
"新参数": ("str", 1000),
"基本型号": ("str", 200),
"公称外径": ("str", 200),
"安装代码": ("str", 200),
"设计形式": ("str", 200),
"技术安装代码": ("str", 200),
"隔膜类型": ("str", 200),
"标准": ("str", 100),
"隔膜大小": ("str", 200),
"隔膜材质": ("str", 200),
"膜片": ("str", 200),
"膜片材质": ("str", 200),
"CRM明细ID号": ("str", 200),
"成品物料编码": ("str", 200),
"工单号": ("str", 200),
"盘号": ("str", 200),
"编码": ("str", 200),
"型批名称": ("str", 200),
"型批型号": ("str", 200),
"开票名称": ("str", 200),
"开票型号": ("str", 200),
"上数据时间": ("date", None),
"生产代码1": ("str", 50),
"生产代码2": ("str", 50)
}
CONTRACT_DATA_FIELDS = {
"合同年份": ("str", 10),
"车间号": ("str", 20),
"工令号": ("str", 200),
"订单号": ("str", 150),
"客户名称": ("str", 200),
"产品型号": ("str", 200),
"量程": ("str", 150),
"数量": ("int", None),
"单价": ("int", None),
"ID": ("int", None),
"位号": ("str", 500)
}
CONTRACT_DATA_MAPPING = {
"合同年份": "合同年份",
"车间号": "车间号",
"工令号": "工令号",
"订单号": "订单号",
"客户名称": "客户名称",
"产品型号": "选型型号",
"量程": "量程",
"数量": "数量",
"单价": None,
"ID": None,
"位号": "位号"
}