- 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.
74 lines
2.9 KiB
Python
74 lines
2.9 KiB
Python
# config/field_mappings.py
|
|
# 字段映射和清洗规则配置
|
|
|
|
import os
|
|
from config.app_settings import EXECUTION_CARD_FIELDS
|
|
|
|
# ================= 字段清洗规则 =================
|
|
# 从原 update_config.py 抽取
|
|
# 基于 NVARCHAR (按字符数计算长度)
|
|
TABLE_SCHEMA = {
|
|
"合同年份": {"type": "str", "max_len": 10},
|
|
"总排号": {"type": "str", "max_len": 50},
|
|
"序号": {"type": "int"},
|
|
"订单号": {"type": "str", "max_len": 150},
|
|
"车间号": {"type": "str", "max_len": 20},
|
|
"销售内部号": {"type": "str", "max_len": 50},
|
|
"经办人": {"type": "str", "max_len": 20},
|
|
"签订日期": {"type": "date"},
|
|
"交货日期": {"type": "date"},
|
|
"客户名称": {"type": "str", "max_len": 200},
|
|
"产品名称": {"type": "str", "max_len": 200},
|
|
"客户型号": {"type": "str", "max_len": 200},
|
|
"选型型号": {"type": "str", "max_len": 200},
|
|
"量程": {"type": "str", "max_len": 150},
|
|
"数量": {"type": "int"},
|
|
"备注2": {"type": "str", "max_len": 500},
|
|
"备注1": {"type": "str", "max_len": 500},
|
|
"位号": {"type": "str", "max_len": 500},
|
|
"技术参数": {"type": "str", "max_len": 1000},
|
|
"车间": {"type": "str", "max_len": 200},
|
|
"工令号": {"type": "str", "max_len": 200},
|
|
"接单日期": {"type": "date"},
|
|
"新参数": {"type": "str", "max_len": 1000},
|
|
"基本型号": {"type": "str", "max_len": 200},
|
|
"公称外径": {"type": "str", "max_len": 200},
|
|
"安装代码": {"type": "str", "max_len": 200},
|
|
"设计形式": {"type": "str", "max_len": 200},
|
|
"技术安装代码": {"type": "str", "max_len": 200},
|
|
"隔膜类型": {"type": "str", "max_len": 200},
|
|
"标准": {"type": "str", "max_len": 100},
|
|
"隔膜大小": {"type": "str", "max_len": 200},
|
|
"隔膜材质": {"type": "str", "max_len": 200},
|
|
"膜片": {"type": "str", "max_len": 200},
|
|
"膜片材质": {"type": "str", "max_len": 200},
|
|
"CRM明细ID号": {"type": "str", "max_len": 200},
|
|
"成品物料编码": {"type": "str", "max_len": 200},
|
|
"工单号": {"type": "str", "max_len": 200},
|
|
"盘号": {"type": "str", "max_len": 200},
|
|
"编码": {"type": "str", "max_len": 200},
|
|
"型批名称": {"type": "str", "max_len": 200},
|
|
"型批型号": {"type": "str", "max_len": 200},
|
|
"开票名称": {"type": "str", "max_len": 200},
|
|
"开票型号": {"type": "str", "max_len": 200},
|
|
"上数据时间": {"type": "date"},
|
|
"生产代码1": {"type": "str", "max_len": 50},
|
|
"生产代码2": {"type": "str", "max_len": 50}
|
|
}
|
|
|
|
# ================= 合同数据映射 =================
|
|
# 从原 update_config.py 抽取
|
|
CONTRACT_MAPPING = {
|
|
"合同年份": "合同年份",
|
|
"车间号": "车间号",
|
|
"工令号": "工令号",
|
|
"订单号": "订单号",
|
|
"客户名称": "客户名称",
|
|
"产品型号": "选型型号",
|
|
"量程": "量程",
|
|
"数量": "数量",
|
|
"单价": None,
|
|
"ID": None,
|
|
"位号": "位号"
|
|
}
|