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

26 lines
1.4 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/README_SQL_TEMPLATES.md')
text = p.read_text(encoding='utf-8')
text = text.replace(
'- 用途:按 SKU/SPU/关键词查询产品基础信息(成本、材质、预览图地址)',
'- 用途:按 SKU/SPU/关键词查询产品基础信息 + 库存与缺货预警(成本、材质、预览图、库存、发货件数、预计缺货天数)'
)
if '- 结果集9:最近N天每日总发货件数(按SKU)' not in text:
text = text.replace(
' - 结果集8:最近N天售后原因TOP(含来源)\n',
' - 结果集8:最近N天售后原因TOP(含来源)\n'
' - 结果集9:最近N天每日总发货件数(按SKU)\n'
' - 结果集10:库存风险预估(当前库存/日均发货/预计缺货天数/补货建议,补货安全线=10天)\n'
)
if '15. `sku_stock_risk_report.sql`' not in text:
insert = '''
15. `sku_stock_risk_report.sql`
- 用途:按 SKU 编码查询库存、近30天日均发货件数、预计缺货天数、补货建议(安全线10天)
- 默认时间:最近30天(模板顶部可改 `@lookback_days`)
- 参数:修改模板顶部 `@sku` 即可
'''
text = text.replace('14. `customer-service-analysis`(CLI辅助命令)\n', '14. `customer-service-analysis`(CLI辅助命令)\n' + insert)
p.write_text(text, encoding='utf-8')
print('updated', p)