Qeasy Cloud
Get Started

MySQL Interface Status Polling + DingTalk Group Alert: A Single-Strategy Tutorial on Qeasy

· 何金辉· Integration Solutions· 10 views· 4 min read

What This Strategy Solves

In manufacturing supply chain integration, dozens of document interfaces run between the MOM system and the downstream ERP: purchase receipts, subcontracting issues, sales shipments, status conversions... If one link fails silently, finance only notices the mismatch the next day during reconciliation. In one customer engagement we watched the IT staff run SQL manually each morning, take screenshots, and paste them into a group chat — slow and error-prone. The goal of this strategy is straightforward: let the Qeasy Data Integration Platform periodically pull an interface status master table from MySQL, format it as a DingTalk group message, and push it to the on-duty owner — turning "firefighting after the fact" into "proactive alerting."

Data Flow and Field Mapping

The overall flow is MySQL → Qeasy middle layer → DingTalk robot. The source is a summary table aggregating exception/pending counts across many document types; the target is a DingTalk custom robot group message API. Key field mapping (abbreviated):

MeaningSource MySQL fieldTarget DingTalk placeholderNotes
Query timetimenow() + titleUsed as message timestamp
Purchase receipt (exception/pending)CGRK_E / CGRK_N{{CGRK_E}} / {{CGRK_N}}E=exception, N=pending
Production issuescll_e / scll_n{{scll_e}} / {{scll_n}}Names follow source table
Sales shipmentxsck_e / xsck_n{{xsck_e}} / {{xsck_n}}Same as above
Status conversionXTZH_E / XTZH_N{{XTZH_E}} / {{XTZH_N}}Case-sensitive
Plan → Reportgxjh_gxhb_e / gxjh_gxhb_n{{gxjh_gxhb_e}} / {{gxjh_gxhb_n}}Cross-domain metric
Multi-org dimension_E1 / _N1 suffixCorresponding {{xxx_e1}}Distinguishes plants/R&D centers

The source uses :limit / :offset placeholders in SQL, bound by Qeasy at runtime. The target uses a _function CONCAT inside msgParam to assemble all placeholders into a Markdown string.

How to Configure in Qeasy

Source (MySQL - WebAPI select)

  • Choose api=select, effect=QUERY, method=POST (wrapping the SQL);
  • main_params passes an object as the container for SQL dynamic parameters;
  • Put the full query in otherRequest.main_sql; Qeasy auto-replaces :limit / :offset;
  • Enable autoFillResponse so response fields are auto-filled for downstream reference.

Target (DingTalk - topapi/message/corpconversation/asyncsend_v2)

  • Configure robotCode with the enterprise custom robot code;
  • userIds is a JSON array listing the on-duty userIds to @;
  • Set msgKey to sampleMarkdown to trigger Markdown rendering;
  • Use _function CONCAT inside msgParam to assemble the Markdown, referencing source fields via {{field}};
  • Enable idCheck for message idempotency.

Qeasy Middle Layer

  • Create the strategy in Qeasy with the source/target above;
  • Turn on "centralized code mapping management": register all xxx_e / xxx_n naming rules in one mapping table so new document types only need a single change;
  • Version-control the Markdown template — reference variables only, never hard-code business values.

Implementation Steps

  1. Incremental start: Run a lightweight SQL like select now() first to confirm "query works + push works" and that DingTalk receives an empty message.
  2. Full trigger: Plug in the real status table SQL, disable pagination (use limit 1 offset 0), and verify a single summary record returns.
  3. Pagination and frequency: Source crontab 1 8-22 * * * (run at minute 1 of every hour); target crontab 3 8-22 * * * (delay 2 minutes for SQL to land).
  4. Shift rotation: Move userIds into a Qeasy parameter table that rotates daily by shift, avoiding hard-coding.
  5. Phased rollout: Push to the IT admin group first; after the template and numbers are confirmed correct, expand to business groups.
  6. Alert escalation: In Qeasy add a secondary alert for "two consecutive push failures" or "SQL error" so a silent robot failure is noticed.

Lessons Learned

  1. Inconsistent placeholder casing: Source uses uppercase XTZH_E, template uses lowercase xtzh_e, so that line is always empty. Safe practice: standardize on uppercase in Qeasy and add a "template validation" step.
  2. SQL performance kills the DB: No index on the status table; a select * with pagination took 40 seconds on the first run. Safe practice: add an index on time and only fetch the latest row in Qeasy.
  3. Hard-coded DingTalk userIds: UserIds pasted directly into userIds; when an employee leaves, the message stops going out. Safe practice: dual-track — daily push by shift table, full push by department group robot, as mutual backup.
  4. Message flooding: Hourly pushes with a long green-state template cause the group to be muted. Safe practice: add an "all-zero skip" check in the template so green status only sends a one-line summary.
  5. Timezone mismatch: now() uses the database timezone; DingTalk shows an 8-hour offset. Safe practice: explicitly convert to UTC+8 inside the Qeasy expression.

Applicable and Non-Applicable Scenarios

Applicable: a fixed set of documents/interfaces (dozens to hundreds), hourly inspection needed, both IT and business sides use DingTalk, source data already aggregated in one status table. Not applicable: interfaces change frequently (added daily), per-document detail traceability required, no unified source aggregation, sub-second real-time alerting needed — those cases are better served by event streams or a dedicated monitoring platform.

Original content. Please credit the source when reposting: https://www.qeasy.cloud/insights/solutions/strat-mysql-dingtalk-4900-mom-1-294daea7

Comments