# `Sp_Msg_SendMsg` (procedure) - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `sProInParam` | `varchar(10000)` | | 2 | IN | `sMakePerson` | `varchar(100)` | | 3 | IN | `sBrId` | `varchar(100)` | | 4 | IN | `sSuId` | `varchar(100)` | | 5 | IN | `sFormId` | `varchar(100)` | | 6 | OUT | `sReturn` | `varchar(1000)` | | 7 | OUT | `sCode` | `int` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_Msg_SendMsg`'`._ ## Narrative **Business context:** 消息管理 → 发送消息 — toolbar 发送 (send) handler on the 发送消息 form. Composes a message defined in `sys_msg_send` (subject, body, attachments, recipients) and fans it out to PC in-app inbox, WeChat, and/or email channels per the message's flags. Drives the platform's manual-broadcast flow; workflow-generated messages take other paths. **What it does:** Parses `$.params[*].value[*].sId` (the `sys_msg_send` row ids). For each id loads `bSendEmail, bSendWechat, bSendDingTaik, bSendPhone, sTitle, sAbstract, sTemplateFullMemo, sBillNo` into locals. Aggregates recipient lists from `viw_msguser JOIN sys_msg_send_receiveuser` (where `sParentId = p_sId`) into `p_sWxUserName` (JSON array of WeChat ids), `p_sEmail` (JSON array), and `p_iCountUser`; missing recipients return `sCode=-1` with "请先选择接收人". Pulls attachments from `sys_msg_send_file` into a JSON array `p_sFilesAdressees`. If `bSendWechat=1` inserts a row into `syssendewxmsg` (the queue scraped by the WeChat sender worker). If `bSendEmail=1` inserts into `syssendemail` (the email queue). Always inserts one PC-inbox row per recipient into `sys_msg` joining `viw_msguser` to `sys_msg_send_receiveuser`. Finally `UPDATE sys_msg_send SET bSend = 1 WHERE sId = p_sId`. **Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` (POST `/procedureCall/doGenericProcedureCall`) — the 发送 button on the 发送消息单据 form (`gdsmodule.sId 101801153119616753489024570`, parent 消息管理) names `Sp_Msg_SendMsg` as the action. xly-src ships `script/标版/upgrade/更新WAR脚本/20230210_消息、工作流、定时 模块/消息、工作流、定时 模块_20230210.sql` (install patch).