Qeasy Cloud
Get Started

WDT Goods Master Sync to MySQL: Incremental Pull + Main and Spec Tables Landing

· 高金凤· Integration Solutions· 26 views· 3 min read
MySQLWDT货品档案Incremental Sync供应链集成轻易云

What This Strategy Solves

The goods master is the foundation of supply-chain integration—downstream inventory, orders, purchasing, and pricing all depend on it. In one real engagement, a retail enterprise used WDT (Wangdiantong) as the front-end ERP and MySQL as the data warehouse. After three months the goods masters on the two sides could not be reconciled, and physical counts never matched the books. The sync strategy had not clearly addressed three things: the incremental starting point, the pagination cursor, and the relationship between the main table and the spec child table. Once we onboarded this on the Qeasy Data Integration Platform, the two sides aligned within a week using the approach below.

Data Flow and Field Mapping

The source is WDT QiMen, API wdt.goods.query, a POST QUERY call. The target is MySQL via the execute SQL action. The key field mapping is:

DimensionWDT (Source)MySQL Main Table jry_wdt_goodsMySQL Spec Child Table jry_wdt_goods_spec_list
Primary keygoods_idgoods_idspec_id (FK to goods_id)
Business numbergoods_nogoods_nospec_no
Namegoods_namegoods_namespec_name
Barcode––barcode
Pricing––retail_price, wholesale_price, member_price
Timestampsmodified, createdmodified, created, goods_created, goods_modifiedspec_created, spec_modified
Relationship–1N (extend_params_2 = spec_list)

The main table uses REPLACE INTO, and so does the spec child table. Both rely on goods_id and spec_id for natural deduplication, which gives us a solid idempotency guarantee.

How to Configure This on Qeasy

In Qeasy's Data Integration Strategy editor, configure a single strategy for the whole flow:

  1. Source configuration: Select WebAPI, enter wdt.goods.query as the API name, POST as the method. Bind the incremental window to start_time and end_time. Use the platform variable {{LAST_SYNC_TIME|datetime}} for the start, and {{CURRENT_TIME|datetime}} for the end. Default deleted to 0 so that only non-deleted goods are returned.
  2. Target configuration: Select MySQL with type SQL. main_params maps to the dynamic parameters of the main SQL, and extend_params_2 is set to spec_list. The platform automatically splits the 1:N relation, writing the main row first and then the spec child rows.
  3. Centralized encoding mapping: This is a common pattern among Qeasy customers—put all enumerations (units, categories, brands, etc.) into a platform-level mapping table, and reuse the same set across many strategies. Change once, apply everywhere, instead of letting each strategy maintain its own script.
  4. Auto-fill response: Enable autoFillResponse on the source side; the platform maps the returned array to target fields, eliminating the manual binding work.

Implementation Steps

  • Incremental starting point: Before the first run, create the two target tables in MySQL and initialize LAST_SYNC_TIME to 1970-01-01 00:00:00 for a full historical pull.
  • Full trigger: After the historical pull completes, advance LAST_SYNC_TIME to the moment the full run started. Subsequent runs use incremental mode.
  • Schedule frequency: Set the source crontab to */13 * * * *. Stagger the target by about 10 minutes with 3-59/13 * * * * to avoid read/write contention on the same table.
  • Page size: Push page_size toward the platform's upper limit to reduce HTTP round trips.
  • Header and detail phased write: The classic "header-then-detail phased" pattern shows up here as "main table first, spec child table second." Qeasy enforces this order via main_params → extend_params_2. If one main row fails, you do not lose the entire spec batch.

Pitfall Review

  1. start_time without timezone handling: WDT returns timestamps as strings. Passing them directly to MySQL can collapse to the year zero. A safe approach is to attach the |datetime converter in the platform variable so the value is normalized to yyyy-MM-dd HH:mm:ss.
  2. Hardcoding page_size to 100: A typical mistake is to start at 100, which triggers interface timeouts. A safer approach is to start at 40, validate end-to-end, and only then nudge to 80.
  3. Mistaking REPLACE INTO for INSERT: REPLACE performs a delete-then-insert, which changes auto-increment IDs and triggers cascading FK effects. Confirm that no downstream reports depend on stable auto-increment IDs.
  4. Memory blow-up after 1:N expansion: Goods with many specs can blow up memory if the full payload is expanded in one go. Qeasy expands by goods_id in batches by default—do not turn that off.
  5. LAST_SYNC_TIME not persisted: After each successful run, the platform writes the current end_time back to LAST_SYNC_TIME. If the run is interrupted and retried, verify that this variable has been persisted correctly; otherwise you will replay the same historical window.

Applicable and Non-applicable Scenarios

Applicable: WDT is the single source of truth for goods master, and a downstream MySQL mirror is needed for BI, labeling, or promotional systems, with goods volume at or below the hundred-thousand level. Not applicable: bi-directional sync, large semantic differences between fields (such as tax rates or unit-of-measure conventions) that require conversion rule editing, or scenarios where multiple sources of goods master need to be merged and deduplicated—those need a separate master-data governance strategy rather than a single sync.

Original content. Please credit the source when reposting: https://www.qeasy.cloud/insights/solutions/strat-mysql-wdt-5427-mysql-f42cfa43

Comments