MySQL Interface Status Polling + DingTalk Group Alert: A Single-Strategy Tutorial on Qeasy
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):
| Meaning | Source MySQL field | Target DingTalk placeholder | Notes |
|---|---|---|---|
| Query time | time | now() + title | Used as message timestamp |
| Purchase receipt (exception/pending) | CGRK_E / CGRK_N | {{CGRK_E}} / {{CGRK_N}} | E=exception, N=pending |
| Production issue | scll_e / scll_n | {{scll_e}} / {{scll_n}} | Names follow source table |
| Sales shipment | xsck_e / xsck_n | {{xsck_e}} / {{xsck_n}} | Same as above |
| Status conversion | XTZH_E / XTZH_N | {{XTZH_E}} / {{XTZH_N}} | Case-sensitive |
| Plan → Report | gxjh_gxhb_e / gxjh_gxhb_n | {{gxjh_gxhb_e}} / {{gxjh_gxhb_n}} | Cross-domain metric |
| Multi-org dimension | _E1 / _N1 suffix | Corresponding {{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_paramspasses an object as the container for SQL dynamic parameters;- Put the full query in
otherRequest.main_sql; Qeasy auto-replaces:limit/:offset; - Enable
autoFillResponseso response fields are auto-filled for downstream reference.
Target (DingTalk - topapi/message/corpconversation/asyncsend_v2)
- Configure
robotCodewith the enterprise custom robot code; userIdsis a JSON array listing the on-duty userIds to @;- Set
msgKeytosampleMarkdownto trigger Markdown rendering; - Use
_function CONCATinsidemsgParamto assemble the Markdown, referencing source fields via{{field}}; - Enable
idCheckfor 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_nnaming 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
- Incremental start: Run a lightweight SQL like
select now()first to confirm "query works + push works" and that DingTalk receives an empty message. - Full trigger: Plug in the real status table SQL, disable pagination (use
limit 1 offset 0), and verify a single summary record returns. - Pagination and frequency: Source crontab
1 8-22 * * *(run at minute 1 of every hour); target crontab3 8-22 * * *(delay 2 minutes for SQL to land). - Shift rotation: Move
userIdsinto a Qeasy parameter table that rotates daily by shift, avoiding hard-coding. - Phased rollout: Push to the IT admin group first; after the template and numbers are confirmed correct, expand to business groups.
- 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
- Inconsistent placeholder casing: Source uses uppercase
XTZH_E, template uses lowercasextzh_e, so that line is always empty. Safe practice: standardize on uppercase in Qeasy and add a "template validation" step. - 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 ontimeand only fetch the latest row in Qeasy. - 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. - 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.
- 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.