feat(business): add Kingdee sales order API sync
Implement private Kingdee config generation, token login/refresh caching, paginated sales order fetching, official response-field normalization, and CLI filters for deterministic business fact sync. Update docs to keep credentials in .runtime and cover dry-run auth. Validation: python3 -m unittest discover -v; python3 -m compileall obsidian_wiki tests; git diff --check.
This commit is contained in:
@@ -127,8 +127,7 @@ Knowledge that's project-specific goes under `projects/<name>/`. Knowledge that'
|
||||
|---|---|---|
|
||||
| `OBSIDIAN_SOURCES_DIR` | Directories with docs to ingest (comma-separated) | *(empty — point agent at specific files)* |
|
||||
| `OBSIDIAN_BUSINESS_FACTS_DB` | Optional path for structured business facts such as Kingdee orders | `<vault>/_meta/business-facts.sqlite` |
|
||||
| `KINGDEE_API_URL` | JSON endpoint used by `obsidian-wiki business sync kingdee` when `--input` is omitted | *(unset)* |
|
||||
| `KINGDEE_API_TOKEN` | Bearer token for the Kingdee-compatible endpoint | *(unset)* |
|
||||
| `.runtime/kingdee.env` | Private local Kingdee sales-order API config created by `obsidian-wiki business config kingdee` | official sales-order URL, blank credentials |
|
||||
| `OBSIDIAN_CATEGORIES` | Wiki page categories | `concepts,entities,skills,references,synthesis,journal` |
|
||||
| `OBSIDIAN_MAX_PAGES_PER_INGEST` | Max pages updated per ingest | `15` |
|
||||
| `CLAUDE_HISTORY_PATH` | Where to find Claude data | *auto-discovers from `~/.claude`* |
|
||||
@@ -161,11 +160,23 @@ Use the business fact database for exact operational questions, for example mont
|
||||
|
||||
```bash
|
||||
obsidian-wiki business sync kingdee --input ./kingdee-orders.json
|
||||
|
||||
obsidian-wiki business config kingdee
|
||||
# Fill .runtime/kingdee.env, then test login/refresh without syncing orders:
|
||||
obsidian-wiki business sync kingdee --dry-run-auth
|
||||
|
||||
obsidian-wiki business sync kingdee \
|
||||
--start-bizdate 2026-06-01 \
|
||||
--end-bizdate 2026-06-30 \
|
||||
--billstatus C
|
||||
|
||||
obsidian-wiki business query "2026年6月接了多少单"
|
||||
obsidian-wiki business query "2026-06 sales amount"
|
||||
```
|
||||
|
||||
Without `--input`, the Kingdee sync command reads `KINGDEE_API_URL` and optional `KINGDEE_API_TOKEN`, then stores the fetched JSON response in `<vault>/_meta/business-facts.sqlite`. The answer reports the statistic, counting basis, data source, and last successful sync time. If the latest successful sync is before today, the answer warns that newer data may be missing.
|
||||
Without `--input`, the Kingdee sync command creates/reads `.runtime/kingdee.env`, obtains or refreshes an access token, calls the official sales order query API, then stores the fetched JSON response in `<vault>/_meta/business-facts.sqlite`. The private config supports configurable login/token URL, request body, response field paths, refresh URL/body, and required `x-acgw-identity`; fetched tokens are cached in `.runtime/kingdee-token.json`. `.runtime/` is ignored by git.
|
||||
|
||||
The answer reports the statistic, counting basis, data source, and last successful sync time. If the latest successful sync is before today, the answer warns that newer data may be missing.
|
||||
|
||||
## How It Works
|
||||
|
||||
|
||||
Reference in New Issue
Block a user