Qeasy Cloud
Get Started

Sales Order Interface Failure DingTalk Notification: A Practical Integration Solution with Qeasy

· 尹春锐· Integration Solutions· 25 views· 3 min read

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 TypeConversion Description
—robotCodeCONSTANTFixed robot code
CONCAT('["',ifnull(user3.userid,''),'","fixed cc"]'userIdsTRANSFORMOperator + fixed cc person, JSON array string
—msgKeyCONSTANTsampleMarkdown
Multi-field combinationmsgParamTRANSFORM_function CONCAT to assemble Markdown text
now()msgParam.textDIRECTMessage generation time
user2.real_namemsgParam.textDIRECTOperator name
a.create_timemsgParam.textDIRECTPosting time
CASE a.business_typemsgParam.textDIRECTChinese document type
CONCAT(Message,',',BillId)msgParam.textDIRECTError info
CASE a.business_typemsgParam.textDIRECTSolution hint

How to Configure in Qeasy

In Qeasy, create an A→B SYNC strategy and configure both endpoints:

  1. Source (MySQL): Use WebAPI type select, main parameter main_params=1, and paginate with :limit / :offset in the main SQL. Use id as the number field with idCheck disabled.
  2. Target (DingTalk): Use topapi/message/corpconversation/asyncsend_v2 with effect: EXECUTE. Pass userid directly as a row-level field to userIds; no script needed.
  3. Message body assembly: Use _function CONCAT in msgParam to build a valid JSON string, with the fixed title, time, real_name, create_time, business_type, json_result, and Solution concatenated in Markdown syntax.
  4. Recipient strategy: The source SQL maps work numbers to DingTalk userid via sys_user.job_number = dingtalk_user.job_number, then uses CONCAT to form ["operator","cc person"].

Implementation Steps

  1. Incremental starting point: Use a.create_time > last execution time as the incremental anchor; this design already filters via SQL WHERE: is_success='1' or intermediate state > 10 minutes.
  2. Full-volume trigger: On day one, manually trigger a full run to push backlogged failures; then switch to incremental.
  3. 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.
  4. Failure retry: Qeasy retries DingTalk push failures by default; cap retries at 3 to avoid spamming users.
  5. Disable strategy: Once stable, you may remove the is_success='1' branch and keep only the >10-minute intermediate-state alerts.

Lessons Learned

  1. Empty userid drops the whole message: The SQL uses ifnull(user3.userid,'') for tolerance, but DingTalk does not handle empty userid well. A safer approach is to replace empty values with a fixed cc placeholder and let humans triage.
  2. Markdown title misalignment: msgParam must be valid JSON, with the title and body in title and text respectively. Use \n for newlines in text—never raw line breaks.
  3. Missing CASE branches: business_type is 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 output null literally.
  4. 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 on create_time plus TIMESTAMPDIFF.
  5. 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.

Original content. Please credit the source when reposting: https://www.qeasy.cloud/insights/solutions/strat-mysql-dingtalk-4900-sihua-0f4c9f2d

Comments