dalongxia/update_company_db_tables.py
2026-03-04 13:25:48 +08:00

54 lines
2.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from pathlib import Path
p=Path('/root/.openclaw/workspace/sqlserver/company_db_tool.py')
text=p.read_text(encoding='utf-8')
old='''BUSINESS_TABLES = [
"jst_goods_profit_kpi_items_afs",
"jst_sku",
"fys_shopInfo",
"jst_order_express_details",
"fys_SkuDataLibrary_SpuConfig",
"op_operManage",
"op_TargetManagement",
"fys_Ticketing_install",
"fys_Ticketing_install_item",
"fys_jstFreightCost",
"fys_jstFreightCostDetail",
"pc_kfChatLog",
]
'''
new='''BUSINESS_TABLES = [
"jst_goods_profit_kpi_items_afs",
"jst_sku",
"fys_shopInfo",
"jst_order_express_details",
"fys_SkuDataLibrary_SpuConfig",
"op_operManage",
"op_TargetManagement",
"fys_Ticketing_install",
"fys_Ticketing_install_item",
"fys_jstFreightCost",
"fys_jstFreightCostDetail",
"pc_kfChatLog",
"jst_inventoryInfo",
"pm_InventoryMonitor",
"pm_stockMonitor",
"wp_stock",
"erp_wms_stockbiz",
]
'''
if old not in text:
raise SystemExit('target block not found')
text=text.replace(old,new,1)
# also update dimension row if exists
needle=''' ("时间维度", "创建时间、支付时间、发货时间、签收时间、订单完成时间", "全表通用时间字段(createdAt/createTime/pay_time/send_time 等)"),
("客服问题维度", "聊天主次原因、问题内容、订单关联", "pc_kfChatLog"),
'''
insert=''' ("时间维度", "创建时间、支付时间、发货时间、签收时间、订单完成时间", "全表通用时间字段(createdAt/createTime/pay_time/send_time 等)"),
("库存维度", "可用库存、锁定库存、在途库存、近7/30天发货均值、缺货预警", "jst_inventoryInfo, pm_InventoryMonitor, pm_stockMonitor, wp_stock, erp_wms_stockbiz"),
("客服问题维度", "聊天主次原因、问题内容、订单关联", "pc_kfChatLog"),
'''
if needle in text:
text=text.replace(needle,insert,1)
p.write_text(text,encoding='utf-8')
print('updated',p)