From e2b0e66b92759eb6a24b0a4e24aa60e76bbdc1a7 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 17 十一月 2026 17:34:30 +0800
Subject: [PATCH] feat: 实现妇幼随访按周期发送

---
 .gitignore                                                                                |    1 
 smartor/src/main/java/com/smartor/service/mch/MchFollowupSendServiceImpl.java             |  210 +++
 smartor/src/main/java/com/smartor/common/MchFollowupConstants.java                        |   79 +
 docs/妇幼随访按周期发送测试报告_20261117.md                                                            |  276 +++++
 smartor/src/main/java/com/smartor/service/mch/MchFollowupDueDecision.java                 |   10 
 smartor/src/test/java/com/smartor/service/mch/MchFollowupPlanServiceCheck.java            |  283 +++++
 smartor/src/main/java/com/smartor/mapper/MchFollowupPlanMapper.java                       |   32 
 smartor/src/main/java/com/smartor/service/mch/MchFollowupMessageSender.java               |  133 ++
 smartor/src/main/resources/mapper/smartor/MchFollowupSendLogMapper.xml                    |   15 
 smartor/src/test/java/com/smartor/service/mch/MchFollowupLogicCheck.java                  |  183 +++
 smartor/src/main/java/com/smartor/domain/MchFollowupArchiveCandidate.java                 |   20 
 docs/妇幼随访按周期发送功能说明_20261117.md                                                            |  378 ++++++
 smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml                       |  126 ++
 smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java             |  321 +++++
 smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml                   |  128 ++
 smartor/src/main/java/com/smartor/service/mch/IMchFollowupSendService.java                |   15 
 smartor/src/main/java/com/smartor/service/mch/IMchFollowupPlanService.java                |   25 
 smartor/src/main/java/com/smartor/domain/MchFollowupSendLog.java                          |   33 
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java                              |   36 
 smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanAssembler.java               |   46 
 smartor/src/main/java/com/smartor/domain/MchFollowupPlan.java                             |   76 +
 smartor/src/main/java/com/smartor/service/mch/MchFollowupSendWindow.java                  |   30 
 smartor/src/main/java/com/smartor/service/mch/MchFollowupTimeResolver.java                |   60 +
 smartor/src/main/java/com/smartor/service/mch/MchFollowupSendOutcome.java                 |   69 +
 smartor/src/main/java/com/smartor/domain/MchFollowupNode.java                             |   32 
 smartor/src/test/java/com/smartor/service/mch/MchFollowupSendServiceCheck.java            |  198 +++
 smartor/src/main/java/com/smartor/mapper/MchFollowupSendLogMapper.java                    |   13 
 smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java        |   17 
 smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java                         |   66 +
 smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java            |   17 
 sql/mch_followup_plan_20261117.sql                                                        |   81 +
 smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateServiceImpl.java |    4 
 smartor/src/main/java/com/smartor/service/mch/MchFollowupPeriodParser.java                |  224 ++++
 smartor/src/main/java/com/smartor/mapper/MchFollowupPlanItemMapper.java                   |   38 
 34 files changed, 3,275 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore
index bdbc2a9..2b810f5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,6 +37,7 @@
 !/sql/quartz.sql
 !/sql/ry_20220822.sql
 !/sql/pat_specific_archive_generate_config_lishui_mch_20261104.sql
+!/sql/mch_followup_plan_20261117.sql
 sql/_probe/
 *.log
 _dbcheck.txt
diff --git "a/docs/\345\246\207\345\271\274\351\232\217\350\256\277\346\214\211\345\221\250\346\234\237\345\217\221\351\200\201\345\212\237\350\203\275\350\257\264\346\230\216_20261117.md" "b/docs/\345\246\207\345\271\274\351\232\217\350\256\277\346\214\211\345\221\250\346\234\237\345\217\221\351\200\201\345\212\237\350\203\275\350\257\264\346\230\216_20261117.md"
new file mode 100644
index 0000000..300c92f
--- /dev/null
+++ "b/docs/\345\246\207\345\271\274\351\232\217\350\256\277\346\214\211\345\221\250\346\234\237\345\217\221\351\200\201\345\212\237\350\203\275\350\257\264\346\230\216_20261117.md"
@@ -0,0 +1,378 @@
+# 濡囧辜闅忚鎸夊懆鏈熷彂閫佸姛鑳借鏄�
+
+> 鐗堟湰锛�2026-11-17  
+> 閫傜敤鏈烘瀯锛氫附姘村競濡囧辜淇濆仴闄� `orgid = 47226079133110211G1001`  
+> 鍏宠仈妯″潡锛歚smartor`銆乣ruoyi-quartz`  
+> 鍏宠仈琛細`mch_followup_plan`銆乣mch_followup_plan_item`銆乣mch_followup_send_log`
+
+---
+
+## 涓�銆佸姛鑳界洰鏍�
+
+濡囧辜涓撶妗f锛堝淇�/鍎夸繚锛夌淮鎶や簡锛�
+
+- `plannedFollowTime`锛氭暣涓殢璁垮懆鏈熺殑**鍩哄噯鏃�**
+- `followupPeriod`锛欽SON 鏍煎紡鐨勯殢璁垮懆鏈燂紝鍖呭惈鍙戦�佹柟寮忋�佸彂閫佸唴瀹广�佸彂閫佸ぉ鏁扮瓑
+
+绯荤粺鎸夎繖涓や釜瀛楁鐢熸垚濡囧辜涓撶敤鐨勫彂閫佽鍒掞紝骞跺湪鍒版湡鏃讹細
+
+- 鐭俊锛氳皟鐢ㄤ腑鍥界Щ鍔ㄤ簯MAS `SmsUtils.sendYunMasSms`
+- 寰俊锛氳皟鐢� `SmsUtils.sendChatLs`锛堝嵆 `/sms/sendChatFuyou` 鐨勫唴閮ㄥ疄鐜帮級
+
+濡囧辜闅忚**涓嶈繘鍏�**鏅�氶殢璁跨殑 `service_subtask_preachform` / `compensateTask` 琛ュ伩閾捐矾锛岄伩鍏嶄笌閫氱敤闅忚浜掔浉褰卞搷銆�
+
+---
+
+## 浜屻�佹椂闂村彛寰�
+
+### 2.1 鍩哄噯鏃�
+
+`plannedFollowTime` 鏄暣涓懆鏈熺殑鍩哄噯鏃ワ紝鎵�鏈夎妭鐐归兘浠ュ畠璁$畻锛�
+
+```text
+鑺傜偣鍙戦�佹椂闂� = plannedFollowTime 鐨勬棩鏈� + item.dayOffset 澶� + 鏃跺垎绉�
+```
+
+**涓嶆槸**鈥滀笂涓�娆″彂閫佸悗椤哄欢鈥濓紝鑰屾槸鍥哄畾浠庡熀鍑嗘棩鎺掓湡銆�
+
+### 2.2 鏃跺垎绉掕鍒�
+
+浼樺厛绾э細
+
+1. `item.sendTime` 鏈夊�� 鈫� 浣跨敤 `item.sendTime`锛�
+2. 鍚﹀垯锛宍plannedFollowTime` 鐨勬椂鍒嗙涓嶆槸 `00:00:00` 鈫� 娌跨敤 `plannedFollowTime` 鐨勬椂鍒嗙锛�
+3. 鍚﹀垯榛樿 `09:00`銆�
+
+濡傛灉纭疄闇�瑕侀浂鐐瑰彂閫侊紝蹇呴』鏄惧紡閰嶇疆锛�
+
+```json
+{"sendTime": "00:00"}
+```
+
+### 2.3 绀轰緥
+
+`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 |
+
+---
+
+## 涓夈�乫ollowupPeriod JSON 鏍煎紡
+
+`followup_period` 宸茬敱 `varchar(100)` 鎵╁睍涓� `TEXT`銆�
+
+### 3.1 鏄惧紡鑺傜偣锛堟帹鑽愶級
+
+```json
+{
+  "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` | 鐭俊蹇呭~ | 鐭俊姝f枃锛涘井淇℃鏂囧彲閫� |
+| `templateId` | 鍚� | 寰俊妯℃澘 ID |
+| `titleName` | 鍚� | 寰俊鏍囬 |
+| `url` | 鍚� | 寰俊璺宠浆鍦板潃 |
+
+鐭俊鑺傜偣濡傛灉 `content` 涓虹┖浼氳В鏋愬け璐ワ紝璁″垝杩涘叆鈥滃緟琛ュ厖/閰嶇疆寮傚父鈥濈姸鎬併��
+
+### 3.2 闂撮殧 + 娆℃暟
+
+```json
+{
+  "intervalDays": 3,
+  "count": 4,
+  "sendTime": "09:00",
+  "sendType": "sms",
+  "content": "鎮ㄥソ${patname}锛岃鎸夎鍒掑璇娿��"
+}
+```
+
+琛ㄧず锛�
+
+```text
+绗�1娆★細鍩哄噯鏃� + 0澶�
+绗�2娆★細鍩哄噯鏃� + 3澶�
+绗�3娆★細鍩哄噯鏃� + 6澶�
+绗�4娆★細鍩哄噯鏃� + 9澶�
+```
+
+`count` 缂虹渷鏃跺彲鐢� `followupCycleTimes` 鍏滃簳銆�
+
+### 3.3 days 鏁扮粍
+
+```json
+{
+  "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`锛屼笉浼氱粰鎮h�呭彂閫佽繃鏃舵秷鎭��
+
+---
+
+## 浜斻�佽鍒掔姸鎬佷笌鑺傜偣鐘舵��
+
+### 5.1 璁″垝鐘舵�� `mch_followup_plan.plan_status`
+
+| 鍊� | 鍚箟 |
+|---|---|
+| 0 | 鏈夋晥 |
+| 1 | 宸插彇娑堬紙閲嶅缓鏃跺彇娑堟棫璁″垝锛� |
+| 2 | 宸插畬鎴愶紙鏃犲緟鍙戦��/鍙戦�佷腑鑺傜偣锛� |
+| 3 | 寰呰ˉ鍏�/閰嶇疆寮傚父锛堟嫙闅忚鏃堕棿涓虹┖銆丣SON 闈炴硶绛夛級 |
+
+### 5.2 鑺傜偣鐘舵�� `mch_followup_plan_item.send_status`
+
+| 鍊� | 鍚箟 |
+|---|---|
+| 0 | 寰呭彂閫� |
+| 1 | 鍙戦�佷腑 |
+| 2 | 鎴愬姛 |
+| 3 | 澶辫触锛堥噸璇曡�楀敖锛� |
+| 4 | 杩囨湡锛堣秴杩� 1 澶╄ˉ鍙戠獥鍙o級 |
+| 5 | 鍙栨秷 |
+| 6 | 璺宠繃锛堟墜鏈哄彿涓虹┖绛夛級 |
+
+---
+
+## 鍏�佹暣浣撴祦绋�
+
+### 6.1 妗f淇濆瓨鍚庤嚜鍔ㄩ噸寤鸿鍒�
+
+浠ヤ笅鍏ュ彛淇濆瓨妗f鍚庨兘浼氳皟鐢� `IMchFollowupPlanService.rebuildForArchive`锛�
+
+- `PatMaternityArchiveServiceImpl.insertOrUpdateMaternityArchive`
+- `PatChildArchiveServiceImpl.insertOrUpdateChildArchive`
+
+鑷姩妗f鐢熸垚锛堥棬璇婃帴璇婂畬鎴愩�佷綇闄㈤殢璁垮畬鎴愶級涔熻蛋杩欎袱涓� Service锛屽洜姝ゅ悓鏍蜂細瑙﹀彂銆�
+
+閲嶅缓瑙勫垯锛�
+
+1. 鍙鐞嗕附姘村骞硷紱
+2. `plannedFollowTime` 涓虹┖ 鈫� 鐢熸垚鈥滃緟琛ュ厖鈥濊鍒掞紝涓嶇敓鎴愯妭鐐癸紱
+3. `followupPeriod` 闈炴硶 鈫� 鐢熸垚鈥滈厤缃紓甯糕�濊鍒掞紝涓嶇敓鎴愯妭鐐癸紱
+4. 鍩哄噯鏃�/JSON 鏈彉鍖� 鈫� 鍙埛鏂拌仈绯讳汉淇℃伅锛屼笉閲嶅鐢熸垚鑺傜偣锛�
+5. 鍩哄噯鏃�/JSON 鍙樺寲 鈫� 鍙栨秷鏃ц鍒掍腑鏈彂閫佽妭鐐癸紝鐢熸垚鏂拌鍒掑拰鏂拌妭鐐癸紱
+6. 宸叉垚鍔�/宸茶繃鏈�/宸插け璐ヨ妭鐐逛繚鐣欏巻鍙层��
+
+### 6.2 瀹氭椂鍙戦��
+
+`RyTask.sendMchFollowup()`锛�
+
+```text
+鏌ヨ 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=涓芥按濡囧辜
+鈫� 閫愭潯鍒ゆ柇琛ュ彂绐楀彛
+鈫� 鐭俊/寰俊鍙戦��
+鈫� 鍐欏彂閫佹棩蹇�
+鈫� 鏇存柊鑺傜偣鐘舵��
+鈫� 鏃犲緟鍙戦�佽妭鐐规椂璁″垝缃负瀹屾垚
+```
+
+### 6.3 鍘嗗彶鏁版嵁琛ヨ鍒�
+
+`RyTask.generateMchFollowupPlan()`锛�
+
+```text
+鎵弿宸叉湁濡囦繚/鍎夸繚妗f璇︽儏
+  planned_follow_time 闈炵┖
+  followup_period 闈炵┖
+鈫� 琛ュ缓璁″垝
+```
+
+---
+
+## 涓冦�佺煭淇″拰寰俊鍙戦��
+
+### 7.1 鐭俊锛氫簯MAS
+
+```java
+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`銆�
+
+鐭俊鍐呭涓嶈鎵嬪伐鎷笺�愮鍚嶃�戯紝浜慚AS 浼氭牴鎹� `sign` 缂栫爜鑷姩杩藉姞銆�
+
+### 7.2 寰俊锛歴endChatLs
+
+```java
+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` 涓�鑷达級銆�
+
+---
+
+## 鍏�侀噸璇曡鍒�
+
+- 鍗曡妭鐐瑰け璐ュ悗鏈�澶氶噸璇� 3 娆★紱
+- 姣忔閲嶈瘯闂撮殧 10 鍒嗛挓锛�
+- 閲嶈瘯娆℃暟杈惧埌涓婇檺鍚庣疆涓衡�滃け璐モ�濓紱
+- 澶辫触涓嶄細鑷姩鍒囨崲鐭俊/寰俊閫氶亾锛�
+- 濡傞渶閫氶亾闄嶇骇锛屽簲鍦� `followupPeriod` 涓樉寮忛厤缃彟涓�涓妭鐐癸紝鑰屼笉鏄鐢ㄦ櫘閫氶殢璁胯ˉ鍋裤��
+
+---
+
+## 涔濄�侀儴缃叉楠�
+
+### 9.1 鎵ц SQL
+
+```text
+sql/mch_followup_plan_20261117.sql
+```
+
+> 2026-11-17 宸插湪鏈湴/寮�鍙戝簱 `smartor_lishui`锛圡ySQL 5.7.34锛夋墽琛岄�氳繃锛�
+> 鎵ц鍓嶈〃缁撴瀯澶囦唤瑙� `target/ddlcheck/backup-before-20261117.sql`銆�
+
+鍖呭惈锛�
+
+- `followup_period` 鎵╁睍涓� `TEXT`锛�
+- `mch_followup_plan`锛�
+- `mch_followup_plan_item`锛�
+- `mch_followup_send_log`銆�
+
+### 9.2 閰嶇疆瀹氭椂浠诲姟
+
+鍦ㄢ�滅郴缁熺鐞� 鈫� 瀹氭椂浠诲姟鈥濇柊澧烇細
+
+| 鐢ㄩ�� | 璋冪敤鐩爣 | 寤鸿棰戠巼 |
+|---|---|---|
+| 鍘嗗彶妗f琛ヨ鍒� | `ryTask.generateMchFollowupPlan()` | 姣忓ぉ涓�娆� |
+| 濡囧辜闅忚鍙戦�� | `ryTask.sendMchFollowup()` | 姣� 5 鍒嗛挓 |
+
+寤鸿鍙湪 `server.port=8095` 鑺傜偣鎵ц锛屽苟璁剧疆鈥滅姝㈠苟鍙戔�濄��
+
+### 9.3 閰嶇疆鍙傛暟
+
+| 閰嶇疆 key | 璇存槑 | 缂虹渷 |
+|---|---|---|
+| `mch.followup.enabled` | 濡囧辜闅忚寮�鍏� | 缂虹渷瑙嗕负 `true` |
+| `ls.msg.yunmas` | 浜慚AS 閰嶇疆 JSON | 浣跨敤 `SmsUtils` 鍐呯疆榛樿 |
+| `ls.wx.fuyou` | 涓芥按濡囧辜寰俊閰嶇疆 JSON | 浣跨敤 `SmsUtils` 鍐呯疆榛樿 |
+
+---
+
+## 鍗併�佷唬鐮佹竻鍗�
+
+### 鏂板
+
+```text
+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
+```
+
+### 淇敼
+
+```text
+PatMaternityArchiveServiceImpl       妗f淇濆瓨鍚庨噸寤鸿鍒�
+PatChildArchiveServiceImpl           妗f淇濆瓨鍚庨噸寤鸿鍒�
+PatSpecificArchiveGenerateServiceImpl 妗f鐢熸垚鏃跺啓鍏� plannedFollowTime
+RyTask                               鏂板 generateMchFollowupPlan / sendMchFollowup
+```
+
+---
+
+## 鍗佷竴銆佹敞鎰忎簨椤�
+
+1. `plannedFollowTime` 蹇呴』鏈夊�硷紝鍚﹀垯涓嶄細鑷姩鍙戦�侊紱
+2. 鑷姩鐢熸垚鐨勫骞兼。妗堜細浼樺厛鍙� `pat_med_outhosp.fudate` / `pat_med_inhosp.fudate` 浣滀负 `plannedFollowTime`锛�
+3. 杩囨湡鑺傜偣涓嶅彂閫侊紝鍙ˉ鍙� 1 澶╁唴鑺傜偣锛�
+4. 濡囧辜璁″垝涓嶈繘鍏ユ櫘閫氶殢璁胯ˉ鍋块摼璺紱
+5. 鍙 `orgid=47226079133110211G1001` 鐢熸晥锛�
+6. 寤鸿鍙戦�佷换鍔″崟鑺傜偣鎵ц锛岄伩鍏嶉噸澶嶅彂閫侊紱
+7. 浜慚AS/寰俊閰嶇疆閿欒鏃跺彧褰卞搷瀵瑰簲鑺傜偣锛屼笉褰卞搷鍏朵粬鑺傜偣銆�
diff --git "a/docs/\345\246\207\345\271\274\351\232\217\350\256\277\346\214\211\345\221\250\346\234\237\345\217\221\351\200\201\346\265\213\350\257\225\346\212\245\345\221\212_20261117.md" "b/docs/\345\246\207\345\271\274\351\232\217\350\256\277\346\214\211\345\221\250\346\234\237\345\217\221\351\200\201\346\265\213\350\257\225\346\212\245\345\221\212_20261117.md"
new file mode 100644
index 0000000..796c7d8
--- /dev/null
+++ "b/docs/\345\246\207\345\271\274\351\232\217\350\256\277\346\214\211\345\221\250\346\234\237\345\217\221\351\200\201\346\265\213\350\257\225\346\212\245\345\221\212_20261117.md"
@@ -0,0 +1,276 @@
+# 濡囧辜闅忚鎸夊懆鏈熷彂閫佹祴璇曟姤鍛�
+
+> 娴嬭瘯鏃ユ湡锛�2026-11-17  
+> 娴嬭瘯妯″潡锛歚smartor`銆乣ruoyi-quartz`  
+> 娴嬭瘯鐜锛歐indows 10 / Git Bash / JDK 21.0.12 / Maven 3.9.9  
+> 娴嬭瘯鏂瑰紡锛氱函 main 鑷锛堜笉渚濊禆 JUnit銆丼pring 瀹瑰櫒銆佹暟鎹簱銆佺涓夋柟鐭俊/寰俊鎺ュ彛锛�
+
+---
+
+## 涓�銆佹祴璇曠粨璁�
+
+| 娴嬭瘯濂椾欢 | 鐢ㄤ緥鏁� | 閫氳繃 | 澶辫触 |
+|---|---:|---:|---:|
+| `MchFollowupLogicCheck` | 40 | 40 | 0 |
+| `MchFollowupPlanServiceCheck` | 19 | 19 | 0 |
+| `MchFollowupSendServiceCheck` | 18 | 18 | 0 |
+| **鍚堣** | **77** | **77** | **0** |
+
+缁撹锛�**鏍稿績閫昏緫娴嬭瘯鍏ㄩ儴閫氳繃銆�**
+
+琛ュ厖锛欴DL 宸插湪鏈湴/寮�鍙戝簱 `smartor_lishui`锛圡ySQL 5.7.34锛夊疄闄呮墽琛岄�氳繃锛�
+璇﹁鈥滀簲銆佹湰鍦版暟鎹簱 DDL 瀹炴祴鈥濄��
+
+鍙﹀宸叉墽琛岋細
+
+```bash
+mvn -q -DskipTests compile
+mvn -q -pl smartor -am -DskipTests test-compile
+```
+
+鍏ㄦā鍧楃紪璇戦�氳繃锛宍smartor` 娴嬭瘯浠g爜缂栬瘧閫氳繃銆�
+
+---
+
+## 浜屻�佹祴璇曡寖鍥�
+
+### 2.1 `MchFollowupLogicCheck`
+
+瑕嗙洊锛�
+
+1. `items` JSON 瑙f瀽锛�
+2. `intervalDays + count` 瑙f瀽锛�
+3. `intervalDays + followupCycleTimes` 鍏滃簳锛�
+4. `days` 鏁扮粍瑙f瀽锛�
+5. 闈炴硶 JSON銆佺┖鑺傜偣銆侀潪娉� `sendType`銆佺煭淇$己 `content`銆侀潪娉� `sendTime`锛�
+6. 鍩哄噯鏃ユ椂闂磋绠楋細
+   - `plannedFollowTime` 甯︽椂鍒嗙鏃舵部鐢紱
+   - `item.sendTime` 瑕嗙洊锛�
+   - 鍩哄噯鏃� `00:00:00` 榛樿 `09:00`锛�
+7. 1 澶╄ˉ鍙戠獥鍙o細
+   - 鏈潵鑺傜偣寰呭彂閫侊紱
+   - 1 灏忔椂鍐呰ˉ鍙戯紱
+   - 鎭板ソ 24 灏忔椂琛ュ彂锛�
+   - 瓒呰繃 24 灏忔椂杩囨湡锛�
+8. 鑺傜偣缁勮锛�
+9. 3 涓柊澧� Mapper XML 鍙В鏋愶紱
+10. DDL 鑴氭湰瀛樺湪銆�
+
+### 2.2 `MchFollowupPlanServiceCheck`
+
+浣跨敤鍔ㄦ�佷唬鐞嗘ā鎷� Mapper 鍜� `ISysConfigService`锛岃鐩栵細
+
+1. 濡囦繚璁″垝鐢熸垚锛岀敓鎴� 3 涓妭鐐癸紱
+2. 鑺傜偣鏃堕棿鎸� `plannedFollowTime + dayOffset` 璁$畻锛�
+3. 鐩稿悓鍩哄噯鏃ュ拰鍛ㄦ湡鏃跺箓绛夛紝涓嶉噸澶嶇敓鎴愶紱
+4. `plannedFollowTime` 涓虹┖鏃剁敓鎴愨�滃緟琛ュ厖鈥濊鍒掞紝涓嶇敓鎴愯妭鐐癸紱
+5. 鍎夸繚妗f浣跨敤 `parentPhone` 鍏滃簳锛�
+6. 闈炰附姘村骞兼満鏋勪笉鐢熸垚璁″垝銆�
+
+### 2.3 `MchFollowupSendServiceCheck`
+
+浣跨敤鍔ㄦ�佷唬鐞嗘ā鎷� Mapper锛屽苟瑕嗗啓娑堟伅鍙戦�佸櫒锛岃鐩栵細
+
+1. 鐭俊鍙戦�佹垚鍔燂細
+   - 鑺傜偣鐘舵�佺疆涓烘垚鍔燂紱
+   - 鍐欏叆绗笁鏂规秷鎭� ID锛�
+   - 鍐欏彂閫佹棩蹇楋紱
+   - 鏃犲緟鍙戦�佽妭鐐规椂璁″垝缃负瀹屾垚锛�
+2. 瓒呰繃 1 澶╄妭鐐癸細
+   - 涓嶈皟鐢� `claimItem`锛�
+   - 鏍囪杩囨湡锛�
+   - 涓嶅彂閫侊紱
+3. 寰俊鍙戦�佸け璐ワ細
+   - 涓嶈鏁版垚鍔燂紱
+   - 鑺傜偣鍥炲埌寰呭彂閫侊紱
+   - 閲嶈瘯娆℃暟 +1锛�
+   - 鐢熸垚涓嬫閲嶈瘯鏃堕棿銆�
+
+---
+
+## 涓夈�佹墽琛屽懡浠�
+
+### 3.1 缂栬瘧
+
+```bash
+mvn -q -DskipTests compile
+mvn -q -pl smartor -am -DskipTests test-compile
+```
+
+缁撴灉锛歚exitCode=0`銆�
+
+### 3.2 鐢熸垚渚濊禆 classpath
+
+```bash
+mvn -q -pl smartor dependency:build-classpath \
+  -Dmdep.outputFile=target/mch-cp.txt
+```
+
+### 3.3 鎵ц鑷
+
+```bash
+CP="smartor/target/classes;smartor/target/test-classes;$(cat smartor/target/mch-cp.txt)"
+
+java -Dfile.encoding=UTF-8 -cp "$CP" \
+  com.smartor.service.mch.MchFollowupLogicCheck
+
+java -Dfile.encoding=UTF-8 -cp "$CP" \
+  com.smartor.service.mch.MchFollowupPlanServiceCheck
+
+java -Dfile.encoding=UTF-8 -cp "$CP" \
+  com.smartor.service.mch.MchFollowupSendServiceCheck
+```
+
+### 3.4 缁撴灉鎽樿
+
+```text
+MchFollowupLogicCheck        PASS=40锛孎AIL=0
+MchFollowupPlanServiceCheck  PASS=19锛孎AIL=0
+MchFollowupSendServiceCheck  PASS=18锛孎AIL=0
+```
+
+---
+
+## 鍥涖�侀噸鐐归獙璇佺粨鏋�
+
+### 4.1 鏃堕棿璁$畻
+
+| 鍦烘櫙 | 鏈熸湜 | 瀹為檯 | 缁撴灉 |
+|---|---|---|---|
+| 鍩哄噯鏃� 14:30锛宒ayOffset=0锛屾棤 sendTime | 14:30 | 14:30 | 閫氳繃 |
+| 鍩哄噯鏃� 14:30锛宒ayOffset=3锛屾棤 sendTime | 绗�3澶� 14:30 | 绗�3澶� 14:30 | 閫氳繃 |
+| dayOffset=7锛宻endTime=09:00 | 绗�7澶� 09:00 | 绗�7澶� 09:00 | 閫氳繃 |
+| 鍩哄噯鏃� 00:00锛屾棤 sendTime | 09:00 | 09:00 | 閫氳繃 |
+
+### 4.2 琛ュ彂绐楀彛
+
+| 鍦烘櫙 | 鏈熸湜 | 瀹為檯 | 缁撴灉 |
+|---|---|---|---|
+| 鏈潵鑺傜偣 | PENDING | PENDING | 閫氳繃 |
+| 1 灏忔椂鍐呭埌鏈� | SEND | SEND | 閫氳繃 |
+| 鎭板ソ 24 灏忔椂 | SEND | SEND | 閫氳繃 |
+| 瓒呰繃 24 灏忔椂 | EXPIRED | EXPIRED | 閫氳繃 |
+
+### 4.3 璁″垝鐢熸垚
+
+| 鍦烘櫙 | 鏈熸湜 | 瀹為檯 | 缁撴灉 |
+|---|---|---|---|
+| 濡囦繚 3 鑺傜偣 | 3 | 3 | 閫氳繃 |
+| 鐩稿悓鍩哄噯鏃�/鍛ㄦ湡閲嶅璋冪敤 | 0 | 0 | 閫氳繃 |
+| 鎷熼殢璁挎椂闂翠负绌� | 0 鑺傜偣锛岃鍒掑緟琛ュ厖 | 涓�鑷� | 閫氳繃 |
+| 鍎夸繚浣跨敤 parentPhone | 13700000000 | 13700000000 | 閫氳繃 |
+| 闈炰附姘村骞� | 0 | 0 | 閫氳繃 |
+
+### 4.4 鍙戦�佺姸鎬�
+
+| 鍦烘櫙 | 鏈熸湜 | 瀹為檯 | 缁撴灉 |
+|---|---|---|---|
+| 鐭俊鎴愬姛 | 鑺傜偣鐘舵�� 2 | 2 | 閫氳繃 |
+| 瓒呰繃 1 澶� | 鑺傜偣鐘舵�� 4 | 4 | 閫氳繃 |
+| 寰俊澶辫触 | 鑺傜偣鐘舵�� 0锛岄噸璇曟鏁� 1 | 涓�鑷� | 閫氳繃 |
+
+---
+
+## 浜斻�佹湰鍦版暟鎹簱 DDL 瀹炴祴
+
+### 5.1 娴嬭瘯搴�
+
+浣跨敤 `application-druid.yml` 褰撳墠閰嶇疆鐨勬湰鍦�/寮�鍙戝簱锛�
+
+```text
+database = smartor_lishui
+version  = MySQL 5.7.34
+```
+
+鎵ц鍓嶅凡鑷姩澶囦唤鍘熻〃缁撴瀯锛�
+
+```text
+target/ddlcheck/backup-before-20261117.sql
+```
+
+### 5.2 鎵ц缁撴灉
+
+鎵ц鑴氭湰锛�
+
+```text
+sql/mch_followup_plan_20261117.sql
+```
+
+鍏� 6 鏉� DDL 璇彞锛屽叏閮ㄦ墽琛屾垚鍔燂細
+
+| 搴忓彿 | 璇彞 | 缁撴灉 |
+|---|---|---|
+| 1 | `pat_maternity_archive_detail.followup_period` 鈫� `TEXT` | 鎴愬姛 |
+| 2 | `pat_child_archive_detail.followup_period` 鈫� `TEXT` | 鎴愬姛 |
+| 3 | `pat_specific_archive_generate_config.followup_period` 鈫� `TEXT` | 鎴愬姛 |
+| 4 | 鍒涘缓 `mch_followup_plan` | 鎴愬姛 |
+| 5 | 鍒涘缓 `mch_followup_plan_item` | 鎴愬姛 |
+| 6 | 鍒涘缓 `mch_followup_send_log` | 鎴愬姛 |
+
+### 5.3 楠岃瘉缁撴灉
+
+| 楠岃瘉椤� | 缁撴灉 |
+|---|---|
+| 3 涓� `followup_period` 瀛楁绫诲瀷鍧囦负 `TEXT` | 閫氳繃 |
+| `mch_followup_plan` 瀛樺湪 | 閫氳繃 |
+| `mch_followup_plan_item` 瀛樺湪 | 閫氳繃 |
+| `mch_followup_send_log` 瀛樺湪 | 閫氳繃 |
+| 鍞竴绱㈠紩 `uk_mch_plan_seq` 瀛樺湪 | 閫氳繃 |
+| 璁″垝 + 鑺傜偣 + 鏃ュ織 DML 鍐欏叆/鍏宠仈鏌ヨ | 閫氳繃 |
+| DML 浜嬪姟鍥炴粴 | 閫氳繃 |
+| 娴嬭瘯鏁版嵁娓呯悊鍚庝笁寮犳柊琛ㄨ鏁� | `0 / 0 / 0` |
+
+### 5.4 鍘熻〃鏁版嵁妫�鏌�
+
+鎵ц鍓嶅悗缁熻涓�鑷达細
+
+```text
+pat_maternity_archive_detail           rows=4, max_followup_period_len=110
+pat_child_archive_detail               rows=3, max_followup_period_len=0
+pat_specific_archive_generate_config   rows=1, max_followup_period_len=2
+```
+
+璇存槑锛�
+
+- 鏈娴嬭瘯搴撲腑 `followup_period` 鍘熸湰宸茬粡鏄� `TEXT`锛宍MODIFY COLUMN` 涓哄箓绛夋搷浣滐紱
+- 鍏朵粬浠嶄负 `varchar(100)` 鐨勭幆澧冩墽琛岃剼鏈椂浼氭甯告墿灞曚负 `TEXT`锛�
+- 娴嬭瘯鏁版嵁宸插洖婊�/娓呯悊锛屾柊琛ㄤ负绌恒��
+
+---
+
+## 鍏�佹湭瑕嗙洊椤�
+
+浠ヤ笅鍐呭鏈湪鏈鑷姩鍖栨祴璇曚腑瑕嗙洊锛岄渶瑕佸湪娴嬭瘯鐜琛ュ厖楠岃瘉锛�
+
+1. **MyBatis XML 涓庣湡瀹炴暟鎹簱鐨� SQL 鍏煎鎬�**  
+   宸叉墽琛� DDL 鍜� JDBC DML锛屼絾鏈�氳繃 MyBatis 鎵ц `selectDueItems`銆乣selectCandidates`銆乣updateSendResult` 绛� SQL銆�
+   宸插仛 XML 鍙В鏋愭�ф鏌ワ紝浣嗘湭杩炴帴鏁版嵁搴撴墽琛� `selectDueItems`銆乣selectCandidates`銆乣updateSendResult` 绛� SQL銆�
+
+3. **鐪熷疄浜慚AS鐭俊鍙戦��**  
+   鏈皟鐢ㄧ湡瀹炰簯MAS鎺ュ彛锛岄伩鍏嶄骇鐢熺湡瀹炵煭淇¤垂鐢ㄥ拰鎮h�呮墦鎵般��
+
+4. **鐪熷疄涓芥按濡囧辜寰俊鍙戦��**  
+   鏈皟鐢ㄧ湡瀹� `sendChatLs` 鎺ュ彛锛岄伩鍏嶅悜鐪熷疄鎮h�呭彂閫佹秷鎭��
+
+5. **Spring 瀹瑰櫒鍚姩楠岃瘉**  
+   鏈惎鍔ㄥ畬鏁� `ruoyi-admin`锛屽缓璁湪娴嬭瘯鐜鍚姩鍚庣‘璁わ細
+   - `IMchFollowupPlanService` / `IMchFollowupSendService` 娉ㄥ叆姝e父锛�
+   - `RyTask` 鑳借皟鐢ㄦ柊浠诲姟锛�
+   - 妗f淇濆瓨鍚庤鍒掕〃鏈夋暟鎹��
+
+6. **澶氳妭鐐瑰苟鍙戝彂閫�**  
+   褰撳墠鍙戦�佷换鍔℃湭鍔犲垎甯冨紡閿侊紝鐢熶骇鐜寤鸿鍙湪 8095 鑺傜偣鎵ц锛屽苟璁剧疆鈥滅姝㈠苟鍙戔�濄��
+
+---
+
+## 涓冦�侀闄╀笌寤鸿
+
+1. `followup_period` 鍦ㄩ儴鍒嗙幆澧冧粛涓� `varchar(100)`锛屽繀椤绘墽琛� DDL 鎵╁睍涓� `TEXT`锛屽惁鍒欏寘鍚彂閫佸唴瀹圭殑 JSON 浼氳鎴柇锛涙湰娆� `smartor_lishui` 娴嬭瘯搴撳師鏈凡鏄� `TEXT`锛岃剼鏈箓绛夋墽琛屾垚鍔熴��
+2. 鑷姩鐢熸垚濡囧辜妗f鏃讹紝`plannedFollowTime` 浼樺厛鍙� `pat_med_outhosp.fudate` / `pat_med_inhosp.fudate`锛涘鏋� HIS 娌$粰闅忚鏃ユ湡锛岃鍒掍細杩涘叆鈥滃緟琛ュ厖鈥濈姸鎬併��
+3. 杩囨湡鑺傜偣鍙爣璁颁笉鍙戦�侊紝绗﹀悎鈥滃彧琛ュ彂 1 澶╁唴鈥濈殑涓氬姟鍙e緞銆�
+4. 浜慚AS/寰俊閰嶇疆閿欒鍙奖鍝嶅搴旇妭鐐癸紝涓嶄細闃绘柇璁″垝鐢熸垚銆�
+5. 寤鸿涓婄嚎鍓嶇敤涓�鏉℃祴璇曟。妗堝畬鏁磋蛋涓�閬嶏細
+   - 妗f淇濆瓨 鈫� 璁″垝鐢熸垚锛�
+   - 淇敼 `plannedFollowTime` 鈫� 鏃ц妭鐐瑰彇娑堛�佹柊鑺傜偣鐢熸垚锛�
+   - 鍒版湡鑺傜偣 鈫� 鐭俊/寰俊鍙戦�侊紱
+   - 瓒呰繃 1 澶╄妭鐐� 鈫� 鏍囪杩囨湡銆�
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
index 5aa2a76..109361b 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
@@ -38,6 +38,8 @@
 import com.ruoyi.task.domain.VO.ServiceSubtaskDetailTraceVO;
 import com.smartor.mapper.*;
 import com.smartor.service.*;
+import com.smartor.service.mch.IMchFollowupPlanService;
+import com.smartor.service.mch.IMchFollowupSendService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.ObjectUtils;
@@ -150,6 +152,12 @@
 
     @Autowired
     private IPatSpecificArchiveGenerateService patSpecificArchiveGenerateService;
+
+    @Autowired
+    private IMchFollowupPlanService mchFollowupPlanService;
+
+    @Autowired
+    private IMchFollowupSendService mchFollowupSendService;
 
     @Autowired
     private com.ruoyi.task.event.FollowupCompletedEventPublisher followupCompletedEventPublisher;
@@ -2373,4 +2381,32 @@
         }
     }
 
+    /**
+     * 濡囧辜闅忚锛氫负宸叉湁濡囧辜妗f琛ュ缓璁″垝銆�
+     *
+     * <p>妗f鏂板/淇敼鏃朵細鑷姩閲嶅缓璁″垝锛涙湰浠诲姟鐢ㄤ簬鍘嗗彶鏁版嵁琛ュ缓鍜屽紓甯歌ˉ鍋裤��</p>
+     */
+    public void generateMchFollowupPlan() {
+        try {
+            int generated = mchFollowupPlanService.rebuildAll(200);
+            log.info("銆恎enerateMchFollowupPlan銆戝骞奸殢璁胯鍒掕ˉ寤哄畬鎴愶紝鐢熸垚鑺傜偣鏁�={}", generated);
+        } catch (Exception e) {
+            log.error("銆恎enerateMchFollowupPlan銆戝骞奸殢璁胯鍒掕ˉ寤哄け璐�", e);
+        }
+    }
+
+    /**
+     * 濡囧辜闅忚锛氭壂鎻忓埌鏈熻妭鐐瑰苟鍙戦�併��
+     *
+     * <p>鍙ˉ鍙� 1 澶╁唴鍒版湡鐨勮妭鐐癸紱瓒呰繃 1 澶╂爣璁拌繃鏈熴�傜煭淇¤蛋浜慚AS锛屽井淇¤蛋 sendChatLs銆�</p>
+     */
+    public void sendMchFollowup() {
+        try {
+            int sent = mchFollowupSendService.sendDue(200);
+            log.info("銆恠endMchFollowup銆戝骞奸殢璁垮彂閫佸畬鎴愶紝鎴愬姛鏁伴噺={}", sent);
+        } catch (Exception e) {
+            log.error("銆恠endMchFollowup銆戝骞奸殢璁垮彂閫佸け璐�", e);
+        }
+    }
+
 }
diff --git a/smartor/src/main/java/com/smartor/common/MchFollowupConstants.java b/smartor/src/main/java/com/smartor/common/MchFollowupConstants.java
new file mode 100644
index 0000000..7eb2ee7
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/common/MchFollowupConstants.java
@@ -0,0 +1,79 @@
+package com.smartor.common;
+
+/**
+ * 濡囧辜闅忚璁″垝鐩稿叧甯搁噺銆�
+ *
+ * <p>濡囧辜闅忚鍙�傜敤浜庝附姘村競濡囧辜淇濆仴闄紝涓斾娇鐢ㄧ嫭绔嬬殑璁″垝琛ㄥ拰鍙戦�佷换鍔★紝
+ * 涓嶈繘鍏ユ櫘閫氶殢璁跨殑 {@code service_subtask_preachform} / {@code compensateTask} 琛ュ伩閾捐矾銆�</p>
+ */
+public final class MchFollowupConstants {
+
+    /** 妗f绫诲瀷锛氬淇� */
+    public static final String ARCHIVE_TYPE_MATERNITY = "1";
+
+    /** 妗f绫诲瀷锛氬効淇� */
+    public static final String ARCHIVE_TYPE_CHILD = "2";
+
+    /** 璁″垝鐘舵�侊細鏈夋晥 */
+    public static final String PLAN_STATUS_ACTIVE = "0";
+
+    /** 璁″垝鐘舵�侊細宸插彇娑� */
+    public static final String PLAN_STATUS_CANCELED = "1";
+
+    /** 璁″垝鐘舵�侊細宸插畬鎴� */
+    public static final String PLAN_STATUS_COMPLETED = "2";
+
+    /** 璁″垝鐘舵�侊細寰呰ˉ鍏呭熀鍑嗘棩/閰嶇疆寮傚父 */
+    public static final String PLAN_STATUS_WAITING = "3";
+
+    /** 鑺傜偣鐘舵�侊細寰呭彂閫� */
+    public static final String ITEM_STATUS_PENDING = "0";
+
+    /** 鑺傜偣鐘舵�侊細鍙戦�佷腑 */
+    public static final String ITEM_STATUS_SENDING = "1";
+
+    /** 鑺傜偣鐘舵�侊細鎴愬姛 */
+    public static final String ITEM_STATUS_SUCCESS = "2";
+
+    /** 鑺傜偣鐘舵�侊細澶辫触锛堥噸璇曡�楀敖锛� */
+    public static final String ITEM_STATUS_FAILED = "3";
+
+    /** 鑺傜偣鐘舵�侊細杩囨湡锛堣秴杩囪ˉ鍙戠獥鍙o紝鏈彂閫侊級 */
+    public static final String ITEM_STATUS_EXPIRED = "4";
+
+    /** 鑺傜偣鐘舵�侊細鍙栨秷 */
+    public static final String ITEM_STATUS_CANCELED = "5";
+
+    /** 鑺傜偣鐘舵�侊細璺宠繃锛堟墜鏈哄彿涓虹┖绛夛級 */
+    public static final String ITEM_STATUS_SKIPPED = "6";
+
+    /** 鍙戦�佹柟寮忥細鐭俊 */
+    public static final String SEND_TYPE_SMS = "sms";
+
+    /** 鍙戦�佹柟寮忥細寰俊鍏紬鍙� */
+    public static final String SEND_TYPE_WECHAT = "wechat";
+
+    /** 琛ュ彂绐楀彛锛氬彧琛ュ彂 1 澶╁唴鍒版湡鐨勮妭鐐广�� */
+    public static final long CATCHUP_MILLIS = 24L * 60L * 60L * 1000L;
+
+    /** 榛樿鏈�澶ч噸璇曟鏁般�� */
+    public static final int DEFAULT_MAX_RETRY = 3;
+
+    /** 榛樿閲嶈瘯闂撮殧锛堝垎閽燂級銆� */
+    public static final int DEFAULT_RETRY_DELAY_MINUTES = 10;
+
+    /** 鍗曟鎵弿榛樿涓婇檺銆� */
+    public static final int DEFAULT_BATCH_SIZE = 200;
+
+    /** 鍚敤寮�鍏筹紙sys_config锛屾寜鏈烘瀯璇诲彇锛涚己鐪佽涓哄惎鐢級銆� */
+    public static final String CONFIG_ENABLED = "mch.followup.enabled";
+
+    /** 浜慚AS 鐭俊閰嶇疆锛坰ys_config锛屾寜鏈烘瀯璇诲彇锛夈�� */
+    public static final String CONFIG_YUNMAS = "ls.msg.yunmas";
+
+    /** 涓芥按濡囧辜寰俊閰嶇疆锛坰ys_config锛屾寜鏈烘瀯璇诲彇锛涗负绌烘椂浣跨敤 SmsUtils 鍐呯疆榛樿閰嶇疆锛夈�� */
+    public static final String CONFIG_LS_WX = "ls.wx.fuyou";
+
+    private MchFollowupConstants() {
+    }
+}
diff --git a/smartor/src/main/java/com/smartor/domain/MchFollowupArchiveCandidate.java b/smartor/src/main/java/com/smartor/domain/MchFollowupArchiveCandidate.java
new file mode 100644
index 0000000..c7bb3ae
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/domain/MchFollowupArchiveCandidate.java
@@ -0,0 +1,20 @@
+package com.smartor.domain;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 濡囧辜闅忚琛ヨ鍒掓壂鎻忓�欓�夈��
+ */
+@Data
+public class MchFollowupArchiveCandidate implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String archiveType;
+
+    private Long archiveId;
+
+    private Long archiveDetailId;
+}
diff --git a/smartor/src/main/java/com/smartor/domain/MchFollowupNode.java b/smartor/src/main/java/com/smartor/domain/MchFollowupNode.java
new file mode 100644
index 0000000..5db2b3c
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/domain/MchFollowupNode.java
@@ -0,0 +1,32 @@
+package com.smartor.domain;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * followupPeriod JSON 瑙f瀽鍚庣殑鍙戦�佽妭鐐瑰畾涔夛紙灏氭湭璁$畻缁濆鍙戦�佹椂闂达級銆�
+ */
+@Data
+public class MchFollowupNode implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private Integer seq;
+
+    private Integer dayOffset;
+
+    /** HH:mm 鎴� HH:mm:ss锛屽彲涓虹┖ */
+    private String sendTime;
+
+    /** sms / wechat */
+    private String sendType;
+
+    private String content;
+
+    private String titleName;
+
+    private Long templateId;
+
+    private String url;
+}
diff --git a/smartor/src/main/java/com/smartor/domain/MchFollowupPlan.java b/smartor/src/main/java/com/smartor/domain/MchFollowupPlan.java
new file mode 100644
index 0000000..d4a2e30
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/domain/MchFollowupPlan.java
@@ -0,0 +1,76 @@
+package com.smartor.domain;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 濡囧辜闅忚璁″垝涓昏〃 mch_followup_plan銆�
+ *
+ * <p>涓�涓。妗堣鎯呭搴斾竴鏉℃湁鏁堣鍒掞紱璁″垝涓嬫寕澶氫釜鍙戦�佽妭鐐广��
+ * plannedFollowTime 鏄暣涓懆鏈熺殑鍩哄噯鏃ワ紝鑺傜偣鍙戦�佹椂闂� = 鍩哄噯鏃� + dayOffset銆�</p>
+ */
+@Data
+@ApiModel(value = "濡囧辜闅忚璁″垝")
+public class MchFollowupPlan implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
+
+    @ApiModelProperty(value = "鏈烘瀯ID")
+    private String orgid;
+
+    @ApiModelProperty(value = "闄㈠尯ID")
+    private String campusid;
+
+    @ApiModelProperty(value = "妗f绫诲瀷锛�1濡囦繚 2鍎夸繚")
+    private String archiveType;
+
+    @ApiModelProperty(value = "妗f涓昏〃ID")
+    private Long archiveId;
+
+    @ApiModelProperty(value = "妗f璇︽儏ID")
+    private Long archiveDetailId;
+
+    @ApiModelProperty(value = "鏉ユ簮绫诲瀷锛�1闂ㄨ瘖 2浣忛櫌闅忚 3鎵嬪伐")
+    private String sourceType;
+
+    @ApiModelProperty(value = "鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙�")
+    private String sourceBizNo;
+
+    @ApiModelProperty(value = "鎮h�匢D")
+    private Long patid;
+
+    @ApiModelProperty(value = "鎮h�呭鍚�")
+    private String patname;
+
+    @ApiModelProperty(value = "鑱旂郴鐢佃瘽")
+    private String phone;
+
+    @ApiModelProperty(value = "璇佷欢鍙风爜")
+    private String idcardno;
+
+    @ApiModelProperty(value = "鍛ㄦ湡鍩哄噯鏃�")
+    private Date plannedFollowTime;
+
+    @ApiModelProperty(value = "闅忚鍛ㄦ湡 JSON 蹇収")
+    private String followupPeriod;
+
+    @ApiModelProperty(value = "璁″垝鐘舵�侊細0鏈夋晥 1鍙栨秷 2瀹屾垚 3寰呰ˉ鍏�/閰嶇疆寮傚父")
+    private String planStatus;
+
+    @ApiModelProperty(value = "澶囨敞")
+    private String remark;
+
+    private Date createTime;
+
+    private Date updateTime;
+
+    @ApiModelProperty(value = "鍙戦�佽妭鐐癸紙闈炶〃瀛楁锛�")
+    private List<MchFollowupPlanItem> items;
+}
diff --git a/smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java b/smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java
new file mode 100644
index 0000000..d8f94f2
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java
@@ -0,0 +1,66 @@
+package com.smartor.domain;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 濡囧辜闅忚璁″垝鍙戦�佽妭鐐� mch_followup_plan_item銆�
+ */
+@Data
+@ApiModel(value = "濡囧辜闅忚璁″垝鍙戦�佽妭鐐�")
+public class MchFollowupPlanItem implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
+
+    @ApiModelProperty(value = "璁″垝ID")
+    private Long planId;
+
+    @ApiModelProperty(value = "鑺傜偣椤哄簭")
+    private Integer seq;
+
+    @ApiModelProperty(value = "鍙戦�佹柟寮忥細sms/wechat")
+    private String sendType;
+
+    @ApiModelProperty(value = "鍙戦�佹椂闂�")
+    private Date sendTime;
+
+    @ApiModelProperty(value = "寰俊鏍囬")
+    private String titleName;
+
+    @ApiModelProperty(value = "鍙戦�佸唴瀹�")
+    private String content;
+
+    @ApiModelProperty(value = "寰俊妯℃澘ID")
+    private Long templateId;
+
+    @ApiModelProperty(value = "寰俊璺宠浆鍦板潃")
+    private String url;
+
+    @ApiModelProperty(value = "鍙戦�佺姸鎬侊細0寰呭彂閫� 1鍙戦�佷腑 2鎴愬姛 3澶辫触 4杩囨湡 5鍙栨秷 6璺宠繃")
+    private String sendStatus;
+
+    @ApiModelProperty(value = "宸查噸璇曟鏁�")
+    private Integer retryCount;
+
+    @ApiModelProperty(value = "涓嬫閲嶈瘯鏃堕棿")
+    private Date nextRetryTime;
+
+    @ApiModelProperty(value = "瀹為檯鍙戦�佹椂闂�")
+    private Date sendTimeActual;
+
+    @ApiModelProperty(value = "缁撴灉璇存槑")
+    private String resultMsg;
+
+    @ApiModelProperty(value = "绗笁鏂规秷鎭疘D")
+    private String providerMsgId;
+
+    private Date createTime;
+
+    private Date updateTime;
+}
diff --git a/smartor/src/main/java/com/smartor/domain/MchFollowupSendLog.java b/smartor/src/main/java/com/smartor/domain/MchFollowupSendLog.java
new file mode 100644
index 0000000..96f7635
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/domain/MchFollowupSendLog.java
@@ -0,0 +1,33 @@
+package com.smartor.domain;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 濡囧辜闅忚鍙戦�佹棩蹇� mch_followup_send_log銆�
+ */
+@Data
+public class MchFollowupSendLog implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
+
+    private Long planId;
+
+    private Long itemId;
+
+    private String sendType;
+
+    private String requestBody;
+
+    private String responseBody;
+
+    private String sendStatus;
+
+    private String resultMsg;
+
+    private Date createTime;
+}
diff --git a/smartor/src/main/java/com/smartor/mapper/MchFollowupPlanItemMapper.java b/smartor/src/main/java/com/smartor/mapper/MchFollowupPlanItemMapper.java
new file mode 100644
index 0000000..2e166a8
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/mapper/MchFollowupPlanItemMapper.java
@@ -0,0 +1,38 @@
+package com.smartor.mapper;
+
+import com.smartor.domain.MchFollowupPlanItem;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 濡囧辜闅忚璁″垝鑺傜偣 Mapper銆�
+ */
+@Mapper
+public interface MchFollowupPlanItemMapper {
+
+    int insertMchFollowupPlanItem(MchFollowupPlanItem item);
+
+    int updateMchFollowupPlanItem(MchFollowupPlanItem item);
+
+    int updateSendResult(MchFollowupPlanItem item);
+
+    MchFollowupPlanItem selectMchFollowupPlanItemById(@Param("id") Long id);
+
+    List<MchFollowupPlanItem> selectByPlanId(@Param("planId") Long planId);
+
+    /**
+     * 鏌ヨ鍒版湡鑺傜偣锛氳鍒掓湁鏁堛�佹満鏋勪负涓芥按濡囧辜銆佸緟鍙戦�併�佸埌杈惧彂閫佹椂闂淬�佷笖涓嶅湪閲嶈瘯绛夊緟涓��
+     */
+    List<MchFollowupPlanItem> selectDueItems(@Param("orgid") String orgid,
+                                             @Param("now") Date now,
+                                             @Param("limit") int limit);
+
+    int claimItem(@Param("id") Long id, @Param("now") Date now);
+
+    int cancelPendingByPlanId(@Param("planId") Long planId, @Param("now") Date now);
+
+    int countPendingByPlanId(@Param("planId") Long planId);
+}
diff --git a/smartor/src/main/java/com/smartor/mapper/MchFollowupPlanMapper.java b/smartor/src/main/java/com/smartor/mapper/MchFollowupPlanMapper.java
new file mode 100644
index 0000000..871f3ed
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/mapper/MchFollowupPlanMapper.java
@@ -0,0 +1,32 @@
+package com.smartor.mapper;
+
+import com.smartor.domain.MchFollowupArchiveCandidate;
+import com.smartor.domain.MchFollowupPlan;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 濡囧辜闅忚璁″垝涓昏〃 Mapper銆�
+ */
+@Mapper
+public interface MchFollowupPlanMapper {
+
+    int insertMchFollowupPlan(MchFollowupPlan plan);
+
+    int updateMchFollowupPlan(MchFollowupPlan plan);
+
+    MchFollowupPlan selectMchFollowupPlanById(@Param("id") Long id);
+
+    List<MchFollowupPlan> selectActiveByArchive(@Param("archiveType") String archiveType,
+                                                @Param("archiveId") Long archiveId,
+                                                @Param("archiveDetailId") Long archiveDetailId);
+
+    int cancelById(@Param("id") Long id, @Param("updateTime") java.util.Date updateTime);
+
+    int completeById(@Param("id") Long id, @Param("updateTime") java.util.Date updateTime);
+
+    List<MchFollowupArchiveCandidate> selectCandidates(@Param("orgid") String orgid,
+                                                       @Param("limit") int limit);
+}
diff --git a/smartor/src/main/java/com/smartor/mapper/MchFollowupSendLogMapper.java b/smartor/src/main/java/com/smartor/mapper/MchFollowupSendLogMapper.java
new file mode 100644
index 0000000..8b1c924
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/mapper/MchFollowupSendLogMapper.java
@@ -0,0 +1,13 @@
+package com.smartor.mapper;
+
+import com.smartor.domain.MchFollowupSendLog;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 濡囧辜闅忚鍙戦�佹棩蹇� Mapper銆�
+ */
+@Mapper
+public interface MchFollowupSendLogMapper {
+
+    int insertMchFollowupSendLog(MchFollowupSendLog log);
+}
diff --git a/smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java
index 9ccd188..d6b44ef 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java
@@ -6,9 +6,11 @@
 import com.ruoyi.common.utils.StringUtils;
 import com.smartor.domain.PatChildArchive;
 import com.smartor.domain.PatChildArchiveDetail;
+import com.smartor.common.MchFollowupConstants;
 import com.smartor.mapper.PatChildArchiveMapper;
 import com.smartor.service.IPatChildArchiveDetailService;
 import com.smartor.service.IPatChildArchiveService;
+import com.smartor.service.mch.IMchFollowupPlanService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,6 +34,9 @@
 
     @Autowired
     private IPatChildArchiveDetailService patChildArchiveDetailService;
+
+    @Autowired
+    private IMchFollowupPlanService mchFollowupPlanService;
 
     @Override
     public PatChildArchive selectPatChildArchiveById(Long id)
@@ -191,6 +196,18 @@
             patChildArchiveDetailService.insertPatChildArchiveDetail(patChildArchiveDetail);
         }
 
+        // 濡囧辜闅忚璁″垝锛氭。妗堟柊澧�/淇敼鍚庢寜 plannedFollowTime + followupPeriod 閲嶅缓
+        try {
+            if (mchFollowupPlanService != null) {
+                mchFollowupPlanService.rebuildForArchive(
+                        MchFollowupConstants.ARCHIVE_TYPE_CHILD,
+                        patChildArchive.getId(), patChildArchiveDetail.getId());
+            }
+        } catch (Exception e) {
+            log.error("濡囧辜闅忚璁″垝閲嶅缓澶辫触锛宎rchiveId={}锛宒etailId={}",
+                    patChildArchive.getId(), patChildArchiveDetail.getId(), e);
+        }
+
         log.info("insertOrUpdateChildArchive澶勭悊瀹屾垚锛屼富琛╥d锛歿}锛岃鎯卛d锛歿}", patChildArchive.getId(), patChildArchiveDetail.getId());
         return patChildArchive.getId().intValue();
     }
diff --git a/smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java
index e7744d3..d7c6fa9 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java
@@ -8,10 +8,12 @@
 import com.smartor.domain.PatChildArchiveDetail;
 import com.smartor.domain.PatMaternityArchive;
 import com.smartor.domain.PatMaternityArchiveDetail;
+import com.smartor.common.MchFollowupConstants;
 import com.smartor.mapper.PatMaternityArchiveDetailMapper;
 import com.smartor.mapper.PatMaternityArchiveMapper;
 import com.smartor.service.IPatMaternityArchiveDetailService;
 import com.smartor.service.IPatMaternityArchiveService;
+import com.smartor.service.mch.IMchFollowupPlanService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -37,6 +39,9 @@
     private IPatMaternityArchiveDetailService patMaternityArchiveDetailService;
     @Autowired
     private PatMaternityArchiveDetailMapper patMaternityArchiveDetailMapper;
+
+    @Autowired
+    private IMchFollowupPlanService mchFollowupPlanService;
 
     @Override
     public PatMaternityArchive selectPatMaternityArchiveById(Long id)
@@ -215,6 +220,18 @@
             patMaternityArchiveDetailService.insertPatMaternityArchiveDetail(patMaternityArchiveDetail);
         }
 
+        // 濡囧辜闅忚璁″垝锛氭。妗堟柊澧�/淇敼鍚庢寜 plannedFollowTime + followupPeriod 閲嶅缓
+        try {
+            if (mchFollowupPlanService != null) {
+                mchFollowupPlanService.rebuildForArchive(
+                        MchFollowupConstants.ARCHIVE_TYPE_MATERNITY,
+                        patMaternityArchive.getId(), patMaternityArchiveDetail.getId());
+            }
+        } catch (Exception e) {
+            log.error("濡囧辜闅忚璁″垝閲嶅缓澶辫触锛宎rchiveId={}锛宒etailId={}",
+                    patMaternityArchive.getId(), patMaternityArchiveDetail.getId(), e);
+        }
+
         log.info("insertOrUpdateMaternityArchive澶勭悊瀹屾垚锛屼富琛╥d锛歿}锛岃鎯卛d锛歿}", patMaternityArchive.getId(), patMaternityArchiveDetail.getId());
         return patMaternityArchive.getId().intValue();
     }
diff --git a/smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateServiceImpl.java
index ee787a2..c0e895c 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateServiceImpl.java
@@ -489,6 +489,7 @@
         PatMaternityArchiveDetail detail = new PatMaternityArchiveDetail();
         detail.setArchiveType(config.getArchiveType());
         detail.setFollowupPeriod(config.getFollowupPeriod());
+        detail.setPlannedFollowTime(patMedOuthosp.getFudate());
         detail.setSourceType(SpecificArchiveConstants.SOURCE_TYPE_OUTHOSP);
         detail.setSourceBizId(patMedOuthosp.getId());
         detail.setSourceBizNo(patMedOuthosp.getOuthospno());
@@ -504,6 +505,7 @@
         PatChildArchiveDetail detail = new PatChildArchiveDetail();
         detail.setArchiveType(config.getArchiveType());
         detail.setFollowupPeriod(config.getFollowupPeriod());
+        detail.setPlannedFollowTime(patMedOuthosp.getFudate());
         detail.setSourceType(SpecificArchiveConstants.SOURCE_TYPE_OUTHOSP);
         detail.setSourceBizId(patMedOuthosp.getId());
         detail.setSourceBizNo(patMedOuthosp.getOuthospno());
@@ -527,6 +529,7 @@
         PatMaternityArchiveDetail detail = new PatMaternityArchiveDetail();
         detail.setArchiveType(config.getArchiveType());
         detail.setFollowupPeriod(config.getFollowupPeriod());
+        detail.setPlannedFollowTime(context.inhosp == null ? null : context.inhosp.getFudate());
         detail.setSourceType(SpecificArchiveConstants.SOURCE_TYPE_INHOSP_FOLLOWUP);
         detail.setSourceBizId(inInhospid(context));
         detail.setSourceBizNo(inInhospno(context));
@@ -574,6 +577,7 @@
         PatChildArchiveDetail detail = new PatChildArchiveDetail();
         detail.setArchiveType(config.getArchiveType());
         detail.setFollowupPeriod(config.getFollowupPeriod());
+        detail.setPlannedFollowTime(context.inhosp == null ? null : context.inhosp.getFudate());
         detail.setSourceType(SpecificArchiveConstants.SOURCE_TYPE_INHOSP_FOLLOWUP);
         detail.setSourceBizId(inInhospid(context));
         detail.setSourceBizNo(inInhospno(context));
diff --git a/smartor/src/main/java/com/smartor/service/mch/IMchFollowupPlanService.java b/smartor/src/main/java/com/smartor/service/mch/IMchFollowupPlanService.java
new file mode 100644
index 0000000..8c52781
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/mch/IMchFollowupPlanService.java
@@ -0,0 +1,25 @@
+package com.smartor.service.mch;
+
+/**
+ * 濡囧辜闅忚璁″垝鏈嶅姟銆�
+ */
+public interface IMchFollowupPlanService {
+
+    /**
+     * 鏍规嵁妗f璇︽儏閲嶅缓濡囧辜闅忚璁″垝銆�
+     *
+     * @param archiveType     1濡囦繚 2鍎夸繚
+     * @param archiveId       妗f涓昏〃ID
+     * @param archiveDetailId 妗f璇︽儏ID
+     * @return 鏂扮敓鎴愮殑鍙戦�佽妭鐐规暟閲�
+     */
+    int rebuildForArchive(String archiveType, Long archiveId, Long archiveDetailId);
+
+    /**
+     * 琛ュ伩鎵弿锛氫负宸叉湁濡囧辜妗f琛ュ缓璁″垝銆�
+     *
+     * @param limit 鍗曟鎵弿涓婇檺
+     * @return 鏂扮敓鎴愮殑鍙戦�佽妭鐐规暟閲�
+     */
+    int rebuildAll(int limit);
+}
diff --git a/smartor/src/main/java/com/smartor/service/mch/IMchFollowupSendService.java b/smartor/src/main/java/com/smartor/service/mch/IMchFollowupSendService.java
new file mode 100644
index 0000000..8632f79
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/mch/IMchFollowupSendService.java
@@ -0,0 +1,15 @@
+package com.smartor.service.mch;
+
+/**
+ * 濡囧辜闅忚鍙戦�佹湇鍔°��
+ */
+public interface IMchFollowupSendService {
+
+    /**
+     * 鎵弿骞跺彂閫佸埌鏈熻妭鐐广��
+     *
+     * @param limit 鍗曟澶勭悊涓婇檺
+     * @return 鏈瀹為檯鍙戦�佹垚鍔熸暟閲�
+     */
+    int sendDue(int limit);
+}
diff --git a/smartor/src/main/java/com/smartor/service/mch/MchFollowupDueDecision.java b/smartor/src/main/java/com/smartor/service/mch/MchFollowupDueDecision.java
new file mode 100644
index 0000000..9af9d13
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/mch/MchFollowupDueDecision.java
@@ -0,0 +1,10 @@
+package com.smartor.service.mch;
+
+/**
+ * 濡囧辜闅忚鍒版湡鍒ゆ柇缁撴灉銆�
+ */
+public enum MchFollowupDueDecision {
+    PENDING,
+    SEND,
+    EXPIRED
+}
diff --git a/smartor/src/main/java/com/smartor/service/mch/MchFollowupMessageSender.java b/smartor/src/main/java/com/smartor/service/mch/MchFollowupMessageSender.java
new file mode 100644
index 0000000..8784bfd
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/mch/MchFollowupMessageSender.java
@@ -0,0 +1,133 @@
+package com.smartor.service.mch;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.sms.SmsUtils;
+import com.ruoyi.system.service.ISysConfigService;
+import com.smartor.common.MchFollowupConstants;
+import com.smartor.domain.MchFollowupPlan;
+import com.smartor.domain.MchFollowupPlanItem;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 濡囧辜闅忚娑堟伅鍙戦�佸櫒銆�
+ *
+ * <p>鐭俊澶嶇敤 {@link SmsUtils#sendYunMasSms}锛屽井淇″鐢�
+ * {@link SmsUtils#sendChatLs}锛堝嵆 {@code /sms/sendChatFuyou} 鐨勫唴閮ㄥ疄鐜帮級銆�
+ * 涓嶇粡杩囨櫘閫氶殢璁跨殑鍙戦�佹柟宸ュ巶涓庤ˉ鍋块摼璺��</p>
+ */
+@Slf4j
+@Component
+public class MchFollowupMessageSender {
+
+    @Autowired
+    private ISysConfigService configService;
+
+    public MchFollowupSendOutcome sendSms(MchFollowupPlan plan, MchFollowupPlanItem item) {
+        String phone = plan == null ? null : plan.getPhone();
+        String content = item == null ? null : item.getContent();
+        if (StringUtils.isBlank(phone)) {
+            return MchFollowupSendOutcome.skip("鎵嬫満鍙蜂负绌�");
+        }
+        if (StringUtils.isBlank(content)) {
+            return MchFollowupSendOutcome.fail("鐭俊鍐呭涓虹┖", requestSummary("sms", phone, null), null);
+        }
+        try {
+            String configJson = configService.selectConfigByKey(
+                    MchFollowupConstants.CONFIG_YUNMAS, plan.getOrgid());
+            SmsUtils.YunMasConfig config = SmsUtils.YunMasConfig.of(configJson);
+            SmsUtils.SmsResult result = SmsUtils.sendYunMasSms(config, phone, content);
+            String requestBody = requestSummary("sms", phone, null);
+            String responseBody = JSON.toJSONString(result);
+            if (result != null && result.isOk()) {
+                return MchFollowupSendOutcome.ok(result.getMsgGroup(), requestBody, responseBody);
+            }
+            String message = result == null ? "浜慚AS杩斿洖涓虹┖" : result.getMessage();
+            return MchFollowupSendOutcome.fail(message, requestBody, responseBody);
+        } catch (Exception e) {
+            log.error("銆愬骞奸殢璁裤�戠煭淇″彂閫佸紓甯革紝planId={}锛宨temId={}", plan.getId(), item.getId(), e);
+            return MchFollowupSendOutcome.fail("鐭俊鍙戦�佸紓甯革細" + e.getMessage(),
+                    requestSummary("sms", phone, null), null);
+        }
+    }
+
+    public MchFollowupSendOutcome sendWechat(MchFollowupPlan plan, MchFollowupPlanItem item) {
+        String phone = plan == null ? null : plan.getPhone();
+        if (StringUtils.isBlank(phone) && StringUtils.isBlank(plan == null ? null : plan.getIdcardno())) {
+            return MchFollowupSendOutcome.skip("鎵嬫満鍙峰拰璇佷欢鍙烽兘涓虹┖");
+        }
+        try {
+            String configJson = configService.selectConfigByKey(
+                    MchFollowupConstants.CONFIG_LS_WX, plan.getOrgid());
+            SmsUtils.LsWxConfig config = SmsUtils.LsWxConfig.of(configJson);
+
+            SmsUtils.LsWxMessage message = new SmsUtils.LsWxMessage();
+            message.setId(item.getTemplateId());
+            message.setPatientId(plan.getPatid() == null ? null : String.valueOf(plan.getPatid()));
+            message.setPatientName(plan.getPatname());
+            message.setIdCard(plan.getIdcardno());
+            message.setMobile(phone);
+            message.setMedCardNo(plan.getSourceBizNo());
+            message.setTitleName(item.getTitleName());
+            message.setContent(item.getContent());
+            message.setUrl(item.getUrl());
+
+            String requestBody = requestSummary("wechat", phone, item.getTemplateId());
+            String resp = SmsUtils.sendChatLs(config, message);
+            String messageText = parseWechatMessage(resp);
+            boolean ok = parseWechatOk(resp);
+            if (ok) {
+                return MchFollowupSendOutcome.ok(null, requestBody, resp);
+            }
+            return MchFollowupSendOutcome.fail(messageText, requestBody, resp);
+        } catch (Exception e) {
+            log.error("銆愬骞奸殢璁裤�戝井淇″彂閫佸紓甯革紝planId={}锛宨temId={}", plan.getId(), item.getId(), e);
+            return MchFollowupSendOutcome.fail("寰俊鍙戦�佸紓甯革細" + e.getMessage(),
+                    requestSummary("wechat", phone, item == null ? null : item.getTemplateId()), null);
+        }
+    }
+
+    private boolean parseWechatOk(String resp) {
+        if (StringUtils.isBlank(resp)) {
+            return false;
+        }
+        try {
+            JSONObject object = JSON.parseObject(resp);
+            return object != null && object.getIntValue("code") == 0;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    private String parseWechatMessage(String resp) {
+        if (StringUtils.isBlank(resp)) {
+            return "寰俊杩斿洖涓虹┖";
+        }
+        try {
+            JSONObject object = JSON.parseObject(resp);
+            if (object == null) {
+                return "寰俊杩斿洖涓虹┖";
+            }
+            String msg = object.getString("msg");
+            return StringUtils.isBlank(msg) ? resp : msg;
+        } catch (Exception e) {
+            return resp;
+        }
+    }
+
+    private String requestSummary(String sendType, String phone, Long templateId) {
+        return "sendType=" + sendType
+                + "锛沺hone=" + maskPhone(phone)
+                + (templateId == null ? "" : "锛泃emplateId=" + templateId);
+    }
+
+    private String maskPhone(String phone) {
+        if (StringUtils.isBlank(phone) || phone.length() < 7) {
+            return phone;
+        }
+        return phone.substring(0, 3) + "****" + phone.substring(phone.length() - 4);
+    }
+}
diff --git a/smartor/src/main/java/com/smartor/service/mch/MchFollowupPeriodParser.java b/smartor/src/main/java/com/smartor/service/mch/MchFollowupPeriodParser.java
new file mode 100644
index 0000000..1c1fd46
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/mch/MchFollowupPeriodParser.java
@@ -0,0 +1,224 @@
+package com.smartor.service.mch;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.smartor.common.MchFollowupConstants;
+import com.smartor.domain.MchFollowupNode;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * 濡囧辜闅忚鍛ㄦ湡 JSON 瑙f瀽鍣ㄣ��
+ *
+ * <p>鏀寔涓ょ鍐欐硶锛�</p>
+ * <pre>
+ * 1) 鏄惧紡鑺傜偣锛�
+ * {
+ *   "items": [
+ *     {"seq":1,"dayOffset":0,"sendTime":"09:00","sendType":"sms","content":"..."},
+ *     {"seq":2,"dayOffset":3,"sendType":"wechat","templateId":16,"content":"..."}
+ *   ]
+ * }
+ *
+ * 2) 闂撮殧 + 娆℃暟锛�
+ * {
+ *   "intervalDays": 3,
+ *   "count": 4,
+ *   "sendType": "sms",
+ *   "content": "..."
+ * }
+ * </pre>
+ *
+ * <p>dayOffset 涓�寰嬭〃绀虹浉瀵� plannedFollowTime 鐨勭粷瀵瑰亸绉诲ぉ鏁帮紝涓嶆槸鈥滀粠涓婁竴娆″彂閫佸悗椤哄欢鈥濄��</p>
+ */
+@Component
+public class MchFollowupPeriodParser {
+
+    public List<MchFollowupNode> parse(String json, String fallbackCycleTimes) {
+        if (StringUtils.isBlank(json)) {
+            throw new IllegalArgumentException("闅忚鍛ㄦ湡 followupPeriod 涓虹┖");
+        }
+        JSONObject root;
+        try {
+            root = JSON.parseObject(json);
+        } catch (Exception e) {
+            throw new IllegalArgumentException("闅忚鍛ㄦ湡涓嶆槸鍚堟硶 JSON锛�" + e.getMessage(), e);
+        }
+        if (root == null) {
+            throw new IllegalArgumentException("闅忚鍛ㄦ湡涓嶆槸鍚堟硶 JSON 瀵硅薄");
+        }
+
+        JSONArray items = root.getJSONArray("items");
+        if (items != null) {
+            return parseItems(items);
+        }
+
+        JSONArray days = root.getJSONArray("days");
+        if (days != null) {
+            return parseDays(days, root);
+        }
+
+        Integer intervalDays = root.getInteger("intervalDays");
+        if (intervalDays != null) {
+            int count = resolveCount(root, fallbackCycleTimes);
+            return parseInterval(intervalDays, count, root);
+        }
+
+        throw new IllegalArgumentException("闅忚鍛ㄦ湡缂哄皯 items / days / intervalDays 閰嶇疆");
+    }
+
+    private List<MchFollowupNode> parseItems(JSONArray items) {
+        if (items.isEmpty()) {
+            throw new IllegalArgumentException("闅忚鍛ㄦ湡 items 涓嶈兘涓虹┖");
+        }
+        List<MchFollowupNode> nodes = new ArrayList<>(items.size());
+        Set<Integer> seqSet = new HashSet<>();
+        for (int i = 0; i < items.size(); i++) {
+            JSONObject item = items.getJSONObject(i);
+            if (item == null) {
+                throw new IllegalArgumentException("闅忚鍛ㄦ湡 items[" + i + "] 涓虹┖");
+            }
+            MchFollowupNode node = buildNode(item, i + 1);
+            if (!seqSet.add(node.getSeq())) {
+                throw new IllegalArgumentException("闅忚鍛ㄦ湡 seq 閲嶅锛�" + node.getSeq());
+            }
+            nodes.add(node);
+        }
+        return nodes;
+    }
+
+    private List<MchFollowupNode> parseDays(JSONArray days, JSONObject root) {
+        if (days.isEmpty()) {
+            throw new IllegalArgumentException("闅忚鍛ㄦ湡 days 涓嶈兘涓虹┖");
+        }
+        List<MchFollowupNode> nodes = new ArrayList<>(days.size());
+        for (int i = 0; i < days.size(); i++) {
+            Integer day = days.getInteger(i);
+            if (day == null || day < 0) {
+                throw new IllegalArgumentException("闅忚鍛ㄦ湡 days[" + i + "] 蹇呴』鏄潪璐熸暣鏁�");
+            }
+            JSONObject item = new JSONObject();
+            item.put("seq", i + 1);
+            item.put("dayOffset", day);
+            copySharedFields(root, item);
+            nodes.add(buildNode(item, i + 1));
+        }
+        return nodes;
+    }
+
+    private List<MchFollowupNode> parseInterval(int intervalDays, int count, JSONObject root) {
+        if (intervalDays < 0) {
+            throw new IllegalArgumentException("intervalDays 涓嶈兘灏忎簬 0");
+        }
+        if (count <= 0) {
+            throw new IllegalArgumentException("count 蹇呴』澶т簬 0");
+        }
+        List<MchFollowupNode> nodes = new ArrayList<>(count);
+        for (int i = 0; i < count; i++) {
+            JSONObject item = new JSONObject();
+            item.put("seq", i + 1);
+            item.put("dayOffset", intervalDays * i);
+            copySharedFields(root, item);
+            nodes.add(buildNode(item, i + 1));
+        }
+        return nodes;
+    }
+
+    private MchFollowupNode buildNode(JSONObject item, int defaultSeq) {
+        MchFollowupNode node = new MchFollowupNode();
+        Integer seq = item.getInteger("seq");
+        node.setSeq(seq == null ? defaultSeq : seq);
+        if (node.getSeq() <= 0) {
+            throw new IllegalArgumentException("闅忚鍛ㄦ湡 seq 蹇呴』澶т簬 0");
+        }
+
+        Integer dayOffset = item.getInteger("dayOffset");
+        if (dayOffset == null) {
+            dayOffset = item.getInteger("day");
+        }
+        if (dayOffset == null || dayOffset < 0) {
+            throw new IllegalArgumentException("闅忚鍛ㄦ湡 dayOffset 蹇呴』鏄潪璐熸暣鏁帮紝seq=" + node.getSeq());
+        }
+        node.setDayOffset(dayOffset);
+
+        String sendType = normalizeSendType(item.getString("sendType"));
+        node.setSendType(sendType);
+        node.setSendTime(normalizeSendTime(item.getString("sendTime")));
+        node.setContent(item.getString("content"));
+        node.setTitleName(item.getString("titleName"));
+        node.setTemplateId(item.getLong("templateId"));
+        node.setUrl(item.getString("url"));
+
+        if (MchFollowupConstants.SEND_TYPE_SMS.equals(sendType)
+                && StringUtils.isBlank(node.getContent())) {
+            throw new IllegalArgumentException("鐭俊鑺傜偣 content 涓嶈兘涓虹┖锛宻eq=" + node.getSeq());
+        }
+        return node;
+    }
+
+    private void copySharedFields(JSONObject root, JSONObject item) {
+        copyIfPresent(root, item, "sendTime");
+        copyIfPresent(root, item, "sendType");
+        copyIfPresent(root, item, "content");
+        copyIfPresent(root, item, "titleName");
+        copyIfPresent(root, item, "templateId");
+        copyIfPresent(root, item, "url");
+    }
+
+    private void copyIfPresent(JSONObject from, JSONObject to, String key) {
+        if (!to.containsKey(key) && from.containsKey(key)) {
+            to.put(key, from.get(key));
+        }
+    }
+
+    private int resolveCount(JSONObject root, String fallbackCycleTimes) {
+        Integer count = root.getInteger("count");
+        if (count == null && StringUtils.isNotBlank(fallbackCycleTimes)) {
+            try {
+                count = Integer.valueOf(fallbackCycleTimes.trim());
+            } catch (NumberFormatException e) {
+                throw new IllegalArgumentException("followupCycleTimes 涓嶆槸鍚堟硶娆℃暟锛�" + fallbackCycleTimes);
+            }
+        }
+        if (count == null || count <= 0) {
+            throw new IllegalArgumentException("intervalDays 妯″紡蹇呴』閰嶇疆 count 鎴� followupCycleTimes");
+        }
+        return count;
+    }
+
+    static String normalizeSendType(String raw) {
+        if (StringUtils.isBlank(raw)) {
+            throw new IllegalArgumentException("闅忚鍛ㄦ湡 sendType 涓嶈兘涓虹┖");
+        }
+        String value = raw.trim().toLowerCase(Locale.ROOT);
+        if ("sms".equals(value) || "4".equals(value) || "鐭俊".equals(raw.trim())) {
+            return MchFollowupConstants.SEND_TYPE_SMS;
+        }
+        if ("wechat".equals(value) || "wechat_mp".equals(value) || "5".equals(value)
+                || "鍏紬鍙�".equals(raw.trim()) || "寰俊".equals(raw.trim())) {
+            return MchFollowupConstants.SEND_TYPE_WECHAT;
+        }
+        throw new IllegalArgumentException("涓嶆敮鎸佺殑 sendType锛�" + raw + "锛堜粎鏀寔 sms/wechat锛�");
+    }
+
+    static String normalizeSendTime(String raw) {
+        if (StringUtils.isBlank(raw)) {
+            return null;
+        }
+        String value = raw.trim();
+        if (value.matches("^([01]\\d|2[0-3]):[0-5]\\d$")) {
+            return value;
+        }
+        if (value.matches("^([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d$")) {
+            return value;
+        }
+        throw new IllegalArgumentException("sendTime 鏍煎紡搴斾负 HH:mm 鎴� HH:mm:ss锛�" + raw);
+    }
+}
diff --git a/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanAssembler.java b/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanAssembler.java
new file mode 100644
index 0000000..2295a5e
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanAssembler.java
@@ -0,0 +1,46 @@
+package com.smartor.service.mch;
+
+import com.smartor.common.MchFollowupConstants;
+import com.smartor.domain.MchFollowupNode;
+import com.smartor.domain.MchFollowupPlanItem;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 鎶婅В鏋愬悗鐨勮妭鐐瑰畾涔夌粍瑁呮垚鍙惤搴撶殑鍙戦�佽妭鐐广��
+ */
+@Component
+public class MchFollowupPlanAssembler {
+
+    @Autowired
+    private MchFollowupTimeResolver timeResolver;
+
+    public List<MchFollowupPlanItem> assemble(Long planId, Date plannedFollowTime, List<MchFollowupNode> nodes) {
+        List<MchFollowupPlanItem> items = new ArrayList<>();
+        if (nodes == null || nodes.isEmpty()) {
+            return items;
+        }
+        Date now = new Date();
+        for (MchFollowupNode node : nodes) {
+            MchFollowupPlanItem item = new MchFollowupPlanItem();
+            item.setPlanId(planId);
+            item.setSeq(node.getSeq());
+            item.setSendType(node.getSendType());
+            item.setSendTime(timeResolver.resolve(plannedFollowTime, node));
+            item.setTitleName(node.getTitleName());
+            item.setContent(node.getContent());
+            item.setTemplateId(node.getTemplateId());
+            item.setUrl(node.getUrl());
+            item.setSendStatus(MchFollowupConstants.ITEM_STATUS_PENDING);
+            item.setRetryCount(0);
+            item.setCreateTime(now);
+            item.setUpdateTime(now);
+            items.add(item);
+        }
+        return items;
+    }
+}
diff --git a/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java b/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java
new file mode 100644
index 0000000..63064f5
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java
@@ -0,0 +1,321 @@
+package com.smartor.service.mch;
+
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.system.service.ISysConfigService;
+import com.smartor.common.MchFollowupConstants;
+import com.smartor.common.SpecificArchiveConstants;
+import com.smartor.domain.MchFollowupArchiveCandidate;
+import com.smartor.domain.MchFollowupNode;
+import com.smartor.domain.MchFollowupPlan;
+import com.smartor.domain.MchFollowupPlanItem;
+import com.smartor.domain.PatChildArchiveDetail;
+import com.smartor.domain.PatMaternityArchiveDetail;
+import com.smartor.mapper.MchFollowupPlanItemMapper;
+import com.smartor.mapper.MchFollowupPlanMapper;
+import com.smartor.mapper.PatChildArchiveDetailMapper;
+import com.smartor.mapper.PatMaternityArchiveDetailMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 濡囧辜闅忚璁″垝鏈嶅姟瀹炵幇銆�
+ *
+ * <p>鍙鐞嗕附姘村競濡囧辜淇濆仴闄€�傝鍒掔敓鎴愪笉鍙戦�佹秷鎭紝鍙戦�佺敱
+ * {@link IMchFollowupSendService} 鐙珛瀹屾垚銆�</p>
+ */
+@Slf4j
+@Service
+public class MchFollowupPlanServiceImpl implements IMchFollowupPlanService {
+
+    @Autowired
+    private MchFollowupPlanMapper planMapper;
+
+    @Autowired
+    private MchFollowupPlanItemMapper itemMapper;
+
+    @Autowired
+    private PatMaternityArchiveDetailMapper maternityDetailMapper;
+
+    @Autowired
+    private PatChildArchiveDetailMapper childDetailMapper;
+
+    @Autowired
+    private MchFollowupPeriodParser periodParser;
+
+    @Autowired
+    private MchFollowupPlanAssembler planAssembler;
+
+    @Autowired
+    private ISysConfigService configService;
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int rebuildForArchive(String archiveType, Long archiveId, Long archiveDetailId) {
+        try {
+            return doRebuildForArchive(archiveType, archiveId, archiveDetailId);
+        } catch (Exception e) {
+            // 璁″垝鐢熸垚澶辫触涓嶈兘褰卞搷妗f涓绘祦绋嬶紝寮傚父鍦ㄤ簨鍔¤竟鐣屽唴娑堝寲
+            log.error("銆愬骞奸殢璁裤�戣鍒掗噸寤哄紓甯革紝archiveType={}锛宎rchiveId={}锛宒etailId={}",
+                    archiveType, archiveId, archiveDetailId, e);
+            return 0;
+        }
+    }
+
+    private int doRebuildForArchive(String archiveType, Long archiveId, Long archiveDetailId) {
+        if (!isEnabled()) {
+            return 0;
+        }
+        ArchiveSnapshot snapshot = loadSnapshot(archiveType, archiveId, archiveDetailId);
+        if (snapshot == null) {
+            return 0;
+        }
+        if (snapshot.archiveId == null || snapshot.archiveDetailId == null) {
+            log.warn("銆愬骞奸殢璁裤�戞。妗堜富閿垨璇︽儏涓婚敭涓虹┖锛岃烦杩囪鍒掗噸寤猴紝archiveType={}锛宎rchiveId={}锛宒etailId={}",
+                    archiveType, archiveId, archiveDetailId);
+            return 0;
+        }
+        if (!SpecificArchiveConstants.LISHUI_MCH_ORG_ID.equals(snapshot.orgid)) {
+            return 0;
+        }
+
+        List<MchFollowupPlan> actives = planMapper.selectActiveByArchive(
+                snapshot.archiveType, snapshot.archiveId, snapshot.archiveDetailId);
+        if (actives == null) {
+            actives = Collections.emptyList();
+        }
+        for (MchFollowupPlan active : actives) {
+            if (sameTime(active.getPlannedFollowTime(), snapshot.plannedFollowTime)
+                    && StringUtils.equals(active.getFollowupPeriod(), snapshot.followupPeriod)) {
+                MchFollowupPlan contactUpdate = new MchFollowupPlan();
+                contactUpdate.setId(active.getId());
+                contactUpdate.setCampusid(snapshot.campusid);
+                contactUpdate.setSourceBizNo(snapshot.sourceBizNo);
+                contactUpdate.setPatname(snapshot.patname);
+                contactUpdate.setPhone(snapshot.phone);
+                contactUpdate.setIdcardno(snapshot.idcardno);
+                contactUpdate.setUpdateTime(DateUtils.getNowDate());
+                planMapper.updateMchFollowupPlan(contactUpdate);
+                log.debug("銆愬骞奸殢璁裤�戣鍒掓湭鍙樺寲锛屼粎鍒锋柊鑱旂郴浜轰俊鎭紝archiveType={}锛宎rchiveId={}锛宒etailId={}",
+                        snapshot.archiveType, snapshot.archiveId, snapshot.archiveDetailId);
+                return 0;
+            }
+        }
+
+        Date now = DateUtils.getNowDate();
+        for (MchFollowupPlan active : actives) {
+            itemMapper.cancelPendingByPlanId(active.getId(), now);
+            planMapper.cancelById(active.getId(), now);
+        }
+
+        MchFollowupPlan plan = new MchFollowupPlan();
+        plan.setOrgid(snapshot.orgid);
+        plan.setCampusid(snapshot.campusid);
+        plan.setArchiveType(snapshot.archiveType);
+        plan.setArchiveId(snapshot.archiveId);
+        plan.setArchiveDetailId(snapshot.archiveDetailId);
+        plan.setSourceType(snapshot.sourceType);
+        plan.setSourceBizNo(snapshot.sourceBizNo);
+        plan.setPatid(snapshot.patid);
+        plan.setPatname(snapshot.patname);
+        plan.setPhone(snapshot.phone);
+        plan.setIdcardno(snapshot.idcardno);
+        plan.setPlannedFollowTime(snapshot.plannedFollowTime);
+        plan.setFollowupPeriod(snapshot.followupPeriod);
+        plan.setCreateTime(now);
+        plan.setUpdateTime(now);
+
+        if (snapshot.plannedFollowTime == null) {
+            plan.setPlanStatus(MchFollowupConstants.PLAN_STATUS_WAITING);
+            plan.setRemark("鎷熼殢璁挎椂闂翠负绌猴紝寰呰ˉ鍏�");
+            planMapper.insertMchFollowupPlan(plan);
+            log.warn("銆愬骞奸殢璁裤�戞嫙闅忚鏃堕棿涓虹┖锛岀敓鎴愬緟琛ュ厖璁″垝锛宎rchiveType={}锛宒etailId={}",
+                    snapshot.archiveType, snapshot.archiveDetailId);
+            return 0;
+        }
+
+        List<MchFollowupNode> nodes;
+        try {
+            nodes = periodParser.parse(snapshot.followupPeriod, snapshot.followupCycleTimes);
+        } catch (Exception e) {
+            plan.setPlanStatus(MchFollowupConstants.PLAN_STATUS_WAITING);
+            plan.setRemark("闅忚鍛ㄦ湡JSON瑙f瀽澶辫触锛�" + truncate(e.getMessage(), 200));
+            planMapper.insertMchFollowupPlan(plan);
+            log.error("銆愬骞奸殢璁裤�戦殢璁垮懆鏈熻В鏋愬け璐ワ紝archiveType={}锛宒etailId={}锛宲eriod={}",
+                    snapshot.archiveType, snapshot.archiveDetailId, snapshot.followupPeriod, e);
+            return 0;
+        }
+        if (nodes.isEmpty()) {
+            plan.setPlanStatus(MchFollowupConstants.PLAN_STATUS_WAITING);
+            plan.setRemark("闅忚鍛ㄦ湡鏈厤缃彂閫佽妭鐐�");
+            planMapper.insertMchFollowupPlan(plan);
+            return 0;
+        }
+
+        plan.setPlanStatus(MchFollowupConstants.PLAN_STATUS_ACTIVE);
+        planMapper.insertMchFollowupPlan(plan);
+        List<MchFollowupPlanItem> items = planAssembler.assemble(plan.getId(), snapshot.plannedFollowTime, nodes);
+        for (MchFollowupPlanItem item : items) {
+            itemMapper.insertMchFollowupPlanItem(item);
+        }
+        log.info("銆愬骞奸殢璁裤�戣鍒掗噸寤哄畬鎴愶紝archiveType={}锛宎rchiveId={}锛宒etailId={}锛岃妭鐐规暟={}",
+                snapshot.archiveType, snapshot.archiveId, snapshot.archiveDetailId, items.size());
+        return items.size();
+    }
+
+    @Override
+    public int rebuildAll(int limit) {
+        if (!isEnabled()) {
+            return 0;
+        }
+        int batch = limit <= 0 ? MchFollowupConstants.DEFAULT_BATCH_SIZE : limit;
+        List<MchFollowupArchiveCandidate> candidates =
+                planMapper.selectCandidates(SpecificArchiveConstants.LISHUI_MCH_ORG_ID, batch);
+        if (candidates == null || candidates.isEmpty()) {
+            return 0;
+        }
+        int generated = 0;
+        for (MchFollowupArchiveCandidate candidate : candidates) {
+            try {
+                generated += rebuildForArchive(candidate.getArchiveType(),
+                        candidate.getArchiveId(), candidate.getArchiveDetailId());
+            } catch (Exception e) {
+                log.error("銆愬骞奸殢璁裤�戣ˉ寤鸿鍒掑け璐ワ紝archiveType={}锛宎rchiveId={}锛宒etailId={}",
+                        candidate.getArchiveType(), candidate.getArchiveId(),
+                        candidate.getArchiveDetailId(), e);
+            }
+        }
+        return generated;
+    }
+
+    private ArchiveSnapshot loadSnapshot(String archiveType, Long archiveId, Long archiveDetailId) {
+        if (MchFollowupConstants.ARCHIVE_TYPE_MATERNITY.equals(archiveType)) {
+            return loadMaternitySnapshot(archiveId, archiveDetailId);
+        }
+        if (MchFollowupConstants.ARCHIVE_TYPE_CHILD.equals(archiveType)) {
+            return loadChildSnapshot(archiveId, archiveDetailId);
+        }
+        log.warn("銆愬骞奸殢璁裤�戞湭鐭ユ。妗堢被鍨嬶細{}", archiveType);
+        return null;
+    }
+
+    private ArchiveSnapshot loadMaternitySnapshot(Long archiveId, Long archiveDetailId) {
+        PatMaternityArchiveDetail detail = null;
+        if (archiveDetailId != null) {
+            detail = maternityDetailMapper.selectPatMaternityArchiveDetailById(archiveDetailId);
+        }
+        if (detail == null && archiveId != null) {
+            PatMaternityArchiveDetail query = new PatMaternityArchiveDetail();
+            query.setArchiveid(archiveId);
+            List<PatMaternityArchiveDetail> list =
+                    maternityDetailMapper.selectPatMaternityArchiveDetailList(query);
+            if (list != null && !list.isEmpty()) {
+                detail = list.get(0);
+            }
+        }
+        if (detail == null) {
+            return null;
+        }
+        ArchiveSnapshot snapshot = new ArchiveSnapshot();
+        snapshot.archiveType = MchFollowupConstants.ARCHIVE_TYPE_MATERNITY;
+        snapshot.archiveId = detail.getArchiveid() == null ? archiveId : detail.getArchiveid();
+        snapshot.archiveDetailId = detail.getId();
+        snapshot.orgid = detail.getOrgid();
+        snapshot.campusid = detail.getCampusid();
+        snapshot.sourceType = detail.getSourceType();
+        snapshot.sourceBizNo = detail.getSourceBizNo();
+        snapshot.patid = detail.getPatid();
+        snapshot.patname = detail.getPatname();
+        snapshot.phone = detail.getPhone();
+        snapshot.idcardno = detail.getIdcardno();
+        snapshot.plannedFollowTime = detail.getPlannedFollowTime();
+        snapshot.followupPeriod = detail.getFollowupPeriod();
+        snapshot.followupCycleTimes = detail.getFollowupCycleTimes();
+        return snapshot;
+    }
+
+    private ArchiveSnapshot loadChildSnapshot(Long archiveId, Long archiveDetailId) {
+        PatChildArchiveDetail detail = null;
+        if (archiveDetailId != null) {
+            detail = childDetailMapper.selectPatChildArchiveDetailById(archiveDetailId);
+        }
+        if (detail == null && archiveId != null) {
+            PatChildArchiveDetail query = new PatChildArchiveDetail();
+            query.setArchiveid(archiveId);
+            List<PatChildArchiveDetail> list =
+                    childDetailMapper.selectPatChildArchiveDetailList(query);
+            if (list != null && !list.isEmpty()) {
+                detail = list.get(0);
+            }
+        }
+        if (detail == null) {
+            return null;
+        }
+        ArchiveSnapshot snapshot = new ArchiveSnapshot();
+        snapshot.archiveType = MchFollowupConstants.ARCHIVE_TYPE_CHILD;
+        snapshot.archiveId = detail.getArchiveid() == null ? archiveId : detail.getArchiveid();
+        snapshot.archiveDetailId = detail.getId();
+        snapshot.orgid = detail.getOrgid();
+        snapshot.campusid = detail.getCampusid();
+        snapshot.sourceType = detail.getSourceType();
+        snapshot.sourceBizNo = detail.getSourceBizNo();
+        snapshot.patid = detail.getPatid();
+        snapshot.patname = detail.getPatname();
+        snapshot.phone = firstNotBlank(detail.getParentPhone(), detail.getPhone());
+        snapshot.idcardno = detail.getIdcardno();
+        snapshot.plannedFollowTime = detail.getPlannedFollowTime();
+        snapshot.followupPeriod = detail.getFollowupPeriod();
+        return snapshot;
+    }
+
+    private boolean isEnabled() {
+        try {
+            String value = configService.selectConfigByKey(MchFollowupConstants.CONFIG_ENABLED);
+            return value == null || !"false".equalsIgnoreCase(value.trim());
+        } catch (Exception e) {
+            log.warn("銆愬骞奸殢璁裤�戣鍙栧惎鐢ㄥ紑鍏冲け璐ワ紝鎸夊惎鐢ㄥ鐞嗭細{}", e.getMessage());
+            return true;
+        }
+    }
+
+    private static boolean sameTime(Date left, Date right) {
+        if (left == null || right == null) {
+            return left == right;
+        }
+        return Math.abs(left.getTime() - right.getTime()) < 1000L;
+    }
+
+    private static String firstNotBlank(String first, String second) {
+        return StringUtils.isNotBlank(first) ? first : second;
+    }
+
+    private static String truncate(String text, int maxLength) {
+        if (text == null || text.length() <= maxLength) {
+            return text;
+        }
+        return text.substring(0, maxLength);
+    }
+
+    private static class ArchiveSnapshot {
+        private String archiveType;
+        private Long archiveId;
+        private Long archiveDetailId;
+        private String orgid;
+        private String campusid;
+        private String sourceType;
+        private String sourceBizNo;
+        private Long patid;
+        private String patname;
+        private String phone;
+        private String idcardno;
+        private Date plannedFollowTime;
+        private String followupPeriod;
+        private String followupCycleTimes;
+    }
+}
diff --git a/smartor/src/main/java/com/smartor/service/mch/MchFollowupSendOutcome.java b/smartor/src/main/java/com/smartor/service/mch/MchFollowupSendOutcome.java
new file mode 100644
index 0000000..2d643bf
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/mch/MchFollowupSendOutcome.java
@@ -0,0 +1,69 @@
+package com.smartor.service.mch;
+
+/**
+ * 濡囧辜闅忚鍗曟鍙戦�佺粨鏋溿��
+ */
+public class MchFollowupSendOutcome {
+
+    private boolean ok;
+
+    private boolean skipped;
+
+    private String message;
+
+    private String providerMsgId;
+
+    private String requestBody;
+
+    private String responseBody;
+
+    public static MchFollowupSendOutcome ok(String providerMsgId, String requestBody, String responseBody) {
+        MchFollowupSendOutcome outcome = new MchFollowupSendOutcome();
+        outcome.ok = true;
+        outcome.providerMsgId = providerMsgId;
+        outcome.requestBody = requestBody;
+        outcome.responseBody = responseBody;
+        return outcome;
+    }
+
+    public static MchFollowupSendOutcome fail(String message, String requestBody, String responseBody) {
+        MchFollowupSendOutcome outcome = new MchFollowupSendOutcome();
+        outcome.ok = false;
+        outcome.message = message;
+        outcome.requestBody = requestBody;
+        outcome.responseBody = responseBody;
+        return outcome;
+    }
+
+    public static MchFollowupSendOutcome skip(String message) {
+        MchFollowupSendOutcome outcome = new MchFollowupSendOutcome();
+        outcome.ok = false;
+        outcome.skipped = true;
+        outcome.message = message;
+        return outcome;
+    }
+
+    public boolean isOk() {
+        return ok;
+    }
+
+    public boolean isSkipped() {
+        return skipped;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public String getProviderMsgId() {
+        return providerMsgId;
+    }
+
+    public String getRequestBody() {
+        return requestBody;
+    }
+
+    public String getResponseBody() {
+        return responseBody;
+    }
+}
diff --git a/smartor/src/main/java/com/smartor/service/mch/MchFollowupSendServiceImpl.java b/smartor/src/main/java/com/smartor/service/mch/MchFollowupSendServiceImpl.java
new file mode 100644
index 0000000..b2b3698
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/mch/MchFollowupSendServiceImpl.java
@@ -0,0 +1,210 @@
+package com.smartor.service.mch;
+
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.system.service.ISysConfigService;
+import com.smartor.common.MchFollowupConstants;
+import com.smartor.common.SpecificArchiveConstants;
+import com.smartor.domain.MchFollowupPlan;
+import com.smartor.domain.MchFollowupPlanItem;
+import com.smartor.domain.MchFollowupSendLog;
+import com.smartor.mapper.MchFollowupPlanItemMapper;
+import com.smartor.mapper.MchFollowupPlanMapper;
+import com.smartor.mapper.MchFollowupSendLogMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 濡囧辜闅忚鍙戦�佹湇鍔″疄鐜般��
+ *
+ * <p>鍙彂閫佷附姘村骞肩殑璁″垝鑺傜偣锛涗笉杩涘叆鏅�氶殢璁跨殑琛ュ伩鍙戦�侀摼璺��</p>
+ */
+@Slf4j
+@Service
+public class MchFollowupSendServiceImpl implements IMchFollowupSendService {
+
+    @Autowired
+    private MchFollowupPlanMapper planMapper;
+
+    @Autowired
+    private MchFollowupPlanItemMapper itemMapper;
+
+    @Autowired
+    private MchFollowupSendLogMapper sendLogMapper;
+
+    @Autowired
+    private MchFollowupMessageSender messageSender;
+
+    @Autowired
+    private MchFollowupSendWindow sendWindow;
+
+    @Autowired
+    private ISysConfigService configService;
+
+    @Override
+    public int sendDue(int limit) {
+        if (!isEnabled()) {
+            return 0;
+        }
+        int batch = limit <= 0 ? MchFollowupConstants.DEFAULT_BATCH_SIZE : limit;
+        Date now = new Date();
+        List<MchFollowupPlanItem> dueItems = itemMapper.selectDueItems(
+                SpecificArchiveConstants.LISHUI_MCH_ORG_ID, now, batch);
+        if (dueItems == null || dueItems.isEmpty()) {
+            return 0;
+        }
+
+        int success = 0;
+        for (MchFollowupPlanItem item : dueItems) {
+            try {
+                MchFollowupDueDecision decision = sendWindow.decide(item.getSendTime(), now);
+                if (decision == MchFollowupDueDecision.PENDING) {
+                    continue;
+                }
+                if (decision == MchFollowupDueDecision.EXPIRED) {
+                    markExpired(item, now);
+                    refreshPlanStatus(item.getPlanId());
+                    continue;
+                }
+                if (itemMapper.claimItem(item.getId(), now) != 1) {
+                    continue;
+                }
+
+                MchFollowupPlan plan = planMapper.selectMchFollowupPlanById(item.getPlanId());
+                if (plan == null || !MchFollowupConstants.PLAN_STATUS_ACTIVE.equals(plan.getPlanStatus())) {
+                    markCanceled(item, now, "璁″垝涓嶅瓨鍦ㄦ垨宸插け鏁�");
+                    refreshPlanStatus(item.getPlanId());
+                    continue;
+                }
+
+                MchFollowupSendOutcome outcome = send(plan, item);
+                Date finishTime = new Date();
+                if (outcome.isSkipped()) {
+                    markSkipped(item, finishTime, outcome.getMessage());
+                } else if (outcome.isOk()) {
+                    markSuccess(item, finishTime, outcome);
+                    success++;
+                } else {
+                    markFailureOrRetry(item, finishTime, outcome);
+                }
+                writeLog(item, outcome, now);
+                refreshPlanStatus(plan.getId());
+            } catch (Exception e) {
+                log.error("銆愬骞奸殢璁裤�戝彂閫佽妭鐐瑰紓甯革紝itemId={}锛宲lanId={}",
+                        item.getId(), item.getPlanId(), e);
+                try {
+                    markFailureOrRetry(item, new Date(),
+                            MchFollowupSendOutcome.fail("鍙戦�佸紓甯革細" + e.getMessage(), null, null));
+                    refreshPlanStatus(item.getPlanId());
+                } catch (Exception ignore) {
+                    log.error("銆愬骞奸殢璁裤�戝紓甯稿洖鍐欏け璐ワ紝itemId={}", item.getId(), ignore);
+                }
+            }
+        }
+        return success;
+    }
+
+    private MchFollowupSendOutcome send(MchFollowupPlan plan, MchFollowupPlanItem item) {
+        if (MchFollowupConstants.SEND_TYPE_SMS.equals(item.getSendType())) {
+            return messageSender.sendSms(plan, item);
+        }
+        if (MchFollowupConstants.SEND_TYPE_WECHAT.equals(item.getSendType())) {
+            return messageSender.sendWechat(plan, item);
+        }
+        return MchFollowupSendOutcome.fail("涓嶆敮鎸佺殑鍙戦�佹柟寮忥細" + item.getSendType(), null, null);
+    }
+
+    private void markExpired(MchFollowupPlanItem item, Date now) {
+        item.setSendStatus(MchFollowupConstants.ITEM_STATUS_EXPIRED);
+        item.setNextRetryTime(null);
+        item.setSendTimeActual(null);
+        item.setProviderMsgId(null);
+        item.setResultMsg("瓒呰繃琛ュ彂绐楀彛锛�1澶╋級锛屾爣璁拌繃鏈�");
+        item.setUpdateTime(now);
+        itemMapper.updateSendResult(item);
+        writeLog(item, MchFollowupSendOutcome.fail(item.getResultMsg(), null, null), now);
+    }
+
+    private void markCanceled(MchFollowupPlanItem item, Date now, String message) {
+        item.setSendStatus(MchFollowupConstants.ITEM_STATUS_CANCELED);
+        item.setNextRetryTime(null);
+        item.setResultMsg(message);
+        item.setUpdateTime(now);
+        itemMapper.updateSendResult(item);
+    }
+
+    private void markSkipped(MchFollowupPlanItem item, Date now, String message) {
+        item.setSendStatus(MchFollowupConstants.ITEM_STATUS_SKIPPED);
+        item.setNextRetryTime(null);
+        item.setResultMsg(message);
+        item.setUpdateTime(now);
+        itemMapper.updateSendResult(item);
+    }
+
+    private void markSuccess(MchFollowupPlanItem item, Date now, MchFollowupSendOutcome outcome) {
+        item.setSendStatus(MchFollowupConstants.ITEM_STATUS_SUCCESS);
+        item.setNextRetryTime(null);
+        item.setSendTimeActual(now);
+        item.setProviderMsgId(outcome.getProviderMsgId());
+        item.setResultMsg("鍙戦�佹垚鍔�");
+        item.setUpdateTime(now);
+        itemMapper.updateSendResult(item);
+    }
+
+    private void markFailureOrRetry(MchFollowupPlanItem item, Date now, MchFollowupSendOutcome outcome) {
+        int retryCount = item.getRetryCount() == null ? 0 : item.getRetryCount();
+        retryCount++;
+        item.setRetryCount(retryCount);
+        item.setSendTimeActual(now);
+        item.setProviderMsgId(outcome.getProviderMsgId());
+        if (retryCount < MchFollowupConstants.DEFAULT_MAX_RETRY) {
+            item.setSendStatus(MchFollowupConstants.ITEM_STATUS_PENDING);
+            item.setNextRetryTime(new Date(now.getTime()
+                    + MchFollowupConstants.DEFAULT_RETRY_DELAY_MINUTES * 60L * 1000L));
+            item.setResultMsg((outcome.getMessage() == null ? "鍙戦�佸け璐�" : outcome.getMessage())
+                    + "锛岀" + retryCount + "娆¢噸璇曞悗杩涘叆绛夊緟");
+        } else {
+            item.setSendStatus(MchFollowupConstants.ITEM_STATUS_FAILED);
+            item.setNextRetryTime(null);
+            item.setResultMsg((outcome.getMessage() == null ? "鍙戦�佸け璐�" : outcome.getMessage())
+                    + "锛岄噸璇曟鏁板凡杈句笂闄�");
+        }
+        item.setUpdateTime(now);
+        itemMapper.updateSendResult(item);
+    }
+
+    private void writeLog(MchFollowupPlanItem item, MchFollowupSendOutcome outcome, Date now) {
+        MchFollowupSendLog sendLog = new MchFollowupSendLog();
+        sendLog.setPlanId(item.getPlanId());
+        sendLog.setItemId(item.getId());
+        sendLog.setSendType(item.getSendType());
+        sendLog.setRequestBody(outcome.getRequestBody());
+        sendLog.setResponseBody(outcome.getResponseBody());
+        sendLog.setSendStatus(item.getSendStatus());
+        sendLog.setResultMsg(item.getResultMsg());
+        sendLog.setCreateTime(now);
+        sendLogMapper.insertMchFollowupSendLog(sendLog);
+    }
+
+    private void refreshPlanStatus(Long planId) {
+        if (planId == null) {
+            return;
+        }
+        if (itemMapper.countPendingByPlanId(planId) == 0) {
+            planMapper.completeById(planId, new Date());
+        }
+    }
+
+    private boolean isEnabled() {
+        try {
+            String value = configService.selectConfigByKey(MchFollowupConstants.CONFIG_ENABLED);
+            return value == null || !"false".equalsIgnoreCase(value.trim());
+        } catch (Exception e) {
+            log.warn("銆愬骞奸殢璁裤�戣鍙栧惎鐢ㄥ紑鍏冲け璐ワ紝鎸夊惎鐢ㄥ鐞嗭細{}", e.getMessage());
+            return true;
+        }
+    }
+}
diff --git a/smartor/src/main/java/com/smartor/service/mch/MchFollowupSendWindow.java b/smartor/src/main/java/com/smartor/service/mch/MchFollowupSendWindow.java
new file mode 100644
index 0000000..3632f02
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/mch/MchFollowupSendWindow.java
@@ -0,0 +1,30 @@
+package com.smartor.service.mch;
+
+import com.smartor.common.MchFollowupConstants;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+/**
+ * 濡囧辜闅忚琛ュ彂绐楀彛鍒ゆ柇銆�
+ *
+ * <p>鍙ˉ鍙� 1 澶╁唴鍒版湡鐨勮妭鐐癸紱瓒呰繃 1 澶╂爣璁拌繃鏈燂紝閬垮厤缁欐偅鑰呭彂杩囨椂娑堟伅銆�</p>
+ */
+@Component
+public class MchFollowupSendWindow {
+
+    public MchFollowupDueDecision decide(Date sendTime, Date now) {
+        if (sendTime == null) {
+            return MchFollowupDueDecision.PENDING;
+        }
+        Date current = now == null ? new Date() : now;
+        if (sendTime.after(current)) {
+            return MchFollowupDueDecision.PENDING;
+        }
+        Date expireBefore = new Date(current.getTime() - MchFollowupConstants.CATCHUP_MILLIS);
+        if (sendTime.before(expireBefore)) {
+            return MchFollowupDueDecision.EXPIRED;
+        }
+        return MchFollowupDueDecision.SEND;
+    }
+}
diff --git a/smartor/src/main/java/com/smartor/service/mch/MchFollowupTimeResolver.java b/smartor/src/main/java/com/smartor/service/mch/MchFollowupTimeResolver.java
new file mode 100644
index 0000000..0aa2129
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/mch/MchFollowupTimeResolver.java
@@ -0,0 +1,60 @@
+package com.smartor.service.mch;
+
+import com.smartor.domain.MchFollowupNode;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Component;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+
+/**
+ * 濡囧辜闅忚鑺傜偣鍙戦�佹椂闂磋绠椼��
+ *
+ * <p>plannedFollowTime 鏄暣涓懆鏈熺殑鍩哄噯鏃ワ細</p>
+ * <pre>
+ * send_time = date(plannedFollowTime) + dayOffset + 鏃跺垎绉�
+ * </pre>
+ *
+ * <p>鏃跺垎绉掍紭鍏堢骇锛歩tem.sendTime &gt; plannedFollowTime 鐨勬椂鍒嗙锛堥潪 00:00:00锛�&gt; 09:00銆�</p>
+ */
+@Component
+public class MchFollowupTimeResolver {
+
+    private static final LocalTime DEFAULT_TIME = LocalTime.of(9, 0);
+
+    private static final DateTimeFormatter HH_MM = DateTimeFormatter.ofPattern("HH:mm");
+
+    private static final DateTimeFormatter HH_MM_SS = DateTimeFormatter.ofPattern("HH:mm:ss");
+
+    public Date resolve(Date plannedFollowTime, MchFollowupNode node) {
+        if (plannedFollowTime == null || node == null || node.getDayOffset() == null) {
+            return null;
+        }
+        LocalDateTime base = LocalDateTime.ofInstant(plannedFollowTime.toInstant(), ZoneId.systemDefault());
+        LocalDate sendDate = base.toLocalDate().plusDays(node.getDayOffset());
+        LocalTime sendTime = resolveTime(base.toLocalTime(), node.getSendTime());
+        return Date.from(LocalDateTime.of(sendDate, sendTime).atZone(ZoneId.systemDefault()).toInstant());
+    }
+
+    private LocalTime resolveTime(LocalTime baselineTime, String itemSendTime) {
+        if (StringUtils.isNotBlank(itemSendTime)) {
+            return parseTime(itemSendTime);
+        }
+        if (baselineTime != null && baselineTime.toSecondOfDay() != 0) {
+            return baselineTime;
+        }
+        return DEFAULT_TIME;
+    }
+
+    private LocalTime parseTime(String value) {
+        String text = value.trim();
+        if (text.length() == 5) {
+            return LocalTime.parse(text, HH_MM);
+        }
+        return LocalTime.parse(text, HH_MM_SS);
+    }
+}
diff --git a/smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml b/smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml
new file mode 100644
index 0000000..1bac046
--- /dev/null
+++ b/smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.smartor.mapper.MchFollowupPlanItemMapper">
+
+    <resultMap id="MchFollowupPlanItemResult" type="com.smartor.domain.MchFollowupPlanItem">
+        <id property="id" column="id"/>
+        <result property="planId" column="plan_id"/>
+        <result property="seq" column="seq"/>
+        <result property="sendType" column="send_type"/>
+        <result property="sendTime" column="send_time"/>
+        <result property="titleName" column="title_name"/>
+        <result property="content" column="content"/>
+        <result property="templateId" column="template_id"/>
+        <result property="url" column="url"/>
+        <result property="sendStatus" column="send_status"/>
+        <result property="retryCount" column="retry_count"/>
+        <result property="nextRetryTime" column="next_retry_time"/>
+        <result property="sendTimeActual" column="send_time_actual"/>
+        <result property="resultMsg" column="result_msg"/>
+        <result property="providerMsgId" column="provider_msg_id"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+    </resultMap>
+
+    <sql id="selectItemVo">
+        select id, plan_id, seq, send_type, send_time, title_name, content, template_id, url,
+               send_status, retry_count, next_retry_time, send_time_actual,
+               result_msg, provider_msg_id, create_time, update_time
+        from mch_followup_plan_item
+    </sql>
+
+    <insert id="insertMchFollowupPlanItem" parameterType="com.smartor.domain.MchFollowupPlanItem"
+            useGeneratedKeys="true" keyProperty="id">
+        insert into mch_followup_plan_item
+        (plan_id, seq, send_type, send_time, title_name, content, template_id, url,
+         send_status, retry_count, next_retry_time, send_time_actual,
+         result_msg, provider_msg_id, create_time, update_time)
+        values
+        (#{planId}, #{seq}, #{sendType}, #{sendTime}, #{titleName}, #{content}, #{templateId}, #{url},
+         #{sendStatus}, #{retryCount}, #{nextRetryTime}, #{sendTimeActual},
+         #{resultMsg}, #{providerMsgId}, #{createTime}, #{updateTime})
+    </insert>
+
+    <update id="updateMchFollowupPlanItem" parameterType="com.smartor.domain.MchFollowupPlanItem">
+        update mch_followup_plan_item
+        <set>
+            <if test="sendType != null">send_type = #{sendType},</if>
+            <if test="sendTime != null">send_time = #{sendTime},</if>
+            <if test="titleName != null">title_name = #{titleName},</if>
+            <if test="content != null">content = #{content},</if>
+            <if test="templateId != null">template_id = #{templateId},</if>
+            <if test="url != null">url = #{url},</if>
+            <if test="sendStatus != null">send_status = #{sendStatus},</if>
+            <if test="retryCount != null">retry_count = #{retryCount},</if>
+            <if test="nextRetryTime != null">next_retry_time = #{nextRetryTime},</if>
+            <if test="sendTimeActual != null">send_time_actual = #{sendTimeActual},</if>
+            <if test="resultMsg != null">result_msg = #{resultMsg},</if>
+            <if test="providerMsgId != null">provider_msg_id = #{providerMsgId},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </set>
+        where id = #{id}
+    </update>
+
+    <update id="updateSendResult" parameterType="com.smartor.domain.MchFollowupPlanItem">
+        update mch_followup_plan_item
+        set send_status = #{sendStatus,jdbcType=CHAR},
+            retry_count = #{retryCount,jdbcType=INTEGER},
+            next_retry_time = #{nextRetryTime,jdbcType=TIMESTAMP},
+            send_time_actual = #{sendTimeActual,jdbcType=TIMESTAMP},
+            result_msg = #{resultMsg,jdbcType=VARCHAR},
+            provider_msg_id = #{providerMsgId,jdbcType=VARCHAR},
+            update_time = #{updateTime,jdbcType=TIMESTAMP}
+        where id = #{id}
+    </update>
+
+    <select id="selectMchFollowupPlanItemById" resultMap="MchFollowupPlanItemResult">
+        <include refid="selectItemVo"/>
+        where id = #{id}
+    </select>
+
+    <select id="selectByPlanId" resultMap="MchFollowupPlanItemResult">
+        <include refid="selectItemVo"/>
+        where plan_id = #{planId}
+        order by seq asc, id asc
+    </select>
+
+    <select id="selectDueItems" resultMap="MchFollowupPlanItemResult">
+        select i.id, i.plan_id, i.seq, i.send_type, i.send_time, i.title_name, i.content,
+               i.template_id, i.url, i.send_status, i.retry_count, i.next_retry_time,
+               i.send_time_actual, i.result_msg, i.provider_msg_id, i.create_time, i.update_time
+        from mch_followup_plan_item i
+        inner join mch_followup_plan p on p.id = i.plan_id
+        where p.orgid = #{orgid}
+          and p.plan_status = '0'
+          and i.send_status = '0'
+          and i.send_time &lt;= #{now}
+          and (i.next_retry_time is null or i.next_retry_time &lt;= #{now})
+        order by i.send_time asc, i.seq asc, i.id asc
+        limit #{limit}
+    </select>
+
+    <update id="claimItem">
+        update mch_followup_plan_item
+        set send_status = '1',
+            update_time = #{now}
+        where id = #{id}
+          and send_status = '0'
+    </update>
+
+    <update id="cancelPendingByPlanId">
+        update mch_followup_plan_item
+        set send_status = '5',
+            result_msg = '璁″垝閲嶅缓锛屽彇娑堟湭鍙戦�佽妭鐐�',
+            update_time = #{now}
+        where plan_id = #{planId}
+          and send_status = '0'
+    </update>
+
+    <select id="countPendingByPlanId" resultType="int">
+        select count(1)
+        from mch_followup_plan_item
+        where plan_id = #{planId}
+          and send_status in ('0', '1')
+    </select>
+
+</mapper>
diff --git a/smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml b/smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml
new file mode 100644
index 0000000..f19893f
--- /dev/null
+++ b/smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.smartor.mapper.MchFollowupPlanMapper">
+
+    <resultMap id="MchFollowupPlanResult" type="com.smartor.domain.MchFollowupPlan">
+        <id property="id" column="id"/>
+        <result property="orgid" column="orgid"/>
+        <result property="campusid" column="campusid"/>
+        <result property="archiveType" column="archive_type"/>
+        <result property="archiveId" column="archive_id"/>
+        <result property="archiveDetailId" column="archive_detail_id"/>
+        <result property="sourceType" column="source_type"/>
+        <result property="sourceBizNo" column="source_biz_no"/>
+        <result property="patid" column="patid"/>
+        <result property="patname" column="patname"/>
+        <result property="phone" column="phone"/>
+        <result property="idcardno" column="idcardno"/>
+        <result property="plannedFollowTime" column="planned_follow_time"/>
+        <result property="followupPeriod" column="followup_period"/>
+        <result property="planStatus" column="plan_status"/>
+        <result property="remark" column="remark"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+    </resultMap>
+
+    <sql id="selectPlanVo">
+        select id, orgid, campusid, archive_type, archive_id, archive_detail_id,
+               source_type, source_biz_no, patid, patname, phone, idcardno,
+               planned_follow_time, followup_period, plan_status, remark,
+               create_time, update_time
+        from mch_followup_plan
+    </sql>
+
+    <insert id="insertMchFollowupPlan" parameterType="com.smartor.domain.MchFollowupPlan"
+            useGeneratedKeys="true" keyProperty="id">
+        insert into mch_followup_plan
+        (orgid, campusid, archive_type, archive_id, archive_detail_id,
+         source_type, source_biz_no, patid, patname, phone, idcardno,
+         planned_follow_time, followup_period, plan_status, remark,
+         create_time, update_time)
+        values
+        (#{orgid}, #{campusid}, #{archiveType}, #{archiveId}, #{archiveDetailId},
+         #{sourceType}, #{sourceBizNo}, #{patid}, #{patname}, #{phone}, #{idcardno},
+         #{plannedFollowTime}, #{followupPeriod}, #{planStatus}, #{remark},
+         #{createTime}, #{updateTime})
+    </insert>
+
+    <update id="updateMchFollowupPlan" parameterType="com.smartor.domain.MchFollowupPlan">
+        update mch_followup_plan
+        <set>
+            <if test="orgid != null">orgid = #{orgid},</if>
+            <if test="campusid != null">campusid = #{campusid},</if>
+            <if test="archiveType != null">archive_type = #{archiveType},</if>
+            <if test="archiveId != null">archive_id = #{archiveId},</if>
+            <if test="archiveDetailId != null">archive_detail_id = #{archiveDetailId},</if>
+            <if test="sourceType != null">source_type = #{sourceType},</if>
+            <if test="sourceBizNo != null">source_biz_no = #{sourceBizNo},</if>
+            <if test="patid != null">patid = #{patid},</if>
+            <if test="patname != null">patname = #{patname},</if>
+            <if test="phone != null">phone = #{phone},</if>
+            <if test="idcardno != null">idcardno = #{idcardno},</if>
+            <if test="plannedFollowTime != null">planned_follow_time = #{plannedFollowTime},</if>
+            <if test="followupPeriod != null">followup_period = #{followupPeriod},</if>
+            <if test="planStatus != null">plan_status = #{planStatus},</if>
+            <if test="remark != null">remark = #{remark},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </set>
+        where id = #{id}
+    </update>
+
+    <select id="selectMchFollowupPlanById" resultMap="MchFollowupPlanResult">
+        <include refid="selectPlanVo"/>
+        where id = #{id}
+    </select>
+
+    <select id="selectActiveByArchive" resultMap="MchFollowupPlanResult">
+        <include refid="selectPlanVo"/>
+        where archive_type = #{archiveType}
+          and archive_id = #{archiveId}
+        <if test="archiveDetailId != null">
+            and archive_detail_id = #{archiveDetailId}
+        </if>
+          and plan_status in ('0', '3')
+        order by id desc
+    </select>
+
+    <update id="cancelById">
+        update mch_followup_plan
+        set plan_status = '1',
+            update_time = #{updateTime}
+        where id = #{id}
+          and plan_status in ('0', '3')
+    </update>
+
+    <update id="completeById">
+        update mch_followup_plan
+        set plan_status = '2',
+            update_time = #{updateTime}
+        where id = #{id}
+          and plan_status = '0'
+    </update>
+
+    <select id="selectCandidates" resultType="com.smartor.domain.MchFollowupArchiveCandidate">
+        select '1' as archiveType, d.archiveid as archiveId, d.id as archiveDetailId
+        from pat_maternity_archive_detail d
+        where d.orgid = #{orgid}
+          and (d.del_flag is null or d.del_flag = '0')
+          and d.planned_follow_time is not null
+          and d.followup_period is not null
+          and d.followup_period &lt;&gt; ''
+          and d.archiveid is not null
+        union all
+        select '2' as archiveType, d.archiveid as archiveId, d.id as archiveDetailId
+        from pat_child_archive_detail d
+        where d.orgid = #{orgid}
+          and (d.del_flag is null or d.del_flag = '0')
+          and d.planned_follow_time is not null
+          and d.followup_period is not null
+          and d.followup_period &lt;&gt; ''
+          and d.archiveid is not null
+        limit #{limit}
+    </select>
+
+</mapper>
diff --git a/smartor/src/main/resources/mapper/smartor/MchFollowupSendLogMapper.xml b/smartor/src/main/resources/mapper/smartor/MchFollowupSendLogMapper.xml
new file mode 100644
index 0000000..f4a9c1a
--- /dev/null
+++ b/smartor/src/main/resources/mapper/smartor/MchFollowupSendLogMapper.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.smartor.mapper.MchFollowupSendLogMapper">
+
+    <insert id="insertMchFollowupSendLog" parameterType="com.smartor.domain.MchFollowupSendLog"
+            useGeneratedKeys="true" keyProperty="id">
+        insert into mch_followup_send_log
+        (plan_id, item_id, send_type, request_body, response_body, send_status, result_msg, create_time)
+        values
+        (#{planId}, #{itemId}, #{sendType}, #{requestBody}, #{responseBody}, #{sendStatus}, #{resultMsg}, #{createTime})
+    </insert>
+
+</mapper>
diff --git a/smartor/src/test/java/com/smartor/service/mch/MchFollowupLogicCheck.java b/smartor/src/test/java/com/smartor/service/mch/MchFollowupLogicCheck.java
new file mode 100644
index 0000000..d6deec2
--- /dev/null
+++ b/smartor/src/test/java/com/smartor/service/mch/MchFollowupLogicCheck.java
@@ -0,0 +1,183 @@
+package com.smartor.service.mch;
+
+import com.smartor.common.MchFollowupConstants;
+import com.smartor.domain.MchFollowupNode;
+import com.smartor.domain.MchFollowupPlanItem;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.File;
+import java.lang.reflect.Field;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 濡囧辜闅忚閫昏緫鑷锛堢函 main锛屼笉渚濊禆 JUnit / Spring / 鏁版嵁搴擄級銆�
+ *
+ * 瑕嗙洊锛歠ollowupPeriod JSON 瑙f瀽銆佽鍒掑熀鍑嗘棩鏃堕棿璁$畻銆�1 澶╄ˉ鍙戠獥鍙c��
+ * 鑺傜偣缁勮銆丮apper XML 鍙В鏋愭�с��
+ */
+public final class MchFollowupLogicCheck {
+
+    private static int passed = 0;
+    private static int failed = 0;
+
+    private static final SimpleDateFormat DATE_TIME = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+    private static void check(String key, Object expected, Object actual) {
+        boolean ok = expected == null ? actual == null : expected.equals(actual);
+        if (ok) {
+            passed++;
+            System.out.println("  [OK]   " + key + " = " + actual);
+        } else {
+            failed++;
+            System.out.println("  [FAIL] " + key + " 鏈熸湜=" + expected + " 瀹為檯=" + actual);
+        }
+    }
+
+    private static void expectFail(String key, Runnable action) {
+        try {
+            action.run();
+            failed++;
+            System.out.println("  [FAIL] " + key + " 鏈熸湜鎶涘紓甯革紝瀹為檯鏈姏");
+        } catch (Exception e) {
+            passed++;
+            System.out.println("  [OK]   " + key + " 鎶涘紓甯革細" + e.getMessage());
+        }
+    }
+
+    private static Date date(String text) throws Exception {
+        return DATE_TIME.parse(text);
+    }
+
+    private static MchFollowupPlanAssembler assembler() throws Exception {
+        MchFollowupPlanAssembler assembler = new MchFollowupPlanAssembler();
+        Field field = MchFollowupPlanAssembler.class.getDeclaredField("timeResolver");
+        field.setAccessible(true);
+        field.set(assembler, new MchFollowupTimeResolver());
+        return assembler;
+    }
+
+    private static MchFollowupNode node(int seq, int dayOffset, String sendTime, String sendType) {
+        MchFollowupNode node = new MchFollowupNode();
+        node.setSeq(seq);
+        node.setDayOffset(dayOffset);
+        node.setSendTime(sendTime);
+        node.setSendType(sendType);
+        node.setContent("鍐呭" + seq);
+        return node;
+    }
+
+    public static void main(String[] args) throws Exception {
+        System.out.println("========== 濡囧辜闅忚閫昏緫鑷 ==========");
+        MchFollowupPeriodParser parser = new MchFollowupPeriodParser();
+        MchFollowupTimeResolver resolver = new MchFollowupTimeResolver();
+        MchFollowupSendWindow window = new MchFollowupSendWindow();
+
+        System.out.println("-- 1) items JSON 瑙f瀽 --");
+        String itemsJson = "{"
+                + "\"version\":1,"
+                + "\"items\":["
+                + "{\"seq\":1,\"dayOffset\":0,\"sendTime\":\"09:00\",\"sendType\":\"sms\",\"content\":\"鐭俊1\"},"
+                + "{\"seq\":2,\"dayOffset\":3,\"sendType\":\"5\",\"templateId\":16,\"titleName\":\"鎻愰啋\",\"content\":\"寰俊2\"},"
+                + "{\"seq\":3,\"dayOffset\":7,\"sendType\":\"鐭俊\",\"content\":\"鐭俊3\"}"
+                + "]}";
+        List<MchFollowupNode> itemNodes = parser.parse(itemsJson, null);
+        check("鑺傜偣鏁�", 3, itemNodes.size());
+        check("seq1", 1, itemNodes.get(0).getSeq());
+        check("dayOffset1", 0, itemNodes.get(0).getDayOffset());
+        check("sendType1", "sms", itemNodes.get(0).getSendType());
+        check("sendType2", "wechat", itemNodes.get(1).getSendType());
+        check("templateId2", 16L, itemNodes.get(1).getTemplateId());
+        check("sendTime1", "09:00", itemNodes.get(0).getSendTime());
+
+        System.out.println("-- 2) intervalDays + count 瑙f瀽 --");
+        String intervalJson = "{\"intervalDays\":3,\"count\":4,\"sendType\":\"sms\",\"content\":\"闂撮殧鐭俊\",\"sendTime\":\"08:30\"}";
+        List<MchFollowupNode> intervalNodes = parser.parse(intervalJson, null);
+        check("闂撮殧鑺傜偣鏁�", 4, intervalNodes.size());
+        check("鑺傜偣1鍋忕Щ", 0, intervalNodes.get(0).getDayOffset());
+        check("鑺傜偣2鍋忕Щ", 3, intervalNodes.get(1).getDayOffset());
+        check("鑺傜偣3鍋忕Щ", 6, intervalNodes.get(2).getDayOffset());
+        check("鑺傜偣4鍋忕Щ", 9, intervalNodes.get(3).getDayOffset());
+        check("闂撮殧sendTime", "08:30", intervalNodes.get(0).getSendTime());
+
+        System.out.println("-- 3) intervalDays + followupCycleTimes 鍏滃簳 --");
+        List<MchFollowupNode> cycleNodes = parser.parse(
+                "{\"intervalDays\":2,\"sendType\":\"wechat\",\"content\":\"寰俊\"}", "3");
+        check("鍏滃簳娆℃暟", 3, cycleNodes.size());
+        check("鍏滃簳鑺傜偣3鍋忕Щ", 4, cycleNodes.get(2).getDayOffset());
+
+        System.out.println("-- 4) days 鏁扮粍瑙f瀽 --");
+        List<MchFollowupNode> dayNodes = parser.parse(
+                "{\"days\":[0,7,14],\"sendType\":\"sms\",\"content\":\"鎸夊ぉ\"}", null);
+        check("days鑺傜偣鏁�", 3, dayNodes.size());
+        check("days鑺傜偣2鍋忕Щ", 7, dayNodes.get(1).getDayOffset());
+
+        System.out.println("-- 5) 闈炴硶 JSON / 闈炴硶瀛楁 --");
+        expectFail("闈炴硶JSON", () -> parser.parse("{bad", null));
+        expectFail("绌鸿妭鐐�", () -> parser.parse("{\"items\":[]}", null));
+        expectFail("闈炴硶sendType", () -> parser.parse(
+                "{\"items\":[{\"dayOffset\":0,\"sendType\":\"phone\",\"content\":\"x\"}]}", null));
+        expectFail("鐭俊缂篶ontent", () -> parser.parse(
+                "{\"items\":[{\"dayOffset\":0,\"sendType\":\"sms\"}]}", null));
+        expectFail("闈炴硶sendTime", () -> parser.parse(
+                "{\"items\":[{\"dayOffset\":0,\"sendTime\":\"25:00\",\"sendType\":\"sms\",\"content\":\"x\"}]}", null));
+
+        System.out.println("-- 6) 鍩哄噯鏃ユ椂闂磋绠� --");
+        Date baseline = date("2026-11-20 14:30:00");
+        check("day0娌跨敤14:30", "2026-11-20 14:30:00",
+                DATE_TIME.format(resolver.resolve(baseline, node(1, 0, null, "sms"))));
+        check("day3娌跨敤14:30", "2026-11-23 14:30:00",
+                DATE_TIME.format(resolver.resolve(baseline, node(2, 3, null, "sms"))));
+        check("day7鏄惧紡09:00", "2026-11-27 09:00:00",
+                DATE_TIME.format(resolver.resolve(baseline, node(3, 7, "09:00", "wechat"))));
+        Date midnight = date("2026-11-20 00:00:00");
+        check("鍩哄噯鏃�00:00榛樿09:00", "2026-11-20 09:00:00",
+                DATE_TIME.format(resolver.resolve(midnight, node(1, 0, null, "sms"))));
+
+        System.out.println("-- 7) 1 澶╄ˉ鍙戠獥鍙� --");
+        Date now = date("2026-11-20 12:00:00");
+        check("鏈潵鑺傜偣寰呭彂閫�", MchFollowupDueDecision.PENDING,
+                window.decide(date("2026-11-20 12:01:00"), now));
+        check("1灏忔椂鍐呰ˉ鍙�", MchFollowupDueDecision.SEND,
+                window.decide(date("2026-11-20 11:00:00"), now));
+        check("鎭板ソ24灏忔椂琛ュ彂", MchFollowupDueDecision.SEND,
+                window.decide(date("2026-11-19 12:00:00"), now));
+        check("瓒呰繃24灏忔椂杩囨湡", MchFollowupDueDecision.EXPIRED,
+                window.decide(date("2026-11-19 11:59:59"), now));
+
+        System.out.println("-- 8) 鑺傜偣缁勮 --");
+        List<MchFollowupPlanItem> items = assembler().assemble(99L, baseline, itemNodes);
+        check("缁勮鑺傜偣鏁�", 3, items.size());
+        check("planId", 99L, items.get(0).getPlanId());
+        check("鍒濆鐘舵��", MchFollowupConstants.ITEM_STATUS_PENDING, items.get(0).getSendStatus());
+        check("閲嶈瘯娆℃暟", 0, items.get(0).getRetryCount());
+        check("缁勮鏃堕棿1", "2026-11-20 09:00:00", DATE_TIME.format(items.get(0).getSendTime()));
+        check("缁勮鏃堕棿3娌跨敤鍩哄噯鏃�14:30", "2026-11-27 14:30:00", DATE_TIME.format(items.get(2).getSendTime()));
+
+        System.out.println("-- 9) Mapper XML 鍙В鏋愭�� --");
+        String[] xmlFiles = new String[]{
+                "smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml",
+                "smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml",
+                "smartor/src/main/resources/mapper/smartor/MchFollowupSendLogMapper.xml"
+        };
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+        for (String xmlFile : xmlFiles) {
+            try {
+                factory.newDocumentBuilder().parse(new File(xmlFile));
+                check(xmlFile, "OK", "OK");
+            } catch (Exception e) {
+                check(xmlFile, "OK", e.getClass().getSimpleName() + ":" + e.getMessage());
+            }
+        }
+
+        System.out.println("-- 10) SQL 鑴氭湰瀛樺湪鎬� --");
+        check("DDL鑴氭湰", true, new File("sql/mch_followup_plan_20261117.sql").isFile());
+
+        System.out.println("========== 缁撴灉锛歅ASS=" + passed + "锛孎AIL=" + failed + " ==========");
+        if (failed > 0) {
+            System.exit(1);
+        }
+    }
+}
diff --git a/smartor/src/test/java/com/smartor/service/mch/MchFollowupPlanServiceCheck.java b/smartor/src/test/java/com/smartor/service/mch/MchFollowupPlanServiceCheck.java
new file mode 100644
index 0000000..028eef8
--- /dev/null
+++ b/smartor/src/test/java/com/smartor/service/mch/MchFollowupPlanServiceCheck.java
@@ -0,0 +1,283 @@
+package com.smartor.service.mch;
+
+import com.ruoyi.system.service.ISysConfigService;
+import com.smartor.common.MchFollowupConstants;
+import com.smartor.common.SpecificArchiveConstants;
+import com.smartor.domain.MchFollowupPlan;
+import com.smartor.domain.MchFollowupPlanItem;
+import com.smartor.domain.PatChildArchiveDetail;
+import com.smartor.domain.PatMaternityArchiveDetail;
+import com.smartor.mapper.MchFollowupPlanItemMapper;
+import com.smartor.mapper.MchFollowupPlanMapper;
+import com.smartor.mapper.PatChildArchiveDetailMapper;
+import com.smartor.mapper.PatMaternityArchiveDetailMapper;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 濡囧辜闅忚璁″垝鏈嶅姟鑷锛堢函 main锛屼娇鐢ㄥ姩鎬佷唬鐞嗘ā鎷� Mapper锛屼笉渚濊禆鏁版嵁搴擄級銆�
+ *
+ * 瑕嗙洊锛氳鍒掔敓鎴愩�佽妭鐐规椂闂淬�佸箓绛夐噸寤恒�佹嫙闅忚鏃堕棿涓虹┖銆佸効淇濆闀跨數璇濆厹搴曘��
+ */
+public final class MchFollowupPlanServiceCheck {
+
+    private static int passed = 0;
+    private static int failed = 0;
+
+    private static final SimpleDateFormat DATE_TIME = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+    private static void check(String key, Object expected, Object actual) {
+        boolean ok = expected == null ? actual == null : expected.equals(actual);
+        if (ok) {
+            passed++;
+            System.out.println("  [OK]   " + key + " = " + actual);
+        } else {
+            failed++;
+            System.out.println("  [FAIL] " + key + " 鏈熸湜=" + expected + " 瀹為檯=" + actual);
+        }
+    }
+
+    private static Date date(String text) throws Exception {
+        return DATE_TIME.parse(text);
+    }
+
+    private static void setField(Object target, String name, Object value) throws Exception {
+        Field field = target.getClass().getDeclaredField(name);
+        field.setAccessible(true);
+        field.set(target, value);
+    }
+
+    private static Object defaultValue(Class<?> type) {
+        if (!type.isPrimitive()) {
+            return null;
+        }
+        if (type == boolean.class) {
+            return false;
+        }
+        if (type == byte.class) {
+            return (byte) 0;
+        }
+        if (type == short.class) {
+            return (short) 0;
+        }
+        if (type == int.class) {
+            return 0;
+        }
+        if (type == long.class) {
+            return 0L;
+        }
+        if (type == float.class) {
+            return 0F;
+        }
+        if (type == double.class) {
+            return 0D;
+        }
+        if (type == char.class) {
+            return '\0';
+        }
+        return null;
+    }
+
+    @SuppressWarnings("unchecked")
+    private static <T> T proxy(Class<T> type, InvocationHandler handler) {
+        return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class[]{type}, handler);
+    }
+
+    private static MchFollowupPlanAssembler assembler() throws Exception {
+        MchFollowupPlanAssembler assembler = new MchFollowupPlanAssembler();
+        setField(assembler, "timeResolver", new MchFollowupTimeResolver());
+        return assembler;
+    }
+
+    private static PatMaternityArchiveDetail maternityDetail(Long detailId, Long archiveId, Date plannedTime) {
+        PatMaternityArchiveDetail detail = new PatMaternityArchiveDetail();
+        detail.setId(detailId);
+        detail.setArchiveid(archiveId);
+        detail.setOrgid(SpecificArchiveConstants.LISHUI_MCH_ORG_ID);
+        detail.setCampusid("1");
+        detail.setSourceType("1");
+        detail.setSourceBizNo("MZ001");
+        detail.setPatid(100L);
+        detail.setPatname("寮犱笁");
+        detail.setPhone("13800000000");
+        detail.setIdcardno("330102199001010000");
+        detail.setPlannedFollowTime(plannedTime);
+        detail.setFollowupPeriod("{\"items\":["
+                + "{\"dayOffset\":0,\"sendTime\":\"09:00\",\"sendType\":\"sms\",\"content\":\"鐭俊1\"},"
+                + "{\"dayOffset\":3,\"sendType\":\"wechat\",\"templateId\":16,\"content\":\"寰俊2\"},"
+                + "{\"dayOffset\":7,\"sendType\":\"sms\",\"content\":\"鐭俊3\"}]}");
+        return detail;
+    }
+
+    private static PatChildArchiveDetail childDetail(Long detailId, Long archiveId, Date plannedTime) {
+        PatChildArchiveDetail detail = new PatChildArchiveDetail();
+        detail.setId(detailId);
+        detail.setArchiveid(archiveId);
+        detail.setOrgid(SpecificArchiveConstants.LISHUI_MCH_ORG_ID);
+        detail.setCampusid("1");
+        detail.setSourceType("1");
+        detail.setSourceBizNo("MZ002");
+        detail.setPatid(200L);
+        detail.setPatname("鏉庡洓");
+        detail.setPhone("13900000000");
+        detail.setParentPhone("13700000000");
+        detail.setIdcardno("330102199202020000");
+        detail.setPlannedFollowTime(plannedTime);
+        detail.setFollowupPeriod("{\"items\":[{\"dayOffset\":1,\"sendType\":\"sms\",\"content\":\"鍎夸繚鐭俊\"}]}");
+        return detail;
+    }
+
+    public static void main(String[] args) throws Exception {
+        System.out.println("========== 濡囧辜闅忚璁″垝鏈嶅姟鑷 ==========");
+
+        List<MchFollowupPlan> activePlans = new ArrayList<>();
+        List<MchFollowupPlanItem> insertedItems = new ArrayList<>();
+        long[] planId = {1L};
+        long[] itemId = {1L};
+
+        MchFollowupPlanMapper planMapper = proxy(MchFollowupPlanMapper.class, (p, method, a) -> {
+            String name = method.getName();
+            if ("selectActiveByArchive".equals(name)) {
+                return new ArrayList<>(activePlans);
+            }
+            if ("insertMchFollowupPlan".equals(name)) {
+                MchFollowupPlan plan = (MchFollowupPlan) a[0];
+                plan.setId(planId[0]++);
+                activePlans.add(plan);
+                return 1;
+            }
+            if ("cancelById".equals(name)) {
+                Long id = (Long) a[0];
+                for (MchFollowupPlan plan : activePlans) {
+                    if (id.equals(plan.getId())) {
+                        plan.setPlanStatus(MchFollowupConstants.PLAN_STATUS_CANCELED);
+                    }
+                }
+                return 1;
+            }
+            if ("completeById".equals(name)) {
+                return 1;
+            }
+            return defaultValue(method.getReturnType());
+        });
+
+        MchFollowupPlanItemMapper itemMapper = proxy(MchFollowupPlanItemMapper.class, (p, method, a) -> {
+            String name = method.getName();
+            if ("insertMchFollowupPlanItem".equals(name)) {
+                MchFollowupPlanItem item = (MchFollowupPlanItem) a[0];
+                item.setId(itemId[0]++);
+                insertedItems.add(item);
+                return 1;
+            }
+            if ("cancelPendingByPlanId".equals(name)) {
+                return 1;
+            }
+            if ("countPendingByPlanId".equals(name)) {
+                return 1;
+            }
+            return defaultValue(method.getReturnType());
+        });
+
+        Map<Long, PatMaternityArchiveDetail> maternityMap = new HashMap<>();
+        maternityMap.put(20L, maternityDetail(20L, 10L, date("2026-11-20 14:30:00")));
+        maternityMap.put(21L, maternityDetail(21L, 11L, null));
+        PatMaternityArchiveDetailMapper maternityMapper = proxy(PatMaternityArchiveDetailMapper.class, (p, method, a) -> {
+            String name = method.getName();
+            if ("selectPatMaternityArchiveDetailById".equals(name)) {
+                return maternityMap.get((Long) a[0]);
+            }
+            if ("selectPatMaternityArchiveDetailList".equals(name)) {
+                PatMaternityArchiveDetail query = (PatMaternityArchiveDetail) a[0];
+                List<PatMaternityArchiveDetail> list = new ArrayList<>();
+                for (PatMaternityArchiveDetail detail : maternityMap.values()) {
+                    if (query.getArchiveid() == null || query.getArchiveid().equals(detail.getArchiveid())) {
+                        list.add(detail);
+                    }
+                }
+                return list;
+            }
+            return defaultValue(method.getReturnType());
+        });
+
+        Map<Long, PatChildArchiveDetail> childMap = new HashMap<>();
+        childMap.put(30L, childDetail(30L, 12L, date("2026-12-01 08:00:00")));
+        PatChildArchiveDetailMapper childMapper = proxy(PatChildArchiveDetailMapper.class, (p, method, a) -> {
+            String name = method.getName();
+            if ("selectPatChildArchiveDetailById".equals(name)) {
+                return childMap.get((Long) a[0]);
+            }
+            if ("selectPatChildArchiveDetailList".equals(name)) {
+                return new ArrayList<>(childMap.values());
+            }
+            return defaultValue(method.getReturnType());
+        });
+
+        ISysConfigService configService = proxy(ISysConfigService.class, (p, method, a) -> {
+            if ("selectConfigByKey".equals(method.getName())) {
+                return null;
+            }
+            return defaultValue(method.getReturnType());
+        });
+
+        MchFollowupPlanServiceImpl service = new MchFollowupPlanServiceImpl();
+        setField(service, "planMapper", planMapper);
+        setField(service, "itemMapper", itemMapper);
+        setField(service, "maternityDetailMapper", maternityMapper);
+        setField(service, "childDetailMapper", childMapper);
+        setField(service, "periodParser", new MchFollowupPeriodParser());
+        setField(service, "planAssembler", assembler());
+        setField(service, "configService", configService);
+
+        System.out.println("-- 1) 濡囦繚璁″垝鐢熸垚 --");
+        int generated = service.rebuildForArchive(MchFollowupConstants.ARCHIVE_TYPE_MATERNITY, 10L, 20L);
+        check("鐢熸垚鑺傜偣鏁�", 3, generated);
+        check("璁″垝鏁�", 1, activePlans.size());
+        check("璁″垝鐘舵��", MchFollowupConstants.PLAN_STATUS_ACTIVE, activePlans.get(0).getPlanStatus());
+        check("璁″垝鏈烘瀯", SpecificArchiveConstants.LISHUI_MCH_ORG_ID, activePlans.get(0).getOrgid());
+        check("鑺傜偣鏁�", 3, insertedItems.size());
+        check("鑺傜偣1鏃堕棿", "2026-11-20 09:00:00", DATE_TIME.format(insertedItems.get(0).getSendTime()));
+        check("鑺傜偣2鏃堕棿", "2026-11-23 14:30:00", DATE_TIME.format(insertedItems.get(1).getSendTime()));
+        check("鑺傜偣3鏃堕棿", "2026-11-27 14:30:00", DATE_TIME.format(insertedItems.get(2).getSendTime()));
+
+        System.out.println("-- 2) 鐩稿悓鍩哄噯鏃�/鍛ㄦ湡骞傜瓑 --");
+        int again = service.rebuildForArchive(MchFollowupConstants.ARCHIVE_TYPE_MATERNITY, 10L, 20L);
+        check("骞傜瓑杩斿洖", 0, again);
+        check("璁″垝鏁颁笉鍙�", 1, activePlans.size());
+        check("鑺傜偣鏁颁笉鍙�", 3, insertedItems.size());
+
+        System.out.println("-- 3) 鎷熼殢璁挎椂闂翠负绌� --");
+        int waiting = service.rebuildForArchive(MchFollowupConstants.ARCHIVE_TYPE_MATERNITY, 11L, 21L);
+        check("绛夊緟璁″垝涓嶇敓鎴愯妭鐐�", 0, waiting);
+        check("绛夊緟璁″垝鏁�", 2, activePlans.size());
+        check("绛夊緟璁″垝鐘舵��", MchFollowupConstants.PLAN_STATUS_WAITING, activePlans.get(1).getPlanStatus());
+
+        System.out.println("-- 4) 鍎夸繚瀹堕暱鐢佃瘽鍏滃簳 --");
+        int childGenerated = service.rebuildForArchive(MchFollowupConstants.ARCHIVE_TYPE_CHILD, 12L, 30L);
+        check("鍎夸繚鑺傜偣鏁�", 1, childGenerated);
+        check("鍎夸繚璁″垝鏁�", 3, activePlans.size());
+        check("鍎夸繚鐢佃瘽", "13700000000", activePlans.get(2).getPhone());
+        check("鍎夸繚鑺傜偣鏃堕棿", "2026-12-02 08:00:00",
+                DATE_TIME.format(insertedItems.get(insertedItems.size() - 1).getSendTime()));
+
+        System.out.println("-- 5) 闈炰附姘村骞间笉鐢熸垚 --");
+        PatMaternityArchiveDetail other = maternityDetail(40L, 20L, date("2026-11-20 14:30:00"));
+        other.setOrgid("OTHER_ORG");
+        maternityMap.put(40L, other);
+        int otherGenerated = service.rebuildForArchive(MchFollowupConstants.ARCHIVE_TYPE_MATERNITY, 20L, 40L);
+        check("鍏朵粬鏈烘瀯涓嶇敓鎴�", 0, otherGenerated);
+
+        System.out.println("========== 缁撴灉锛歅ASS=" + passed + "锛孎AIL=" + failed + " ==========");
+        if (failed > 0) {
+            System.exit(1);
+        }
+    }
+}
diff --git a/smartor/src/test/java/com/smartor/service/mch/MchFollowupSendServiceCheck.java b/smartor/src/test/java/com/smartor/service/mch/MchFollowupSendServiceCheck.java
new file mode 100644
index 0000000..be59015
--- /dev/null
+++ b/smartor/src/test/java/com/smartor/service/mch/MchFollowupSendServiceCheck.java
@@ -0,0 +1,198 @@
+package com.smartor.service.mch;
+
+import com.ruoyi.system.service.ISysConfigService;
+import com.smartor.common.MchFollowupConstants;
+import com.smartor.domain.MchFollowupPlan;
+import com.smartor.domain.MchFollowupPlanItem;
+import com.smartor.domain.MchFollowupSendLog;
+import com.smartor.mapper.MchFollowupPlanItemMapper;
+import com.smartor.mapper.MchFollowupPlanMapper;
+import com.smartor.mapper.MchFollowupSendLogMapper;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 濡囧辜闅忚鍙戦�佹湇鍔¤嚜妫�锛堢函 main锛屽姩鎬佷唬鐞嗘ā鎷� Mapper锛屼笉渚濊禆鏁版嵁搴�/绗笁鏂规帴鍙o級銆�
+ */
+public final class MchFollowupSendServiceCheck {
+
+    private static int passed = 0;
+    private static int failed = 0;
+
+    private static void check(String key, Object expected, Object actual) {
+        boolean ok = expected == null ? actual == null : expected.equals(actual);
+        if (ok) {
+            passed++;
+            System.out.println("  [OK]   " + key + " = " + actual);
+        } else {
+            failed++;
+            System.out.println("  [FAIL] " + key + " 鏈熸湜=" + expected + " 瀹為檯=" + actual);
+        }
+    }
+
+    private static void setField(Object target, String name, Object value) throws Exception {
+        Field field = target.getClass().getDeclaredField(name);
+        field.setAccessible(true);
+        field.set(target, value);
+    }
+
+    private static Object defaultValue(Class<?> type) {
+        if (!type.isPrimitive()) {
+            return null;
+        }
+        if (type == boolean.class) {
+            return false;
+        }
+        if (type == int.class) {
+            return 0;
+        }
+        if (type == long.class) {
+            return 0L;
+        }
+        return null;
+    }
+
+    @SuppressWarnings("unchecked")
+    private static <T> T proxy(Class<T> type, InvocationHandler handler) {
+        return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class[]{type}, handler);
+    }
+
+    private static MchFollowupPlanItem item(String sendType, long sendTimeMillis) {
+        MchFollowupPlanItem item = new MchFollowupPlanItem();
+        item.setId(1L);
+        item.setPlanId(10L);
+        item.setSeq(1);
+        item.setSendType(sendType);
+        item.setSendTime(new Date(sendTimeMillis));
+        item.setContent("鍐呭");
+        item.setSendStatus(MchFollowupConstants.ITEM_STATUS_PENDING);
+        item.setRetryCount(0);
+        return item;
+    }
+
+    private static MchFollowupPlan plan() {
+        MchFollowupPlan plan = new MchFollowupPlan();
+        plan.setId(10L);
+        plan.setOrgid("47226079133110211G1001");
+        plan.setPlanStatus(MchFollowupConstants.PLAN_STATUS_ACTIVE);
+        plan.setPhone("13800000000");
+        return plan;
+    }
+
+    private static int run(MchFollowupPlanItem targetItem, MchFollowupMessageSender sender,
+                           boolean expectClaim) throws Exception {
+        List<MchFollowupPlanItem> dueItems = new ArrayList<>();
+        dueItems.add(targetItem);
+        List<MchFollowupSendLog> logs = new ArrayList<>();
+        boolean[] claimed = {false};
+        boolean[] planCompleted = {false};
+
+        MchFollowupPlanItemMapper itemMapper = proxy(MchFollowupPlanItemMapper.class, (p, method, a) -> {
+            String name = method.getName();
+            if ("selectDueItems".equals(name)) {
+                return dueItems;
+            }
+            if ("claimItem".equals(name)) {
+                claimed[0] = true;
+                return 1;
+            }
+            if ("updateSendResult".equals(name)) {
+                return 1;
+            }
+            if ("countPendingByPlanId".equals(name)) {
+                return 0;
+            }
+            return defaultValue(method.getReturnType());
+        });
+
+        MchFollowupPlanMapper planMapper = proxy(MchFollowupPlanMapper.class, (p, method, a) -> {
+            String name = method.getName();
+            if ("selectMchFollowupPlanById".equals(name)) {
+                return plan();
+            }
+            if ("completeById".equals(name)) {
+                planCompleted[0] = true;
+                return 1;
+            }
+            return defaultValue(method.getReturnType());
+        });
+
+        MchFollowupSendLogMapper logMapper = proxy(MchFollowupSendLogMapper.class, (p, method, a) -> {
+            if ("insertMchFollowupSendLog".equals(method.getName())) {
+                logs.add((MchFollowupSendLog) a[0]);
+                return 1;
+            }
+            return defaultValue(method.getReturnType());
+        });
+
+        ISysConfigService configService = proxy(ISysConfigService.class, (p, method, a) -> {
+            if ("selectConfigByKey".equals(method.getName())) {
+                return null;
+            }
+            return defaultValue(method.getReturnType());
+        });
+
+        MchFollowupSendServiceImpl service = new MchFollowupSendServiceImpl();
+        setField(service, "planMapper", planMapper);
+        setField(service, "itemMapper", itemMapper);
+        setField(service, "sendLogMapper", logMapper);
+        setField(service, "messageSender", sender);
+        setField(service, "sendWindow", new MchFollowupSendWindow());
+        setField(service, "configService", configService);
+
+        int sent = service.sendDue(10);
+        check("claimItem璋冪敤", expectClaim, claimed[0]);
+        check("璁″垝瀹屾垚鏇存柊", true, planCompleted[0]);
+        check("鍙戦�佹棩蹇楁暟", 1, logs.size());
+        return sent;
+    }
+
+    public static void main(String[] args) throws Exception {
+        System.out.println("========== 濡囧辜闅忚鍙戦�佹湇鍔¤嚜妫� ==========");
+        long now = System.currentTimeMillis();
+
+        System.out.println("-- 1) 鐭俊鍙戦�佹垚鍔� --");
+        MchFollowupPlanItem smsItem = item(MchFollowupConstants.SEND_TYPE_SMS, now - 60L * 60L * 1000L);
+        MchFollowupMessageSender okSender = new MchFollowupMessageSender() {
+            @Override
+            public MchFollowupSendOutcome sendSms(MchFollowupPlan plan, MchFollowupPlanItem item) {
+                return MchFollowupSendOutcome.ok("MSG-1", "req", "resp");
+            }
+
+            @Override
+            public MchFollowupSendOutcome sendWechat(MchFollowupPlan plan, MchFollowupPlanItem item) {
+                return MchFollowupSendOutcome.fail("寰俊澶辫触", "req", "resp");
+            }
+        };
+        int success = run(smsItem, okSender, true);
+        check("鎴愬姛鏁伴噺", 1, success);
+        check("鑺傜偣鐘舵��", MchFollowupConstants.ITEM_STATUS_SUCCESS, smsItem.getSendStatus());
+        check("绗笁鏂笽D", "MSG-1", smsItem.getProviderMsgId());
+
+        System.out.println("-- 2) 瓒呰繃 1 澶╂爣璁拌繃鏈� --");
+        MchFollowupPlanItem expiredItem = item(
+                MchFollowupConstants.SEND_TYPE_SMS, now - 25L * 60L * 60L * 1000L);
+        int expiredSent = run(expiredItem, okSender, false);
+        check("杩囨湡涓嶅彂閫�", 0, expiredSent);
+        check("杩囨湡鐘舵��", MchFollowupConstants.ITEM_STATUS_EXPIRED, expiredItem.getSendStatus());
+
+        System.out.println("-- 3) 寰俊澶辫触杩涘叆閲嶈瘯 --");
+        MchFollowupPlanItem retryItem = item(
+                MchFollowupConstants.SEND_TYPE_WECHAT, now - 60L * 60L * 1000L);
+        int retrySent = run(retryItem, okSender, true);
+        check("澶辫触涓嶈鏁�", 0, retrySent);
+        check("閲嶈瘯鐘舵��", MchFollowupConstants.ITEM_STATUS_PENDING, retryItem.getSendStatus());
+        check("閲嶈瘯娆℃暟", 1, retryItem.getRetryCount());
+        check("涓嬫閲嶈瘯鏃堕棿闈炵┖", true, retryItem.getNextRetryTime() != null);
+
+        System.out.println("========== 缁撴灉锛歅ASS=" + passed + "锛孎AIL=" + failed + " ==========");
+        if (failed > 0) {
+            System.exit(1);
+        }
+    }
+}
diff --git a/sql/mch_followup_plan_20261117.sql b/sql/mch_followup_plan_20261117.sql
new file mode 100644
index 0000000..4b5ce24
--- /dev/null
+++ b/sql/mch_followup_plan_20261117.sql
@@ -0,0 +1,81 @@
+-- =============================================================================
+-- 濡囧辜闅忚鎸夊懆鏈熷彂閫侊細璁″垝琛� + 鑺傜偣琛� + 鍙戦�佹棩蹇楄〃
+-- 閫傜敤鏈烘瀯锛氫附姘村競濡囧辜淇濆仴闄� orgid = 47226079133110211G1001
+-- 鏃ユ湡锛�2026-11-17
+-- =============================================================================
+
+-- 1. followup_period 鏀逛负 TEXT锛屽绾� JSON锛堝師 varchar(100) 鏀句笉涓嬪彂閫佸唴瀹癸級
+ALTER TABLE pat_maternity_archive_detail
+    MODIFY COLUMN followup_period TEXT NULL COMMENT '闅忚鍛ㄦ湡JSON';
+
+ALTER TABLE pat_child_archive_detail
+    MODIFY COLUMN followup_period TEXT NULL COMMENT '闅忚鍛ㄦ湡JSON';
+
+ALTER TABLE pat_specific_archive_generate_config
+    MODIFY COLUMN followup_period TEXT NULL COMMENT '闅忚鍛ㄦ湡JSON';
+
+-- 2. 濡囧辜闅忚璁″垝涓昏〃
+CREATE TABLE IF NOT EXISTS mch_followup_plan (
+    id                  BIGINT       NOT NULL AUTO_INCREMENT COMMENT '涓婚敭',
+    orgid               VARCHAR(64)  NOT NULL COMMENT '鏈烘瀯ID',
+    campusid            VARCHAR(64)  DEFAULT NULL COMMENT '闄㈠尯ID',
+    archive_type        VARCHAR(8)   NOT NULL COMMENT '妗f绫诲瀷锛�1濡囦繚 2鍎夸繚',
+    archive_id          BIGINT       NOT NULL COMMENT '妗f涓昏〃ID',
+    archive_detail_id   BIGINT       NOT NULL COMMENT '妗f璇︽儏ID',
+    source_type         VARCHAR(8)   DEFAULT NULL COMMENT '鏉ユ簮绫诲瀷锛�1闂ㄨ瘖 2浣忛櫌闅忚 3鎵嬪伐',
+    source_biz_no       VARCHAR(128) DEFAULT NULL COMMENT '鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙�',
+    patid               BIGINT       DEFAULT NULL COMMENT '鎮h�匢D',
+    patname             VARCHAR(255) DEFAULT NULL COMMENT '鎮h�呭鍚�',
+    phone               VARCHAR(32)  DEFAULT NULL COMMENT '鑱旂郴鐢佃瘽',
+    idcardno            VARCHAR(64)  DEFAULT NULL COMMENT '璇佷欢鍙风爜',
+    planned_follow_time DATETIME     DEFAULT NULL COMMENT '鍛ㄦ湡鍩哄噯鏃�',
+    followup_period     TEXT         DEFAULT NULL COMMENT '闅忚鍛ㄦ湡JSON蹇収',
+    plan_status         CHAR(1)      NOT NULL DEFAULT '0' COMMENT '鐘舵�侊細0鏈夋晥 1鍙栨秷 2瀹屾垚 3寰呰ˉ鍏�/閰嶇疆寮傚父',
+    remark              VARCHAR(500) DEFAULT NULL COMMENT '澶囨敞',
+    create_time         DATETIME     DEFAULT NULL,
+    update_time         DATETIME     DEFAULT NULL,
+    PRIMARY KEY (id),
+    KEY idx_mch_plan_archive (archive_type, archive_id, archive_detail_id),
+    KEY idx_mch_plan_status (orgid, plan_status)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='濡囧辜闅忚璁″垝涓昏〃';
+
+-- 3. 濡囧辜闅忚璁″垝鍙戦�佽妭鐐�
+CREATE TABLE IF NOT EXISTS mch_followup_plan_item (
+    id                BIGINT       NOT NULL AUTO_INCREMENT COMMENT '涓婚敭',
+    plan_id           BIGINT       NOT NULL COMMENT '璁″垝ID',
+    seq               INT          NOT NULL COMMENT '鑺傜偣椤哄簭',
+    send_type         VARCHAR(16)  NOT NULL COMMENT '鍙戦�佹柟寮忥細sms/wechat',
+    send_time         DATETIME     NOT NULL COMMENT '鍙戦�佹椂闂�',
+    title_name        VARCHAR(255) DEFAULT NULL COMMENT '寰俊鏍囬',
+    content           TEXT         DEFAULT NULL COMMENT '鍙戦�佸唴瀹�',
+    template_id       BIGINT       DEFAULT NULL COMMENT '寰俊妯℃澘ID',
+    url               VARCHAR(1000) DEFAULT NULL COMMENT '寰俊璺宠浆鍦板潃',
+    send_status       CHAR(1)      NOT NULL DEFAULT '0' COMMENT '鐘舵�侊細0寰呭彂閫� 1鍙戦�佷腑 2鎴愬姛 3澶辫触 4杩囨湡 5鍙栨秷 6璺宠繃',
+    retry_count       INT          NOT NULL DEFAULT 0 COMMENT '宸查噸璇曟鏁�',
+    next_retry_time   DATETIME     DEFAULT NULL COMMENT '涓嬫閲嶈瘯鏃堕棿',
+    send_time_actual  DATETIME     DEFAULT NULL COMMENT '瀹為檯鍙戦�佹椂闂�',
+    result_msg        VARCHAR(1000) DEFAULT NULL COMMENT '缁撴灉璇存槑',
+    provider_msg_id   VARCHAR(255) DEFAULT NULL COMMENT '绗笁鏂规秷鎭疘D',
+    create_time       DATETIME     DEFAULT NULL,
+    update_time       DATETIME     DEFAULT NULL,
+    PRIMARY KEY (id),
+    UNIQUE KEY uk_mch_plan_seq (plan_id, seq),
+    KEY idx_mch_item_due (send_status, send_time),
+    KEY idx_mch_item_plan (plan_id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='濡囧辜闅忚璁″垝鍙戦�佽妭鐐�';
+
+-- 4. 濡囧辜闅忚鍙戦�佹棩蹇�
+CREATE TABLE IF NOT EXISTS mch_followup_send_log (
+    id            BIGINT       NOT NULL AUTO_INCREMENT COMMENT '涓婚敭',
+    plan_id       BIGINT       DEFAULT NULL COMMENT '璁″垝ID',
+    item_id       BIGINT       DEFAULT NULL COMMENT '鑺傜偣ID',
+    send_type     VARCHAR(16)  DEFAULT NULL COMMENT '鍙戦�佹柟寮�',
+    request_body  TEXT         DEFAULT NULL COMMENT '璇锋眰鎽樿锛堟墜鏈哄彿鑴辨晱锛�',
+    response_body TEXT         DEFAULT NULL COMMENT '绗笁鏂瑰搷搴�',
+    send_status   CHAR(1)      DEFAULT NULL COMMENT '鍙戦�佸悗鐘舵��',
+    result_msg    VARCHAR(1000) DEFAULT NULL COMMENT '缁撴灉璇存槑',
+    create_time   DATETIME     DEFAULT NULL,
+    PRIMARY KEY (id),
+    KEY idx_mch_log_item (item_id),
+    KEY idx_mch_log_plan (plan_id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='濡囧辜闅忚鍙戦�佹棩蹇�';

--
Gitblit v1.9.3