版本:2026-11-17
适用机构:丽水市妇幼保健院orgid = 47226079133110211G1001
关联模块:smartor、ruoyi-quartz
关联表:mch_followup_plan、mch_followup_plan_item、mch_followup_send_log
妇幼专科档案(妇保/儿保)维护了:
plannedFollowTime:整个随访周期的**基准日**followupPeriod:JSON 格式的随访周期,包含发送方式、发送内容、发送天数等系统按这两个字段生成妇幼专用的发送计划,并在到期时:
SmsUtils.sendYunMasSmsSmsUtils.sendChatLs(即 /sms/sendChatFuyou 的内部实现)妇幼随访**不进入**普通随访的 service_subtask_preachform / compensateTask 补偿链路,避免与通用随访互相影响。
plannedFollowTime 是整个周期的基准日,所有节点都以它计算:
节点发送时间 = plannedFollowTime 的日期 + item.dayOffset 天 + 时分秒
不是“上一次发送后顺延”,而是固定从基准日排期。
优先级:
item.sendTime 有值 → 使用 item.sendTime;plannedFollowTime 的时分秒不是 00:00:00 → 沿用 plannedFollowTime 的时分秒;09:00。如果确实需要零点发送,必须显式配置:
{"sendTime": "00:00"}
plannedFollowTime = 2026-11-20 14:30:00
| dayOffset | sendTime | 实际发送时间 |
|---|---|---|
| 0 | 空 | 2026-11-20 14:30:00 |
| 3 | 空 | 2026-11-23 14:30:00 |
| 7 | 09:00 | 2026-11-27 09:00:00 |
plannedFollowTime = 2026-11-20 00:00:00
| dayOffset | sendTime | 实际发送时间 |
|---|---|---|
| 0 | 空 | 2026-11-20 09:00:00 |
| 3 | 空 | 2026-11-23 09:00:00 |
followup_period 已由 varchar(100) 扩展为 TEXT。
{
"version": 1,
"items": [
{
"seq": 1,
"dayOffset": 0,
"sendTime": "09:00",
"sendType": "sms",
"content": "您好${patname},请按计划复诊。"
},
{
"seq": 2,
"dayOffset": 3,
"sendTime": "09:00",
"sendType": "wechat",
"templateId": 16,
"titleName": "诊后随访提醒",
"content": "您好${patname},请按计划复诊。",
"url": "https://example.com/followup"
},
{
"seq": 3,
"dayOffset": 7,
"sendType": "sms",
"content": "您好${patname},请按时复诊。"
}
]
}
字段:
| 字段 | 必填 | 说明 |
|---|---|---|
seq |
否 | 节点顺序,缺省按数组顺序 1..N |
dayOffset |
是 | 相对 plannedFollowTime 的绝对天数,必须 ≥ 0 |
sendTime |
否 | HH:mm 或 HH:mm:ss |
sendType |
是 | sms / wechat;兼容 4 / 5、短信 / 公众号 / 微信 |
content |
短信必填 | 短信正文;微信正文可选 |
templateId |
否 | 微信模板 ID |
titleName |
否 | 微信标题 |
url |
否 | 微信跳转地址 |
短信节点如果 content 为空会解析失败,计划进入“待补充/配置异常”状态。
content 和 titleName 支持占位符:
${patname} 患者姓名
${patid} 患者ID
${phone} 联系电话
${idcardno} 证件号码
${plannedFollowTime} 周期基准日(yyyy-MM-dd HH:mm:ss)
${sourceBizNo} 门诊号/住院号
${archiveType} 档案类型:1妇保 2儿保
${orgid} 机构ID
${seq} 节点顺序
{
"intervalDays": 3,
"count": 4,
"sendTime": "09:00",
"sendType": "sms",
"content": "您好${patname},请按计划复诊。"
}
表示:
第1次:基准日 + 0天
第2次:基准日 + 3天
第3次:基准日 + 6天
第4次:基准日 + 9天
count 缺省时可用 followupCycleTimes 兜底。
{
"days": [0, 7, 14],
"sendType": "sms",
"content": "您好${patname},请按计划复诊。"
}
表示基准日 + 0/7/14 天。
只补发 1 天内到期的节点:
| 条件 | 处理 |
|---|---|
send_time > now |
待发送 |
now - 24小时 <= send_time <= now |
补发 |
send_time < now - 24小时 |
标记“过期”,不再发送 |
过期节点状态为 4,不会给患者发送过时消息。
mch_followup_plan.plan_status| 值 | 含义 |
|---|---|
| 0 | 有效 |
| 1 | 已取消(重建时取消旧计划) |
| 2 | 已完成(无待发送/发送中节点) |
| 3 | 待补充/配置异常(拟随访时间为空、JSON 非法等) |
mch_followup_plan_item.send_status| 值 | 含义 |
|---|---|
| 0 | 待发送 |
| 1 | 发送中 |
| 2 | 成功 |
| 3 | 失败(重试耗尽) |
| 4 | 过期(超过 1 天补发窗口) |
| 5 | 取消 |
| 6 | 跳过(手机号为空等) |
以下入口保存档案后都会调用 IMchFollowupPlanService.rebuildForArchive:
PatMaternityArchiveServiceImpl.insertOrUpdateMaternityArchivePatChildArchiveServiceImpl.insertOrUpdateChildArchive自动档案生成(门诊接诊完成、住院随访完成)也走这两个 Service,因此同样会触发。
重建规则:
plannedFollowTime 为空 → 生成“待补充”计划,不生成节点;followupPeriod 非法 → 生成“配置异常”计划,不生成节点;RyTask.sendMchFollowup():
查询 send_status=0
and send_time <= now
and (next_retry_time is null or next_retry_time <= now)
and plan.plan_status=0
and plan.orgid=丽水妇幼
→ 逐条判断补发窗口
→ 短信/微信发送
→ 写发送日志
→ 更新节点状态
→ 无待发送节点时计划置为完成
RyTask.generateMchFollowupPlan():
扫描已有妇保/儿保档案详情
planned_follow_time 非空
followup_period 非空
→ 补建计划
String configJson = sysConfigService.selectConfigByKey("ls.msg.yunmas", orgid);
SmsUtils.YunMasConfig config = SmsUtils.YunMasConfig.of(configJson);
SmsUtils.SmsResult result = SmsUtils.sendYunMasSms(config, phone, content);
成功判定:result.isOk(),即 success=true 且 rspcod=success。
短信内容不要手工拼【签名】,云MAS 会根据 sign 编码自动追加。
String configJson = sysConfigService.selectConfigByKey("ls.wx.fuyou", orgid);
SmsUtils.LsWxConfig config = SmsUtils.LsWxConfig.of(configJson);
SmsUtils.LsWxMessage message = new SmsUtils.LsWxMessage();
message.setId(templateId);
message.setPatientId(String.valueOf(patid));
message.setPatientName(patname);
message.setIdCard(idcardno);
message.setMobile(phone);
message.setMedCardNo(sourceBizNo);
message.setTitleName(titleName);
message.setContent(content);
message.setUrl(url);
String resp = SmsUtils.sendChatLs(config, message);
成功判定:响应 JSON code == 0。
ls.wx.fuyou 未配置时,LsWxConfig.of(null) 使用内置的丽水妇幼默认配置(与 /sms/sendChatFuyou 一致)。
followupPeriod 中显式配置另一个节点,而不是复用普通随访补偿。sql/mch_followup_plan_20261117.sql
2026-11-17 已在本地/开发库
smartor_lishui(MySQL 5.7.34)执行通过;
执行前表结构备份见target/ddlcheck/backup-before-20261117.sql。
包含:
followup_period 扩展为 TEXT;mch_followup_plan;mch_followup_plan_item;mch_followup_send_log。在“系统管理 → 定时任务”新增:
| 用途 | 调用目标 | 建议频率 |
|---|---|---|
| 历史档案补计划 | ryTask.generateMchFollowupPlan() |
每天一次 |
| 妇幼随访发送 | ryTask.sendMchFollowup() |
每 5 分钟 |
建议只在 server.port=8095 节点执行,并设置“禁止并发”。
| 配置 key | 说明 | 缺省 |
|---|---|---|
mch.followup.enabled |
妇幼随访开关 | 缺省视为 true |
ls.msg.yunmas |
云MAS 配置 JSON | 使用 SmsUtils 内置默认 |
ls.wx.fuyou |
丽水妇幼微信配置 JSON | 使用 SmsUtils 内置默认 |
smartor/src/main/java/com/smartor/common/MchFollowupConstants.java
smartor/src/main/java/com/smartor/domain/MchFollowupPlan.java
smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java
smartor/src/main/java/com/smartor/domain/MchFollowupSendLog.java
smartor/src/main/java/com/smartor/domain/MchFollowupNode.java
smartor/src/main/java/com/smartor/domain/MchFollowupArchiveCandidate.java
smartor/src/main/java/com/smartor/mapper/MchFollowupPlanMapper.java
smartor/src/main/java/com/smartor/mapper/MchFollowupPlanItemMapper.java
smartor/src/main/java/com/smartor/mapper/MchFollowupSendLogMapper.java
smartor/src/main/java/com/smartor/service/mch/*
smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml
smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml
smartor/src/main/resources/mapper/smartor/MchFollowupSendLogMapper.xml
sql/mch_followup_plan_20261117.sql
PatMaternityArchiveServiceImpl 档案保存后重建计划
PatChildArchiveServiceImpl 档案保存后重建计划
PatSpecificArchiveGenerateServiceImpl 档案生成时写入 plannedFollowTime
RyTask 新增 generateMchFollowupPlan / sendMchFollowup
plannedFollowTime 必须有值,否则不会自动发送;pat_med_outhosp.fudate / pat_med_inhosp.fudate 作为 plannedFollowTime;orgid=47226079133110211G1001 生效;