Syncing MySQL Defective-Product Production Warehousing Orders to Kingdee Cloud Galaxy: A Single-Strategy Field Guide
What This Strategy Solves
On a discrete-manufacturing shop floor, defective-product warehousing documents often live in MES/WMS MySQL tables, while quality and finance teams need them in Kingdee Cloud Galaxy (金蝶云星空) as cost-bearing warehousing vouchers. In one real engagement, the quality manager complained, "We scrapped it, but it doesn't show up in Galaxy, so it can't go to the non-conforming stockroom." We used Qeasy (轻易云) to deliver a minimum-viable strategy that incrementally writes confirmed defective-production warehousing orders from MySQL into Kingdee Cloud Galaxy — solving the "does it exist?" question first, then refining cost accuracy.
Data Flow and Field Mapping (Source → Middle Layer → Target)
Data flows from the MySQL source through the Qeasy integration platform's middle layer and lands in Kingdee Cloud Galaxy's production warehousing order via the batchSave API. Key field mapping:
| Business meaning | MySQL source field (sample) | Middle-layer variable | Kingdee target field |
|---|---|---|---|
| Warehousing order no. | RKBLP_ + main task ID | 入库单号 | FBillNo |
| Document type | — | Constant SCRKD01_SYS | FBillType |
| Date | date(a.update_time) | 日期 | FDate |
| Production order no. | a.dispatch_prefix | 生产订单号 | Linked production order |
| Finished-good code | a.part_no | 成品编号 | Material code |
| Plan tracking no. | d.bom_no | 计划跟踪号 | Tracking no. |
| Warehousing qty | a.instock_numb | 入库数量 | Quantity |
| Labor hours (computed) | Subquery sum × qty / 3600 | 工时 | Custom field |
In the source SQL we use named placeholders like :created_at, :limit, :offset — this is Qeasy's standard convention for MySQL. Do not use ? in the SQL, because behaviour becomes inconsistent on heterogeneous databases.
How to Configure It in Qeasy
- Register data sources: Create a MySQL data source pointing to the business DB with a read-only account; create a Kingdee Cloud Galaxy data source using its open-platform authorization.
- Source API (SQL query): Paste the main SQL above into "Main Query Statement" and expose
limit/offsetas themain_paramsobject so Qeasy can inject named values when paginating. - Target API (
batchSave): Pull in Kingdee's standard "Production Warehousing Order"SaveAPI, mapping bill no., document type, orgs, owner, stock status, etc. EnableidCheckto avoid duplicate submissions. - Centralised code mapping: Material codes, orgs, owner types and other master data should live in Qeasy's "Master Data Mapping" table rather than being hard-coded in the strategy. This is a common pattern among Qeasy customers — when master data changes, only one place needs to be updated.
- Header / body in phases: This strategy only persists the header (bill no., date, orgs) first; line items go into a second strategy. When something breaks, it's much easier to locate.
Implementation Steps (Phased Scheduling)
- Phase 0 — One-shot full trigger. Manually trigger a full run in Qeasy to sync all historical records that already meet the filter (
confirm_status='20',is_success='1',is_success1 !='1',is_defect='1',matterial_type=4, material source2), establishing the baseline. - Phase 1 — Incremental start point. Record the maximum
update_timeafter the full run finishes and write it into Qeasy's "cursor variable." Subsequent SQL becomeswhere update_time > :created_at. - Phase 2 — Scheduling cadence. Source:
3-59/8 7-22 * * *(every 8 minutes during business hours); target:*/10 7-22 * * *(every 10 minutes during business hours). Source is faster than target — this is Qeasy's typical "incremental + full dual-track" rhythm: the source side fetches as quickly as possible, the target side commits steadily. - Phase 3 — Exception isolation. In Qeasy, route Kingdee's failures to a "retry queue" instead of rolling back the whole batch; flag documents where the header succeeded but the body failed.
Lessons from the Field
is_success1compared as a string. The column isvarcharin MySQL; forgetting quotes turns it into a numeric comparison, causing "it's actually non-conforming but the system treats it as conforming" to be missed. Always use string equality for status fields.- Subquery without
LIMIT 1. Whenmes_dispatch_record_processhas multiple rows perbom_uuid, omittingLIMIT 1raises "Subquery returns more than 1 row." - Cross-company code leakage. Hard-coding literals like
company_code='gdTY'in SQL breaks the moment another company goes live. In Qeasy, expose the company code as a named parameter and pass it from upstream. - Duplicate warehousing order numbers. The source main-task ID is numeric, but Kingdee's
FBillNois a string; after prefix concatenation, length may collide with existing codes. EnableidCheck=trueand bake the prefix into your naming convention. - Timezone drift.
update_timeis in the MySQL DB's timezone; Kingdee uses the business date, so cross-day records get dropped. Standardise on UTC+8 business date inside Qeasy before posting.
When to Use It (and When Not To)
Use when: MES/WMS MySQL tables already hold quality-decision results and you need to incrementally, steadily write defective-production warehousing orders into Kingdee Cloud Galaxy for cost posting in an on-premise deployment. Don't use when: you need real-time second-level sync, the source is a view without change logs, or the Kingdee side requires a complex approval workflow — in those cases, route through Kingdee's workflow engine rather than pushing directly from Qeasy.