Add configuration and synchronization logic for Excel to SQL Server data processing
This commit is contained in:
154
update_config.py
Normal file
154
update_config.py
Normal file
@@ -0,0 +1,154 @@
|
||||
import os
|
||||
|
||||
# ================= 数据库配置 =================
|
||||
DB_CONFIG = {
|
||||
"server": "192.168.110.114",
|
||||
"database": "CompanyDB",
|
||||
"username": "peng",
|
||||
"password": "Cqbld123456.",
|
||||
"driver": "ODBC Driver 18 for SQL Server",
|
||||
"TrustServerCertificate": "yes"
|
||||
}
|
||||
|
||||
# ================= 全局配置 =================
|
||||
CACHE_DIR = os.path.join(os.getcwd(), "temp")
|
||||
BATCH_SIZE = 5000
|
||||
|
||||
# ================= 字段清洗规则 =================
|
||||
# 基于 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}
|
||||
}
|
||||
|
||||
CONTRACT_MAPPING = {
|
||||
"合同年份": "合同年份",
|
||||
"车间号": "车间号",
|
||||
"工令号": "工令号",
|
||||
"订单号": "订单号",
|
||||
"客户名称": "客户名称",
|
||||
"产品型号": "选型型号",
|
||||
"量程": "量程",
|
||||
"数量": "数量",
|
||||
"单价": None,
|
||||
"ID": None,
|
||||
"位号": "位号"
|
||||
}
|
||||
|
||||
EXCEL_CONFIGS = [
|
||||
{
|
||||
"file_path": r"\\192.168.110.113\生产执行卡\往年生产执行卡\生产执行卡2022.xlsm",
|
||||
"sheet_names": ["Sheet1"],
|
||||
"contract_year": "2022",
|
||||
"field_mapping": {
|
||||
"产品型号": "选型型号",
|
||||
"备注": "备注1",
|
||||
"下单日期": "接单日期"
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
"file_path": r"\\192.168.110.113\生产执行卡\往年生产执行卡\生产执行卡2023(1-5月).xlsm",
|
||||
"sheet_names": ["Sheet1"],
|
||||
"contract_year": "2023",
|
||||
"field_mapping": {
|
||||
"产品型号": "选型型号",
|
||||
"备注": "备注1",
|
||||
"下单日期": "接单日期"
|
||||
}
|
||||
},
|
||||
{
|
||||
"file_path": r"\\192.168.110.113\生产执行卡\往年生产执行卡\生产执行卡2023(6月-.xlsm",
|
||||
"sheet_names": ["Sheet1"],
|
||||
"contract_year": "2023",
|
||||
"field_mapping": {
|
||||
"产品型号": "选型型号",
|
||||
"备注": "备注1",
|
||||
"下单日期": "接单日期"
|
||||
}
|
||||
},
|
||||
{
|
||||
"file_path": r"\\192.168.110.113\生产执行卡\往年生产执行卡\生产执行卡2024 6月.xlsm",
|
||||
"sheet_names": ["重庆数据","北京数据"],
|
||||
"contract_year": "2024",
|
||||
"field_mapping": {
|
||||
"产品型号": "选型型号",
|
||||
"备注": "备注1",
|
||||
"下单日期": "接单日期"
|
||||
}
|
||||
},
|
||||
{
|
||||
"file_path": r"\\192.168.110.113\生产执行卡\往年生产执行卡\生产执行卡2024.xlsm",
|
||||
"sheet_names": ["重庆数据","北京数据"],
|
||||
"contract_year": "2024",
|
||||
"field_mapping": {
|
||||
"产品型号": "选型型号",
|
||||
"备注": "备注1",
|
||||
"下单日期": "接单日期"
|
||||
}
|
||||
},
|
||||
{
|
||||
"file_path": r"\\192.168.110.113\生产执行卡\生产执行卡2025年.xlsm",
|
||||
"sheet_names": ["重庆数据","北京数据"],
|
||||
"contract_year": "2025",
|
||||
"field_mapping": {
|
||||
"产品型号": "选型型号",
|
||||
"备注": "备注1",
|
||||
"下单日期": "接单日期"
|
||||
}
|
||||
},
|
||||
{
|
||||
"file_path": r"\\192.168.110.113\生产执行卡\生产执行卡2026年.xlsm",
|
||||
"sheet_names": ["重庆数据","北京数据"],
|
||||
"contract_year": "2026",
|
||||
"field_mapping": {
|
||||
"产品型号": "选型型号",
|
||||
"备注": "备注1",
|
||||
"下单日期": "接单日期"
|
||||
}
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user