Sales Order Interface Failure DingTalk Notification: A Practical Integration Solution with Qeasy
What This Strategy Solves
In a privately deployed retail/manufacturing environment, the sys_http_req_log table in MySQL continuously records every Kingdee sales order and forecast order interface attempt. When the interface fails, the business team's first need is not "the log is queryable" but "the responsible person knows immediately and can act on the suggested fix." We use the Qeasy Data Integration Platform to poll failed records row by row, classify them by business_type, assemble Markdown alert messages, and push them to DingTalk or the responsible person. The strategy also includes records that remain in an intermediate state for more than 10 minutes, to avoid missed alerts.
Data Flow and Field Mapping
The source is a MySQL query request (effect: QUERY), and the target is DingTalk's asyncsend_v2 (effect: EXECUTE). Each source row corresponds to one DingTalk message; there is no nested detail structure.
Key field mapping (desensitized):
| Source Field (MySQL) | Target Field (DingTalk) | Mapping Type | Conversion Description |
|---|---|---|---|
| — | robotCode | CONSTANT | Fixed robot code |
CONCAT('["',ifnull(user3.userid,''),'","fixed cc"]' | userIds | TRANSFORM | Operator + fixed cc person, JSON array string |
| — | msgKey | CONSTANT | sampleMarkdown |
| Multi-field combination | msgParam | TRANSFORM | _function CONCAT to assemble Markdown text |
now() | msgParam.text | DIRECT | Message generation time |
user2.real_name | msgParam.text | DIRECT | Operator name |
a.create_time | msgParam.text | DIRECT | Posting time |
CASE a.business_type | msgParam.text | DIRECT | Chinese document type |
CONCAT(Message,',',BillId) | msgParam.text | DIRECT | Error info |
CASE a.business_type | msgParam.text | DIRECT | Solution hint |
How to Configure in Qeasy
In Qeasy, create an A→B SYNC strategy and configure both endpoints:
- Source (MySQL): Use
WebAPItypeselect, main parametermain_params=1, and paginate with:limit/:offsetin the main SQL. Useidas the number field withidCheckdisabled. - Target (DingTalk): Use
topapi/message/corpconversation/asyncsend_v2witheffect: EXECUTE. Passuseriddirectly as a row-level field touserIds; no script needed. - Message body assembly: Use
_function CONCATinmsgParamto build a valid JSON string, with the fixed title, time, real_name, create_time, business_type, json_result, and Solution concatenated in Markdown syntax. - Recipient strategy: The source SQL maps work numbers to DingTalk
useridviasys_user.job_number = dingtalk_user.job_number, then usesCONCATto form["operator","cc person"].
Implementation Steps
- Incremental starting point: Use
a.create_time > last execution timeas the incremental anchor; this design already filters via SQL WHERE:is_success='1'or intermediate state > 10 minutes. - Full-volume trigger: On day one, manually trigger a full run to push backlogged failures; then switch to incremental.
- Scheduling frequency: Source
*/29 8-21 * * *, target*/30 8-21 * * *—offset by 1 minute so the target is not invoked before the source has fetched. - Failure retry: Qeasy retries DingTalk push failures by default; cap retries at 3 to avoid spamming users.
- Disable strategy: Once stable, you may remove the
is_success='1'branch and keep only the >10-minute intermediate-state alerts.
Lessons Learned
- Empty
useriddrops the whole message: The SQL usesifnull(user3.userid,'')for tolerance, but DingTalk does not handle emptyuseridwell. A safer approach is to replace empty values with a fixed cc placeholder and let humans triage. - Markdown title misalignment:
msgParammust be valid JSON, with the title and body intitleandtextrespectively. Use\nfor newlines intext—never raw line breaks. - Missing CASE branches:
business_typeis a numeric code; the SQL CASE must cover all 6 values (1/2/3/11/12/13), otherwise unmapped values become NULL and DingTalk will outputnullliterally. - Incremental field trap: Don't use the timestamp of an
is_success='1'record as the incremental anchor because failures can be very old; rely oncreate_timeplusTIMESTAMPDIFF. - Offset scheduling: Using the same frequency for source and target causes collisions. Source at minute 29 and target at minute 30 is the dual-track rhythm commonly used by Qeasy customers.
Applicable and Non-Applicable Scenarios
Applicable: MySQL/ERP-style log-based failure notifications, time-window polled alert pushes, and scenarios where routing by business_type is required. Not applicable: Sub-second real-time alerts (this design's floor is 29 minutes), cases where DingTalk is disabled or replaced by other IM tools, and scenarios requiring historical alert state tracking.