Qeasy Cloud
Get Started

Production Material Requisition Return Sync Strategy: Pushing Status from Kingdee Cosmic to MySQL MES

· 吕修远· Integration Solutions· 21 views· 5 min read

What This Strategy Solves (Scenario & Value)

In supply-chain integration, the production material requisition is usually a two-way loop: MES initiates → ERP receives and approves → MES receives the receipt. After the MES pushes the requisition into Kingdee Cosmic, the shop floor needs to know whether Kingdee approved it and what formal ERP document number was generated before it can continue issuing materials, reporting labor, and closing books.

So the core of this strategy is not "push the requisition again," but a return-write: feeding Kingdee Cosmic's processing result (document number, success flag, error message) back into the MySQL requisition interface table. We use the Qeasy Data Integration Platform to host this "return action"—essentially a high-frequency, lightweight callback channel.

Data Flow and Field Mapping

The whole link breaks into two steps:

Step 1: Trigger Query (Kingdee Cosmic → Qeasy) The source side hooks into Kingdee Cosmic, using a Request Empty Operation (POST, QUERY) to pull back the processed requisition results. There are only 5 fields in the response, but each is critical:

FieldTypeMeaning
sourceidintPrimary key of the MES interface table, locating which row to update
Production Order No.stringLinked to the work order on the MES side
is_sucessstringWhether Kingdee approved it (note the spelling)
result_messagestringError or success description
Document No.stringDocument number generated by Kingdee

Step 2: Landing the Write-back (Qeasy → MySQL) The target is two UPDATE SQL statements on MySQL: a main one that updates the interface table (hme_wo_material_sum_iface), and an extended one that uses LEFT JOIN to sync the document number onto the input-record table (hme_wo_input_record) via extension fields.

Key field mapping:

Source Field (Kingdee Response)Target SQL Bind VariableLanding Point
sourceid:sourceidInterface table WHERE clause
is_sucess:is_successInterface table status
result_message:messageInterface table message
Document No.:NumberInterface table attribute9 / Input record attribute14
(System generated):Id / :timeInterface table attribute8 / attribute10

There is one design detail: both Number and Id are written to both the interface table and the input record table, so shop-floor users can see the Kingdee document number on either table without cross-table queries.

How to Configure It on Qeasy

On Qeasy, this strategy can be built as two adjacent strategy nodes:

Source Strategy (QUERY side): Pick Request Empty Operation for the API, set effect to QUERY, method POST. Model all 5 response fields as listed above, keep autoFillResponse on—this tells Qeasy "I don't need to pass parameters; just build the model based on Kingdee's response structure."

Target Strategy (EXECUTE side): Choose MySQL as the platform, type SQL, effect EXECUTE. Enable otherRequest and fill in both main_sql and extend_sql_1. Use object type for main_params, and keep the field names strictly aligned with the SQL bind variables (sourceid, is_success, message, Id, Number, time).

Field Mapping: One-to-one correspondence between the 5 source response fields and the target SQL bind variables. Production Order No. does not flow directly into SQL but stays in context for logging and troubleshooting.

Scheduling: Source crontab set to */7 * * * *, target */1 * * * *—this is the typical slow-source / fast-target pattern. The source pulls receipts from Kingdee every 7 minutes; the target lands them almost in real time, ensuring the MES side refreshes fast enough.

Implementation Steps

  1. Confirm the incremental starting point: In Kingdee Cosmic, filter requisitions that are "approved and already pushed from MES" as the first pull baseline. Qeasy's polling will naturally take only the increment based on sourceid.
  2. Trigger one full-volume run: At first go-live, manually trigger a full-volume return-write to verify both UPDATE statements run, especially the LEFT JOIN in the extended SQL—it's easy to end up with 0 updated rows due to empty fields.
  3. Lock down the schedule: Source every 7 minutes, target every minute. After go-live, observe for 24 hours to check Kingdee-side API pressure and MySQL-side update latency.
  4. Monitoring spot: On Qeasy, flag records where is_sucess = 'N' as a separate metric and read result_message directly for the failure reason, avoiding manual Kingdee log digging.
  5. Reconciliation mechanism: Run a daily early-morning reconciliation that counts "pushed by MES but not written back within 24 hours" records as a missed-record patrol.

Pitfalls and Lessons

Pitfall 1: Inconsistent field-name spelling. The source side has is_sucess (missing a 'c'), but the target bind variable is written as is_success. If you miss this in mapping, it ends up as null. The safe approach is to add a "field-name alias table" at the Qeasy mapping layer to centrally manage spelling drift.

Pitfall 2: WHERE conditions on the extended SQL. extend_sql_1 writes t4.attribute14 = '', meaning "only update input records that haven't yet been written with a document number." This condition is critical—remove it and every return run overwrites the existing document number, causing Kingdee-side numbers to be repeatedly overwritten.

Pitfall 3: Over-aggressive source scheduling. If the source is also set to once per minute, Kingdee Cosmic's approval API gets hammered. This time we set the source to 7 minutes, which doesn't hurt business perception but significantly reduces source-system pressure. This is the classic dual-track incremental and full-volume pattern: high frequency for incremental return-write, low frequency for compensation reconciliation.

Pitfall 4: sourceid not bound, table-wide update. One on-site accident: the target SQL forgot to bind :sourceid, leaving the UPDATE without a WHERE clause and almost overwriting the entire interface table. We later turned idCheck on explicitly as a hard pre-launch check.

Pitfall 5: Centralized encoding mapping management. Kingdee's "Document No." actually displays as a string on the MES side, but Kingdee sometimes returns it with a prefix (e.g., PRD-2024...). If the MES side doesn't strip the prefix, you get "matches the interface table but not the work order." We unified prefix stripping in a Qeasy script node rather than scattering it across every caller.

Applicable and Non-applicable Scenarios

Applicable: The "initiate—approve—receipt" loop between MES and ERP, especially state-machine-driven business documents (material requisition, material return, labor reporting, completion入库).

Not applicable: Businesses that need sub-second real-time feedback (such as barcode-scan write-back), because minute-level polling introduces noticeable latency. Also not suitable for one-off large-volume historical data migration—that should go through full-volume ETL, not callback-style return-write.

Original content. Please credit the source when reposting: https://www.qeasy.cloud/insights/solutions/strat-mysql-kingdee-cloud-2246-mom-scll-ee80d5ce

Comments