feat(business): add staff queries and incremental sync
Add order_staff normalization, salesperson query templates, guarded read-only SQL fallback, and incremental Kingdee sync cursor handling. Add a user-level systemd timer manager for daily Kingdee business sync and document the new workflow. Validation: python3 -m unittest discover -v; python3 -m compileall obsidian_wiki tests scripts; git diff --check.
This commit is contained in:
@@ -333,13 +333,29 @@ obsidian-wiki business sync kingdee \
|
||||
--end-bizdate 2026-06-30 \
|
||||
--billstatus C
|
||||
|
||||
# Or fetch incrementally by Kingdee modify time.
|
||||
obsidian-wiki business sync kingdee --incremental
|
||||
|
||||
# Ask deterministic statistics questions.
|
||||
obsidian-wiki business query "2026年6月接了多少单"
|
||||
obsidian-wiki business query "2026-06 sales amount"
|
||||
obsidian-wiki business query "2026-06 top customer"
|
||||
obsidian-wiki business query "徐丽最近一周订单"
|
||||
obsidian-wiki business query "徐丽最近一周销售额" --all-staff
|
||||
obsidian-wiki business sql "SELECT COUNT(*) AS order_count FROM orders"
|
||||
```
|
||||
|
||||
V1 uses fixed templates for monthly order count, monthly sales amount, monthly top customers, and a customer trend query. The default order-count basis is distinct Kingdee sales order number by order date. Detailed order rows stay in SQLite; the wiki remains for business context, customer/project knowledge, and later summary pages when you choose to generate them. Real Kingdee credentials live in `.runtime/kingdee.env`, and fetched tokens are cached in `.runtime/kingdee-token.json`; both files are local-only and ignored by git.
|
||||
V1 uses fixed templates for monthly order count, monthly sales amount, monthly top customers, customer trend, and salesperson order list/count/amount queries. Salesperson queries default to the main Kingdee salesperson and can include secondary/follow-up roles with `--all-staff`. If no template fits, `business sql` and `business query --fallback-sql` allow guarded read-only SQL against structured tables only; raw JSON and write statements are blocked. Detailed order rows stay in SQLite; the wiki remains for business context, customer/project knowledge, and later summary pages when you choose to generate them. Real Kingdee credentials live in `.runtime/kingdee.env`, and fetched tokens are cached in `.runtime/kingdee-token.json`; both files are local-only and ignored by git.
|
||||
|
||||
For daily unattended sync on Linux:
|
||||
|
||||
```bash
|
||||
bash scripts/business_sync_service.sh start --vault /path/to/vault
|
||||
bash scripts/business_sync_service.sh run-now --vault /path/to/vault
|
||||
bash scripts/business_sync_service.sh status
|
||||
```
|
||||
|
||||
The timer runs as a user-level systemd timer, defaults to `07:10` daily, and uses `--incremental` with a 48-hour lookback window.
|
||||
|
||||
### Optional: Source File MCP Server
|
||||
|
||||
|
||||
Reference in New Issue
Block a user