From 5b5b3860b978f9ac5860b9def1c4898ad2e380e6 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 17 十一月 2026 14:59:25 +0800
Subject: [PATCH] Merge branch '20261111-妇幼档案随访' into smartor_ls_merge

---
 smartor/src/main/java/com/smartor/domain/PatChildArchiveDetail.java                          |   16 
 smartor/src/main/java/com/smartor/listener/InhospFollowupArchiveListener.java                |   42 +
 smartor/src/main/java/com/smartor/domain/PatSpecificArchiveGenerateLog.java                  |   90 ++
 ruoyi-common/src/main/java/com/ruoyi/common/core/event/FollowupCompletedEvent.java           |   46 +
 ruoyi-task/src/main/java/com/ruoyi/task/api/contract/TaskSubtaskApiImpl.java                 |   14 
 smartor/src/main/java/com/smartor/mapper/PatSpecificArchiveGenerateLogMapper.java            |   41 +
 ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java          |   13 
 smartor/src/main/resources/mapper/smartor/PatChildArchiveMapper.xml                          |   24 
 smartor/src/main/java/com/smartor/domain/PatChildArchive.java                                |   17 
 smartor/src/main/java/com/smartor/domain/PatMaternityArchive.java                            |   17 
 smartor/src/main/resources/mapper/smartor/PatMaternityArchiveDetailMapper.xml                |   18 
 sql/pat_specific_archive_generate_log_and_source_20261111.sql                                |  105 ++
 smartor/src/test/java/com/smartor/service/InhospFollowupArchiveLogicCheck.java               |  130 +++
 smartor/src/main/java/com/smartor/domain/PatMaternityArchiveDetail.java                      |   16 
 smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateLogServiceImpl.java |   74 +
 smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java          |    7 
 doc/api/妇保接口文档.md                                                                            |  646 +++++++++++++++++
 smartor/src/main/resources/mapper/smartor/PatChildArchiveDetailMapper.xml                    |   18 
 ruoyi-task/src/main/java/com/ruoyi/task/api/TaskSubtaskApi.java                              |   13 
 ruoyi-task/src/main/java/com/ruoyi/task/event/FollowupCompletedEventPublisher.java           |   37 
 ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml                           |   17 
 smartor/src/main/java/com/smartor/service/IPatSpecificArchiveGenerateLogService.java         |   18 
 smartor/src/main/resources/mapper/smartor/PatSpecificArchiveGenerateLogMapper.xml            |   94 ++
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java                                 |   25 
 ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java                       |    7 
 ruoyi-task/src/main/java/com/ruoyi/task/mapper/ServiceSubtaskMapper.java                     |   14 
 smartor/src/main/java/com/smartor/service/IPatSpecificArchiveGenerateService.java            |   18 
 smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java           |   19 
 smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java               |   18 
 smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateServiceImpl.java    |  601 +++++++++++++++
 smartor/src/main/java/com/smartor/common/SpecificArchiveConstants.java                       |   30 
 smartor/src/main/resources/mapper/smartor/PatMaternityArchiveMapper.xml                      |   24 
 32 files changed, 2,235 insertions(+), 34 deletions(-)

diff --git "a/doc/api/\345\246\207\344\277\235\346\216\245\345\217\243\346\226\207\346\241\243.md" "b/doc/api/\345\246\207\344\277\235\346\216\245\345\217\243\346\226\207\346\241\243.md"
new file mode 100644
index 0000000..5724f39
--- /dev/null
+++ "b/doc/api/\345\246\207\344\277\235\346\216\245\345\217\243\346\226\207\346\241\243.md"
@@ -0,0 +1,646 @@
+# 濡囦繚鎺ュ彛鏂囨。锛堝绉� / 鍎跨妗f锛�
+
+> 鏈枃妗d粎鍖呭惈浠ヤ笅 8 涓帴鍙o細
+
+| 搴忓彿 | 妯″潡 | 鎺ュ彛 | 鏂规硶 | 璇存槑 |
+| --- | --- | --- | --- | --- |
+| 1 | 濡囩妗f | `/smartor/maternityArchive/selectPatMaternityArchiveList` | POST | 鏌ヨ濡囩妗f鍒楄〃 |
+| 2 | 濡囩妗f | `/smartor/maternityArchive/insertOrUpdateMaternityArchive` | POST | 鏂板鎴栦慨鏀瑰绉戞。妗� |
+| 3 | 濡囩妗f | `/smartor/maternityArchive/batchDelete` | POST | 鎵归噺鍒犻櫎濡囩妗f锛堝惈璇︽儏锛� |
+| 4 | 濡囩妗f璇︽儏 | `/smartor/maternityArchiveDetail/getInfo/{archiveid}` | GET | 鑾峰彇濡囩妗f璇︽儏 |
+| 5 | 鍎跨妗f | `/smartor/childArchive/selectPatChildArchiveList` | POST | 鏌ヨ鍎跨妗f鍒楄〃 |
+| 6 | 鍎跨妗f | `/smartor/childArchive/insertOrUpdateChildArchive` | POST | 鏂板鎴栦慨鏀瑰効绉戞。妗� |
+| 7 | 鍎跨妗f | `/smartor/childArchive/batchDelete` | POST | 鎵归噺鍒犻櫎鍎跨妗f锛堝惈璇︽儏锛� |
+| 8 | 鍎跨妗f璇︽儏 | `/smartor/childArchiveDetail/getInfo/{archiveid}` | GET | 鑾峰彇鍎跨妗f璇︽儏 |
+
+---
+
+## 涓�銆侀�氱敤璇存槑
+
+### 1.1 鏈嶅姟鍦板潃
+
+- 鍓嶇紑锛歚http://鏈嶅姟IP:绔彛`锛堥粯璁ゅ紑鍙戠幆澧冧负 `http://localhost:8080`锛�
+
+### 1.2 璁よ瘉鏂瑰紡
+
+- 鎵�鏈夋帴鍙e潎闇�鐧诲綍鍚庤皟鐢ㄣ��
+- 璇锋眰澶存惡甯︼細`Authorization: Bearer {token}`
+
+### 1.3 璇锋眰涓庡搷搴旀牸寮�
+
+- 璇锋眰浣擄細`Content-Type: application/json`
+- 鍒楄〃鎺ュ彛鍝嶅簲缁撴瀯锛圱ableDataInfo锛夛細
+
+| 瀛楁 | 绫诲瀷 | 璇存槑 |
+| --- | --- | --- |
+| total | long | 鎬昏褰曟暟 |
+| rows | array | 鏁版嵁鍒楄〃 |
+| code | int | 鐘舵�佺爜锛�200 涓烘垚鍔� |
+| msg | string | 鎻愮ず淇℃伅锛屽鈥滄煡璇㈡垚鍔熲�� |
+
+- 闈炲垪琛ㄦ帴鍙e搷搴旂粨鏋勶紙AjaxResult锛夛細
+
+| 瀛楁 | 绫诲瀷 | 璇存槑 |
+| --- | --- | --- |
+| code | int | 鐘舵�佺爜锛�200 涓烘垚鍔燂紝500 涓哄け璐� |
+| msg | string | 鎻愮ず淇℃伅锛屽鈥滄搷浣滄垚鍔熲�濄�佲�滄搷浣滃け璐モ�� |
+| data | object | 涓氬姟鏁版嵁锛堝彲鑳戒负绌猴級 |
+
+---
+
+## 浜屻�佸绉戞。妗堟帴鍙�
+
+### 2.1 鏌ヨ濡囩妗f鍒楄〃
+
+- **URL**锛歚POST /smartor/maternityArchive/selectPatMaternityArchiveList`
+- **璇存槑**锛氬垎椤垫煡璇㈠绉戞。妗堜富琛ㄥ垪琛紙鏈垹闄ゆ暟鎹� `del_flag = '0'`锛夈��
+
+**璇锋眰浣擄紙JSON锛屽叏閮ㄥ彲閫夛級**
+
+| 鍙傛暟鍚� | 绫诲瀷 | 蹇呭~ | 璇存槑 |
+| --- | --- | --- | --- |
+| pageNum | Integer | 鍚� | 椤电爜锛堝垎椤垫椂蹇呭~锛� |
+| pageSize | Integer | 鍚� | 姣忛〉鏉℃暟锛堝垎椤垫椂蹇呭~锛� |
+| archiveType | String | 鍚� | 妗f绫诲瀷锛�1 鏃╁瓡鍏崇埍锛�2 鍥寸粷缁忔湡MHI |
+| outhospno | String | 鍚� | 闂ㄨ瘖缂栧彿锛堢簿纭尮閰嶏級 |
+| inhospno | String | 鍚� | 浣忛櫌缂栧彿锛堢簿纭尮閰嶏級 |
+| serialnum | String | 鍚� | 娴佹按鍙凤紙绮剧‘鍖归厤锛� |
+| patid | Long | 鍚� | 鎮h�匢D |
+| patname | String | 鍚� | 鎮h�呭鍚嶏紙妯$硦鍖归厤锛� |
+| parentname | String | 鍚� | 瀹堕暱濮撳悕锛堟ā绯婂尮閰嶏級 |
+| birthdate | Date | 鍚� | 鍑虹敓鏃ユ湡 |
+| idcardno | String | 鍚� | 璇佷欢鍙风爜锛堢簿纭尮閰嶏級 |
+| phone | String | 鍚� | 鑱旂郴鐢佃瘽锛堢簿纭尮閰嶏級 |
+| diagTime | Date | 鍚� | 璇婃柇鏃堕棿 |
+| plannedFollowTime | Date | 鍚� | 鎷熼殢璁挎椂闂� |
+| followupCycleTimes | String | 鍚� | 闅忚鍛ㄦ湡(娆℃暟) |
+| sex | Long | 鍚� | 鎬у埆锛�1 鐢凤紝2 濂� |
+| doctorCode | String | 鍚� | 涓绘不鍖荤敓锛堢簿纭尮閰嶏級 |
+| doctorName | String | 鍚� | 涓绘不鍖荤敓濮撳悕锛堟ā绯婂尮閰嶏級 |
+| managementDoctorCode | String | 鍚� | 缁忕鍖荤敓锛堢簿纭尮閰嶏級 |
+| managementDoctorName | String | 鍚� | 缁忕鍖荤敓濮撳悕锛堟ā绯婂尮閰嶏級 |
+| deptcode | String | 鍚� | 绉戝缂栧彿锛堢簿纭尮閰嶏級 |
+| deptname | String | 鍚� | 绉戝鍚嶇О锛堟ā绯婂尮閰嶏級 |
+| wardcode | String | 鍚� | 鐥呭尯缂栧彿锛堢簿纭尮閰嶏級 |
+| wardname | String | 鍚� | 鐥呭尯鍚嶇О锛堟ā绯婂尮閰嶏級 |
+| icd10code | String | 鍚� | 璇婃柇ID锛堢簿纭尮閰嶏級 |
+| diagname | String | 鍚� | 璇婃柇鍚嶇О锛堟ā绯婂尮閰嶏級 |
+| pregnancySituation | String | 鍚� | 濡婂鎯呭喌 |
+| closeStatus | String | 鍚� | 缁撴鐘舵�� |
+| registerUser | String | 鍚� | 鐧昏浜哄憳 |
+| orgid | String | 鍚� | 鍖婚櫌鏈烘瀯ID锛堝悗绔寜鐧诲綍鐢ㄦ埛鑷姩娉ㄥ叆锛� |
+| campusid | String | 鍚� | 闄㈠尯ID锛堝悗绔寜鐧诲綍鐢ㄦ埛鑷姩娉ㄥ叆锛� |
+| params.beginTime | String | 鍚� | 寤烘。鏃堕棿鑼冨洿寮�濮嬶紝鏍煎紡 yyyy-MM-dd |
+| params.endTime | String | 鍚� | 寤烘。鏃堕棿鑼冨洿缁撴潫锛屾牸寮� yyyy-MM-dd |
+
+**璇锋眰绀轰緥**
+
+```json
+{
+  "pageNum": 1,
+  "pageSize": 10,
+  "patname": "寮�",
+  "archiveType": "1"
+}
+```
+
+**鍝嶅簲绀轰緥**
+
+```json
+{
+  "code": 200,
+  "msg": "鏌ヨ鎴愬姛",
+  "total": 1,
+  "rows": [
+    {
+      "id": 1001,
+      "archiveType": "1",
+      "outhospno": "MZ20261001001",
+      "inhospno": null,
+      "serialnum": "LS20261001001",
+      "patid": 9001,
+      "patname": "寮犱笁",
+      "parentname": null,
+      "birthdate": "1995-06-01 00:00:00",
+      "idcardno": "330102199506010022",
+      "phone": "13800000000",
+      "diagTime": "2026-10-01 09:30:00",
+      "archiveTime": "2026-10-01 10:00:00",
+      "plannedFollowTime": "2026-11-01 00:00:00",
+      "followupCycleTimes": "4",
+      "sex": 2,
+      "doctorCode": "D001",
+      "doctorName": "鏉庡尰鐢�",
+      "managementDoctorCode": "D002",
+      "managementDoctorName": "鐜嬪尰鐢�",
+      "deptcode": "FK",
+      "deptname": "濡囩",
+      "wardcode": null,
+      "wardname": null,
+      "icd10code": "O20.0",
+      "diagname": "鍏堝厗娴佷骇",
+      "pregnancySituation": "瀛�12鍛�",
+      "closeStatus": "0",
+      "registerUser": "鏉庡尰鐢�",
+      "orgid": "1",
+      "campusid": "1",
+      "delFlag": "0"
+    }
+  ]
+}
+```
+
+---
+
+### 2.2 鏂板鎴栦慨鏀瑰绉戞。妗�
+
+- **URL**锛歚POST /smartor/maternityArchive/insertOrUpdateMaternityArchive`
+- **璇存槑**锛氬悓鏃剁淮鎶ゅ绉戞。妗堜富琛ㄤ笌璇︽儏琛ㄣ��
+  - 涓昏〃鏈� `archiveid`锛堟垨璇︽儏鏈� `id` 涓旇兘鍙嶆煡锛変笖瀛樺湪鏃舵洿鏂帮紝鍚﹀垯鏂板銆�
+  - 杩斿洖 `data` 涓哄绉戞。妗堜富琛↖D銆�
+
+**璇锋眰浣擄紙JSON锛�**
+
+| 鍙傛暟鍚� | 绫诲瀷 | 蹇呭~ | 璇存槑 |
+| --- | --- | --- | --- |
+| id | Long | 鍚� | 濡囩妗f璇︽儏涓婚敭ID锛堟洿鏂拌鎯呮椂浼犲叆锛� |
+| archiveid | Long | 鍚� | 濡囩妗f涓昏〃ID锛堟洿鏂颁富琛ㄦ椂浼犲叆锛� |
+| archiveType | String | 鍚� | 妗f绫诲瀷锛�1 鏃╁瓡鍏崇埍锛�2 鍥寸粷缁忔湡MHI |
+| sourceType | String | 鍚� | 鏉ユ簮绫诲瀷锛�1 闂ㄨ瘖鎺ヨ瘖锛�2 浣忛櫌闅忚锛�3 鎵嬪伐鏂板 |
+| sourceBizId | Long | 鍚� | 鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID |
+| sourceBizNo | String | 鍚� | 鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙� |
+| sourceSubId | Long | 鍚� | 鏉ユ簮闅忚瀛愪换鍔D锛氫綇闄㈤殢璁跨敓鎴愭椂涓� service_subtask.id |
+| outhospno | String | 鍚� | 闂ㄨ瘖缂栧彿 |
+| inhospno | String | 鍚� | 浣忛櫌缂栧彿 |
+| serialnum | String | 鍚� | 娴佹按鍙� |
+| patid | Long | 鍚� | 鎮h�匢D |
+| patname | String | 鍚� | 鎮h�呭鍚� |
+| birthdate | Date | 鍚� | 鍑虹敓鏃ユ湡锛屾牸寮� yyyy-MM-dd HH:mm:ss |
+| idcardno | String | 鍚� | 璇佷欢鍙风爜 |
+| phone | String | 鍚� | 鑱旂郴鐢佃瘽 |
+| diagTime | Date | 鍚� | 璇婃柇鏃堕棿 |
+| archiveTime | Date | 鍚� | 寤烘。鏃堕棿 |
+| plannedFollowTime | Date | 鍚� | 鎷熼殢璁挎椂闂� |
+| sex | Long | 鍚� | 鎬у埆锛�1 鐢凤紝2 濂� |
+| doctorCode | String | 鍚� | 涓绘不鍖荤敓 |
+| doctorName | String | 鍚� | 涓绘不鍖荤敓濮撳悕 |
+| managementDoctorCode | String | 鍚� | 缁忕鍖荤敓 |
+| managementDoctorName | String | 鍚� | 缁忕鍖荤敓濮撳悕 |
+| deptcode | String | 鍚� | 绉戝缂栧彿 |
+| deptname | String | 鍚� | 绉戝鍚嶇О |
+| wardcode | String | 鍚� | 鐥呭尯缂栧彿 |
+| wardname | String | 鍚� | 鐥呭尯鍚嶇О |
+| icd10code | String | 鍚� | 璇婃柇ID |
+| diagname | String | 鍚� | 璇婃柇鍚嶇О |
+| pregnancySituation | String | 鍚� | 濡婂鎯呭喌 |
+| specificSituation | String | 鍚� | 鍏蜂綋鎯呭喌 |
+| handleSuggestion | String | 鍚� | 澶勭悊寤鸿 |
+| closeStatus | String | 鍚� | 缁撴鐘舵�� |
+| isRecordEstablished | String | 鍚� | 鏄惁寤哄唽锛�0 鍚︼紝1 鏄� |
+| dueDate | Date | 鍚� | 棰勪骇鏈� |
+| registerUser | String | 鍚� | 鐧昏浜哄憳 |
+| followupPeriod | String | 鍚� | 闅忚鍛ㄦ湡 |
+| followupCycleTimes | String | 鍚� | 闅忚鍛ㄦ湡(娆℃暟) |
+| lastMenstrualTime | Date | 鍚� | 鏈鏈堢粡 |
+| firstDoctorCode | String | 鍚� | 棣栬瘖鍖荤敓 |
+| firstDoctorName | String | 鍚� | 棣栬瘖鍖荤敓濮撳悕 |
+| contactPhone | String | 鍚� | 鑱旂郴浜鸿仈绯荤數璇� |
+| address | String | 鍚� | 灞呬綇鍦板潃 |
+| epEarlyPregnancyFollowupForm | String | 鍚� | 鏃╁瓡鍏崇埍-鏃╁瓡闅忚琛� |
+| mhiMenopauseFollowupSystemIssuesForm | String | 鍚� | 鍥寸粷缁忔湡MHI-鏇村勾鏈熼殢璁跨郴缁熼棶棰樿〃 |
+| mhiMhtInitialVisitMedicalRecordForm | String | 鍚� | 鍥寸粷缁忔湡MHI-MHT棣栬瘖鐥呭巻琛� |
+| mhiMhtFollowUpMedicalRecordForm | String | 鍚� | 鍥寸粷缁忔湡MHI-MHT澶嶈瘖鐥呭巻琛� |
+| mhiModifiedKuppermanScoringScaleForm | String | 鍚� | 鍥寸粷缁忔湡MHI-鏀硅壇Kupperman璇勫垎鏍囧噯琛� |
+| mhiMenopauseRatingScaleForm | String | 鍚� | 鍥寸粷缁忔湡MHI-鏇村勾鏈熻瘎瀹氶噺琛紙MRS锛� |
+| mhiPittsburghSleepQualityIndexForm | String | 鍚� | 鍥寸粷缁忔湡MHI-鍖瑰吂鍫$潯鐪犺川閲忔寚鏁伴噺琛紙PSQI锛� |
+| remark | String | 鍚� | 澶囨敞 |
+| orgid | String | 鍚� | 鍖婚櫌鏈烘瀯ID锛堝悗绔寜鐧诲綍鐢ㄦ埛鑷姩瑕嗙洊锛� |
+| campusid | String | 鍚� | 闄㈠尯ID锛堝悗绔寜鐧诲綍鐢ㄦ埛鑷姩瑕嗙洊锛� |
+| delFlag | String | 鍚� | 鍒犻櫎鏍囧織锛�0 鏈垹闄わ紝1 宸插垹闄わ紙榛樿 0锛� |
+
+**璇锋眰绀轰緥锛堟柊澧烇級**
+
+```json
+{
+  "archiveType": "1",
+  "patid": 9001,
+  "patname": "寮犱笁",
+  "birthdate": "1995-06-01 00:00:00",
+  "idcardno": "330102199506010022",
+  "phone": "13800000000",
+  "diagTime": "2026-10-01 09:30:00",
+  "archiveTime": "2026-10-01 10:00:00",
+  "sex": 2,
+  "deptcode": "FK",
+  "deptname": "濡囩",
+  "pregnancySituation": "瀛�12鍛�",
+  "closeStatus": "0"
+}
+```
+
+**鍝嶅簲绀轰緥**
+
+```json
+{
+  "code": 200,
+  "msg": "鎿嶄綔鎴愬姛",
+  "data": 1001
+}
+```
+
+---
+
+### 2.3 鎵归噺鍒犻櫎濡囩妗f
+
+- **URL**锛歚POST /smartor/maternityArchive/batchDelete`
+- **璇存槑**锛氭寜涓昏〃ID鎵归噺鍒犻櫎濡囩妗f锛屽悓鏃堕�昏緫鍒犻櫎瀵瑰簲鐨勫绉戞。妗堣鎯呰〃鏁版嵁锛坄del_flag` 缃负 1锛夛紝涓ゆ鍦ㄥ悓涓�浜嬪姟涓��
+
+**璇锋眰浣擄紙JSON锛�**
+
+| 鍙傛暟鍚� | 绫诲瀷 | 蹇呭~ | 璇存槑 |
+| --- | --- | --- | --- |
+| ids | Long[] | 鏄� | 濡囩妗f涓昏〃ID鏁扮粍 |
+
+**璇锋眰绀轰緥**
+
+```json
+[1001, 1002, 1003]
+```
+
+**鍝嶅簲绀轰緥**
+
+```json
+{
+  "code": 200,
+  "msg": "鎿嶄綔鎴愬姛"
+}
+```
+
+---
+
+### 2.4 鑾峰彇濡囩妗f璇︽儏
+
+- **URL**锛歚GET /smartor/maternityArchiveDetail/getInfo/{archiveid}`
+- **璇存槑**锛氭寜妗f涓昏〃ID鏌ヨ濡囩妗f璇︽儏锛堟湭鍒犻櫎鏁版嵁 `del_flag = '0'`锛夛紝杩斿洖绗竴鏉¤鎯呰褰曪紱鏃犳暟鎹椂 `data` 涓� `null`銆�
+
+**璺緞鍙傛暟**
+
+| 鍙傛暟鍚� | 绫诲瀷 | 蹇呭~ | 璇存槑 |
+| --- | --- | --- | --- |
+| archiveid | Long | 鏄� | 濡囩妗f涓昏〃ID锛坄pat_maternity_archive.id`锛� |
+
+**鍝嶅簲绀轰緥**
+
+```json
+{
+  "code": 200,
+  "msg": "鎿嶄綔鎴愬姛",
+  "data": {
+    "id": 5001,
+    "archiveid": 1001,
+    "archiveType": "1",
+    "sourceType": "1",
+    "outhospno": "MZ20261001001",
+    "inhospno": null,
+    "serialnum": "LS20261001001",
+    "patid": 9001,
+    "patname": "寮犱笁",
+    "birthdate": "1995-06-01 00:00:00",
+    "idcardno": "330102199506010022",
+    "phone": "13800000000",
+    "diagTime": "2026-10-01 09:30:00",
+    "archiveTime": "2026-10-01 10:00:00",
+    "plannedFollowTime": "2026-11-01 00:00:00",
+    "sex": 2,
+    "doctorCode": "D001",
+    "doctorName": "鏉庡尰鐢�",
+    "managementDoctorCode": "D002",
+    "managementDoctorName": "鐜嬪尰鐢�",
+    "deptcode": "FK",
+    "deptname": "濡囩",
+    "wardcode": null,
+    "wardname": null,
+    "icd10code": "O20.0",
+    "diagname": "鍏堝厗娴佷骇",
+    "pregnancySituation": "瀛�12鍛�",
+    "specificSituation": "鍏蜂綋鎯呭喌",
+    "handleSuggestion": "娉ㄦ剰浼戞伅",
+    "closeStatus": "0",
+    "isRecordEstablished": "1",
+    "dueDate": "2027-03-20 00:00:00",
+    "registerUser": "鏉庡尰鐢�",
+    "followupPeriod": "姣忔湀",
+    "followupCycleTimes": "4",
+    "lastMenstrualTime": "2026-06-10 00:00:00",
+    "firstDoctorCode": "D001",
+    "firstDoctorName": "鏉庡尰鐢�",
+    "contactPhone": "13900000000",
+    "address": "鏉窞甯傝タ婀栧尯",
+    "orgid": "1",
+    "campusid": "1",
+    "delFlag": "0"
+  }
+}
+```
+
+> 杩斿洖瀵硅薄 `data` 涓哄绉戞。妗堣鎯呭璞★紝瀛楁璇存槑鍚� 2.2 璇锋眰浣撳瓧娈点��
+
+---
+
+## 涓夈�佸効绉戞。妗堟帴鍙�
+
+### 3.1 鏌ヨ鍎跨妗f鍒楄〃
+
+- **URL**锛歚POST /smartor/childArchive/selectPatChildArchiveList`
+- **璇存槑**锛氬垎椤垫煡璇㈠効绉戞。妗堜富琛ㄥ垪琛紙鏈垹闄ゆ暟鎹� `del_flag = '0'`锛夈��
+
+**璇锋眰浣擄紙JSON锛屽叏閮ㄥ彲閫夛級**
+
+| 鍙傛暟鍚� | 绫诲瀷 | 蹇呭~ | 璇存槑 |
+| --- | --- | --- | --- |
+| pageNum | Integer | 鍚� | 椤电爜锛堝垎椤垫椂蹇呭~锛� |
+| pageSize | Integer | 鍚� | 姣忛〉鏉℃暟锛堝垎椤垫椂蹇呭~锛� |
+| archiveType | String | 鍚� | 妗f绫诲瀷锛�1 钀ュ吇鎬х柧鐥咃紝2 瀛︿範鍥伴毦锛�3 楂樺嵄鍎夸笓妗� |
+| outhospno | String | 鍚� | 闂ㄨ瘖缂栧彿锛堢簿纭尮閰嶏級 |
+| inhospno | String | 鍚� | 浣忛櫌缂栧彿锛堢簿纭尮閰嶏級 |
+| serialnum | String | 鍚� | 娴佹按鍙凤紙绮剧‘鍖归厤锛� |
+| patid | Long | 鍚� | 鎮h�匢D |
+| patname | String | 鍚� | 鎮h�呭鍚嶏紙妯$硦鍖归厤锛� |
+| parentname | String | 鍚� | 瀹堕暱濮撳悕锛堟ā绯婂尮閰嶏級 |
+| birthdate | Date | 鍚� | 鍑虹敓鏃ユ湡 |
+| idcardno | String | 鍚� | 璇佷欢鍙风爜锛堢簿纭尮閰嶏級 |
+| phone | String | 鍚� | 鑱旂郴鐢佃瘽锛堢簿纭尮閰嶏級 |
+| diagTime | Date | 鍚� | 璇婃柇鏃堕棿 |
+| plannedFollowTime | Date | 鍚� | 鎷熼殢璁挎椂闂� |
+| followupCycleTimes | String | 鍚� | 闅忚鍛ㄦ湡(娆℃暟) |
+| sex | Long | 鍚� | 鎬у埆锛�1 鐢凤紝2 濂� |
+| doctorCode | String | 鍚� | 涓绘不鍖荤敓锛堢簿纭尮閰嶏級 |
+| doctorName | String | 鍚� | 涓绘不鍖荤敓濮撳悕锛堟ā绯婂尮閰嶏級 |
+| managementDoctorCode | String | 鍚� | 缁忕鍖荤敓锛堢簿纭尮閰嶏級 |
+| managementDoctorName | String | 鍚� | 缁忕鍖荤敓濮撳悕锛堟ā绯婂尮閰嶏級 |
+| deptcode | String | 鍚� | 绉戝缂栧彿锛堢簿纭尮閰嶏級 |
+| deptname | String | 鍚� | 绉戝鍚嶇О锛堟ā绯婂尮閰嶏級 |
+| wardcode | String | 鍚� | 鐥呭尯缂栧彿锛堢簿纭尮閰嶏級 |
+| wardname | String | 鍚� | 鐥呭尯鍚嶇О锛堟ā绯婂尮閰嶏級 |
+| icd10code | String | 鍚� | 璇婃柇ID锛堢簿纭尮閰嶏級 |
+| diagname | String | 鍚� | 璇婃柇鍚嶇О锛堟ā绯婂尮閰嶏級 |
+| closeStatus | String | 鍚� | 缁撴鐘舵�� |
+| registerUser | String | 鍚� | 鐧昏浜哄憳 |
+| orgid | String | 鍚� | 鍖婚櫌鏈烘瀯ID锛堝悗绔寜鐧诲綍鐢ㄦ埛鑷姩娉ㄥ叆锛� |
+| campusid | String | 鍚� | 闄㈠尯ID锛堝悗绔寜鐧诲綍鐢ㄦ埛鑷姩娉ㄥ叆锛� |
+| params.beginTime | String | 鍚� | 寤烘。鏃堕棿鑼冨洿寮�濮嬶紝鏍煎紡 yyyy-MM-dd |
+| params.endTime | String | 鍚� | 寤烘。鏃堕棿鑼冨洿缁撴潫锛屾牸寮� yyyy-MM-dd |
+
+**璇锋眰绀轰緥**
+
+```json
+{
+  "pageNum": 1,
+  "pageSize": 10,
+  "patname": "鐜�",
+  "archiveType": "1"
+}
+```
+
+**鍝嶅簲绀轰緥**
+
+```json
+{
+  "code": 200,
+  "msg": "鏌ヨ鎴愬姛",
+  "total": 1,
+  "rows": [
+    {
+      "id": 2001,
+      "archiveType": "1",
+      "outhospno": "MZ20261001002",
+      "inhospno": null,
+      "serialnum": "LS20261001002",
+      "patid": 9002,
+      "patname": "鐜嬪皬瀹�",
+      "parentname": "鐜嬪己",
+      "birthdate": "2023-01-15 00:00:00",
+      "idcardno": null,
+      "phone": "13800000001",
+      "diagTime": "2026-10-01 09:00:00",
+      "archiveTime": "2026-10-01 09:30:00",
+      "plannedFollowTime": "2026-11-01 00:00:00",
+      "followupCycleTimes": "3",
+      "sex": 1,
+      "doctorCode": "D003",
+      "doctorName": "璧靛尰鐢�",
+      "managementDoctorCode": "D004",
+      "managementDoctorName": "瀛欏尰鐢�",
+      "deptcode": "EK",
+      "deptname": "鍎跨",
+      "wardcode": null,
+      "wardname": null,
+      "icd10code": "E44.0",
+      "diagname": "涓害钀ュ吇涓嶈壇",
+      "closeStatus": "0",
+      "registerUser": "璧靛尰鐢�",
+      "orgid": "1",
+      "campusid": "1",
+      "delFlag": "0"
+    }
+  ]
+}
+```
+
+---
+
+### 3.2 鏂板鎴栦慨鏀瑰効绉戞。妗�
+
+- **URL**锛歚POST /smartor/childArchive/insertOrUpdateChildArchive`
+- **璇存槑**锛氬悓鏃剁淮鎶ゅ効绉戞。妗堜富琛ㄤ笌璇︽儏琛ㄣ��
+  - 涓昏〃鏈� `archiveid`锛堟垨璇︽儏鏈� `id` 涓旇兘鍙嶆煡锛変笖瀛樺湪鏃舵洿鏂帮紝鍚﹀垯鏂板銆�
+  - 杩斿洖 `data` 涓哄効绉戞。妗堜富琛↖D銆�
+
+**璇锋眰浣擄紙JSON锛�**
+
+| 鍙傛暟鍚� | 绫诲瀷 | 蹇呭~ | 璇存槑 |
+| --- | --- | --- | --- |
+| id | Long | 鍚� | 鍎跨妗f璇︽儏涓婚敭ID锛堟洿鏂拌鎯呮椂浼犲叆锛� |
+| archiveid | Long | 鍚� | 鍎跨妗f涓昏〃ID锛堟洿鏂颁富琛ㄦ椂浼犲叆锛� |
+| archiveType | String | 鍚� | 妗f绫诲瀷锛�1 钀ュ吇鎬х柧鐥咃紝2 瀛︿範鍥伴毦锛�3 楂樺嵄鍎夸笓妗� |
+| sourceType | String | 鍚� | 鏉ユ簮绫诲瀷锛�1 闂ㄨ瘖鎺ヨ瘖锛�2 浣忛櫌闅忚锛�3 鎵嬪伐鏂板 |
+| sourceBizId | Long | 鍚� | 鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID |
+| sourceBizNo | String | 鍚� | 鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙� |
+| sourceSubId | Long | 鍚� | 鏉ユ簮闅忚瀛愪换鍔D锛氫綇闄㈤殢璁跨敓鎴愭椂涓� service_subtask.id |
+| outhospno | String | 鍚� | 闂ㄨ瘖缂栧彿 |
+| inhospno | String | 鍚� | 浣忛櫌缂栧彿 |
+| serialnum | String | 鍚� | 娴佹按鍙� |
+| patid | Long | 鍚� | 鎮h�匢D |
+| patname | String | 鍚� | 鎮h�呭鍚� |
+| parentname | String | 鍚� | 瀹堕暱濮撳悕 |
+| parentRelation | String | 鍚� | 瀹堕暱涓庡効绔ュ叧绯� |
+| parentPhone | String | 鍚� | 瀹堕暱鑱旂郴鐢佃瘽 |
+| parentIdcardno | String | 鍚� | 瀹堕暱璇佷欢鍙风爜 |
+| parentAddress | String | 鍚� | 瀹堕暱鑱旂郴鍦板潃 |
+| birthdate | Date | 鍚� | 鍑虹敓鏃ユ湡锛屾牸寮� yyyy-MM-dd HH:mm:ss |
+| idcardno | String | 鍚� | 璇佷欢鍙风爜 |
+| phone | String | 鍚� | 鑱旂郴鐢佃瘽 |
+| diagTime | Date | 鍚� | 璇婃柇鏃堕棿 |
+| archiveTime | Date | 鍚� | 寤烘。鏃堕棿 |
+| sex | Long | 鍚� | 鎬у埆锛�1 鐢凤紝2 濂� |
+| doctorCode | String | 鍚� | 涓绘不鍖荤敓 |
+| doctorName | String | 鍚� | 涓绘不鍖荤敓濮撳悕 |
+| managementDoctorCode | String | 鍚� | 缁忕鍖荤敓 |
+| managementDoctorName | String | 鍚� | 缁忕鍖荤敓濮撳悕 |
+| deptcode | String | 鍚� | 绉戝缂栧彿 |
+| deptname | String | 鍚� | 绉戝鍚嶇О |
+| wardcode | String | 鍚� | 鐥呭尯缂栧彿 |
+| wardname | String | 鍚� | 鐥呭尯鍚嶇О |
+| icd10code | String | 鍚� | 璇婃柇ID |
+| diagname | String | 鍚� | 璇婃柇鍚嶇О |
+| nutritionIcd10Code | String | 鍚� | 钀ュ吇鎬х柧鐥匢D |
+| nutritionDiagName | String | 鍚� | 钀ュ吇鎬х柧鐥呭悕绉� |
+| ndPhysicalMeasurements | String | 鍚� | 钀ュ吇鎬х柧鐥�-浣撴牸娴嬮噺 |
+| ndDietaryAssessment | String | 鍚� | 钀ュ吇鎬х柧鐥�-鑶抽璇勪及 |
+| ndInterventionProgram | String | 鍚� | 钀ュ吇鎬х柧鐥�-骞查鏂规 |
+| appointmentSituation | String | 鍚� | 瀛︿範鍥伴毦-棰勭害鎯呭喌 |
+| ldLearningAbilityAssessment | String | 鍚� | 瀛︿範鍥伴毦-瀛︿範鑳藉姏璇勪及 |
+| ldBehavioralAssessment | String | 鍚� | 瀛︿範鍥伴毦-琛屼负璇勪及 |
+| ldInterventionTrainingRecord | String | 鍚� | 瀛︿範鍥伴毦-骞查璁粌璁板綍 |
+| highRiskChildType | String | 鍚� | 楂樺嵄鍎夸笓妗�-楂樺嵄鍎垮垎绫� |
+| highRiskChildName | String | 鍚� | 楂樺嵄鍎夸笓妗�-楂樺嵄鍎垮悕绉� |
+| plannedFollowTime | Date | 鍚� | 楂樺嵄鍎夸笓妗�-鎷熼殢璁挎椂闂� |
+| hrcGrowthDevelopmentMonitoring | String | 鍚� | 楂樺嵄鍎夸笓妗�-鐢熼暱鍙戣偛妫�娴� |
+| hrcNeurologicalEvaluation | String | 鍚� | 楂樺嵄鍎夸笓妗�-绁炵粡绯荤粺璇勪及 |
+| hrcInterventionRecords | String | 鍚� | 楂樺嵄鍎夸笓妗�-骞查璁板綍 |
+| closeStatus | String | 鍚� | 缁撴鐘舵�� |
+| gestationalWeek | BigDecimal | 鍚� | 鍑虹敓瀛曞懆 |
+| birthWeight | BigDecimal | 鍚� | 鍑虹敓浣撻噸(kg) |
+| registerUser | String | 鍚� | 鐧昏浜哄憳 |
+| remark | String | 鍚� | 澶囨敞 |
+| orgid | String | 鍚� | 鍖婚櫌鏈烘瀯ID锛堝悗绔寜鐧诲綍鐢ㄦ埛鑷姩瑕嗙洊锛� |
+| campusid | String | 鍚� | 闄㈠尯ID锛堝悗绔寜鐧诲綍鐢ㄦ埛鑷姩瑕嗙洊锛� |
+| delFlag | String | 鍚� | 鍒犻櫎鏍囧織锛�0 鏈垹闄わ紝1 宸插垹闄わ紙榛樿 0锛� |
+
+**璇锋眰绀轰緥锛堟柊澧烇級**
+
+```json
+{
+  "archiveType": "1",
+  "patid": 9002,
+  "patname": "鐜嬪皬瀹�",
+  "parentname": "鐜嬪己",
+  "parentRelation": "鐖跺瓙",
+  "parentPhone": "13900000001",
+  "birthdate": "2023-01-15 00:00:00",
+  "phone": "13800000001",
+  "diagTime": "2026-10-01 09:00:00",
+  "archiveTime": "2026-10-01 09:30:00",
+  "sex": 1,
+  "deptcode": "EK",
+  "deptname": "鍎跨",
+  "icd10code": "E44.0",
+  "diagname": "涓害钀ュ吇涓嶈壇",
+  "nutritionIcd10Code": "E44.0",
+  "nutritionDiagName": "涓害钀ュ吇涓嶈壇",
+  "closeStatus": "0"
+}
+```
+
+**鍝嶅簲绀轰緥**
+
+```json
+{
+  "code": 200,
+  "msg": "鎿嶄綔鎴愬姛",
+  "data": 2001
+}
+```
+
+---
+
+### 3.3 鎵归噺鍒犻櫎鍎跨妗f
+
+- **URL**锛歚POST /smartor/childArchive/batchDelete`
+- **璇存槑**锛氭寜涓昏〃ID鎵归噺鍒犻櫎鍎跨妗f锛屽悓鏃堕�昏緫鍒犻櫎瀵瑰簲鐨勫効绉戞。妗堣鎯呰〃鏁版嵁锛坄del_flag` 缃负 1锛夛紝涓ゆ鍦ㄥ悓涓�浜嬪姟涓��
+
+**璇锋眰浣擄紙JSON锛�**
+
+| 鍙傛暟鍚� | 绫诲瀷 | 蹇呭~ | 璇存槑 |
+| --- | --- | --- | --- |
+| ids | Long[] | 鏄� | 鍎跨妗f涓昏〃ID鏁扮粍 |
+
+**璇锋眰绀轰緥**
+
+```json
+[2001, 2002, 2003]
+```
+
+**鍝嶅簲绀轰緥**
+
+```json
+{
+  "code": 200,
+  "msg": "鎿嶄綔鎴愬姛"
+}
+```
+
+---
+
+### 3.4 鑾峰彇鍎跨妗f璇︽儏
+
+- **URL**锛歚GET /smartor/childArchiveDetail/getInfo/{archiveid}`
+- **璇存槑**锛氭寜妗f涓昏〃ID鏌ヨ鍎跨妗f璇︽儏锛堟湭鍒犻櫎鏁版嵁 `del_flag = '0'`锛夛紝杩斿洖绗竴鏉¤鎯呰褰曪紱鏃犳暟鎹椂 `data` 涓� `null`銆�
+
+**璺緞鍙傛暟**
+
+| 鍙傛暟鍚� | 绫诲瀷 | 蹇呭~ | 璇存槑 |
+| --- | --- | --- | --- |
+| archiveid | Long | 鏄� | 鍎跨妗f涓昏〃ID锛坄pat_child_archive.id`锛� |
+
+**鍝嶅簲绀轰緥**
+
+```json
+{
+  "code": 200,
+  "msg": "鎿嶄綔鎴愬姛",
+  "data": {
+    "id": 6001,
+    "archiveid": 2001,
+    "archiveType": "1",
+    "sourceType": "1",
+    "outhospno": "MZ20261001002",
+    "inhospno": null,
+    "serialnum": "LS20261001002",
+    "patid": 9002,
+    "patname": "鐜嬪皬瀹�",
+    "parentname": "鐜嬪己",
+    "parentRelation": "鐖跺瓙",
+    "parentPhone": "13900000001",
+    "parentIdcardno": null,
+    "parentAddress": "鏉窞甯傛嫳澧呭尯",
+    "birthdate": "2023-01-15 00:00:00",
+    "idcardno": null,
+    "phone": "13800000001",
+    "diagTime": "2026-10-01 09:00:00",
+    "archiveTime": "2026-10-01 09:30:00",
+    "sex": 1,
+    "doctorCode": "D003",
+    "doctorName": "璧靛尰鐢�",
+    "managementDoctorCode": "D004",
+    "managementDoctorName": "瀛欏尰鐢�",
+    "deptcode": "EK",
+    "deptname": "鍎跨",
+    "wardcode": null,
+    "wardname": null,
+    "icd10code": "E44.0",
+    "diagname": "涓害钀ュ吇涓嶈壇",
+    "nutritionIcd10Code": "E44.0",
+    "nutritionDiagName": "涓害钀ュ吇涓嶈壇",
+    "closeStatus": "0",
+    "gestationalWeek": 39.5,
+    "birthWeight": 3.2,
+    "registerUser": "璧靛尰鐢�",
+    "orgid": "1",
+    "campusid": "1",
+    "delFlag": "0"
+  }
+}
+```
+
+> 杩斿洖瀵硅薄 `data` 涓哄効绉戞。妗堣鎯呭璞★紝瀛楁璇存槑鍚� 3.2 璇锋眰浣撳瓧娈点��
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java b/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java
index e889ed6..df9e6b7 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java
@@ -56,6 +56,7 @@
 import com.ruoyi.task.domain.SendMagParam;
 import com.ruoyi.task.service.IServiceSubtaskRecordService;
 import com.ruoyi.task.mapper.ServiceSubtaskPreachformMapper;
+import com.ruoyi.task.event.FollowupCompletedEventPublisher;
 import com.ruoyi.patarchive.mapper.PatArchiveMapper;
 @Slf4j
 @Component//鐩戝惉姝ら槦鍒�
@@ -72,6 +73,9 @@
 
     @Value("${req_path}")
     private String req_path;
+
+    @Autowired
+    private FollowupCompletedEventPublisher followupCompletedEventPublisher;
 
     @Autowired
     private IServiceOutPathService iServiceOutPathService;
@@ -898,6 +902,9 @@
             serviceSubtask.setSendstate(6L);
         }
         serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
+        if (Long.valueOf(6L).equals(serviceSubtask.getSendstate())) {
+            followupCompletedEventPublisher.publish(serviceSubtask.getId());
+        }
 
         // 鏇存柊褰撳墠鍙戦�佹柟寮忔槑缁嗭紱鍙戦�佹垚鍔熸椂鍏佽褰撳墠琛屽凡缁忔槸 sendstate=2銆�
         currentPreachformRow.setSendstate(failSendstate);
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/event/FollowupCompletedEvent.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/event/FollowupCompletedEvent.java
new file mode 100644
index 0000000..43ad2c9
--- /dev/null
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/event/FollowupCompletedEvent.java
@@ -0,0 +1,46 @@
+package com.ruoyi.common.core.event;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 闅忚瀹屾垚浜嬩欢銆�
+ *
+ * <p>浠呮惡甯﹀瓙浠诲姟ID锛屾秷璐规柟鎸塈D閲嶆柊鍔犺浇鏈�鏂版暟鎹紝閬垮厤浜嬩欢鍐呭涓庡簱鍐呯姸鎬佷笉涓�鑷淬��</p>
+ *
+ * @author ruoyi
+ * @date 2026-11-11
+ */
+public class FollowupCompletedEvent implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /** 闅忚瀛愪换鍔D */
+    private Long subId;
+
+    /** 瀹屾垚鏃堕棿 */
+    private Date finishTime;
+
+    public FollowupCompletedEvent() {
+    }
+
+    public FollowupCompletedEvent(Long subId, Date finishTime) {
+        this.subId = subId;
+        this.finishTime = finishTime;
+    }
+
+    public Long getSubId() {
+        return subId;
+    }
+
+    public void setSubId(Long subId) {
+        this.subId = subId;
+    }
+
+    public Date getFinishTime() {
+        return finishTime;
+    }
+
+    public void setFinishTime(Date finishTime) {
+        this.finishTime = finishTime;
+    }
+}
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 b5cafc8..5aa2a76 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
@@ -149,6 +149,12 @@
     private ICollectHISService ichService;
 
     @Autowired
+    private IPatSpecificArchiveGenerateService patSpecificArchiveGenerateService;
+
+    @Autowired
+    private com.ruoyi.task.event.FollowupCompletedEventPublisher followupCompletedEventPublisher;
+
+    @Autowired
     private ISysConfigService configService;
 
     @Autowired
@@ -1220,6 +1226,7 @@
                 if (finishState) {
                     serviceSubtask.setSendstate(6L);
                     serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
+                    followupCompletedEventPublisher.publish(serviceSubtask.getId());
                     continue;
                 }
 
@@ -1832,6 +1839,7 @@
                 //璇存槑锛屽湪鏌愮鏂瑰紡鍙戦�佸け璐ュ悗锛屽張鎴愬姛浜嗭紙渚嬪鐭俊鎴栧叕浼楀彿锛屽湪瑙勫畾鏃堕棿澶栨偅鑰呭仛瀹屼簡锛岃繖涓椂鍊欙紝鐘舵�佹敼鎴愪簡9锛�
                 serviceSubtask.setSendstate(6L);
                 serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
+                followupCompletedEventPublisher.publish(serviceSubtask.getId());
                 return "-1";
             }
             // 褰搒ort绛変簬鍒楄〃size鏃讹紝骞朵笖鎵�鏈塻endstate閮戒笉绛変簬9锛屽垯杩斿洖-1
@@ -2093,6 +2101,9 @@
         serviceSubtask.setRemark(StringUtils.isNotEmpty(serviceSubtask.getRemark()) ? serviceSubtask.getRemark() + "," + remark : remark);
         log.info("serviceSubtask鐨勫叆鍙傛槸锛歿}",serviceSubtask);
         serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
+        if (Long.valueOf(6L).equals(serviceSubtask.getSendstate())) {
+            followupCompletedEventPublisher.publish(serviceSubtask.getId());
+        }
         return true;
     }
 
@@ -2348,4 +2359,18 @@
         }
     }
 
+    /**
+     * 浣忛櫌闅忚瀹屾垚鐢熸垚涓撶妗f琛ュ伩浠诲姟銆�
+     *
+     * <p>鎵弿杩� 7 澶╁凡瀹屾垚浣嗘湭鐢熸垚鏃ュ織鐨勪綇闄㈤殢璁匡紝鎸夐厤缃ˉ鐢熸垚濡囩/鍎跨妗f銆�</p>
+     */
+    public void generateInhospFollowupArchive() {
+        try {
+            int generated = patSpecificArchiveGenerateService.compensateInhospFollowups();
+            log.info("銆恎enerateInhospFollowupArchive銆戜綇闄㈤殢璁夸笓绉戞。妗堣ˉ鍋垮畬鎴愶紝鐢熸垚鏁伴噺={}", generated);
+        } catch (Exception e) {
+            log.error("銆恎enerateInhospFollowupArchive銆戜綇闄㈤殢璁夸笓绉戞。妗堣ˉ鍋垮け璐�", e);
+        }
+    }
+
 }
diff --git a/ruoyi-task/src/main/java/com/ruoyi/task/api/TaskSubtaskApi.java b/ruoyi-task/src/main/java/com/ruoyi/task/api/TaskSubtaskApi.java
index d0b9827..2e921e1 100644
--- a/ruoyi-task/src/main/java/com/ruoyi/task/api/TaskSubtaskApi.java
+++ b/ruoyi-task/src/main/java/com/ruoyi/task/api/TaskSubtaskApi.java
@@ -53,6 +53,19 @@
     List<ServiceSubtask> findSubtasks(ServiceSubtaskEntity query);
 
     /**
+     * 鏌ヨ宸插畬鎴愩�佹寚瀹氭満鏋�/鏈嶅姟绫诲瀷銆佸畬鎴愭椂闂村湪 startTime 涔嬪悗鐨勪綇闄㈤殢璁垮瓙浠诲姟銆�
+     * 渚涗綇闄㈤殢璁挎。妗堣ˉ鍋夸换鍔′娇鐢ㄣ��
+     *
+     * @param orgid        鏈烘瀯ID
+     * @param serviceTypes 鏈嶅姟绫诲瀷鐧藉悕鍗�
+     * @param startTime    瀹屾垚鏃堕棿涓嬮檺
+     * @param limit        鏈�澶ф潯鏁�
+     * @return 瀛愪换鍔″垪琛�
+     */
+    List<ServiceSubtask> findCompletedInhospFollowups(String orgid, List<String> serviceTypes,
+                                                      java.util.Date startTime, int limit);
+
+    /**
      * 鏇存柊瀛愪换鍔★紙鍘� {@code ServiceSubtaskMapper#updateServiceSubtask}锛屽姩鎬� SQL 鍙敼闈炵┖瀛楁锛�
      *
      * @param subtask 寰呮洿鏂板璞★紙蹇呴』甯� id锛�
diff --git a/ruoyi-task/src/main/java/com/ruoyi/task/api/contract/TaskSubtaskApiImpl.java b/ruoyi-task/src/main/java/com/ruoyi/task/api/contract/TaskSubtaskApiImpl.java
index dc88006..54a73a8 100644
--- a/ruoyi-task/src/main/java/com/ruoyi/task/api/contract/TaskSubtaskApiImpl.java
+++ b/ruoyi-task/src/main/java/com/ruoyi/task/api/contract/TaskSubtaskApiImpl.java
@@ -12,6 +12,7 @@
 import com.ruoyi.task.mapper.ServiceSubtaskMapper;
 import com.ruoyi.task.service.IServiceSubtaskDetailTraceService;
 import com.ruoyi.task.service.IServiceTaskService;
+import com.ruoyi.task.event.FollowupCompletedEventPublisher;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -49,6 +50,9 @@
     @Autowired
     private IServiceSubtaskDetailTraceService traceService;
 
+    @Autowired
+    private FollowupCompletedEventPublisher followupCompletedEventPublisher;
+
     @Override
     public ServiceSubtask getSubtask(Long subId) {
         return serviceSubtaskMapper.selectServiceSubtaskById(subId);
@@ -60,8 +64,18 @@
     }
 
     @Override
+    public List<ServiceSubtask> findCompletedInhospFollowups(String orgid, List<String> serviceTypes,
+                                                             java.util.Date startTime, int limit) {
+        return serviceSubtaskMapper.selectCompletedInhospFollowups(orgid, serviceTypes, startTime, limit);
+    }
+
+    @Override
     public int updateSubtask(ServiceSubtask subtask) {
         Boolean updated = serviceSubtaskMapper.updateServiceSubtask(subtask);
+        if (Boolean.TRUE.equals(updated) && subtask.getSendstate() != null
+                && subtask.getSendstate() == 6 && subtask.getId() != null) {
+            followupCompletedEventPublisher.publish(subtask.getId());
+        }
         return Boolean.TRUE.equals(updated) ? 1 : 0;
     }
 
diff --git a/ruoyi-task/src/main/java/com/ruoyi/task/event/FollowupCompletedEventPublisher.java b/ruoyi-task/src/main/java/com/ruoyi/task/event/FollowupCompletedEventPublisher.java
new file mode 100644
index 0000000..aefaebe
--- /dev/null
+++ b/ruoyi-task/src/main/java/com/ruoyi/task/event/FollowupCompletedEventPublisher.java
@@ -0,0 +1,37 @@
+package com.ruoyi.task.event;
+
+import com.ruoyi.common.core.event.FollowupCompletedEvent;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationEventPublisher;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+/**
+ * 闅忚瀹屾垚浜嬩欢鍙戝竷鍣ㄣ��
+ *
+ * <p>浠诲姟妯″潡鍦ㄥ瓙浠诲姟鐘舵�佹洿鏂颁负宸插畬鎴愶紙sendstate=6锛夊悗鍙戝竷浜嬩欢锛�
+ * 妗f绛変笅娓告ā鍧楅�氳繃 {@code @TransactionalEventListener} 寮傛娑堣垂銆�</p>
+ *
+ * @author ruoyi
+ * @date 2026-11-11
+ */
+@Slf4j
+@Component
+public class FollowupCompletedEventPublisher {
+
+    @Autowired
+    private ApplicationEventPublisher applicationEventPublisher;
+
+    public void publish(Long subId) {
+        if (subId == null) {
+            return;
+        }
+        try {
+            applicationEventPublisher.publishEvent(new FollowupCompletedEvent(subId, new Date()));
+        } catch (Exception e) {
+            log.error("鍙戝竷闅忚瀹屾垚浜嬩欢澶辫触锛宻ubId={}", subId, e);
+        }
+    }
+}
diff --git a/ruoyi-task/src/main/java/com/ruoyi/task/mapper/ServiceSubtaskMapper.java b/ruoyi-task/src/main/java/com/ruoyi/task/mapper/ServiceSubtaskMapper.java
index 1bbb207..fa5e26e 100644
--- a/ruoyi-task/src/main/java/com/ruoyi/task/mapper/ServiceSubtaskMapper.java
+++ b/ruoyi-task/src/main/java/com/ruoyi/task/mapper/ServiceSubtaskMapper.java
@@ -48,6 +48,20 @@
     public List<ServiceSubtask> selectServiceSubtaskList(ServiceSubtaskEntity serviceSubtaskVO);
 
     /**
+     * 鏌ヨ宸插畬鎴愩�佷笖灏氭湭琚笓绉戞。妗堢敓鎴愭棩蹇楀鐞嗙殑浣忛櫌闅忚瀛愪换鍔★紙琛ュ伩鎵弿鐢級銆�
+     *
+     * @param orgid        鏈烘瀯ID
+     * @param serviceTypes 鏈嶅姟绫诲瀷鐧藉悕鍗�
+     * @param startTime    瀹屾垚鏃堕棿涓嬮檺
+     * @param limit        鏈�澶ф潯鏁�
+     * @return 瀛愪换鍔¢泦鍚�
+     */
+    public List<ServiceSubtask> selectCompletedInhospFollowups(@Param("orgid") String orgid,
+                                                               @Param("serviceTypes") List<String> serviceTypes,
+                                                               @Param("startTime") Date startTime,
+                                                               @Param("limit") int limit);
+
+    /**
      * 鍒嗛〉绗竴闃舵锛氬彧鍙栧綋鍓嶉〉鐨勫瓙浠诲姟 id銆�
      * <p>
      * where / order 涓� {@link #selectServiceSubtaskList} 鍏辩敤鍚屼竴浠� XML 鐗囨
diff --git a/ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java b/ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java
index 897f1a9..f094195 100644
--- a/ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java
+++ b/ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java
@@ -126,6 +126,7 @@
 import com.ruoyi.system.service.ISysDeptService;
 import com.ruoyi.system.mapper.ext.SysDept2Mapper;
 import com.ruoyi.task.api.contract.OperationSubtaskWriter;
+import com.ruoyi.task.event.FollowupCompletedEventPublisher;
 
 /**
  * 鍗曚竴浠诲姟锛堥殢璁匡級Service涓氬姟灞傚鐞�
@@ -145,6 +146,9 @@
      */
     @Autowired
     private OperationSubtaskWriter operationSubtaskWriter;
+
+    @Autowired
+    private FollowupCompletedEventPublisher followupCompletedEventPublisher;
 
     /**
      * 婊℃剰搴︽ā鍧楀澶栭棬闈紙甯搁┗ Bean锛夈��
@@ -1579,7 +1583,12 @@
         if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 6)
             serviceSubtask.setFinishtime(new Date());
 
-        return serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
+        Boolean updated = serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
+        if (Boolean.TRUE.equals(updated) && serviceSubtask.getSendstate() != null
+                && serviceSubtask.getSendstate() == 6 && serviceSubtask.getId() != null) {
+            followupCompletedEventPublisher.publish(serviceSubtask.getId());
+        }
+        return updated;
     }
 
     @Override
@@ -4958,6 +4967,7 @@
             serviceSubtask.setSendstate(6L);
             serviceSubtask.setPreachform("1");
             serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
+            followupCompletedEventPublisher.publish(serviceSubtask.getId());
         }
     }
 
@@ -5102,6 +5112,7 @@
         if (subtaskUpdated == 0) {
             throw new BaseException("寰俊鍏紬鍙烽粯璁ゅ畬鎴愬け璐ワ細瀛愪换鍔$姸鎬佸凡鍙樺寲锛宻ubid=" + current.getId());
         }
+        followupCompletedEventPublisher.publish(current.getId());
 
         log.info("銆愬井淇″叕浼楀彿榛樿瀹屾垚銆憇ubid锛歿}锛屽凡鎸夐粯璁ら�夐」瀹屾垚锛屽~鍏呴鐩暟锛歿}", current.getId(), filled);
         return true;
diff --git a/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml b/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
index 93d3c3d..b344cdf 100644
--- a/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
+++ b/ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.xml
@@ -1200,6 +1200,23 @@
         where id = #{id}
     </select>
 
+    <select id="selectCompletedInhospFollowups" resultMap="ServiceSubtaskResult">
+        <include refid="selectServiceSubtaskVo"/>
+        where del_flag = '0'
+          and sendstate = 6
+          and hosp_type in ('2', '6')
+          and orgid = #{orgid}
+          and finishtime &gt;= #{startTime}
+        <if test="serviceTypes != null and serviceTypes.size() > 0">
+            and service_type in
+            <foreach collection="serviceTypes" item="serviceType" open="(" separator="," close=")">
+                #{serviceType}
+            </foreach>
+        </if>
+        order by id asc
+        limit #{limit}
+    </select>
+
     <select id="selectServiceSubtaskByDiagname" parameterType="com.ruoyi.task.domain.ServiceSubtask"
             resultMap="ServiceSubtaskResult">
         select sendstate,starttime,endtime,nurse_name,phone,sex,task_name,sendname,leavediagname,visit_time FROM
diff --git a/smartor/src/main/java/com/smartor/common/SpecificArchiveConstants.java b/smartor/src/main/java/com/smartor/common/SpecificArchiveConstants.java
index ce0c778..10792bb 100644
--- a/smartor/src/main/java/com/smartor/common/SpecificArchiveConstants.java
+++ b/smartor/src/main/java/com/smartor/common/SpecificArchiveConstants.java
@@ -16,6 +16,36 @@
      */
     public static final String DEFAULT_CAMPUS_ID = "1";
 
+    /** 鏉ユ簮绫诲瀷锛氶棬璇婃帴璇婂畬鎴� */
+    public static final String SOURCE_TYPE_OUTHOSP = "1";
+
+    /** 鏉ユ簮绫诲瀷锛氫綇闄㈤殢璁垮畬鎴� */
+    public static final String SOURCE_TYPE_INHOSP_FOLLOWUP = "2";
+
+    /** 鏉ユ簮绫诲瀷锛氭墜宸ユ柊澧�/鎵嬪伐瀵煎叆 */
+    public static final String SOURCE_TYPE_MANUAL = "3";
+
+    /** 閮ㄩ棬鍒嗙被锛氬绉� */
+    public static final String DEPT_CATEGORY_GYNECOLOGY = "1";
+
+    /** 閮ㄩ棬鍒嗙被锛氬効绉� */
+    public static final String DEPT_CATEGORY_PEDIATRICS = "2";
+
+    /** 鐢熸垚缁撴灉锛氬凡鐢熸垚 */
+    public static final String RESULT_GENERATED = "1";
+
+    /** 鐢熸垚缁撴灉锛氭偅鑰呭凡鏈夊搴旀。妗堬紝璺宠繃 */
+    public static final String RESULT_EXISTS = "2";
+
+    /** 鐢熸垚缁撴灉锛氭湭鍛戒腑閰嶇疆 */
+    public static final String RESULT_NO_MATCH = "3";
+
+    /** 鐢熸垚缁撴灉锛氬け璐� */
+    public static final String RESULT_FAILED = "4";
+
+    /** 浣忛櫌闅忚鏉ユ簮鐨勯粯璁ら厤缃甀D锛堟湭鍛戒腑閰嶇疆鏃跺啓鏃ュ織鐢級 */
+    public static final int NO_CONFIG_ID = 0;
+
     private SpecificArchiveConstants() {
     }
 }
diff --git a/smartor/src/main/java/com/smartor/domain/PatChildArchive.java b/smartor/src/main/java/com/smartor/domain/PatChildArchive.java
index 013137d..c300014 100644
--- a/smartor/src/main/java/com/smartor/domain/PatChildArchive.java
+++ b/smartor/src/main/java/com/smartor/domain/PatChildArchive.java
@@ -30,6 +30,23 @@
     @ApiModelProperty(value = "鍎跨妗f绫诲瀷: 1 钀ュ吇鎬х柧鐥�2 瀛︿範鍥伴毦3 楂樺嵄鍎夸笓妗�")
     private String archiveType;
 
+    /** 鏉ユ簮绫诲瀷锛�1闂ㄨ瘖鎺ヨ瘖 2浣忛櫌闅忚 3鎵嬪伐鏂板 */
+    @Excel(name = "鏉ユ簮绫诲瀷")
+    @ApiModelProperty(value = "鏉ユ簮绫诲瀷锛�1闂ㄨ瘖鎺ヨ瘖 2浣忛櫌闅忚 3鎵嬪伐鏂板")
+    private String sourceType;
+
+    /** 鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID */
+    @ApiModelProperty(value = "鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID")
+    private Long sourceBizId;
+
+    /** 鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙� */
+    @ApiModelProperty(value = "鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙�")
+    private String sourceBizNo;
+
+    /** 鏉ユ簮闅忚瀛愪换鍔D锛氫綇闄㈤殢璁跨敓鎴愭椂璁板綍瑙﹀彂妗f鐢熸垚鐨� service_subtask.id */
+    @ApiModelProperty(value = "鏉ユ簮闅忚瀛愪换鍔D锛氫綇闄㈤殢璁跨敓鎴愭椂璁板綍瑙﹀彂妗f鐢熸垚鐨� service_subtask.id")
+    private Long sourceSubId;
+
     /** 闂ㄨ瘖缂栧彿 */
     @Excel(name = "闂ㄨ瘖缂栧彿")
     @ApiModelProperty(value = "闂ㄨ瘖缂栧彿")
diff --git a/smartor/src/main/java/com/smartor/domain/PatChildArchiveDetail.java b/smartor/src/main/java/com/smartor/domain/PatChildArchiveDetail.java
index a4fce85..c336e02 100644
--- a/smartor/src/main/java/com/smartor/domain/PatChildArchiveDetail.java
+++ b/smartor/src/main/java/com/smartor/domain/PatChildArchiveDetail.java
@@ -35,11 +35,23 @@
     @ApiModelProperty(value = "妗f绫诲瀷: 1 钀ュ吇鎬х柧鐥�2 瀛︿範鍥伴毦3 楂樺嵄鍎夸笓妗�")
     private String archiveType;
 
-    /** 鏉ユ簮绫诲瀷: 1 闂ㄨ瘖璁板綍 */
+    /** 鏉ユ簮绫诲瀷锛�1闂ㄨ瘖鎺ヨ瘖 2浣忛櫌闅忚 3鎵嬪伐鏂板 */
     @Excel(name = "鏉ユ簮绫诲瀷")
-    @ApiModelProperty(value = "鏉ユ簮绫诲瀷: 1 闂ㄨ瘖璁板綍")
+    @ApiModelProperty(value = "鏉ユ簮绫诲瀷锛�1闂ㄨ瘖鎺ヨ瘖 2浣忛櫌闅忚 3鎵嬪伐鏂板")
     private String sourceType;
 
+    /** 鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID */
+    @ApiModelProperty(value = "鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID")
+    private Long sourceBizId;
+
+    /** 鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙� */
+    @ApiModelProperty(value = "鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙�")
+    private String sourceBizNo;
+
+    /** 鏉ユ簮闅忚瀛愪换鍔D锛氫綇闄㈤殢璁跨敓鎴愭椂璁板綍瑙﹀彂妗f鐢熸垚鐨� service_subtask.id */
+    @ApiModelProperty(value = "鏉ユ簮闅忚瀛愪换鍔D锛氫綇闄㈤殢璁跨敓鎴愭椂璁板綍瑙﹀彂妗f鐢熸垚鐨� service_subtask.id")
+    private Long sourceSubId;
+
     /** 闂ㄨ瘖缂栧彿 */
     @Excel(name = "闂ㄨ瘖缂栧彿")
     @ApiModelProperty(value = "闂ㄨ瘖缂栧彿")
diff --git a/smartor/src/main/java/com/smartor/domain/PatMaternityArchive.java b/smartor/src/main/java/com/smartor/domain/PatMaternityArchive.java
index 6d48ea4..30a1c29 100644
--- a/smartor/src/main/java/com/smartor/domain/PatMaternityArchive.java
+++ b/smartor/src/main/java/com/smartor/domain/PatMaternityArchive.java
@@ -29,6 +29,23 @@
     @ApiModelProperty(value = "濡囧辜妗f绫诲瀷: 1 鏃╁瓡鍏崇埍2 鍥寸粷缁忔湡MHI")
     private String archiveType;
 
+    /** 鏉ユ簮绫诲瀷锛�1闂ㄨ瘖鎺ヨ瘖 2浣忛櫌闅忚 3鎵嬪伐鏂板 */
+    @Excel(name = "鏉ユ簮绫诲瀷")
+    @ApiModelProperty(value = "鏉ユ簮绫诲瀷锛�1闂ㄨ瘖鎺ヨ瘖 2浣忛櫌闅忚 3鎵嬪伐鏂板")
+    private String sourceType;
+
+    /** 鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID */
+    @ApiModelProperty(value = "鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID")
+    private Long sourceBizId;
+
+    /** 鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙� */
+    @ApiModelProperty(value = "鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙�")
+    private String sourceBizNo;
+
+    /** 鏉ユ簮闅忚瀛愪换鍔D锛氫綇闄㈤殢璁跨敓鎴愭椂璁板綍瑙﹀彂妗f鐢熸垚鐨� service_subtask.id */
+    @ApiModelProperty(value = "鏉ユ簮闅忚瀛愪换鍔D锛氫綇闄㈤殢璁跨敓鎴愭椂璁板綍瑙﹀彂妗f鐢熸垚鐨� service_subtask.id")
+    private Long sourceSubId;
+
     /** 闂ㄨ瘖缂栧彿 */
     @Excel(name = "闂ㄨ瘖缂栧彿")
     @ApiModelProperty(value = "闂ㄨ瘖缂栧彿")
diff --git a/smartor/src/main/java/com/smartor/domain/PatMaternityArchiveDetail.java b/smartor/src/main/java/com/smartor/domain/PatMaternityArchiveDetail.java
index af5f83b..79480fe 100644
--- a/smartor/src/main/java/com/smartor/domain/PatMaternityArchiveDetail.java
+++ b/smartor/src/main/java/com/smartor/domain/PatMaternityArchiveDetail.java
@@ -34,11 +34,23 @@
     @ApiModelProperty(value = "妗f绫诲瀷: 1 鏃╁瓡鍏崇埍2 鍥寸粷缁忔湡MHI")
     private String archiveType;
 
-    /** 鏉ユ簮绫诲瀷: 1 闂ㄨ瘖璁板綍 */
+    /** 鏉ユ簮绫诲瀷锛�1闂ㄨ瘖鎺ヨ瘖 2浣忛櫌闅忚 3鎵嬪伐鏂板 */
     @Excel(name = "鏉ユ簮绫诲瀷")
-    @ApiModelProperty(value = "鏉ユ簮绫诲瀷: 1 闂ㄨ瘖璁板綍")
+    @ApiModelProperty(value = "鏉ユ簮绫诲瀷锛�1闂ㄨ瘖鎺ヨ瘖 2浣忛櫌闅忚 3鎵嬪伐鏂板")
     private String sourceType;
 
+    /** 鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID */
+    @ApiModelProperty(value = "鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID")
+    private Long sourceBizId;
+
+    /** 鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙� */
+    @ApiModelProperty(value = "鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙�")
+    private String sourceBizNo;
+
+    /** 鏉ユ簮闅忚瀛愪换鍔D锛氫綇闄㈤殢璁跨敓鎴愭椂璁板綍瑙﹀彂妗f鐢熸垚鐨� service_subtask.id */
+    @ApiModelProperty(value = "鏉ユ簮闅忚瀛愪换鍔D锛氫綇闄㈤殢璁跨敓鎴愭椂璁板綍瑙﹀彂妗f鐢熸垚鐨� service_subtask.id")
+    private Long sourceSubId;
+
     /** 闂ㄨ瘖缂栧彿 */
     @Excel(name = "闂ㄨ瘖缂栧彿")
     @ApiModelProperty(value = "闂ㄨ瘖缂栧彿")
diff --git a/smartor/src/main/java/com/smartor/domain/PatSpecificArchiveGenerateLog.java b/smartor/src/main/java/com/smartor/domain/PatSpecificArchiveGenerateLog.java
new file mode 100644
index 0000000..fcdf5c5
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/domain/PatSpecificArchiveGenerateLog.java
@@ -0,0 +1,90 @@
+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;
+
+/**
+ * 涓撶妗f鐢熸垚鏃ュ織瀵硅薄 pat_specific_archive_generate_log銆�
+ *
+ * <p>鐢ㄤ簬浣忛櫌闅忚瀹屾垚鍚庣殑骞傜瓑鎺у埗銆佹潵婧愯拷婧拰琛ュ伩浠诲姟绛涢�夈��</p>
+ *
+ * @author ruoyi
+ * @date 2026-11-11
+ */
+@Data
+@ApiModel(value = "涓撶妗f鐢熸垚鏃ュ織瀵硅薄")
+public class PatSpecificArchiveGenerateLog implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /** 涓婚敭ID */
+    @ApiModelProperty(value = "涓婚敭ID")
+    private Long id;
+
+    /** 鏉ユ簮绫诲瀷锛�1闂ㄨ瘖鎺ヨ瘖 2浣忛櫌闅忚 */
+    @ApiModelProperty(value = "鏉ユ簮绫诲瀷锛�1闂ㄨ瘖鎺ヨ瘖 2浣忛櫌闅忚")
+    private String sourceType;
+
+    /** 鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID */
+    @ApiModelProperty(value = "鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID")
+    private Long sourceBizId;
+
+    /** 鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙� */
+    @ApiModelProperty(value = "鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙�")
+    private String sourceBizNo;
+
+    /** 鏉ユ簮闅忚瀛愪换鍔D锛氳Е鍙戞。妗堢敓鎴愮殑 service_subtask.id */
+    @ApiModelProperty(value = "鏉ユ簮闅忚瀛愪换鍔D锛氳Е鍙戞。妗堢敓鎴愮殑 service_subtask.id")
+    private Long sourceSubId;
+
+    /** 鎮h�匢D */
+    @ApiModelProperty(value = "鎮h�匢D")
+    private Long patid;
+
+    /** 鏈烘瀯ID */
+    @ApiModelProperty(value = "鏈烘瀯ID")
+    private String orgid;
+
+    /** 闄㈠尯ID */
+    @ApiModelProperty(value = "闄㈠尯ID")
+    private String campusid;
+
+    /** 閮ㄩ棬鍒嗙被锛�1濡囩 2鍎跨 */
+    @ApiModelProperty(value = "閮ㄩ棬鍒嗙被锛�1濡囩 2鍎跨")
+    private String deptCategory;
+
+    /** 妗f绫诲瀷 */
+    @ApiModelProperty(value = "妗f绫诲瀷")
+    private String archiveType;
+
+    /** 鍛戒腑鐨勯厤缃甀D锛涙湭鍛戒腑閰嶇疆鏃朵负0 */
+    @ApiModelProperty(value = "鍛戒腑鐨勯厤缃甀D锛涙湭鍛戒腑閰嶇疆鏃朵负0")
+    private Integer configId;
+
+    /** 鐢熸垚鎴栧懡涓殑妗f涓昏〃ID */
+    @ApiModelProperty(value = "鐢熸垚鎴栧懡涓殑妗f涓昏〃ID")
+    private Long archiveId;
+
+    /** 澶勭悊缁撴灉锛�1鐢熸垚 2宸插瓨鍦ㄨ烦杩� 3鏈尮閰� 4澶辫触 */
+    @ApiModelProperty(value = "澶勭悊缁撴灉锛�1鐢熸垚 2宸插瓨鍦ㄨ烦杩� 3鏈尮閰� 4澶辫触")
+    private String processResult;
+
+    /** 澶勭悊璇存槑 */
+    @ApiModelProperty(value = "澶勭悊璇存槑")
+    private String processMsg;
+
+    /** 閲嶈瘯娆℃暟 */
+    @ApiModelProperty(value = "閲嶈瘯娆℃暟")
+    private Integer retryCount;
+
+    /** 鍒涘缓鏃堕棿 */
+    @ApiModelProperty(value = "鍒涘缓鏃堕棿")
+    private Date createTime;
+
+    /** 鏇存柊鏃堕棿 */
+    @ApiModelProperty(value = "鏇存柊鏃堕棿")
+    private Date updateTime;
+}
diff --git a/smartor/src/main/java/com/smartor/listener/InhospFollowupArchiveListener.java b/smartor/src/main/java/com/smartor/listener/InhospFollowupArchiveListener.java
new file mode 100644
index 0000000..b9f2bbd
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/listener/InhospFollowupArchiveListener.java
@@ -0,0 +1,42 @@
+package com.smartor.listener;
+
+import com.ruoyi.common.core.event.FollowupCompletedEvent;
+import com.smartor.service.IPatSpecificArchiveGenerateService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.event.TransactionPhase;
+import org.springframework.transaction.event.TransactionalEventListener;
+
+/**
+ * 闅忚瀹屾垚鐢熸垚涓撶妗f鐩戝惉鍣ㄣ��
+ *
+ * <p>浣跨敤 AFTER_COMMIT 淇濊瘉闅忚瀹屾垚鐘舵�佸凡钀藉簱锛涘紓甯稿彧璁板綍鏃ュ織锛屼笉褰卞搷闅忚涓绘祦绋嬨��</p>
+ *
+ * @author ruoyi
+ * @date 2026-11-11
+ */
+@Slf4j
+@Component
+public class InhospFollowupArchiveListener {
+
+    @Autowired
+    private IPatSpecificArchiveGenerateService patSpecificArchiveGenerateService;
+
+    @Async("threadPoolTaskExecutor")
+    @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT, fallbackExecution = true)
+    public void onFollowupCompleted(FollowupCompletedEvent event) {
+        if (event == null || event.getSubId() == null) {
+            return;
+        }
+        try {
+            int generated = patSpecificArchiveGenerateService.generateByInhospFollowup(event.getSubId());
+            if (generated > 0) {
+                log.info("浣忛櫌闅忚瀹屾垚鐢熸垚涓撶妗f鎴愬姛锛宻ubId={}锛岀敓鎴愭暟閲�={}", event.getSubId(), generated);
+            }
+        } catch (Throwable e) {
+            log.error("浣忛櫌闅忚瀹屾垚鐢熸垚涓撶妗f澶辫触锛宻ubId={}", event.getSubId(), e);
+        }
+    }
+}
diff --git a/smartor/src/main/java/com/smartor/mapper/PatSpecificArchiveGenerateLogMapper.java b/smartor/src/main/java/com/smartor/mapper/PatSpecificArchiveGenerateLogMapper.java
new file mode 100644
index 0000000..e5971c8
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/mapper/PatSpecificArchiveGenerateLogMapper.java
@@ -0,0 +1,41 @@
+package com.smartor.mapper;
+
+import com.smartor.domain.PatSpecificArchiveGenerateLog;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 涓撶妗f鐢熸垚鏃ュ織Mapper鎺ュ彛銆�
+ *
+ * @author ruoyi
+ * @date 2026-11-11
+ */
+@Mapper
+public interface PatSpecificArchiveGenerateLogMapper {
+
+    /**
+     * 鎸夋潵婧� + 闅忚瀛愪换鍔� + 閰嶇疆鏌ヨ鏃ュ織銆�
+     *
+     * @param sourceType  鏉ユ簮绫诲瀷
+     * @param sourceSubId 鏉ユ簮闅忚瀛愪换鍔D
+     * @param configId    閰嶇疆ID锛屾湭鍛戒腑閰嶇疆浼�0
+     * @return 鏃ュ織璁板綍锛屼笉瀛樺湪杩斿洖 null
+     */
+    PatSpecificArchiveGenerateLog selectBySourceSubAndConfig(@Param("sourceType") String sourceType,
+                                                             @Param("sourceSubId") Long sourceSubId,
+                                                             @Param("configId") Integer configId);
+
+    /**
+     * 鏌ヨ鏉ユ簮闅忚瀛愪换鍔′笅鏄惁宸叉湁鎴愬姛/璺宠繃/鏈尮閰嶇殑缁撴灉銆�
+     *
+     * @param sourceType  鏉ユ簮绫诲瀷
+     * @param sourceSubId 鏉ユ簮闅忚瀛愪换鍔D
+     * @return 宸插鐞嗘潯鏁�
+     */
+    int countProcessedBySourceSub(@Param("sourceType") String sourceType,
+                                  @Param("sourceSubId") Long sourceSubId);
+
+    int insertPatSpecificArchiveGenerateLog(PatSpecificArchiveGenerateLog log);
+
+    int updatePatSpecificArchiveGenerateLog(PatSpecificArchiveGenerateLog log);
+}
diff --git a/smartor/src/main/java/com/smartor/service/IPatSpecificArchiveGenerateLogService.java b/smartor/src/main/java/com/smartor/service/IPatSpecificArchiveGenerateLogService.java
new file mode 100644
index 0000000..47f812a
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/IPatSpecificArchiveGenerateLogService.java
@@ -0,0 +1,18 @@
+package com.smartor.service;
+
+import com.smartor.domain.PatSpecificArchiveGenerateLog;
+
+/**
+ * 涓撶妗f鐢熸垚鏃ュ織Service鎺ュ彛銆�
+ *
+ * @author ruoyi
+ * @date 2026-11-11
+ */
+public interface IPatSpecificArchiveGenerateLogService {
+
+    PatSpecificArchiveGenerateLog selectBySourceSubAndConfig(String sourceType, Long sourceSubId, Integer configId);
+
+    boolean existsProcessedBySourceSub(String sourceType, Long sourceSubId);
+
+    int saveOrUpdate(PatSpecificArchiveGenerateLog log);
+}
diff --git a/smartor/src/main/java/com/smartor/service/IPatSpecificArchiveGenerateService.java b/smartor/src/main/java/com/smartor/service/IPatSpecificArchiveGenerateService.java
index 4ad425f..f25a083 100644
--- a/smartor/src/main/java/com/smartor/service/IPatSpecificArchiveGenerateService.java
+++ b/smartor/src/main/java/com/smartor/service/IPatSpecificArchiveGenerateService.java
@@ -19,4 +19,22 @@
      * @return 鏈鐢熸垚/鏇存柊鐨勬。妗堟暟閲�
      */
     int generateByOuthosp(PatMedOuthosp patMedOuthosp, PatArchive patArchive);
+
+    /**
+     * 鏍规嵁浣忛櫌闅忚瀛愪换鍔$敓鎴愪笓绉戞。妗堛��
+     *
+     * <p>浠呭鐞嗗凡瀹屾垚鐨勪綇闄㈤殢璁匡紙hosp_type 2/6 + service_type 鐧藉悕鍗曪級锛�
+     * 涓斾粎瀵逛附姘村競濡囧辜淇濆仴闄㈢敓鏁堛�傜敓鎴愬墠鎸夆�滄偅鑰� + 涓撶 + 妗f绫诲瀷鈥濆垽鏂槸鍚﹀凡鏈夋。妗堛��</p>
+     *
+     * @param subId 闅忚瀛愪换鍔D
+     * @return 鏈鐢熸垚鏁伴噺
+     */
+    int generateByInhospFollowup(Long subId);
+
+    /**
+     * 琛ュ伩鎵弿锛氭煡璇㈣繎 7 澶╁凡瀹屾垚浣嗗皻鏈鐞嗙殑浣忛櫌闅忚骞跺皾璇曠敓鎴愭。妗堛��
+     *
+     * @return 鏈鐢熸垚鏁伴噺
+     */
+    int compensateInhospFollowups();
 }
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 4dd9148..9ccd188 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java
@@ -88,8 +88,9 @@
             log.error("insertOrUpdateChildArchive鍏ュ弬涓虹┖锛岃妫�鏌ュ叆鍙�");
             throw new BaseException("鍎跨妗f鍏ュ弬涓虹┖锛岃妫�鏌ュ叆鍙�");
         }
-        if (StringUtils.isEmpty(patChildArchiveDetail.getOuthospno())) {
-            throw new BaseException("鍎跨妗f鍏ュ弬闂ㄨ瘖缂栧彿outhospno涓虹┖锛岃妫�鏌ュ叆鍙傞棬璇婄紪鍙�");
+        if (StringUtils.isEmpty(patChildArchiveDetail.getOuthospno())
+                && StringUtils.isEmpty(patChildArchiveDetail.getInhospno())) {
+            throw new BaseException("鍎跨妗f鍏ュ弬闂ㄨ瘖缂栧彿outhospno鍜屼綇闄㈢紪鍙穒nhospno涓嶈兘鍚屾椂涓虹┖");
         }
         if (StringUtils.isEmpty(patChildArchiveDetail.getArchiveType())) {
             throw new BaseException("鍎跨妗f鍏ュ弬妗f绫诲瀷archiveType涓虹┖锛岃妫�鏌ュ叆鍙傛。妗堢被鍨�");
@@ -100,6 +101,7 @@
         key.setOrgid(patChildArchiveDetail.getOrgid());
         key.setPatid(patChildArchiveDetail.getPatid());
         key.setOuthospno(patChildArchiveDetail.getOuthospno());
+        key.setInhospno(patChildArchiveDetail.getInhospno());
         key.setArchiveType(patChildArchiveDetail.getArchiveType());
         List<PatChildArchiveDetail> olds =
                 patChildArchiveDetailService.selectPatChildArchiveDetailList(key);
@@ -117,6 +119,7 @@
             mainKey.setOrgid(patChildArchiveDetail.getOrgid());
             mainKey.setPatid(patChildArchiveDetail.getPatid());
             mainKey.setOuthospno(patChildArchiveDetail.getOuthospno());
+            mainKey.setInhospno(patChildArchiveDetail.getInhospno());
             mainKey.setArchiveType(patChildArchiveDetail.getArchiveType());
             List<PatChildArchive> mainOlds =
                     patChildArchiveMapper.selectPatChildArchiveList(mainKey);
@@ -133,6 +136,17 @@
         }
 
 
+        // 鏂板妗f鏃惰ˉ榛樿鏉ユ簮锛屾洿鏂版椂淇濈暀鍘熸潵婧�
+        if (existArchiveId == null && patChildArchiveDetail.getId() == null) {
+            if (StringUtils.isEmpty(patChildArchiveDetail.getSourceType())) {
+                patChildArchiveDetail.setSourceType("3");
+            }
+            if (StringUtils.isEmpty(patChildArchiveDetail.getSourceBizNo())) {
+                patChildArchiveDetail.setSourceBizNo(StringUtils.isNotEmpty(patChildArchiveDetail.getOuthospno())
+                        ? patChildArchiveDetail.getOuthospno() : patChildArchiveDetail.getInhospno());
+            }
+        }
+
         // 灏嗚鎯呬腑鐨勫叕鍏卞瓧娈靛鍒跺埌涓昏〃瀵硅薄
         PatChildArchive patChildArchive = DtoConversionUtils.sourceToTarget(patChildArchiveDetail, PatChildArchive.class);
         if (patChildArchive == null) {
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 cea1042..e7744d3 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java
@@ -99,13 +99,15 @@
         patMaternityArchiveDetailVo.setOrgid(patMaternityArchiveDetail.getOrgid());
         patMaternityArchiveDetailVo.setPatid(patMaternityArchiveDetail.getPatid());
         patMaternityArchiveDetailVo.setOuthospno(patMaternityArchiveDetail.getOuthospno());
+        patMaternityArchiveDetailVo.setInhospno(patMaternityArchiveDetail.getInhospno());
         patMaternityArchiveDetailVo.setArchiveType(patMaternityArchiveDetail.getArchiveType());
         List<PatMaternityArchiveDetail> patMaternityArchiveDetailOlds
                 = patMaternityArchiveDetailService.selectPatMaternityArchiveDetailList(patMaternityArchiveDetailVo);
 
 
-        if (StringUtils.isEmpty(patMaternityArchiveDetail.getOuthospno())) {
-            throw new BaseException("濡囩妗f鍏ュ弬闂ㄨ瘖缂栧彿outhospno涓虹┖锛岃妫�鏌ュ叆鍙傞棬璇婄紪鍙�");
+        if (StringUtils.isEmpty(patMaternityArchiveDetail.getOuthospno())
+                && StringUtils.isEmpty(patMaternityArchiveDetail.getInhospno())) {
+            throw new BaseException("濡囩妗f鍏ュ弬闂ㄨ瘖缂栧彿outhospno鍜屼綇闄㈢紪鍙穒nhospno涓嶈兘鍚屾椂涓虹┖");
         }
         if (StringUtils.isEmpty(patMaternityArchiveDetail.getArchiveType())) {
             throw new BaseException("濡囩妗f鍏ュ弬妗f绫诲瀷archiveType涓虹┖锛岃妫�鏌ュ叆鍙傛。妗堢被鍨�");
@@ -116,6 +118,7 @@
         key.setOrgid(patMaternityArchiveDetail.getOrgid());
         key.setPatid(patMaternityArchiveDetail.getPatid());
         key.setOuthospno(patMaternityArchiveDetail.getOuthospno());
+        key.setInhospno(patMaternityArchiveDetail.getInhospno());
         key.setArchiveType(patMaternityArchiveDetail.getArchiveType());
         List<PatMaternityArchiveDetail> olds =
                 patMaternityArchiveDetailService.selectPatMaternityArchiveDetailList(key);
@@ -133,6 +136,7 @@
             mainKey.setOrgid(patMaternityArchiveDetail.getOrgid());
             mainKey.setPatid(patMaternityArchiveDetail.getPatid());
             mainKey.setOuthospno(patMaternityArchiveDetail.getOuthospno());
+            mainKey.setInhospno(patMaternityArchiveDetail.getInhospno());
             mainKey.setArchiveType(patMaternityArchiveDetail.getArchiveType());
             List<PatMaternityArchive> mainOlds =
                     patMaternityArchiveMapper.selectPatMaternityArchiveList(mainKey);
@@ -156,6 +160,17 @@
             }
         }
 
+        // 鏂板妗f鏃惰ˉ榛樿鏉ユ簮锛屾洿鏂版椂淇濈暀鍘熸潵婧�
+        if (existArchiveId == null && patMaternityArchiveDetail.getId() == null) {
+            if (StringUtils.isEmpty(patMaternityArchiveDetail.getSourceType())) {
+                patMaternityArchiveDetail.setSourceType("3");
+            }
+            if (StringUtils.isEmpty(patMaternityArchiveDetail.getSourceBizNo())) {
+                patMaternityArchiveDetail.setSourceBizNo(StringUtils.isNotEmpty(patMaternityArchiveDetail.getOuthospno())
+                        ? patMaternityArchiveDetail.getOuthospno() : patMaternityArchiveDetail.getInhospno());
+            }
+        }
+
         // 灏嗚鎯呬腑鐨勫叕鍏卞瓧娈靛鍒跺埌涓昏〃瀵硅薄
         PatMaternityArchive patMaternityArchive = DtoConversionUtils.sourceToTarget(patMaternityArchiveDetail, PatMaternityArchive.class);
         if (patMaternityArchive == null) {
diff --git a/smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateLogServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateLogServiceImpl.java
new file mode 100644
index 0000000..7071a9e
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateLogServiceImpl.java
@@ -0,0 +1,74 @@
+package com.smartor.service.impl;
+
+import com.smartor.domain.PatSpecificArchiveGenerateLog;
+import com.smartor.mapper.PatSpecificArchiveGenerateLogMapper;
+import com.smartor.service.IPatSpecificArchiveGenerateLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DuplicateKeyException;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+
+/**
+ * 涓撶妗f鐢熸垚鏃ュ織Service涓氬姟灞傚鐞嗐��
+ *
+ * @author ruoyi
+ * @date 2026-11-11
+ */
+@Service
+public class PatSpecificArchiveGenerateLogServiceImpl implements IPatSpecificArchiveGenerateLogService {
+
+    @Autowired
+    private PatSpecificArchiveGenerateLogMapper logMapper;
+
+    @Override
+    public PatSpecificArchiveGenerateLog selectBySourceSubAndConfig(String sourceType, Long sourceSubId, Integer configId) {
+        return logMapper.selectBySourceSubAndConfig(sourceType, sourceSubId,
+                configId == null ? 0 : configId);
+    }
+
+    @Override
+    public boolean existsProcessedBySourceSub(String sourceType, Long sourceSubId) {
+        return logMapper.countProcessedBySourceSub(sourceType, sourceSubId) > 0;
+    }
+
+    @Override
+    public int saveOrUpdate(PatSpecificArchiveGenerateLog log) {
+        if (log == null) {
+            return 0;
+        }
+        if (log.getSourceType() == null) {
+            log.setSourceType("2");
+        }
+        if (log.getConfigId() == null) {
+            log.setConfigId(0);
+        }
+        if (log.getRetryCount() == null) {
+            log.setRetryCount(0);
+        }
+        Date now = new Date();
+        log.setUpdateTime(now);
+        PatSpecificArchiveGenerateLog old = logMapper.selectBySourceSubAndConfig(
+                log.getSourceType(), log.getSourceSubId(), log.getConfigId());
+        if (old == null) {
+            log.setCreateTime(now);
+            try {
+                return logMapper.insertPatSpecificArchiveGenerateLog(log);
+            } catch (DuplicateKeyException e) {
+                // 骞跺彂涓嬪彟涓�涓嚎绋嬪凡鍐欏叆锛岃浆涓烘洿鏂帮紝淇濊瘉骞傜瓑
+                old = logMapper.selectBySourceSubAndConfig(
+                        log.getSourceType(), log.getSourceSubId(), log.getConfigId());
+                if (old == null) {
+                    throw e;
+                }
+                log.setId(old.getId());
+                return logMapper.updatePatSpecificArchiveGenerateLog(log);
+            }
+        }
+        log.setId(old.getId());
+        if (log.getCreateTime() == null) {
+            log.setCreateTime(old.getCreateTime());
+        }
+        return logMapper.updatePatSpecificArchiveGenerateLog(log);
+    }
+}
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 d0c7d20..ee787a2 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateServiceImpl.java
@@ -3,20 +3,31 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.ruoyi.common.core.domain.entity.PatArchive;
+import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.inhospvisit.api.InhospVisitFacade;
+import com.ruoyi.inhospvisit.domain.PatMedInhosp;
 import com.ruoyi.outpatientvisit.domain.PatMedOuthosp;
 import com.ruoyi.patarchive.domain.PatSpecificArchiveGenerateConfig;
 import com.ruoyi.patarchive.mapper.PatArchiveMapper;
 import com.ruoyi.patarchive.service.IPatSpecificArchiveGenerateConfigService;
+import com.ruoyi.task.api.TaskSubtaskApi;
+import com.ruoyi.task.domain.ServiceSubtask;
+import com.ruoyi.task.service.IServiceSubtaskService;
 import com.smartor.common.SpecificArchiveConstants;
+import com.smartor.domain.PatChildArchive;
 import com.smartor.domain.PatChildArchiveDetail;
+import com.smartor.domain.PatMaternityArchive;
 import com.smartor.domain.PatMaternityArchiveDetail;
+import com.smartor.domain.PatSpecificArchiveGenerateLog;
 import com.smartor.service.IPatChildArchiveService;
 import com.smartor.service.IPatMaternityArchiveService;
+import com.smartor.service.IPatSpecificArchiveGenerateLogService;
 import com.smartor.service.IPatSpecificArchiveGenerateService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
@@ -26,27 +37,37 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 /**
  * 涓撶妗f鐢熸垚Service涓氬姟灞傚鐞嗐��
  *
- * <p>鍙鐞嗕附姘村競濡囧辜淇濆仴闄紙orgid = 47226079133110211G1001锛夌殑闂ㄨ瘖鎺ヨ瘖瀹屾垚璁板綍锛�
- * 鎸� {@code pat_specific_archive_generate_config} 閰嶇疆鍖归厤绉戝鍜岃瘖鏂悗锛�
- * 鐢熸垚瀵瑰簲绫诲瀷鐨勫绉戞。妗堟垨鍎跨妗f銆�</p>
+ * <p>鍙鐞嗕附姘村競濡囧辜淇濆仴闄紙orgid = 47226079133110211G1001锛夛細</p>
+ * <ul>
+ *     <li>闂ㄨ瘖鎺ヨ瘖瀹屾垚锛氭寜绉戝/璇婃柇鍖归厤閰嶇疆鍚庣敓鎴愬绉�/鍎跨妗f锛�</li>
+ *     <li>浣忛櫌闅忚瀹屾垚锛氭寜鍑洪櫌/鍦ㄩ櫌绉戝銆佺梾鍖恒�佽瘖鏂尮閰嶉厤缃悗鐢熸垚濡囩/鍎跨妗f锛�
+ *     鐢熸垚鍓嶆寜鈥滄偅鑰� + 涓撶 + 妗f绫诲瀷鈥濆垽鏂槸鍚﹀凡鏈夊搴旀。妗堬紝宸叉湁鍒欒烦杩囥��</li>
+ * </ul>
  */
 @Slf4j
 @Service
 public class PatSpecificArchiveGenerateServiceImpl implements IPatSpecificArchiveGenerateService {
 
-    /** 閮ㄩ棬鍒嗙被锛氬绉� */
-    private static final String DEPT_CATEGORY_GYNECOLOGY = "1";
-    /** 閮ㄩ棬鍒嗙被锛氬効绉� */
-    private static final String DEPT_CATEGORY_PEDIATRICS = "2";
     /** 閮ㄩ棬绫诲瀷锛氱瀹� */
     private static final String DEPT_TYPE_DEPARTMENT = "1";
-    /** 鏉ユ簮绫诲瀷锛氶棬璇婅褰� */
-    private static final String SOURCE_TYPE_OUTHOSP = "1";
+    /** 閮ㄩ棬绫诲瀷锛氱梾鍖� */
+    private static final String DEPT_TYPE_WARD = "2";
+    /** 灏辫瘖绫诲瀷锛氬嚭闄� */
+    private static final String HOSP_TYPE_DISCHARGE = "2";
+    /** 灏辫瘖绫诲瀷锛氫綇闄�/鍏ラ櫌 */
+    private static final String HOSP_TYPE_INHOSP = "6";
+    /** 浣忛櫌闅忚瀹屾垚鐘舵�� */
+    private static final Long SEND_STATE_FINISHED = 6L;
+    /** 浣忛櫌闅忚妗f鐢熸垚鐨勬渶澶ч噸璇曟鏁� */
+    private static final int MAX_RETRY = 3;
+    /** Redis 閿佸墠缂� */
+    private static final String LOCK_PREFIX = "lock:archive:inhosp:";
 
     @Autowired
     private IPatSpecificArchiveGenerateConfigService patSpecificArchiveGenerateConfigService;
@@ -58,7 +79,32 @@
     private IPatChildArchiveService patChildArchiveService;
 
     @Autowired
+    private IPatSpecificArchiveGenerateLogService patSpecificArchiveGenerateLogService;
+
+    @Autowired
     private PatArchiveMapper patArchiveMapper;
+
+    @Autowired
+    private IServiceSubtaskService serviceSubtaskService;
+
+    @Autowired
+    private InhospVisitFacade inhospVisitFacade;
+
+    @Autowired
+    private TaskSubtaskApi taskSubtaskApi;
+
+    @Autowired
+    private RedisCache redisCache;
+
+    /**
+     * 浣忛櫌闅忚鏈嶅姟绫诲瀷鐧藉悕鍗曪紝榛樿鍑洪櫌闅忚銆佷笓绉戦殢璁裤�佸叆闄㈤殢璁裤�佹墜鏈殢璁裤��
+     */
+    @Value("${archive.inhosp.followup.service-types:2,13,18,19}")
+    private String inhospFollowupServiceTypes;
+
+    /** 浣忛櫌闅忚鐢熸垚涓撶妗f寮�鍏筹紝榛樿寮�鍚紝渚夸簬鎸夋満鏋勭伆搴︺�� */
+    @Value("${archive.inhosp.followup.enabled:true}")
+    private boolean inhospFollowupEnabled;
 
     @Override
     public int generateByOuthosp(PatMedOuthosp patMedOuthosp, PatArchive patArchive) {
@@ -86,7 +132,7 @@
         }
 
         String campusid = StringUtils.isNotBlank(patMedOuthosp.getCampusid())
-                ? patMedOuthosp.getCampusid() : "1";
+                ? patMedOuthosp.getCampusid() : SpecificArchiveConstants.DEFAULT_CAMPUS_ID;
         List<PatSpecificArchiveGenerateConfig> configs =
                 patSpecificArchiveGenerateConfigService.selectEffectiveConfigList(patMedOuthosp.getOrgid(), campusid);
         if (CollectionUtils.isEmpty(configs)) {
@@ -99,7 +145,8 @@
         Set<String> generatedKeys = new HashSet<>();
         int generatedCount = 0;
         for (PatSpecificArchiveGenerateConfig config : configs) {
-            if (!matchConfig(config, patMedOuthosp)) {
+            if (!matchConfig(config, patMedOuthosp.getDeptcode(), null,
+                    patMedOuthosp.getIcd10code(), patMedOuthosp.getDiagname())) {
                 continue;
             }
             String archiveType = config.getArchiveType();
@@ -116,12 +163,12 @@
             }
 
             try {
-                if (DEPT_CATEGORY_GYNECOLOGY.equals(deptCategory)) {
+                if (SpecificArchiveConstants.DEPT_CATEGORY_GYNECOLOGY.equals(deptCategory)) {
                     PatMaternityArchiveDetail detail =
                             buildMaternityDetail(patMedOuthosp, targetArchive, config, campusid);
                     patMaternityArchiveService.insertOrUpdateMaternityArchive(detail);
                     generatedCount++;
-                } else if (DEPT_CATEGORY_PEDIATRICS.equals(deptCategory)) {
+                } else if (SpecificArchiveConstants.DEPT_CATEGORY_PEDIATRICS.equals(deptCategory)) {
                     PatChildArchiveDetail detail =
                             buildChildDetail(patMedOuthosp, targetArchive, config, campusid);
                     patChildArchiveService.insertOrUpdateChildArchive(detail);
@@ -138,12 +185,276 @@
         return generatedCount;
     }
 
+    @Override
+    public int generateByInhospFollowup(Long subId) {
+        if (!inhospFollowupEnabled || subId == null) {
+            return 0;
+        }
+        ServiceSubtask subtask = serviceSubtaskService.selectServiceSubtaskById(subId);
+        if (subtask == null || !SEND_STATE_FINISHED.equals(subtask.getSendstate())) {
+            return 0;
+        }
+        if (!isInhospFollowup(subtask)) {
+            return 0;
+        }
+
+        // 浠呴檺涓芥按濡囧辜锛屾満鏋勪负绌烘椂鐢ㄤ綇闄㈣褰�/鎮h�呮。妗堝厹搴�
+        PatMedInhosp inhosp = resolveInhosp(subtask);
+        PatArchive patArchive = resolvePatArchive(subtask.getPatid(), inhosp);
+        String orgid = firstNotBlank(subtask.getOrgid(),
+                inhosp == null ? null : inhosp.getOrgid(),
+                patArchive == null ? null : patArchive.getOrgid());
+        if (!SpecificArchiveConstants.LISHUI_MCH_ORG_ID.equals(orgid)) {
+            log.debug("浣忛櫌闅忚鐢熸垚涓撶妗f璺宠繃锛氶潪涓芥按濡囧辜鏈烘瀯锛宻ubId={}锛宱rgid={}", subId, orgid);
+            return 0;
+        }
+
+        Long patid = firstNonNull(subtask.getPatid(),
+                inhosp == null ? null : inhosp.getPatid(),
+                patArchive == null ? null : patArchive.getId());
+        if (patid == null) {
+            log.warn("浣忛櫌闅忚鐢熸垚涓撶妗f璺宠繃锛氭湭鎵惧埌鎮h�咃紝subId={}锛宨nhospid={}", subId, subtask.getInhospid());
+            return 0;
+        }
+        if (patArchive == null) {
+            patArchive = patArchiveMapper.selectPatArchiveByPatid(patid);
+        }
+
+        String campusid = firstNotBlank(subtask.getCampusid(),
+                inhosp == null ? null : inhosp.getCampusid(),
+                patArchive == null ? null : patArchive.getCampusid(),
+                SpecificArchiveConstants.DEFAULT_CAMPUS_ID);
+
+        boolean admission = HOSP_TYPE_INHOSP.equals(subtask.getHospType());
+        String deptCode = admission
+                ? firstNotBlank(inhosp == null ? null : inhosp.getDeptcode(), subtask.getDeptcode(),
+                subtask.getVisitDeptCode(), subtask.getLeaveldeptcode())
+                : firstNotBlank(inhosp == null ? null : inhosp.getLeaveldeptcode(), subtask.getLeaveldeptcode(),
+                subtask.getVisitDeptCode(), inhosp == null ? null : inhosp.getDeptcode());
+        String deptName = admission
+                ? firstNotBlank(inhosp == null ? null : inhosp.getDeptname(), subtask.getDeptname(),
+                subtask.getVisitDeptName(), subtask.getLeaveldeptname())
+                : firstNotBlank(inhosp == null ? null : inhosp.getLeaveldeptname(), subtask.getLeaveldeptname(),
+                subtask.getVisitDeptName(), inhosp == null ? null : inhosp.getDeptname());
+        String wardCode = admission
+                ? firstNotBlank(inhosp == null ? null : inhosp.getHospitaldistrictcode(),
+                subtask.getHospitaldistrictcode(), subtask.getLeavehospitaldistrictcode())
+                : firstNotBlank(inhosp == null ? null : inhosp.getLeavehospitaldistrictcode(),
+                subtask.getLeavehospitaldistrictcode(), subtask.getHospitaldistrictcode());
+        String wardName = admission
+                ? firstNotBlank(inhosp == null ? null : inhosp.getHospitaldistrictname(),
+                subtask.getHospitaldistrictname(), subtask.getLeavehospitaldistrictname())
+                : firstNotBlank(inhosp == null ? null : inhosp.getLeavehospitaldistrictname(),
+                subtask.getLeavehospitaldistrictname(), subtask.getHospitaldistrictname());
+        String icd10Code = admission
+                ? firstNotBlank(inhosp == null ? null : inhosp.getIcd10code(), subtask.getLeaveicd10code())
+                : firstNotBlank(inhosp == null ? null : inhosp.getLeaveicd10code(),
+                subtask.getLeaveicd10code(), inhosp == null ? null : inhosp.getIcd10code());
+        String diagName = admission
+                ? firstNotBlank(inhosp == null ? null : inhosp.getDiagname(), subtask.getDiagname())
+                : firstNotBlank(inhosp == null ? null : inhosp.getLeavediagname(),
+                subtask.getLeavediagname(), inhosp == null ? null : inhosp.getDiagname());
+
+        InhospArchiveContext context = new InhospArchiveContext();
+        context.subtask = subtask;
+        context.inhosp = inhosp;
+        context.patArchive = patArchive;
+        context.patid = patid;
+        context.orgid = orgid;
+        context.campusid = campusid;
+        context.deptCode = deptCode;
+        context.deptName = deptName;
+        context.wardCode = wardCode;
+        context.wardName = wardName;
+        context.icd10Code = icd10Code;
+        context.diagName = diagName;
+        context.diagTime = firstDate(subtask.getFinishtime(), inhosp == null ? null : inhosp.getEndtime());
+
+        List<PatSpecificArchiveGenerateConfig> configs =
+                patSpecificArchiveGenerateConfigService.selectEffectiveConfigList(orgid, campusid);
+        if (CollectionUtils.isEmpty(configs)) {
+            recordLog(context, null, null, null, SpecificArchiveConstants.RESULT_NO_MATCH, null,
+                    "鏈烘瀯鏈厤缃。妗堢敓鎴愯鍒�");
+            return 0;
+        }
+
+        Set<String> generatedKeys = new HashSet<>();
+        int generatedCount = 0;
+        boolean anyMatched = false;
+        for (PatSpecificArchiveGenerateConfig config : configs) {
+            String archiveType = config.getArchiveType();
+            String deptCategory = config.getDeptCategory();
+            if (StringUtils.isBlank(archiveType) || StringUtils.isBlank(deptCategory)) {
+                log.warn("浣忛櫌闅忚鐢熸垚涓撶妗f璺宠繃锛氶厤缃笉瀹屾暣锛宑onfigId={}锛宒eptCategory={}锛宎rchiveType={}",
+                        config.getId(), deptCategory, archiveType);
+                continue;
+            }
+            if (!matchConfig(config, deptCode, wardCode, icd10Code, diagName)) {
+                continue;
+            }
+            anyMatched = true;
+            String generatedKey = deptCategory + "|" + archiveType;
+            if (!generatedKeys.add(generatedKey)) {
+                continue;
+            }
+            if (alreadyProcessed(subId, config.getId())) {
+                continue;
+            }
+
+            String lockKey = LOCK_PREFIX + orgid + ":" + patid + ":" + deptCategory + ":" + archiveType;
+            boolean locked = false;
+            try {
+                locked = redisCache.setCacheObjectIfAbsent(lockKey, "1", 30, TimeUnit.SECONDS);
+            } catch (Exception e) {
+                // Redis 涓嶅彲鐢ㄦ椂 fail-open锛屼緷璧栫敓鎴愭棩蹇楀拰鏁版嵁搴撴煡璇㈠厹搴曪紝閬垮厤妗f鐢熸垚鏁翠綋鍋滄憜
+                locked = true;
+                log.warn("浣忛櫌闅忚鐢熸垚涓撶妗f鑾峰彇Redis閿佸紓甯革紝闄嶇骇涓烘棤閿佹墽琛岋紝subId={}锛宭ockKey={}", subId, lockKey, e);
+            }
+            if (!locked) {
+                // 鏈嬁鍒伴攣鏃剁敱琛ュ伩浠诲姟閲嶈瘯锛岄伩鍏嶅苟鍙戦噸澶嶇敓鎴�
+                log.info("浣忛櫌闅忚鐢熸垚涓撶妗f鏈幏鍙栧埌閿侊紝绛夊緟琛ュ伩閲嶈瘯锛宻ubId={}锛宭ockKey={}", subId, lockKey);
+                recordLog(context, config, deptCategory, archiveType, SpecificArchiveConstants.RESULT_FAILED,
+                        null, "鑾峰彇鐢熸垚閿佸け璐�");
+                continue;
+            }
+
+            try {
+                Long existingArchiveId = findExistingArchiveId(orgid, patid, deptCategory, archiveType);
+                if (existingArchiveId != null) {
+                    recordLog(context, config, deptCategory, archiveType,
+                            SpecificArchiveConstants.RESULT_EXISTS, existingArchiveId, "鎮h�呭凡鏈夊搴旀。妗堬紝璺宠繃鐢熸垚");
+                    continue;
+                }
+
+                Long archiveId;
+                if (SpecificArchiveConstants.DEPT_CATEGORY_GYNECOLOGY.equals(deptCategory)) {
+                    PatMaternityArchiveDetail detail = buildInhospMaternityDetail(context, config);
+                    archiveId = (long) patMaternityArchiveService.insertOrUpdateMaternityArchive(detail);
+                } else if (SpecificArchiveConstants.DEPT_CATEGORY_PEDIATRICS.equals(deptCategory)) {
+                    PatChildArchiveDetail detail = buildInhospChildDetail(context, config);
+                    archiveId = (long) patChildArchiveService.insertOrUpdateChildArchive(detail);
+                } else {
+                    log.warn("浣忛櫌闅忚鐢熸垚涓撶妗f璺宠繃锛氭湭鐭ラ儴闂ㄥ垎绫伙紝configId={}锛宒eptCategory={}",
+                            config.getId(), deptCategory);
+                    continue;
+                }
+                recordLog(context, config, deptCategory, archiveType,
+                        SpecificArchiveConstants.RESULT_GENERATED, archiveId, "鐢熸垚鎴愬姛");
+                generatedCount++;
+            } catch (Exception e) {
+                log.error("浣忛櫌闅忚鐢熸垚涓撶妗f澶辫触锛宻ubId={}锛宑onfigId={}锛宒eptCategory={}锛宎rchiveType={}",
+                        subId, config.getId(), deptCategory, archiveType, e);
+                recordLog(context, config, deptCategory, archiveType,
+                        SpecificArchiveConstants.RESULT_FAILED, null, truncateMsg(e.getMessage()));
+            } finally {
+                if (locked) {
+                    try {
+                        redisCache.deleteObject(lockKey);
+                    } catch (Exception e) {
+                        log.warn("浣忛櫌闅忚鐢熸垚涓撶妗f閲婃斁Redis閿佸紓甯革紝lockKey={}", lockKey, e);
+                    }
+                }
+            }
+        }
+
+        if (!anyMatched) {
+            recordLog(context, null, null, null, SpecificArchiveConstants.RESULT_NO_MATCH, null,
+                    "鏈懡涓瀹�/鐥呭尯/璇婃柇閰嶇疆");
+        }
+        return generatedCount;
+    }
+
+    @Override
+    public int compensateInhospFollowups() {
+        if (!inhospFollowupEnabled) {
+            return 0;
+        }
+        List<String> serviceTypes = parseCsv(inhospFollowupServiceTypes);
+        if (CollectionUtils.isEmpty(serviceTypes)) {
+            return 0;
+        }
+        Date startTime = new Date(System.currentTimeMillis() - 7L * 24 * 60 * 60 * 1000);
+        List<ServiceSubtask> subtasks = taskSubtaskApi.findCompletedInhospFollowups(
+                SpecificArchiveConstants.LISHUI_MCH_ORG_ID, serviceTypes, startTime, 200);
+        if (CollectionUtils.isEmpty(subtasks)) {
+            return 0;
+        }
+        int generated = 0;
+        for (ServiceSubtask subtask : subtasks) {
+            if (subtask.getId() == null
+                    || patSpecificArchiveGenerateLogService.existsProcessedBySourceSub(
+                    SpecificArchiveConstants.SOURCE_TYPE_INHOSP_FOLLOWUP, subtask.getId())) {
+                continue;
+            }
+            try {
+                generated += generateByInhospFollowup(subtask.getId());
+            } catch (Exception e) {
+                log.error("琛ュ伩鐢熸垚浣忛櫌闅忚涓撶妗f澶辫触锛宻ubId={}", subtask.getId(), e);
+            }
+        }
+        return generated;
+    }
+
     /**
-     * 鍒ゆ柇闂ㄨ瘖璁板綍鏄惁鍛戒腑閰嶇疆銆�
+     * 鍒ゆ柇闅忚瀛愪换鍔℃槸鍚﹀睘浜庨渶瑕佺敓鎴愭。妗堢殑浣忛櫌闅忚銆�
+     */
+    private boolean isInhospFollowup(ServiceSubtask subtask) {
+        if (!HOSP_TYPE_DISCHARGE.equals(subtask.getHospType())
+                && !HOSP_TYPE_INHOSP.equals(subtask.getHospType())) {
+            return false;
+        }
+        if (StringUtils.isBlank(subtask.getServiceType())) {
+            return false;
+        }
+        return parseCsv(inhospFollowupServiceTypes).contains(subtask.getServiceType().trim());
+    }
+
+    private boolean alreadyProcessed(Long subId, Long configId) {
+        int cid = configId == null ? SpecificArchiveConstants.NO_CONFIG_ID : configId.intValue();
+        PatSpecificArchiveGenerateLog old = patSpecificArchiveGenerateLogService
+                .selectBySourceSubAndConfig(SpecificArchiveConstants.SOURCE_TYPE_INHOSP_FOLLOWUP, subId, cid);
+        if (old == null) {
+            return false;
+        }
+        if (SpecificArchiveConstants.RESULT_FAILED.equals(old.getProcessResult())) {
+            return old.getRetryCount() != null && old.getRetryCount() >= MAX_RETRY;
+        }
+        return true;
+    }
+
+    /**
+     * 鏌ヨ鎮h�呮槸鍚﹀凡鏈夊搴斾笓绉戞。妗堛��
+     *
+     * <p>鐢ㄦ埛纭鍙e緞锛氭寜鈥滀笓绉� + 妗f绫诲瀷鈥濆垽鏂�傚绉戙�佸効绉戝垎琛ㄥ瓨鍌紝鍥犳濡囩鏌ュ绉戣〃锛�
+     * 鍎跨鏌ュ効绉戣〃锛屽啀鎸夋。妗堢被鍨嬪尯鍒嗐��</p>
+     */
+    private Long findExistingArchiveId(String orgid, Long patid, String deptCategory, String archiveType) {
+        if (SpecificArchiveConstants.DEPT_CATEGORY_GYNECOLOGY.equals(deptCategory)) {
+            PatMaternityArchive query = new PatMaternityArchive();
+            query.setOrgid(orgid);
+            query.setPatid(patid);
+            query.setArchiveType(archiveType);
+            List<PatMaternityArchive> list = patMaternityArchiveService.selectPatMaternityArchiveList(query);
+            return CollectionUtils.isNotEmpty(list) ? list.get(0).getId() : null;
+        }
+        if (SpecificArchiveConstants.DEPT_CATEGORY_PEDIATRICS.equals(deptCategory)) {
+            PatChildArchive query = new PatChildArchive();
+            query.setOrgid(orgid);
+            query.setPatid(patid);
+            query.setArchiveType(archiveType);
+            List<PatChildArchive> list = patChildArchiveService.selectPatChildArchiveList(query);
+            return CollectionUtils.isNotEmpty(list) ? list.get(0).getId() : null;
+        }
+        return null;
+    }
+
+    /**
+     * 鍒ゆ柇绉戝/鐥呭尯銆佽瘖鏂槸鍚﹀懡涓厤缃��
      *
      * <p>閮ㄩ棬鏉′欢涓庤瘖鏂潯浠朵负 OR 鍏崇郴锛氫换涓�鏉′欢鍛戒腑鍗崇敓鎴愶紱涓や釜闆嗗悎閮戒负绌烘椂閰嶇疆鏃犳晥銆�</p>
      */
-    private boolean matchConfig(PatSpecificArchiveGenerateConfig config, PatMedOuthosp patMedOuthosp) {
+    private boolean matchConfig(PatSpecificArchiveGenerateConfig config, String deptCode, String wardCode,
+                                String icd10Code, String diagName) {
         List<String> deptCodes = parseCodes(config.getDeptCodes());
         List<String> icd10Codes = parseCodes(config.getIcd10Codes());
         if (CollectionUtils.isEmpty(deptCodes) && CollectionUtils.isEmpty(icd10Codes)) {
@@ -152,22 +463,21 @@
 
         boolean deptMatched = false;
         if (CollectionUtils.isNotEmpty(deptCodes)) {
-            // 闂ㄨ瘖璁板綍鍙湁绉戝锛屾病鏈夌梾鍖猴紱dept_type=2锛堢梾鍖猴級涓嶅弬涓庨棬璇婂尮閰�
             if (DEPT_TYPE_DEPARTMENT.equals(config.getDeptType())) {
-                deptMatched = containsIgnoreCase(deptCodes, patMedOuthosp.getDeptcode());
+                deptMatched = containsIgnoreCase(deptCodes, deptCode);
+            } else if (DEPT_TYPE_WARD.equals(config.getDeptType())) {
+                deptMatched = containsIgnoreCase(deptCodes, wardCode);
             }
         }
 
         boolean diagnosisMatched = false;
         if (CollectionUtils.isNotEmpty(icd10Codes)) {
-            String icd10code = patMedOuthosp.getIcd10code();
-            String diagname = patMedOuthosp.getDiagname();
             diagnosisMatched = icd10Codes.stream().anyMatch(code -> {
-                if (equalsIgnoreCase(code, icd10code)) {
+                if (equalsIgnoreCase(code, icd10Code)) {
                     return true;
                 }
                 // 閮ㄥ垎 HIS 鏁版嵁鍙湁璇婃柇鍚嶇О娌℃湁璇婃柇鐮侊紝姝ゆ椂鍏佽鎸夎瘖鏂悕绉板厹搴曞尮閰�
-                return StringUtils.isBlank(icd10code) && equalsIgnoreCase(code, diagname);
+                return StringUtils.isBlank(icd10Code) && equalsIgnoreCase(code, diagName);
             });
         }
 
@@ -179,7 +489,9 @@
         PatMaternityArchiveDetail detail = new PatMaternityArchiveDetail();
         detail.setArchiveType(config.getArchiveType());
         detail.setFollowupPeriod(config.getFollowupPeriod());
-        detail.setSourceType(SOURCE_TYPE_OUTHOSP);
+        detail.setSourceType(SpecificArchiveConstants.SOURCE_TYPE_OUTHOSP);
+        detail.setSourceBizId(patMedOuthosp.getId());
+        detail.setSourceBizNo(patMedOuthosp.getOuthospno());
         fillCommonDetail(detail, patMedOuthosp, patArchive, campusid);
         if (patArchive != null) {
             detail.setAddress(patArchive.getPlaceOfResidence());
@@ -192,7 +504,9 @@
         PatChildArchiveDetail detail = new PatChildArchiveDetail();
         detail.setArchiveType(config.getArchiveType());
         detail.setFollowupPeriod(config.getFollowupPeriod());
-        detail.setSourceType(SOURCE_TYPE_OUTHOSP);
+        detail.setSourceType(SpecificArchiveConstants.SOURCE_TYPE_OUTHOSP);
+        detail.setSourceBizId(patMedOuthosp.getId());
+        detail.setSourceBizNo(patMedOuthosp.getOuthospno());
         fillCommonChildDetail(detail, patMedOuthosp, patArchive, campusid);
         detail.setParentPhone(patArchive != null
                 ? firstNotBlank(patArchive.getTelcode(), patMedOuthosp.getTelcode())
@@ -205,6 +519,104 @@
             detail.setNutritionIcd10Code(patMedOuthosp.getIcd10code());
             detail.setNutritionDiagName(patMedOuthosp.getDiagname());
         }
+        return detail;
+    }
+
+    private PatMaternityArchiveDetail buildInhospMaternityDetail(InhospArchiveContext context,
+                                                                 PatSpecificArchiveGenerateConfig config) {
+        PatMaternityArchiveDetail detail = new PatMaternityArchiveDetail();
+        detail.setArchiveType(config.getArchiveType());
+        detail.setFollowupPeriod(config.getFollowupPeriod());
+        detail.setSourceType(SpecificArchiveConstants.SOURCE_TYPE_INHOSP_FOLLOWUP);
+        detail.setSourceBizId(inInhospid(context));
+        detail.setSourceBizNo(inInhospno(context));
+        detail.setSourceSubId(context.subtask.getId());
+        detail.setOuthospno(null);
+        detail.setInhospno(inInhospno(context));
+        detail.setSerialnum(inSerialnum(context));
+        detail.setPatid(context.patid);
+        detail.setPatname(firstNotBlank(context.patArchive == null ? null : context.patArchive.getName(),
+                context.inhosp == null ? null : context.inhosp.getPatname()));
+        detail.setBirthdate(context.patArchive == null ? null : context.patArchive.getBirthdate());
+        detail.setIdcardno(firstNotBlank(context.patArchive == null ? null : context.patArchive.getIdcardno(),
+                context.inhosp == null ? null : context.inhosp.getIdcardno()));
+        detail.setPhone(firstNotBlank(context.patArchive == null ? null : context.patArchive.getTelcode(),
+                context.inhosp == null ? null : context.inhosp.getTelcode()));
+        detail.setSex(firstNonNull(context.patArchive == null ? null : context.patArchive.getSex(),
+                context.inhosp == null ? null : context.inhosp.getSex(),
+                context.subtask.getSex()));
+        detail.setDiagTime(context.diagTime);
+        detail.setArchiveTime(new Date());
+        detail.setDoctorCode(inDrcode(context));
+        detail.setDoctorName(inDrname(context));
+        detail.setManagementDoctorCode(firstNotBlank(context.inhosp == null ? null : context.inhosp.getManagementDoctorCode(),
+                inDrcode(context)));
+        detail.setManagementDoctorName(firstNotBlank(context.inhosp == null ? null : context.inhosp.getManagementDoctor(),
+                inDrname(context)));
+        detail.setFirstDoctorCode(inDrcode(context));
+        detail.setFirstDoctorName(inDrname(context));
+        detail.setDeptcode(context.deptCode);
+        detail.setDeptname(context.deptName);
+        detail.setWardcode(context.wardCode);
+        detail.setWardname(context.wardName);
+        detail.setIcd10code(context.icd10Code);
+        detail.setDiagname(context.diagName);
+        detail.setAddress(context.patArchive == null ? null : context.patArchive.getPlaceOfResidence());
+        detail.setRegisterUser("浣忛櫌闅忚");
+        detail.setOrgid(context.orgid);
+        detail.setCampusid(context.campusid);
+        detail.setDelFlag("0");
+        return detail;
+    }
+
+    private PatChildArchiveDetail buildInhospChildDetail(InhospArchiveContext context,
+                                                         PatSpecificArchiveGenerateConfig config) {
+        PatChildArchiveDetail detail = new PatChildArchiveDetail();
+        detail.setArchiveType(config.getArchiveType());
+        detail.setFollowupPeriod(config.getFollowupPeriod());
+        detail.setSourceType(SpecificArchiveConstants.SOURCE_TYPE_INHOSP_FOLLOWUP);
+        detail.setSourceBizId(inInhospid(context));
+        detail.setSourceBizNo(inInhospno(context));
+        detail.setSourceSubId(context.subtask.getId());
+        detail.setOuthospno(null);
+        detail.setInhospno(inInhospno(context));
+        detail.setSerialnum(inSerialnum(context));
+        detail.setPatid(context.patid);
+        detail.setPatname(firstNotBlank(context.patArchive == null ? null : context.patArchive.getName(),
+                context.inhosp == null ? null : context.inhosp.getPatname()));
+        detail.setBirthdate(context.patArchive == null ? null : context.patArchive.getBirthdate());
+        detail.setIdcardno(firstNotBlank(context.patArchive == null ? null : context.patArchive.getIdcardno(),
+                context.inhosp == null ? null : context.inhosp.getIdcardno()));
+        detail.setPhone(firstNotBlank(context.patArchive == null ? null : context.patArchive.getTelcode(),
+                context.inhosp == null ? null : context.inhosp.getTelcode()));
+        detail.setSex(firstNonNull(context.patArchive == null ? null : context.patArchive.getSex(),
+                context.inhosp == null ? null : context.inhosp.getSex(),
+                context.subtask.getSex()));
+        detail.setDiagTime(context.diagTime);
+        detail.setArchiveTime(new Date());
+        detail.setDoctorCode(inDrcode(context));
+        detail.setDoctorName(inDrname(context));
+        detail.setManagementDoctorCode(firstNotBlank(context.inhosp == null ? null : context.inhosp.getManagementDoctorCode(),
+                inDrcode(context)));
+        detail.setManagementDoctorName(firstNotBlank(context.inhosp == null ? null : context.inhosp.getManagementDoctor(),
+                inDrname(context)));
+        detail.setDeptcode(context.deptCode);
+        detail.setDeptname(context.deptName);
+        detail.setWardcode(context.wardCode);
+        detail.setWardname(context.wardName);
+        detail.setIcd10code(context.icd10Code);
+        detail.setDiagname(context.diagName);
+        detail.setParentPhone(firstNotBlank(context.patArchive == null ? null : context.patArchive.getTelcode(),
+                context.inhosp == null ? null : context.inhosp.getTelcode()));
+        detail.setParentAddress(context.patArchive == null ? null : context.patArchive.getPlaceOfResidence());
+        if ("1".equals(config.getArchiveType())) {
+            detail.setNutritionIcd10Code(context.icd10Code);
+            detail.setNutritionDiagName(context.diagName);
+        }
+        detail.setRegisterUser("浣忛櫌闅忚");
+        detail.setOrgid(context.orgid);
+        detail.setCampusid(context.campusid);
+        detail.setDelFlag("0");
         return detail;
     }
 
@@ -289,6 +701,85 @@
         return CollectionUtils.isNotEmpty(archives) ? archives.get(0) : null;
     }
 
+    private PatArchive resolvePatArchive(Long patid, PatMedInhosp inhosp) {
+        if (patid != null) {
+            PatArchive archive = patArchiveMapper.selectPatArchiveByPatid(patid);
+            if (archive != null) {
+                return archive;
+            }
+        }
+        Long inhospPatid = inhosp == null ? null : inhosp.getPatid();
+        return inhospPatid == null ? null : patArchiveMapper.selectPatArchiveByPatid(inhospPatid);
+    }
+
+    private PatMedInhosp resolveInhosp(ServiceSubtask subtask) {
+        if (subtask.getInhospid() != null) {
+            PatMedInhosp inhosp = inhospVisitFacade.selectPatMedInhospByInhospid(subtask.getInhospid());
+            if (inhosp != null) {
+                return inhosp;
+            }
+        }
+        if (StringUtils.isNotBlank(subtask.getHospno())) {
+            PatMedInhosp query = new PatMedInhosp();
+            query.setInhospno(subtask.getHospno());
+            query.setOrgid(subtask.getOrgid());
+            List<PatMedInhosp> list = inhospVisitFacade.selectPatMedInhosp(query);
+            if (CollectionUtils.isNotEmpty(list)) {
+                return list.get(0);
+            }
+        }
+        return null;
+    }
+
+    private void recordLog(InhospArchiveContext context, PatSpecificArchiveGenerateConfig config,
+                           String deptCategory, String archiveType, String result, Long archiveId, String msg) {
+        PatSpecificArchiveGenerateLog log = new PatSpecificArchiveGenerateLog();
+        log.setSourceType(SpecificArchiveConstants.SOURCE_TYPE_INHOSP_FOLLOWUP);
+        log.setSourceBizId(inInhospid(context));
+        log.setSourceBizNo(inInhospno(context));
+        log.setSourceSubId(context.subtask.getId());
+        log.setPatid(context.patid);
+        log.setOrgid(context.orgid);
+        log.setCampusid(context.campusid);
+        log.setDeptCategory(deptCategory);
+        log.setArchiveType(archiveType);
+        log.setConfigId(config == null || config.getId() == null
+                ? SpecificArchiveConstants.NO_CONFIG_ID : config.getId().intValue());
+        log.setArchiveId(archiveId);
+        log.setProcessResult(result);
+        log.setProcessMsg(msg);
+        PatSpecificArchiveGenerateLog old = patSpecificArchiveGenerateLogService.selectBySourceSubAndConfig(
+                log.getSourceType(), log.getSourceSubId(), log.getConfigId());
+        int retry = old == null || old.getRetryCount() == null ? 0 : old.getRetryCount();
+        if (SpecificArchiveConstants.RESULT_FAILED.equals(result)) {
+            retry++;
+        }
+        log.setRetryCount(retry);
+        patSpecificArchiveGenerateLogService.saveOrUpdate(log);
+    }
+
+    private Long inInhospid(InhospArchiveContext context) {
+        return firstNonNull(context.inhosp == null ? null : context.inhosp.getInhospid(),
+                context.subtask.getInhospid());
+    }
+
+    private String inInhospno(InhospArchiveContext context) {
+        return firstNotBlank(context.inhosp == null ? null : context.inhosp.getInhospno(),
+                context.subtask.getHospno());
+    }
+
+    private String inSerialnum(InhospArchiveContext context) {
+        return context.inhosp == null ? null : context.inhosp.getSerialnum();
+    }
+
+    private String inDrcode(InhospArchiveContext context) {
+        return firstNotBlank(context.inhosp == null ? null : context.inhosp.getDrcode(), context.subtask.getDrcode());
+    }
+
+    private String inDrname(InhospArchiveContext context) {
+        return firstNotBlank(context.inhosp == null ? null : context.inhosp.getDrname(), context.subtask.getDrname());
+    }
+
     private List<String> parseCodes(String raw) {
         if (StringUtils.isBlank(raw)) {
             return Collections.emptyList();
@@ -314,8 +805,42 @@
                 .collect(Collectors.toList());
     }
 
-    private String firstNotBlank(String first, String second) {
-        return StringUtils.isNotBlank(first) ? first : second;
+    private List<String> parseCsv(String raw) {
+        if (StringUtils.isBlank(raw)) {
+            return Collections.emptyList();
+        }
+        return Arrays.stream(raw.split(","))
+                .map(String::trim)
+                .filter(StringUtils::isNotBlank)
+                .collect(Collectors.toList());
+    }
+
+    private String firstNotBlank(String... values) {
+        if (values == null) {
+            return null;
+        }
+        for (String value : values) {
+            if (StringUtils.isNotBlank(value)) {
+                return value;
+            }
+        }
+        return null;
+    }
+
+    private <T> T firstNonNull(T... values) {
+        if (values == null) {
+            return null;
+        }
+        for (T value : values) {
+            if (value != null) {
+                return value;
+            }
+        }
+        return null;
+    }
+
+    private Date firstDate(Date first, Date second) {
+        return first != null ? first : second;
     }
 
     private boolean containsIgnoreCase(List<String> source, String target) {
@@ -328,4 +853,30 @@
     private boolean equalsIgnoreCase(String first, String second) {
         return first != null && second != null && first.trim().equalsIgnoreCase(second.trim());
     }
+
+    private String truncateMsg(String msg) {
+        if (msg == null) {
+            return null;
+        }
+        return msg.length() <= 900 ? msg : msg.substring(0, 900);
+    }
+
+    /**
+     * 浣忛櫌闅忚鐢熸垚妗f鏃剁敤鍒扮殑涓婁笅鏂囥��
+     */
+    private static class InhospArchiveContext {
+        private ServiceSubtask subtask;
+        private PatMedInhosp inhosp;
+        private PatArchive patArchive;
+        private Long patid;
+        private String orgid;
+        private String campusid;
+        private String deptCode;
+        private String deptName;
+        private String wardCode;
+        private String wardName;
+        private String icd10Code;
+        private String diagName;
+        private Date diagTime;
+    }
 }
diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java
index 80225ac..3b24af5 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java
@@ -64,6 +64,7 @@
 import com.ruoyi.task.domain.ServiceSubtaskPreachform;
 import com.ruoyi.task.service.IServiceTaskService;
 import com.ruoyi.task.mapper.ServiceSubtaskPreachformMapper;
+import com.ruoyi.task.event.FollowupCompletedEventPublisher;
 import com.ruoyi.patarchive.mapper.PatArchiveMapper;
 /**
  * 浠诲姟闂嵎闂閫夐」Service涓氬姟灞傚鐞�
@@ -91,6 +92,9 @@
 
     @Autowired
     private ServiceSubtaskMapper serviceSubtaskMapper;
+
+    @Autowired
+    private FollowupCompletedEventPublisher followupCompletedEventPublisher;
 
     @Autowired
     private ServiceSubtaskPreachformMapper serviceSubtaskPreachformMapper;
@@ -476,6 +480,7 @@
                 log.error("灏嗚key鍜寁alue浠巖edis涓�,serviceSubtask鐨勫�间负--------锛歿}", serviceSubtask);
                 serviceSubtask.setScore(formatScore(scoreTotal));
                 serviceSubtaskMapper.updateServiceSubtaskByCondition(serviceSubtask);
+                followupCompletedEventPublisher.publish(serviceSubtask.getId());
 
                 //灏嗗綋鍓嶅彂閫佺姸鎬佹敼鎴� 9 瀹屾垚锛堢紦瀛� preachform 鏌ヨ锛�
                 String currentPreachform = serviceSubtask.getCurrentPreachform();
@@ -664,6 +669,7 @@
             serviceSubtask.setUpdateTime(new Date());
             serviceSubtask.setScore(formatScore(scoreTotal));
             serviceSubtaskMapper.updateServiceSubtaskByCondition(serviceSubtask);
+            followupCompletedEventPublisher.publish(serviceSubtask.getId());
 
             //灏嗗綋鍓嶅彂閫佺姸鎬佹敼鎴�9瀹屾垚
             ServiceSubtaskPreachform serviceSubtaskPreachform = new ServiceSubtaskPreachform();
@@ -823,6 +829,7 @@
                 serviceSubtask.setVisitTime(new Date());
                 serviceSubtask.setScore(formatScore(scoreTotal));
                 serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
+                followupCompletedEventPublisher.publish(serviceSubtask.getId());
                 //灏嗗綋鍓嶅彂閫佺姸鎬佹敼鎴�9瀹屾垚
                 ServiceSubtaskPreachform serviceSubtaskPreachform = new ServiceSubtaskPreachform();
                 serviceSubtaskPreachform.setPreachform(serviceSubtask.getCurrentPreachform());
diff --git a/smartor/src/main/resources/mapper/smartor/PatChildArchiveDetailMapper.xml b/smartor/src/main/resources/mapper/smartor/PatChildArchiveDetailMapper.xml
index b2d555a..bd865d7 100644
--- a/smartor/src/main/resources/mapper/smartor/PatChildArchiveDetailMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatChildArchiveDetailMapper.xml
@@ -9,6 +9,9 @@
         <result property="archiveid" column="archiveid"/>
         <result property="archiveType" column="archive_type"/>
         <result property="sourceType" column="source_type"/>
+        <result property="sourceBizId" column="source_biz_id"/>
+        <result property="sourceBizNo" column="source_biz_no"/>
+        <result property="sourceSubId" column="source_sub_id"/>
         <result property="outhospno" column="outhospno"/>
         <result property="inhospno" column="inhospno"/>
         <result property="serialnum" column="serialnum"/>
@@ -70,6 +73,9 @@
                archiveid,
                archive_type,
                source_type,
+               source_biz_id,
+               source_biz_no,
+               source_sub_id,
                outhospno,
                inhospno,
                serialnum,
@@ -136,6 +142,9 @@
             <if test="archiveType != null and archiveType != ''">and archive_type = #{archiveType}</if>
             <if test="followupPeriod != null and followupPeriod != ''">and followup_period = #{followupPeriod}</if>
             <if test="sourceType != null and sourceType != ''">and source_type = #{sourceType}</if>
+            <if test="sourceBizId != null">and source_biz_id = #{sourceBizId}</if>
+            <if test="sourceBizNo != null and sourceBizNo != ''">and source_biz_no = #{sourceBizNo}</if>
+            <if test="sourceSubId != null">and source_sub_id = #{sourceSubId}</if>
             <if test="outhospno != null and outhospno != ''">and outhospno = #{outhospno}</if>
             <if test="inhospno != null and inhospno != ''">and inhospno = #{inhospno}</if>
             <if test="serialnum != null and serialnum != ''">and serialnum = #{serialnum}</if>
@@ -187,6 +196,9 @@
             <if test="archiveid != null">archiveid,</if>
             <if test="archiveType != null">archive_type,</if>
             <if test="sourceType != null">source_type,</if>
+            <if test="sourceBizId != null">source_biz_id,</if>
+            <if test="sourceBizNo != null">source_biz_no,</if>
+            <if test="sourceSubId != null">source_sub_id,</if>
             <if test="outhospno != null">outhospno,</if>
             <if test="inhospno != null">inhospno,</if>
             <if test="serialnum != null">serialnum,</if>
@@ -246,6 +258,9 @@
             <if test="archiveid != null">#{archiveid},</if>
             <if test="archiveType != null">#{archiveType},</if>
             <if test="sourceType != null">#{sourceType},</if>
+            <if test="sourceBizId != null">#{sourceBizId},</if>
+            <if test="sourceBizNo != null">#{sourceBizNo},</if>
+            <if test="sourceSubId != null">#{sourceSubId},</if>
             <if test="outhospno != null">#{outhospno},</if>
             <if test="inhospno != null">#{inhospno},</if>
             <if test="serialnum != null">#{serialnum},</if>
@@ -309,6 +324,9 @@
             <if test="archiveid != null">archiveid = #{archiveid},</if>
             <if test="archiveType != null">archive_type = #{archiveType},</if>
             <if test="sourceType != null">source_type = #{sourceType},</if>
+            <if test="sourceBizId != null">source_biz_id = #{sourceBizId},</if>
+            <if test="sourceBizNo != null">source_biz_no = #{sourceBizNo},</if>
+            <if test="sourceSubId != null">source_sub_id = #{sourceSubId},</if>
             <if test="outhospno != null">outhospno = #{outhospno},</if>
             <if test="inhospno != null">inhospno = #{inhospno},</if>
             <if test="serialnum != null">serialnum = #{serialnum},</if>
diff --git a/smartor/src/main/resources/mapper/smartor/PatChildArchiveMapper.xml b/smartor/src/main/resources/mapper/smartor/PatChildArchiveMapper.xml
index 95fb901..1e8dbc2 100644
--- a/smartor/src/main/resources/mapper/smartor/PatChildArchiveMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatChildArchiveMapper.xml
@@ -7,6 +7,10 @@
     <resultMap type="com.smartor.domain.PatChildArchive" id="PatChildArchiveResult">
         <result property="id" column="id"/>
         <result property="archiveType" column="archive_type"/>
+        <result property="sourceType" column="source_type"/>
+        <result property="sourceBizId" column="source_biz_id"/>
+        <result property="sourceBizNo" column="source_biz_no"/>
+        <result property="sourceSubId" column="source_sub_id"/>
         <result property="outhospno" column="outhospno"/>
         <result property="inhospno" column="inhospno"/>
         <result property="serialnum" column="serialnum"/>
@@ -52,6 +56,10 @@
     <sql id="selectPatChildArchiveVo">
         select id,
                archive_type,
+               source_type,
+               source_biz_id,
+               source_biz_no,
+               source_sub_id,
                outhospno,
                inhospno,
                serialnum,
@@ -101,6 +109,10 @@
         where 1=1
             and del_flag = '0'
             <if test="archiveType != null and archiveType != ''">and archive_type = #{archiveType}</if>
+            <if test="sourceType != null and sourceType != ''">and source_type = #{sourceType}</if>
+            <if test="sourceBizId != null">and source_biz_id = #{sourceBizId}</if>
+            <if test="sourceBizNo != null and sourceBizNo != ''">and source_biz_no = #{sourceBizNo}</if>
+            <if test="sourceSubId != null">and source_sub_id = #{sourceSubId}</if>
             <if test="outhospno != null and outhospno != ''">and outhospno = #{outhospno}</if>
             <if test="inhospno != null and inhospno != ''">and inhospno = #{inhospno}</if>
             <if test="serialnum != null and serialnum != ''">and serialnum = #{serialnum}</if>
@@ -152,6 +164,10 @@
         insert into pat_child_archive
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="archiveType != null">archive_type,</if>
+            <if test="sourceType != null">source_type,</if>
+            <if test="sourceBizId != null">source_biz_id,</if>
+            <if test="sourceBizNo != null">source_biz_no,</if>
+            <if test="sourceSubId != null">source_sub_id,</if>
             <if test="outhospno != null">outhospno,</if>
             <if test="inhospno != null">inhospno,</if>
             <if test="serialnum != null">serialnum,</if>
@@ -195,6 +211,10 @@
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="archiveType != null">#{archiveType},</if>
+            <if test="sourceType != null">#{sourceType},</if>
+            <if test="sourceBizId != null">#{sourceBizId},</if>
+            <if test="sourceBizNo != null">#{sourceBizNo},</if>
+            <if test="sourceSubId != null">#{sourceSubId},</if>
             <if test="outhospno != null">#{outhospno},</if>
             <if test="inhospno != null">#{inhospno},</if>
             <if test="serialnum != null">#{serialnum},</if>
@@ -242,6 +262,10 @@
         update pat_child_archive
         <trim prefix="SET" suffixOverrides=",">
             <if test="archiveType != null">archive_type = #{archiveType},</if>
+            <if test="sourceType != null">source_type = #{sourceType},</if>
+            <if test="sourceBizId != null">source_biz_id = #{sourceBizId},</if>
+            <if test="sourceBizNo != null">source_biz_no = #{sourceBizNo},</if>
+            <if test="sourceSubId != null">source_sub_id = #{sourceSubId},</if>
             <if test="outhospno != null">outhospno = #{outhospno},</if>
             <if test="inhospno != null">inhospno = #{inhospno},</if>
             <if test="serialnum != null">serialnum = #{serialnum},</if>
diff --git a/smartor/src/main/resources/mapper/smartor/PatMaternityArchiveDetailMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMaternityArchiveDetailMapper.xml
index fb2fef3..7c2ba79 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMaternityArchiveDetailMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMaternityArchiveDetailMapper.xml
@@ -9,6 +9,9 @@
         <result property="archiveid" column="archiveid"/>
         <result property="archiveType" column="archive_type"/>
         <result property="sourceType" column="source_type"/>
+        <result property="sourceBizId" column="source_biz_id"/>
+        <result property="sourceBizNo" column="source_biz_no"/>
+        <result property="sourceSubId" column="source_sub_id"/>
         <result property="outhospno" column="outhospno"/>
         <result property="inhospno" column="inhospno"/>
         <result property="serialnum" column="serialnum"/>
@@ -67,6 +70,9 @@
                archiveid,
                archive_type,
                source_type,
+               source_biz_id,
+               source_biz_no,
+               source_sub_id,
                outhospno,
                inhospno,
                serialnum,
@@ -129,6 +135,9 @@
             <if test="archiveid != null">and archiveid = #{archiveid}</if>
             <if test="archiveType != null and archiveType != ''">and archive_type = #{archiveType}</if>
             <if test="sourceType != null and sourceType != ''">and source_type = #{sourceType}</if>
+            <if test="sourceBizId != null">and source_biz_id = #{sourceBizId}</if>
+            <if test="sourceBizNo != null and sourceBizNo != ''">and source_biz_no = #{sourceBizNo}</if>
+            <if test="sourceSubId != null">and source_sub_id = #{sourceSubId}</if>
             <if test="outhospno != null and outhospno != ''">and outhospno = #{outhospno}</if>
             <if test="inhospno != null and inhospno != ''">and inhospno = #{inhospno}</if>
             <if test="serialnum != null and serialnum != ''">and serialnum = #{serialnum}</if>
@@ -174,6 +183,9 @@
             <if test="archiveid != null">archiveid,</if>
             <if test="archiveType != null">archive_type,</if>
             <if test="sourceType != null">source_type,</if>
+            <if test="sourceBizId != null">source_biz_id,</if>
+            <if test="sourceBizNo != null">source_biz_no,</if>
+            <if test="sourceSubId != null">source_sub_id,</if>
             <if test="outhospno != null">outhospno,</if>
             <if test="inhospno != null">inhospno,</if>
             <if test="serialnum != null">serialnum,</if>
@@ -230,6 +242,9 @@
             <if test="archiveid != null">#{archiveid},</if>
             <if test="archiveType != null">#{archiveType},</if>
             <if test="sourceType != null">#{sourceType},</if>
+            <if test="sourceBizId != null">#{sourceBizId},</if>
+            <if test="sourceBizNo != null">#{sourceBizNo},</if>
+            <if test="sourceSubId != null">#{sourceSubId},</if>
             <if test="outhospno != null">#{outhospno},</if>
             <if test="inhospno != null">#{inhospno},</if>
             <if test="serialnum != null">#{serialnum},</if>
@@ -290,6 +305,9 @@
             <if test="archiveid != null">archiveid = #{archiveid},</if>
             <if test="archiveType != null">archive_type = #{archiveType},</if>
             <if test="sourceType != null">source_type = #{sourceType},</if>
+            <if test="sourceBizId != null">source_biz_id = #{sourceBizId},</if>
+            <if test="sourceBizNo != null">source_biz_no = #{sourceBizNo},</if>
+            <if test="sourceSubId != null">source_sub_id = #{sourceSubId},</if>
             <if test="outhospno != null">outhospno = #{outhospno},</if>
             <if test="inhospno != null">inhospno = #{inhospno},</if>
             <if test="serialnum != null">serialnum = #{serialnum},</if>
diff --git a/smartor/src/main/resources/mapper/smartor/PatMaternityArchiveMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMaternityArchiveMapper.xml
index 194b85f..45ad106 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMaternityArchiveMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMaternityArchiveMapper.xml
@@ -7,6 +7,10 @@
     <resultMap type="com.smartor.domain.PatMaternityArchive" id="PatMaternityArchiveResult">
         <result property="id" column="id"/>
         <result property="archiveType" column="archive_type"/>
+        <result property="sourceType" column="source_type"/>
+        <result property="sourceBizId" column="source_biz_id"/>
+        <result property="sourceBizNo" column="source_biz_no"/>
+        <result property="sourceSubId" column="source_sub_id"/>
         <result property="outhospno" column="outhospno"/>
         <result property="inhospno" column="inhospno"/>
         <result property="serialnum" column="serialnum"/>
@@ -47,6 +51,10 @@
     <sql id="selectPatMaternityArchiveVo">
         select id,
                archive_type,
+               source_type,
+               source_biz_id,
+               source_biz_no,
+               source_sub_id,
                outhospno,
                inhospno,
                serialnum,
@@ -91,6 +99,10 @@
         where 1=1
             and del_flag = '0'
             <if test="archiveType != null and archiveType != ''">and archive_type = #{archiveType}</if>
+            <if test="sourceType != null and sourceType != ''">and source_type = #{sourceType}</if>
+            <if test="sourceBizId != null">and source_biz_id = #{sourceBizId}</if>
+            <if test="sourceBizNo != null and sourceBizNo != ''">and source_biz_no = #{sourceBizNo}</if>
+            <if test="sourceSubId != null">and source_sub_id = #{sourceSubId}</if>
             <if test="outhospno != null and outhospno != ''">and outhospno = #{outhospno}</if>
             <if test="inhospno != null and inhospno != ''">and inhospno = #{inhospno}</if>
             <if test="serialnum != null and serialnum != ''">and serialnum = #{serialnum}</if>
@@ -138,6 +150,10 @@
         insert into pat_maternity_archive
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="archiveType != null">archive_type,</if>
+            <if test="sourceType != null">source_type,</if>
+            <if test="sourceBizId != null">source_biz_id,</if>
+            <if test="sourceBizNo != null">source_biz_no,</if>
+            <if test="sourceSubId != null">source_sub_id,</if>
             <if test="outhospno != null">outhospno,</if>
             <if test="inhospno != null">inhospno,</if>
             <if test="serialnum != null">serialnum,</if>
@@ -176,6 +192,10 @@
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="archiveType != null">#{archiveType},</if>
+            <if test="sourceType != null">#{sourceType},</if>
+            <if test="sourceBizId != null">#{sourceBizId},</if>
+            <if test="sourceBizNo != null">#{sourceBizNo},</if>
+            <if test="sourceSubId != null">#{sourceSubId},</if>
             <if test="outhospno != null">#{outhospno},</if>
             <if test="inhospno != null">#{inhospno},</if>
             <if test="serialnum != null">#{serialnum},</if>
@@ -218,6 +238,10 @@
         update pat_maternity_archive
         <trim prefix="SET" suffixOverrides=",">
             <if test="archiveType != null">archive_type = #{archiveType},</if>
+            <if test="sourceType != null">source_type = #{sourceType},</if>
+            <if test="sourceBizId != null">source_biz_id = #{sourceBizId},</if>
+            <if test="sourceBizNo != null">source_biz_no = #{sourceBizNo},</if>
+            <if test="sourceSubId != null">source_sub_id = #{sourceSubId},</if>
             <if test="outhospno != null">outhospno = #{outhospno},</if>
             <if test="inhospno != null">inhospno = #{inhospno},</if>
             <if test="serialnum != null">serialnum = #{serialnum},</if>
diff --git a/smartor/src/main/resources/mapper/smartor/PatSpecificArchiveGenerateLogMapper.xml b/smartor/src/main/resources/mapper/smartor/PatSpecificArchiveGenerateLogMapper.xml
new file mode 100644
index 0000000..ddcfef9
--- /dev/null
+++ b/smartor/src/main/resources/mapper/smartor/PatSpecificArchiveGenerateLogMapper.xml
@@ -0,0 +1,94 @@
+<?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.PatSpecificArchiveGenerateLogMapper">
+
+    <resultMap type="com.smartor.domain.PatSpecificArchiveGenerateLog" id="PatSpecificArchiveGenerateLogResult">
+        <result property="id" column="id"/>
+        <result property="sourceType" column="source_type"/>
+        <result property="sourceBizId" column="source_biz_id"/>
+        <result property="sourceBizNo" column="source_biz_no"/>
+        <result property="sourceSubId" column="source_sub_id"/>
+        <result property="patid" column="patid"/>
+        <result property="orgid" column="orgid"/>
+        <result property="campusid" column="campusid"/>
+        <result property="deptCategory" column="dept_category"/>
+        <result property="archiveType" column="archive_type"/>
+        <result property="configId" column="config_id"/>
+        <result property="archiveId" column="archive_id"/>
+        <result property="processResult" column="process_result"/>
+        <result property="processMsg" column="process_msg"/>
+        <result property="retryCount" column="retry_count"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+    </resultMap>
+
+    <sql id="selectPatSpecificArchiveGenerateLogVo">
+        select id,
+               source_type,
+               source_biz_id,
+               source_biz_no,
+               source_sub_id,
+               patid,
+               orgid,
+               campusid,
+               dept_category,
+               archive_type,
+               config_id,
+               archive_id,
+               process_result,
+               process_msg,
+               retry_count,
+               create_time,
+               update_time
+        from pat_specific_archive_generate_log
+    </sql>
+
+    <select id="selectBySourceSubAndConfig" resultMap="PatSpecificArchiveGenerateLogResult">
+        <include refid="selectPatSpecificArchiveGenerateLogVo"/>
+        where source_type = #{sourceType}
+          and source_sub_id = #{sourceSubId}
+          and config_id = #{configId}
+        limit 1
+    </select>
+
+    <select id="countProcessedBySourceSub" resultType="int">
+        select count(1)
+        from pat_specific_archive_generate_log
+        where source_type = #{sourceType}
+          and source_sub_id = #{sourceSubId}
+          and process_result in ('1', '2', '3')
+    </select>
+
+    <insert id="insertPatSpecificArchiveGenerateLog" parameterType="com.smartor.domain.PatSpecificArchiveGenerateLog"
+            useGeneratedKeys="true" keyProperty="id">
+        insert into pat_specific_archive_generate_log
+        (source_type, source_biz_id, source_biz_no, source_sub_id, patid, orgid, campusid,
+         dept_category, archive_type, config_id, archive_id, process_result,
+         process_msg, retry_count, create_time, update_time)
+        values
+        (#{sourceType}, #{sourceBizId}, #{sourceBizNo}, #{sourceSubId}, #{patid}, #{orgid}, #{campusid},
+         #{deptCategory}, #{archiveType}, #{configId}, #{archiveId}, #{processResult},
+         #{processMsg}, #{retryCount}, #{createTime}, #{updateTime})
+    </insert>
+
+    <update id="updatePatSpecificArchiveGenerateLog" parameterType="com.smartor.domain.PatSpecificArchiveGenerateLog">
+        update pat_specific_archive_generate_log
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="sourceBizNo != null">source_biz_no = #{sourceBizNo},</if>
+            <if test="sourceSubId != null">source_sub_id = #{sourceSubId},</if>
+            <if test="patid != null">patid = #{patid},</if>
+            <if test="orgid != null">orgid = #{orgid},</if>
+            <if test="campusid != null">campusid = #{campusid},</if>
+            <if test="deptCategory != null">dept_category = #{deptCategory},</if>
+            <if test="archiveType != null">archive_type = #{archiveType},</if>
+            <if test="archiveId != null">archive_id = #{archiveId},</if>
+            <if test="processResult != null">process_result = #{processResult},</if>
+            <if test="processMsg != null">process_msg = #{processMsg},</if>
+            <if test="retryCount != null">retry_count = #{retryCount},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+</mapper>
diff --git a/smartor/src/test/java/com/smartor/service/InhospFollowupArchiveLogicCheck.java b/smartor/src/test/java/com/smartor/service/InhospFollowupArchiveLogicCheck.java
new file mode 100644
index 0000000..a14ad68
--- /dev/null
+++ b/smartor/src/test/java/com/smartor/service/InhospFollowupArchiveLogicCheck.java
@@ -0,0 +1,130 @@
+package com.smartor.service;
+
+import com.ruoyi.patarchive.domain.PatSpecificArchiveGenerateConfig;
+import com.ruoyi.task.domain.ServiceSubtask;
+import com.smartor.service.impl.PatSpecificArchiveGenerateServiceImpl;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.File;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * 浣忛櫌闅忚鐢熸垚涓撶妗f閫昏緫鑷锛堢函 main锛屼笉渚濊禆 JUnit / Spring / 鏁版嵁搴擄級銆�
+ *
+ * <p>瑕嗙洊锛氫綇闄㈤殢璁胯寖鍥村垽鏂�佺瀹�/鐥呭尯/璇婃柇閰嶇疆鍖归厤銆丣SON/閫楀彿閰嶇疆瑙f瀽銆丮apper XML 鍙В鏋愭�с��</p>
+ */
+public final class InhospFollowupArchiveLogicCheck {
+
+    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 ServiceSubtask subtask(String hospType, String serviceType) {
+        ServiceSubtask subtask = new ServiceSubtask();
+        subtask.setId(1001L);
+        subtask.setHospType(hospType);
+        subtask.setServiceType(serviceType);
+        return subtask;
+    }
+
+    private static PatSpecificArchiveGenerateConfig config(String deptType, String archiveType,
+                                                           String deptCodes, String icd10Codes) {
+        PatSpecificArchiveGenerateConfig config = new PatSpecificArchiveGenerateConfig();
+        config.setId(1L);
+        config.setDeptType(deptType);
+        config.setDeptCategory("2");
+        config.setArchiveType(archiveType);
+        config.setDeptCodes(deptCodes);
+        config.setIcd10Codes(icd10Codes);
+        return config;
+    }
+
+    public static void main(String[] args) throws Exception {
+        System.out.println("========== 浣忛櫌闅忚鐢熸垚涓撶妗f閫昏緫鑷 ==========");
+
+        PatSpecificArchiveGenerateServiceImpl service = new PatSpecificArchiveGenerateServiceImpl();
+        setField(service, "inhospFollowupServiceTypes", "2,13,18,19");
+
+        Method isInhosp = PatSpecificArchiveGenerateServiceImpl.class
+                .getDeclaredMethod("isInhospFollowup", ServiceSubtask.class);
+        isInhosp.setAccessible(true);
+
+        System.out.println("-- 1) 浣忛櫌闅忚鑼冨洿 --");
+        check("鍑洪櫌闅忚 serviceType=2", true, isInhosp.invoke(service, subtask("2", "2")));
+        check("鍏ラ櫌闅忚 serviceType=18", true, isInhosp.invoke(service, subtask("6", "18")));
+        check("闂ㄨ瘖浠诲姟 hospType=1", false, isInhosp.invoke(service, subtask("1", "3")));
+        check("瀹f暀浠诲姟 serviceType=4", false, isInhosp.invoke(service, subtask("2", "4")));
+        check("serviceType 涓虹┖", false, isInhosp.invoke(service, subtask("2", null)));
+
+        Method match = PatSpecificArchiveGenerateServiceImpl.class.getDeclaredMethod(
+                "matchConfig", PatSpecificArchiveGenerateConfig.class,
+                String.class, String.class, String.class, String.class);
+        match.setAccessible(true);
+
+        System.out.println("-- 2) 绉戝鍖归厤 --");
+        PatSpecificArchiveGenerateConfig deptConfig = config("1", "1", "[\"D001\"]", null);
+        check("绉戝 D001 鍛戒腑", true, match.invoke(service, deptConfig, "D001", null, null, null));
+        check("绉戝 D002 涓嶅懡涓�", false, match.invoke(service, deptConfig, "D002", null, null, null));
+
+        System.out.println("-- 3) 鐥呭尯鍖归厤 --");
+        PatSpecificArchiveGenerateConfig wardConfig = config("2", "3", "[\"W001\"]", null);
+        check("鐥呭尯 W001 鍛戒腑", true, match.invoke(service, wardConfig, "D001", "W001", null, null));
+        check("绉戝 D001 瀵圭梾鍖洪厤缃笉鍛戒腑", false,
+                match.invoke(service, wardConfig, "D001", "D001", null, null));
+
+        System.out.println("-- 4) 璇婃柇鍖归厤 --");
+        PatSpecificArchiveGenerateConfig diagConfig = config("1", "1", null, "[\"E46.x00x003\"]");
+        check("璇婃柇鐮佸懡涓�", true, match.invoke(service, diagConfig, "D001", null, "E46.x00x003", "钀ュ吇涓嶈壇"));
+        check("鏃犺瘖鏂爜鏃舵寜璇婃柇鍚嶇О鍏滃簳", true,
+                match.invoke(service, diagConfig, "D001", null, null, "E46.x00x003"));
+        check("璇婃柇涓嶅懡涓�", false, match.invoke(service, diagConfig, "D001", null, "R00", "鍏朵粬"));
+
+        System.out.println("-- 5) 閰嶇疆涓虹┖ / 闈炴硶 JSON --");
+        PatSpecificArchiveGenerateConfig emptyConfig = config("1", "1", null, null);
+        check("绉戝鍜岃瘖鏂兘涓虹┖", false, match.invoke(service, emptyConfig, "D001", null, null, null));
+        PatSpecificArchiveGenerateConfig commaConfig = config("1", "1", "D001,D002", null);
+        check("閫楀彿鍒嗛殧閰嶇疆鍏滃簳", true, match.invoke(service, commaConfig, "D002", null, null, null));
+
+        System.out.println("-- 6) Mapper XML 鍙В鏋愭�� --");
+        String[] xmlFiles = new String[]{
+                "smartor/src/main/resources/mapper/smartor/PatMaternityArchiveMapper.xml",
+                "smartor/src/main/resources/mapper/smartor/PatChildArchiveMapper.xml",
+                "smartor/src/main/resources/mapper/smartor/PatMaternityArchiveDetailMapper.xml",
+                "smartor/src/main/resources/mapper/smartor/PatChildArchiveDetailMapper.xml",
+                "smartor/src/main/resources/mapper/smartor/PatSpecificArchiveGenerateLogMapper.xml",
+                "ruoyi-task/src/main/resources/mapper/task/ServiceSubtaskMapper.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("========== 缁撴灉锛歅ASS=" + passed + "锛孎AIL=" + failed + " ==========");
+        if (failed > 0) {
+            System.exit(1);
+        }
+    }
+}
diff --git a/sql/pat_specific_archive_generate_log_and_source_20261111.sql b/sql/pat_specific_archive_generate_log_and_source_20261111.sql
new file mode 100644
index 0000000..c94af5c
--- /dev/null
+++ b/sql/pat_specific_archive_generate_log_and_source_20261111.sql
@@ -0,0 +1,105 @@
+-- =============================================================================
+-- 浣忛櫌闅忚瀹屾垚鐢熸垚濡囩/鍎跨涓撶妗f
+-- 1. 妗f涓昏〃/璇︽儏琛ㄥ鍔犳潵婧愬瓧娈�
+-- 2. 鏂板涓撶妗f鐢熸垚鏃ュ織琛紙骞傜瓑 + 琛ュ伩 + 杩芥函锛�
+-- 3. 澧炲姞鎮h�呮。妗堟煡璇㈢储寮�
+-- 鏃ユ湡锛�2026-11-11
+-- =============================================================================
+
+-- -----------------------------------------------------------------------------
+-- 1. 妗f涓昏〃鏉ユ簮瀛楁
+-- -----------------------------------------------------------------------------
+ALTER TABLE pat_maternity_archive
+    ADD COLUMN source_type CHAR(1) DEFAULT NULL COMMENT '鏉ユ簮绫诲瀷锛�1闂ㄨ瘖鎺ヨ瘖 2浣忛櫌闅忚 3鎵嬪伐鏂板',
+    ADD COLUMN source_biz_id BIGINT DEFAULT NULL COMMENT '鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID',
+    ADD COLUMN source_biz_no VARCHAR(64) DEFAULT NULL COMMENT '鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙�',
+    ADD COLUMN source_sub_id BIGINT DEFAULT NULL COMMENT '鏉ユ簮闅忚瀛愪换鍔D锛歴ervice_subtask.id';
+
+ALTER TABLE pat_child_archive
+    ADD COLUMN source_type CHAR(1) DEFAULT NULL COMMENT '鏉ユ簮绫诲瀷锛�1闂ㄨ瘖鎺ヨ瘖 2浣忛櫌闅忚 3鎵嬪伐鏂板',
+    ADD COLUMN source_biz_id BIGINT DEFAULT NULL COMMENT '鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID',
+    ADD COLUMN source_biz_no VARCHAR(64) DEFAULT NULL COMMENT '鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙�',
+    ADD COLUMN source_sub_id BIGINT DEFAULT NULL COMMENT '鏉ユ簮闅忚瀛愪换鍔D锛歴ervice_subtask.id';
+
+-- -----------------------------------------------------------------------------
+-- 2. 妗f璇︽儏琛ㄨˉ鍏呮潵婧愪笟鍔D/缂栧彿锛坰ource_type 鍘熻〃宸叉湁锛�
+-- -----------------------------------------------------------------------------
+ALTER TABLE pat_maternity_archive_detail
+    ADD COLUMN source_biz_id BIGINT DEFAULT NULL COMMENT '鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID',
+    ADD COLUMN source_biz_no VARCHAR(64) DEFAULT NULL COMMENT '鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙�',
+    ADD COLUMN source_sub_id BIGINT DEFAULT NULL COMMENT '鏉ユ簮闅忚瀛愪换鍔D锛歴ervice_subtask.id';
+
+ALTER TABLE pat_child_archive_detail
+    ADD COLUMN source_biz_id BIGINT DEFAULT NULL COMMENT '鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID',
+    ADD COLUMN source_biz_no VARCHAR(64) DEFAULT NULL COMMENT '鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙�',
+    ADD COLUMN source_sub_id BIGINT DEFAULT NULL COMMENT '鏉ユ簮闅忚瀛愪换鍔D锛歴ervice_subtask.id';
+
+-- -----------------------------------------------------------------------------
+-- 3. 鐢熸垚鏃ュ織琛�
+-- -----------------------------------------------------------------------------
+CREATE TABLE IF NOT EXISTS pat_specific_archive_generate_log
+(
+    id            BIGINT        NOT NULL AUTO_INCREMENT COMMENT '涓婚敭ID',
+    source_type   CHAR(1)       NOT NULL DEFAULT '2' COMMENT '鏉ユ簮绫诲瀷锛�1闂ㄨ瘖鎺ヨ瘖 2浣忛櫌闅忚',
+    source_biz_id BIGINT        DEFAULT NULL COMMENT '鏉ユ簮涓氬姟ID锛氶棬璇婅褰旾D/浣忛櫌璁板綍ID',
+    source_biz_no VARCHAR(64)   DEFAULT NULL COMMENT '鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙�',
+    source_sub_id BIGINT        DEFAULT NULL COMMENT '鏉ユ簮闅忚瀛愪换鍔D锛歴ervice_subtask.id',
+    patid         BIGINT        DEFAULT NULL COMMENT '鎮h�匢D',
+    orgid         VARCHAR(64)   DEFAULT NULL COMMENT '鏈烘瀯ID',
+    campusid      VARCHAR(64)   DEFAULT NULL COMMENT '闄㈠尯ID',
+    dept_category CHAR(1)       DEFAULT NULL COMMENT '閮ㄩ棬鍒嗙被锛�1濡囩 2鍎跨',
+    archive_type  VARCHAR(32)   DEFAULT NULL COMMENT '妗f绫诲瀷',
+    config_id     INT           NOT NULL DEFAULT 0 COMMENT '鍛戒腑鐨勯厤缃甀D锛涙湭鍛戒腑閰嶇疆鏃朵负0',
+    archive_id    BIGINT        DEFAULT NULL COMMENT '鐢熸垚鎴栧懡涓殑妗f涓昏〃ID',
+    process_result CHAR(1)      NOT NULL COMMENT '澶勭悊缁撴灉锛�1鐢熸垚 2宸插瓨鍦ㄨ烦杩� 3鏈尮閰� 4澶辫触',
+    process_msg   VARCHAR(1000) DEFAULT NULL COMMENT '澶勭悊璇存槑',
+    retry_count   INT           NOT NULL DEFAULT 0 COMMENT '閲嶈瘯娆℃暟',
+    create_time   DATETIME      DEFAULT CURRENT_TIMESTAMP COMMENT '鍒涘缓鏃堕棿',
+    update_time   DATETIME      DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '鏇存柊鏃堕棿',
+    PRIMARY KEY (id),
+    UNIQUE KEY uk_pasgl_source_sub_config (source_type, source_sub_id, config_id),
+    KEY idx_pasgl_biz_id (source_biz_id),
+    KEY idx_pasgl_patid (patid, dept_category, archive_type),
+    KEY idx_pasgl_archive (archive_id)
+) ENGINE = InnoDB
+  DEFAULT CHARSET = utf8mb4 COMMENT ='涓撶妗f鐢熸垚鏃ュ織琛�';
+
+-- -----------------------------------------------------------------------------
+-- 4. 鎮h�呭凡鏈夋。妗堟煡璇㈢储寮�
+-- -----------------------------------------------------------------------------
+ALTER TABLE pat_maternity_archive
+    ADD INDEX idx_pma_patid_type (orgid, patid, archive_type, del_flag);
+
+ALTER TABLE pat_child_archive
+    ADD INDEX idx_pca_patid_type (orgid, patid, archive_type, del_flag);
+
+-- -----------------------------------------------------------------------------
+-- 5. 鏉ユ簮绫诲瀷瀛楀吀锛堝瀛楀吀琛ㄥ凡鏈夊悓绫诲瀷鏁版嵁锛屽彲璺宠繃锛�
+-- -----------------------------------------------------------------------------
+INSERT INTO sys_dict_type (dict_name, dict_type, status, create_by, create_time, remark)
+SELECT '涓撶妗f鏉ユ簮', 'pat_archive_source_type', '0', 'system', NOW(), '涓撶妗f鐢熸垚鏉ユ簮'
+FROM DUAL
+WHERE NOT EXISTS (
+    SELECT 1 FROM sys_dict_type WHERE dict_type = 'pat_archive_source_type'
+);
+
+INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
+SELECT 1, '闂ㄨ瘖鎺ヨ瘖', '1', 'pat_archive_source_type', 'N', '0', 'system', NOW(), '闂ㄨ瘖鎺ヨ瘖瀹屾垚鐢熸垚'
+FROM DUAL
+WHERE NOT EXISTS (
+    SELECT 1 FROM sys_dict_data WHERE dict_type = 'pat_archive_source_type' AND dict_value = '1'
+);
+
+INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
+SELECT 2, '浣忛櫌闅忚', '2', 'pat_archive_source_type', 'N', '0', 'system', NOW(), '浣忛櫌闅忚瀹屾垚鐢熸垚'
+FROM DUAL
+WHERE NOT EXISTS (
+    SELECT 1 FROM sys_dict_data WHERE dict_type = 'pat_archive_source_type' AND dict_value = '2'
+);
+
+INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
+SELECT 3, '鎵嬪伐鏂板', '3', 'pat_archive_source_type', 'N', '0', 'system', NOW(), '鎵嬪伐鏂板/瀵煎叆'
+FROM DUAL
+WHERE NOT EXISTS (
+    SELECT 1 FROM sys_dict_data WHERE dict_type = 'pat_archive_source_type' AND dict_value = '3'
+);

--
Gitblit v1.9.3