Qeasy Cloud
Get Started

Inventory Sync from Wangdian Stock-In Orders to Kingdee Cloud: A Single-Strategy Walkthrough

· 冯潇· Integration Solutions· 7 views· 4 min read

What This Strategy Solves

Surplus stock-in (盘盈入库) is the type of document that tends to fail silently. When a physical count turns up more goods than the system expects, that surplus needs to flow into both the financial ledger and the inventory ledger. In one retail deployment we worked on, surplus entries existed only inside Wangdian, leaving Kingdee Cloud with no matching voucher — so the two systems never agreed at month-end.

This strategy does exactly one thing: pull Wangdian orders where order_type=4 on a last-modified-time incremental basis, and write them into Kingdee Cloud as "Other Stock-In" documents. We wired both ends through the Qeasy data-integration platform — the source call is wdt.stockin.order.query, the target write is Kingdee's batchSave. The pipeline is short, which is precisely why each step has to be airtight.

Data Flow and Field Mapping

The flow is one-way: Wangdian → Qeasy middle layer → Kingdee Cloud. The source side uses a start_time / end_time window, with order_type pinned to 4 and status pinned to 80 (completed). The target side maps the same fields into Kingdee's header and entity structures.

Below is the field mapping table that matters most for this strategy:

Business meaningWangdian source fieldKingdee target fieldNotes
Document numberorder_noFBillNoPass through for traceability; Kingdee can also auto-generate
Document typeDerived from order_typeFBillTypeIDFixed value QTRKD01_SYS (Other Stock-In)
Stock org / warehousewarehouse_noFStockOrgIdWarehouse-to-org mapping must be centralized
Stock directionDerived from businessFStockDirectSurplus is normal inbound; fixed 0
Stock-in datestockin_timeFDateWatch the time zone; format yyyy-MM-dd HH:mm:ss
Line itemsdetailsFEntity arrayEach row is expanded; material code is the key

Code mapping (warehouse → stock org, material code) is the single thing most likely to derail go-live. A common pattern on Qeasy deployments is to keep the mapping table in a dedicated dictionary strategy rather than hard-coding it on the main pipeline. When a warehouse or org changes, you edit it in one place.

How to Configure It in Qeasy

Source platform configuration:

  • Pick "Wangdian · QiQiMen" and the wdt.stockin.order.query interface.
  • Use {{LAST_SYNC_TIME|datetime}} for start_time and {{CURRENT_TIME|datetime}} for end_time so the window stays contiguous.
  • Hard-code order_type=4 and status=80. Never pull procurement or transfer-in by accident.
  • Do not pass warehouse_no if you want a single-warehouse pull. For multi-warehouse deployments, split into multiple strategy instances — the API does not accept a list.

Target platform configuration:

  • Pick "Kingdee Cloud" and the batchSave action (EXECUTE).
  • Fix FBillTypeID to QTRKD01_SYS.
  • Do not hard-code FStockOrgId. Use a lookup function to translate the source warehouse_no through the mapping table.
  • Expand the entity rows and write FMaterialId, FQty, FBatchNo, etc. line by line.

The "header-then-entity phased write" pattern on Qeasy is very useful here: persist the header first, capture Kingdee's returned id, then write the entity rows bound to that id. This avoids header/entity mismatch inside a single batchSave call.

Implementation Steps

We typically run a strategy like this in four phases:

  1. Initial full trigger: set start_time far enough back (e.g. three months before go-live) so all historical surplus entries are pulled in one go. Run it once, then immediately switch to incremental mode.
  2. Anchor the incremental start: lock LAST_SYNC_TIME to the end of the full run. All subsequent incremental windows start from here.
  3. Schedule cadence: run the source strategy at */5 * * * *. The target write goes to Kingdee's API, which is concurrency-limited, so we set it to */10 * * * * to avoid pile-ups inside the 5-minute window.
  4. Replay and reconciliation: rely on Qeasy's built-in retry; in addition, run an EOD reconciliation that compares the day's surplus numbers on both sides and dumps deltas into an exception table.

Pitfalls from the Field

Pitfall 1: start_time written as a literal string instead of a platform variable. A common mistake is to write 2024-01-01 00:00:00 directly. It looks fine until the server's time zone is not Asia/Shanghai — then the incremental window drifts. The robust approach is to always use {{LAST_SYNC_TIME|datetime}} so the platform computes it in a single canonical zone.

Pitfall 2: status=80 and order_type=4 must travel together. The interface contract requires the original order type whenever status filtering is used. Drop order_type and Wangdian returns all completed documents, which Kingdee will reject outright.

Pitfall 3: FMaterialId is sent without a mapping lookup. Surplus entries often carry material codes with SKU suffixes; passing them straight as Kingdee master keys returns 404. We require a separate material-master sync strategy to populate the mapping table first, so the inventory strategy only ever reads from it.

Pitfall 4: Kingdee's batchSave returns success but inventory does not move. This is a classic Kingdee behavior — a saved document is not an approved document. The Qeasy callback handler must re-check the status and call the approval interface when needed; otherwise the ledger has a document but the stock account does not move.

Pitfall 5: Cross-warehouse documents get merged. The Wangdian API only takes a single warehouse_no, but customers often try to pull everything in one call. The robust approach is to split into per-warehouse strategy instances and run them in parallel, instead of stuffing multiple warehouse codes into a single request.

When to Use It — and When Not To

Use it when you have a single warehouse or a small set of warehouses, surplus and other inbound volumes are modest, and the financial/inventory ledger must stay in sync with the WMS in near real time — typical of retail and warehouse-led operations. Do not use it when the warehouse footprint is large and distributed (prefer a master-data-plus-distributed-scheduler split), when the direction is Kingdee → Wangdian (a different strategy is required), or for other inventory variances such as stock-out (盘亏) or write-offs — those need their own dedicated strategies.

Original content. Please credit the source when reposting: https://www.qeasy.cloud/insights/solutions/strat-wdt-kingdee-cloud-2008-n55333177-baa73148

Comments