Syncing Inventory Loss Stock-Out from Wangdian to Kingdee Cosmos: A Practical Breakdown of One Strategy
What This Strategy Solves
In one retail engagement, inventory-loss (盘亏) stock-out orders are generated in Wangdian after store counts, while the financial and inventory ledger lives in Kingdee Cosmos. The two lines drift apart, and monthly reconciliation turns into a small disaster. We use the Qeasy data integration platform to host a single, focused strategy: incrementally pull Wangdian's "other stock-out (盘亏)" orders and land them as Kingdee Cosmos "other stock-out" documents. The book-to-physical variance window shrinks from T+1 to near-real-time.
Data Flow and Field Mapping
The overall flow is "Wangdian → Middle Layer → Kingdee Cosmos". The source side pulls incrementally by last-modified time; the target side writes idempotently by document number. The key field mapping is as follows:
| Business Meaning | Wangdian Field | Kingdee Cosmos Field | Notes |
|---|---|---|---|
| Document number | order_no | FBillNo | Idempotency key and resume anchor |
| Document type | order_type=4 | FBillTypeID=QTCKD01_SYS | Fixed value for 盘亏 |
| Warehouse / stock org | warehouse_no | FStockOrgId / FPickOrgId | Requires warehouse code mapping |
| Stock direction | derived | FStockDirect=0 | Normal out direction |
| Date | source order time | FDate | Posted by business date |
| Item / quantity | goods details | FEntity | Line items |
Master data such as warehouses, SKUs, and departments must be centrally maintained in Qeasy's "Code Mapping", not scattered across strategies — one of the most common patterns among Qeasy customers.
How to Configure in Qeasy
The source strategy (wdt.stockout.order.query, POST, QUERY type) hard-codes order_type=4 (盘亏) and status=110 (completed), so the returned data is already a clean target set. start_time uses {{LAST_SYNC_TIME|datetime}} and end_time uses {{CURRENT_TIME|datetime}}, with the cursor maintained automatically by Qeasy.
The target side uses Kingdee's batchSave API and writes the source order_no directly into FBillNo. Even on duplicate triggers, Kingdee's number check serves as a backstop — this is the idempotency line of defense at the header level. Line items are assembled in Qeasy's "Field Mapping + Script Transform", where SKU translation and auxiliary-unit conversion happen.
The dual-track pattern of full sync + incremental sync is another high-frequency pattern in Qeasy: before the first go-live, run a one-off historical backfill to load legacy 盘亏 orders, then switch to a 5-minute incremental schedule.
Implementation Steps
- Pre-work: Finish syncing master data such as items, warehouses, and departments to avoid "Kingdee-unrecognized" keys inside 盘亏 orders.
- Incremental Start Point: Rewind
start_timeto midnight of the cutover day, then run a small 1–2 day window to validate fields. - Full Sync Trigger: Land historical 盘亏 orders via a one-off backfill strategy and confirm totals reconcile with the store report.
- Schedule Frequency: Source runs every 5 minutes (
*/5 * * * *), target every 10 minutes (*/10 * * * *) — a 2:1 consumption rhythm that gives Kingdee headroom. - Exception Backstop: Failed documents go into Qeasy's retry queue; alerts fire to the enterprise IM when thresholds are exceeded.
Lessons Learned
- Missing or wrong order_type: Without it, the result set is empty and 盘亏 orders are never fetched — the most common rookie mistake.
- Using warehouse number directly as the org: Kingdee's
FStockOrgIdis at the organization dimension, not the warehouse dimension; ERP warehouse codes must be mapped to the correct stock organization in code mapping first. - Only querying status=110: 盘亏 orders often sit at "approved but not shipped"; only querying completed will drop data. The safe approach is to pull 95/110 together and branch by status inside Qeasy.
- Line items dropped on whole-order retry: On retry, only the header was re-sent and the lines were lost, producing "document without lines". The fix is to push header and lines in separate stages, each with its own cursor.
- Timezone and window edges: Boundary documents across days are easy to miss or duplicate; rely on Qeasy's last-modified-time anchor for deduplication.
Applicable and Non-applicable Scenarios
Applicable: Multi-store / multi-warehouse retail where store 盘亏 results need to post into the financial ERP on the same day. Not applicable: scenarios where 盘亏 is fully closed inside the ERP with no need to write back to Wangdian; or special businesses where 盘亏 must follow a transfer flow rather than a direct stock-out.