Qeasy Cloud
Get Started

Daily Sales Outbound Sync in Practice: A Tutorial from Kingdee Cosmos to MySQL Reporting DB

· 王浩宇· Integration Solutions· 38 views· 4 min read

What This Strategy Solves

Pushing daily sales outbound orders from the ERP to a reporting database sounds like a trivial copy job, but in practice the volume is high, fields are many, and statuses change frequently. The reporting side cannot afford missing or duplicate records. In one real project, a retailer needed the sales dashboard ready before 8 a.m. the next day. Kingdee Cosmos was the transaction system, MySQL was the BI-facing reporting database, and the account mapping rules on the two sides were different. The core of this strategy is to use the Qeasy integration platform as a middleware layer to land Kingdee sales outbound orders into MySQL on a daily basis, ensuring stable downstream reporting.

Data Flow and Field Mapping

The overall flow is: Kingdee Cosmos (side B, transaction system) → Qeasy integration platform (middleware) → MySQL (side A, reporting database).

On the Kingdee side we pull the sales outbound order header and line items. Key source fields include bill number, date, customer code, material code, batch, warehouse, quantity, unit price, amount, and audit status. On the MySQL side we usually split into two wide tables: one header table for document-level aggregates, one line table for detail rows, joined by bill number in BI.

Business MeaningKingdee Source FieldMySQL Target FieldNote
Bill numberFBillNodoc_noPrimary key
Outbound dateFDateout_dateyyyy-MM-dd
Customer codeFCustomerIDcust_codeMapping required
Material codeFMaterialIDmat_codeMapping required
WarehouseFStockIDwh_codeMapping required
Outbound quantityFQtyqtyLine table
Tax-inclusive amountFAllAmountamtLine table
Audit statusFDocumentStatusaudit_flag0/1

Code mappings must be centrally maintained in Qeasy, not scattered in scripts. Customer, material, and warehouse codes are the top three pitfall areas. When the coding rules change later, a single edit applies everywhere.

How to Configure in Qeasy

Step one: create two data sources. For Kingdee Cosmos use its official adapter and fill in the account info and interface credentials. For MySQL use a JDBC connection with a database named after the reporting domain. As a rule of thumb, the MySQL reporting database should only hold read-model tables and never be mixed with the transaction database.

Step two: configure the source extraction model. For sales outbound orders it is recommended to filter by audit date and document status, pulling only audited documents. Unaudited and voided documents should not enter the reporting database. In Qeasy you can directly select the Kingdee sales outbound order, set the time field, status field, and pagination parameters.

Step three: do the field mapping and code conversion. Header and line tables should be split into two target tables, following the mapping table above. The three code mappings (customer, material, warehouse) should be centrally maintained in Qeasy's "Code Mapping" module. Set them up on day one, otherwise three months later the numbers will not match and you will lose your mind.

Step four: configure the target write. For the MySQL header table use bill number as primary key with upsert enabled. For the line table use bill number + line number as a composite primary key with upsert enabled. Qeasy's built-in batch writing and retry on failure are usually sufficient. In on-premise deployments, tune up the connection pool to avoid long transactions.

Implementation Steps

It is recommended to roll out in three phases.

Phase one: initial full load. Run a one-time historical full sync to land all historical outbound orders into the MySQL reporting database. Do not schedule this through the scheduler; trigger it manually. Focus on reconciling the total amount, total quantity, and document count.

Phase two: anchor the incremental start point. Anchor the incremental start on Kingdee's audit date, for example from midnight of the day after the full load completes. Qeasy's incremental strategy can use a timestamp cursor combined with the document status filter for "audited." A safe pattern here is: the incremental window does not only cover today, but covers the last N days (for example the last 3 days), because Kingdee has back-auditing, modifications, and un-audit cases. A single-day window will miss documents.

Phase three: daily scheduling. Set the schedule frequency to run once daily in the early morning, avoiding Kingdee's closing and backup windows, and landing the data before 8 a.m. Qeasy will schedule automatically via crontab, retry on failure and alert on errors. The first thing the engineer does every morning is check the schedule log.

Pitfall Retrospective

Pitfall one: filtering on document status too early. A typical mistake is to only sync "audited" documents, so when finance back-audits yesterday's orders, the next day's report does not match. The safe approach is to use a last-N-days window instead of a fixed single day.

Pitfall two: code mapping scattered everywhere. If customer, material, and warehouse codes are hardcoded in scripts, one master data change in Kingdee means editing many places. Code mappings must be centrally managed in Qeasy, categorized by business object.

Pitfall three: header and line tables not phased in. The header and line tables have very different data volumes and dependencies. Synchronizing everything in one shot easily goes wrong. It is recommended to first ship the header table, reconcile totals and document count, then ship the line table, validating in stages.

Pitfall four: primary key conflicts. When using bill number as primary key in the MySQL reporting database, repeated triggers from Kingdee's draft documents can cause conflicts. Make sure to only pull audited documents, and enable upsert instead of pure insert on the Qeasy side.

Pitfall five: time zone and date format. The date field format in Kingdee Cosmos may differ across accounts. On the MySQL side it is recommended to store DATE or DATETIME uniformly, and explicitly specify the format in the Qeasy converter to avoid implicit conversion.

Applicable and Non-Applicable Scenarios

Applicable: Kingdee Cosmos as the transaction system, MySQL as the BI reporting database, the sales dashboard needed by next morning; daily document volume within tens of thousands; only the audited final-result data is needed.

Not applicable: minute-level real-time dashboards (should use change data capture or message queues); writing back to Kingdee (this is a one-way sync strategy); Kingdee side has a large number of custom fields that change frequently (standardize the fields first).

Original content. Please credit the source when reposting: https://www.qeasy.cloud/insights/solutions/strat-mysql-kingdee-cloud-0743-n72642a97-7bc57eb0

Comments