From 3acf9415fce2dd21c0fd5d67805b72a8bde24a81 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期一, 23 十一月 2026 17:12:00 +0800
Subject: [PATCH] 【丽水】妇幼随访发送

---
 smartor/src/main/java/com/smartor/domain/PatChildArchiveDetail.java                       |   16 +
 smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java             |   69 ++++++
 smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml                   |  143 ++++++++++++
 .gitignore                                                                                |    2 
 smartor/src/main/resources/mapper/smartor/PatChildArchiveDetailMapper.xml                 |   16 +
 smartor/src/main/java/com/smartor/common/MchFollowupConstants.java                        |   30 ++
 smartor/src/main/java/com/smartor/service/IPatChildArchiveService.java                    |   13 +
 smartor/src/main/java/com/smartor/service/mch/IMchFollowupPlanService.java                |   32 ++
 smartor/src/main/resources/mapper/smartor/PatMaternityArchiveDetailMapper.xml             |   16 +
 smartor/src/test/java/com/smartor/service/mch/MchFollowupPlanServiceCheck.java            |   72 ++++++
 smartor/src/main/java/com/smartor/service/IPatMaternityArchiveService.java                |   13 +
 smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanAssembler.java               |    1 
 smartor/src/main/java/com/smartor/domain/PatMaternityArchiveDetail.java                   |   16 +
 smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java        |   74 ++++++
 smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java                         |   17 +
 smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java            |   73 ++++++
 smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateServiceImpl.java |   12 
 smartor/src/main/java/com/smartor/mapper/MchFollowupPlanItemMapper.java                   |   12 +
 smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml                       |   14 +
 19 files changed, 627 insertions(+), 14 deletions(-)

diff --git a/.gitignore b/.gitignore
index 2b810f5..10438f8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,6 +38,8 @@
 !/sql/ry_20220822.sql
 !/sql/pat_specific_archive_generate_config_lishui_mch_20261104.sql
 !/sql/mch_followup_plan_20261117.sql
+!/sql/pat_mch_archive_followup_status_20261123.sql
+!/sql/mch_followup_plan_item_add_followup_fields_20261123.sql
 sql/_probe/
 *.log
 _dbcheck.txt
diff --git a/smartor/src/main/java/com/smartor/common/MchFollowupConstants.java b/smartor/src/main/java/com/smartor/common/MchFollowupConstants.java
index 7eb2ee7..8b3935c 100644
--- a/smartor/src/main/java/com/smartor/common/MchFollowupConstants.java
+++ b/smartor/src/main/java/com/smartor/common/MchFollowupConstants.java
@@ -14,6 +14,21 @@
     /** 妗f绫诲瀷锛氬効淇� */
     public static final String ARCHIVE_TYPE_CHILD = "2";
 
+    /**
+     * 妗f闅忚鐘舵�侊細寰呯‘璁ゃ��
+     *
+     * <p>闂ㄨ瘖鎺ヨ瘖瀹屾垚/浣忛櫌闅忚瀹屾垚鑷姩寤烘。鏃跺啓鍏ワ紝琛ㄧず妗f灏氭湭缁忚繃浜哄伐纭锛�
+     * 涓嶇敓鎴愰殢璁胯鍒掞紝涔熶笉浼氬彂閫佹秷鎭��</p>
+     */
+    public static final String FOLLOWUP_STATUS_PENDING = "0";
+
+    /**
+     * 妗f闅忚鐘舵�侊細闅忚涓��
+     *
+     * <p>浜哄伐淇濆瓨/纭妗f鍚庡啓鍏ワ紝鍏佽鎸� plannedFollowTime + followupPeriod 鐢熸垚璁″垝銆�</p>
+     */
+    public static final String FOLLOWUP_STATUS_ACTIVE = "1";
+
     /** 璁″垝鐘舵�侊細鏈夋晥 */
     public static final String PLAN_STATUS_ACTIVE = "0";
 
@@ -47,6 +62,21 @@
     /** 鑺傜偣鐘舵�侊細璺宠繃锛堟墜鏈哄彿涓虹┖绛夛級 */
     public static final String ITEM_STATUS_SKIPPED = "6";
 
+    /** 鑺傜偣闅忚鐘舵�侊細鏈殢璁� */
+    public static final String ITEM_FOLLOWUP_STATUS_PENDING = "0";
+
+    /** 鑺傜偣闅忚鐘舵�侊細宸查殢璁� */
+    public static final String ITEM_FOLLOWUP_STATUS_DONE = "1";
+
+    /** 鑺傜偣闅忚鐘舵�侊細澶辫 */
+    public static final String ITEM_FOLLOWUP_STATUS_LOST = "2";
+
+    /** 鑺傜偣闅忚鐘舵�侊細鎷掕 */
+    public static final String ITEM_FOLLOWUP_STATUS_REFUSED = "3";
+
+    /** 鑺傜偣闅忚鐘舵�侊細鍙风爜閿欒 */
+    public static final String ITEM_FOLLOWUP_STATUS_BAD_NUMBER = "4";
+
     /** 鍙戦�佹柟寮忥細鐭俊 */
     public static final String SEND_TYPE_SMS = "sms";
 
diff --git a/smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java b/smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java
index d8f94f2..27502c5 100644
--- a/smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java
+++ b/smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java
@@ -1,5 +1,6 @@
 package com.smartor.domain;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -54,6 +55,22 @@
     @ApiModelProperty(value = "瀹為檯鍙戦�佹椂闂�")
     private Date sendTimeActual;
 
+    @ApiModelProperty(value = "闅忚鏃ユ湡")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date followupDate;
+
+    @ApiModelProperty(value = "闅忚浜哄憳ID")
+    private String followupUserId;
+
+    @ApiModelProperty(value = "闅忚浜哄憳濮撳悕")
+    private String followupUserName;
+
+    @ApiModelProperty(value = "闅忚鎯呭喌")
+    private String followupSituation;
+
+    @ApiModelProperty(value = "闅忚鐘舵�侊細0鏈殢璁� 1宸查殢璁� 2澶辫 3鎷掕 4鍙风爜閿欒")
+    private String followupStatus;
+
     @ApiModelProperty(value = "缁撴灉璇存槑")
     private String resultMsg;
 
diff --git a/smartor/src/main/java/com/smartor/domain/PatChildArchiveDetail.java b/smartor/src/main/java/com/smartor/domain/PatChildArchiveDetail.java
index c336e02..0972740 100644
--- a/smartor/src/main/java/com/smartor/domain/PatChildArchiveDetail.java
+++ b/smartor/src/main/java/com/smartor/domain/PatChildArchiveDetail.java
@@ -260,6 +260,22 @@
     @ApiModelProperty(value = "缁撴鐘舵��")
     private String closeStatus;
 
+    /** 闅忚鐘舵�侊細0寰呯‘璁� 1闅忚涓� */
+    @Excel(name = "闅忚鐘舵��")
+    @ApiModelProperty(value = "闅忚鐘舵�侊細0寰呯‘璁� 1闅忚涓�")
+    private String followupStatus;
+
+    /** 闅忚纭鏃堕棿 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "闅忚纭鏃堕棿", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "闅忚纭鏃堕棿")
+    private Date followupConfirmTime;
+
+    /** 闅忚纭浜� */
+    @Excel(name = "闅忚纭浜�")
+    @ApiModelProperty(value = "闅忚纭浜�")
+    private String followupConfirmBy;
+
     /** 鍑虹敓瀛曞懆 */
     @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 79480fe..3086d2d 100644
--- a/smartor/src/main/java/com/smartor/domain/PatMaternityArchiveDetail.java
+++ b/smartor/src/main/java/com/smartor/domain/PatMaternityArchiveDetail.java
@@ -182,6 +182,22 @@
     @ApiModelProperty(value = "缁撴鐘舵��")
     private String closeStatus;
 
+    /** 闅忚鐘舵�侊細0寰呯‘璁� 1闅忚涓� */
+    @Excel(name = "闅忚鐘舵��")
+    @ApiModelProperty(value = "闅忚鐘舵�侊細0寰呯‘璁� 1闅忚涓�")
+    private String followupStatus;
+
+    /** 闅忚纭鏃堕棿 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "闅忚纭鏃堕棿", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "闅忚纭鏃堕棿")
+    private Date followupConfirmTime;
+
+    /** 闅忚纭浜� */
+    @Excel(name = "闅忚纭浜�")
+    @ApiModelProperty(value = "闅忚纭浜�")
+    private String followupConfirmBy;
+
     /** 鏄惁寤哄唽 0-鍚� 1-鏄� */
     @Excel(name = "鏄惁寤哄唽")
     @ApiModelProperty(value = "鏄惁寤哄唽 0-鍚� 1-鏄�")
diff --git a/smartor/src/main/java/com/smartor/mapper/MchFollowupPlanItemMapper.java b/smartor/src/main/java/com/smartor/mapper/MchFollowupPlanItemMapper.java
index 2e166a8..87f1bb5 100644
--- a/smartor/src/main/java/com/smartor/mapper/MchFollowupPlanItemMapper.java
+++ b/smartor/src/main/java/com/smartor/mapper/MchFollowupPlanItemMapper.java
@@ -1,6 +1,8 @@
 package com.smartor.mapper;
 
 import com.smartor.domain.MchFollowupPlanItem;
+import com.smartor.domain.MchFollowupTaskQuery;
+import com.smartor.domain.MchFollowupTaskVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -19,6 +21,11 @@
 
     int updateSendResult(MchFollowupPlanItem item);
 
+    /**
+     * 鍥炲~浜哄伐闅忚缁撴灉锛氶殢璁挎棩鏈熴�侀殢璁夸汉鍛樸�侀殢璁挎儏鍐点�侀殢璁跨姸鎬併��
+     */
+    int updateFollowupResult(MchFollowupPlanItem item);
+
     MchFollowupPlanItem selectMchFollowupPlanItemById(@Param("id") Long id);
 
     List<MchFollowupPlanItem> selectByPlanId(@Param("planId") Long planId);
@@ -35,4 +42,9 @@
     int cancelPendingByPlanId(@Param("planId") Long planId, @Param("now") Date now);
 
     int countPendingByPlanId(@Param("planId") Long planId);
+
+    /**
+     * 濡囧辜闅忚浠诲姟鍒楄〃锛歫oin 璁″垝銆佹。妗堣鎯呫�侀棬璇婅褰曘��
+     */
+    List<MchFollowupTaskVO> selectTaskList(MchFollowupTaskQuery query);
 }
diff --git a/smartor/src/main/java/com/smartor/service/IPatChildArchiveService.java b/smartor/src/main/java/com/smartor/service/IPatChildArchiveService.java
index 62b0f5c..3ed1edd 100644
--- a/smartor/src/main/java/com/smartor/service/IPatChildArchiveService.java
+++ b/smartor/src/main/java/com/smartor/service/IPatChildArchiveService.java
@@ -27,5 +27,18 @@
 
     public int deletePatChildArchiveById(Long id);
 
+    /**
+     * 浜哄伐淇濆瓨/纭妗f銆備繚瀛樻垚鍔熷悗妗f杩涘叆鈥滈殢璁夸腑鈥濓紝骞舵寜闅忚鍛ㄦ湡鍜屾嫙闅忚鏃堕棿鐢熸垚璁″垝銆�
+     */
     public int insertOrUpdateChildArchive(PatChildArchiveDetail patChildArchiveDetail);
+
+    /**
+     * 淇濆瓨妗f锛屽苟鎸囧畾鏄惁鐢变汉宸ョ‘璁ら殢璁裤��
+     *
+     * @param patChildArchiveDetail 妗f璇︽儏
+     * @param confirmFollowup       true=浜哄伐淇濆瓨/纭锛屽厑璁哥敓鎴愰殢璁胯鍒掞紱
+     *                              false=闂ㄨ瘖鎺ヨ瘖/浣忛櫌闅忚鑷姩寤烘。锛屽彧寤鸿崏绋匡紝涓嶇敓鎴愯鍒�
+     */
+    public int insertOrUpdateChildArchive(PatChildArchiveDetail patChildArchiveDetail,
+                                          boolean confirmFollowup);
 }
diff --git a/smartor/src/main/java/com/smartor/service/IPatMaternityArchiveService.java b/smartor/src/main/java/com/smartor/service/IPatMaternityArchiveService.java
index d4dc017..142475f 100644
--- a/smartor/src/main/java/com/smartor/service/IPatMaternityArchiveService.java
+++ b/smartor/src/main/java/com/smartor/service/IPatMaternityArchiveService.java
@@ -27,5 +27,18 @@
 
     public int deletePatMaternityArchiveById(Long id);
 
+    /**
+     * 浜哄伐淇濆瓨/纭妗f銆備繚瀛樻垚鍔熷悗妗f杩涘叆鈥滈殢璁夸腑鈥濓紝骞舵寜闅忚鍛ㄦ湡鍜屾嫙闅忚鏃堕棿鐢熸垚璁″垝銆�
+     */
     public int insertOrUpdateMaternityArchive(PatMaternityArchiveDetail patMaternityArchiveDetail);
+
+    /**
+     * 淇濆瓨妗f锛屽苟鎸囧畾鏄惁鐢变汉宸ョ‘璁ら殢璁裤��
+     *
+     * @param patMaternityArchiveDetail 妗f璇︽儏
+     * @param confirmFollowup           true=浜哄伐淇濆瓨/纭锛屽厑璁哥敓鎴愰殢璁胯鍒掞紱
+     *                                  false=闂ㄨ瘖鎺ヨ瘖/浣忛櫌闅忚鑷姩寤烘。锛屽彧寤鸿崏绋匡紝涓嶇敓鎴愯鍒�
+     */
+    public int insertOrUpdateMaternityArchive(PatMaternityArchiveDetail patMaternityArchiveDetail,
+                                              boolean confirmFollowup);
 }
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 d6b44ef..765cbdc 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java
@@ -89,6 +89,13 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int insertOrUpdateChildArchive(PatChildArchiveDetail patChildArchiveDetail) {
+        return insertOrUpdateChildArchive(patChildArchiveDetail, true);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int insertOrUpdateChildArchive(PatChildArchiveDetail patChildArchiveDetail,
+                                          boolean confirmFollowup) {
         if (patChildArchiveDetail == null) {
             log.error("insertOrUpdateChildArchive鍏ュ弬涓虹┖锛岃妫�鏌ュ叆鍙�");
             throw new BaseException("鍎跨妗f鍏ュ弬涓虹┖锛岃妫�鏌ュ叆鍙�");
@@ -113,10 +120,15 @@
 
         Long existArchiveId = null;
         Long existDetailId = null;
+        PatChildArchiveDetail existingDetail = null;
         if (CollectionUtils.isNotEmpty(olds)) {
-            existArchiveId = olds.get(0).getArchiveid();
-            existDetailId = olds.get(0).getId();
+            existingDetail = olds.get(0);
+            existArchiveId = existingDetail.getArchiveid();
+            existDetailId = existingDetail.getId();
         }
+
+        // 浜哄伐淇濆瓨/纭鏃惰繘鍏ラ殢璁夸腑锛汬IS 鑷姩寤烘。鍙啓寰呯‘璁わ紝涓嶇敓鎴愰殢璁胯鍒�
+        applyFollowupState(patChildArchiveDetail, existingDetail, confirmFollowup);
 
         // 璇︽儏娌℃煡鍒帮紝鍐嶅厹搴曟寜鍚屾牱閿煡涓昏〃锛岄伩鍏嶄富琛ㄩ噸澶�
         if (existArchiveId == null) {
@@ -196,7 +208,8 @@
             patChildArchiveDetailService.insertPatChildArchiveDetail(patChildArchiveDetail);
         }
 
-        // 濡囧辜闅忚璁″垝锛氭。妗堟柊澧�/淇敼鍚庢寜 plannedFollowTime + followupPeriod 閲嶅缓
+        // 濡囧辜闅忚璁″垝锛氬彧鏈変汉宸ョ‘璁わ紙followup_status=1锛夌殑妗f鎵嶇敓鎴�/閲嶅缓锛�
+        // 鑷姩寤烘。涓哄緟纭锛宺ebuildForArchive 鍐呴儴浼氱洿鎺ヨ烦杩囥��
         try {
             if (mchFollowupPlanService != null) {
                 mchFollowupPlanService.rebuildForArchive(
@@ -208,7 +221,59 @@
                     patChildArchive.getId(), patChildArchiveDetail.getId(), e);
         }
 
-        log.info("insertOrUpdateChildArchive澶勭悊瀹屾垚锛屼富琛╥d锛歿}锛岃鎯卛d锛歿}", patChildArchive.getId(), patChildArchiveDetail.getId());
+        log.info("insertOrUpdateChildArchive澶勭悊瀹屾垚锛屼富琛╥d锛歿}锛岃鎯卛d锛歿}锛岄殢璁跨姸鎬侊細{}",
+                patChildArchive.getId(), patChildArchiveDetail.getId(),
+                patChildArchiveDetail.getFollowupStatus());
         return patChildArchive.getId().intValue();
     }
+
+    /**
+     * 澶勭悊妗f闅忚鐘舵�併��
+     *
+     * <p>浜哄伐淇濆瓨/纭锛氭。妗堣繘鍏ラ殢璁夸腑锛屽苟璁板綍棣栨纭鏃堕棿/纭浜猴紱
+     * HIS 鑷姩寤烘。锛氭柊妗f杩涘叆寰呯‘璁わ紝鏇存柊鏃朵笉鏀瑰姩宸叉湁鐘舵�侊紝涔熶笉瑕嗙洊浜哄伐缁存姢鐨�
+     * plannedFollowTime / followupPeriod銆�</p>
+     */
+    private void applyFollowupState(PatChildArchiveDetail detail,
+                                    PatChildArchiveDetail existing,
+                                    boolean confirmFollowup) {
+        if (confirmFollowup) {
+            boolean alreadyActive = existing != null
+                    && MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE.equals(existing.getFollowupStatus())
+                    && existing.getFollowupConfirmTime() != null;
+            detail.setFollowupStatus(MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE);
+            if (alreadyActive) {
+                // 宸茬‘璁よ繃鐨勬。妗堥噸澶嶄繚瀛樻椂锛屼繚鐣欓娆$‘璁ゆ椂闂�/纭浜�
+                detail.setFollowupConfirmTime(null);
+                detail.setFollowupConfirmBy(null);
+            } else {
+                detail.setFollowupConfirmTime(DateUtils.getNowDate());
+                String confirmBy = detail.getUpdateBy();
+                if (StringUtils.isEmpty(confirmBy)) {
+                    confirmBy = detail.getCreateBy();
+                }
+                detail.setFollowupConfirmBy(confirmBy);
+            }
+            return;
+        }
+
+        // HIS 鑷姩寤烘。锛氭柊澧炲彧杩涘叆寰呯‘璁わ紝涓嶇敓鎴愯鍒�
+        if (existing == null) {
+            detail.setFollowupStatus(MchFollowupConstants.FOLLOWUP_STATUS_PENDING);
+            detail.setFollowupConfirmTime(null);
+            detail.setFollowupConfirmBy(null);
+            return;
+        }
+
+        // 鏇存柊鏃朵繚鎸佸師鐘舵�侊紝閬垮厤 HIS 閲嶅鎺ㄩ�佹妸宸茬‘璁ゆ。妗堥��鍥炲緟纭
+        detail.setFollowupStatus(null);
+        detail.setFollowupConfirmTime(null);
+        detail.setFollowupConfirmBy(null);
+        // 宸茬‘璁�/鍘嗗彶宸茬敓鏁堟。妗堢殑闅忚鏃ユ湡涓庡懆鏈熺敱浜哄伐缁存姢锛孒IS 鍚屾涓嶈鐩�
+        if (StringUtils.isEmpty(existing.getFollowupStatus())
+                || MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE.equals(existing.getFollowupStatus())) {
+            detail.setPlannedFollowTime(null);
+            detail.setFollowupPeriod(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 d7c6fa9..b3c106d 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java
@@ -94,6 +94,13 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int insertOrUpdateMaternityArchive(PatMaternityArchiveDetail patMaternityArchiveDetail) {
+        return insertOrUpdateMaternityArchive(patMaternityArchiveDetail, true);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int insertOrUpdateMaternityArchive(PatMaternityArchiveDetail patMaternityArchiveDetail,
+                                              boolean confirmFollowup) {
         if (patMaternityArchiveDetail == null) {
             log.error("insertOrUpdateMaternityArchive鍏ュ弬涓虹┖锛岃妫�鏌ュ叆鍙�");
             throw new BaseException("濡囩妗f鍏ュ弬涓虹┖锛岃妫�鏌ュ叆鍙�");
@@ -130,10 +137,15 @@
 
         Long existArchiveId = null;
         Long existDetailId = null;
+        PatMaternityArchiveDetail existingDetail = null;
         if (CollectionUtils.isNotEmpty(olds)) {
-            existArchiveId = olds.get(0).getArchiveid();
-            existDetailId = olds.get(0).getId();
+            existingDetail = olds.get(0);
+            existArchiveId = existingDetail.getArchiveid();
+            existDetailId = existingDetail.getId();
         }
+
+        // 浜哄伐淇濆瓨/纭鏃惰繘鍏ラ殢璁夸腑锛汬IS 鑷姩寤烘。鍙啓寰呯‘璁わ紝涓嶇敓鎴愰殢璁胯鍒�
+        applyFollowupState(patMaternityArchiveDetail, existingDetail, confirmFollowup);
 
         // 璇︽儏娌℃煡鍒帮紝鍐嶅厹搴曟寜鍚屾牱閿煡涓昏〃锛岄伩鍏嶄富琛ㄩ噸澶�
         if (existArchiveId == null) {
@@ -220,7 +232,8 @@
             patMaternityArchiveDetailService.insertPatMaternityArchiveDetail(patMaternityArchiveDetail);
         }
 
-        // 濡囧辜闅忚璁″垝锛氭。妗堟柊澧�/淇敼鍚庢寜 plannedFollowTime + followupPeriod 閲嶅缓
+        // 濡囧辜闅忚璁″垝锛氬彧鏈変汉宸ョ‘璁わ紙followup_status=1锛夌殑妗f鎵嶇敓鎴�/閲嶅缓锛�
+        // 鑷姩寤烘。涓哄緟纭锛宺ebuildForArchive 鍐呴儴浼氱洿鎺ヨ烦杩囥��
         try {
             if (mchFollowupPlanService != null) {
                 mchFollowupPlanService.rebuildForArchive(
@@ -232,7 +245,60 @@
                     patMaternityArchive.getId(), patMaternityArchiveDetail.getId(), e);
         }
 
-        log.info("insertOrUpdateMaternityArchive澶勭悊瀹屾垚锛屼富琛╥d锛歿}锛岃鎯卛d锛歿}", patMaternityArchive.getId(), patMaternityArchiveDetail.getId());
+        log.info("insertOrUpdateMaternityArchive澶勭悊瀹屾垚锛屼富琛╥d锛歿}锛岃鎯卛d锛歿}锛岄殢璁跨姸鎬侊細{}",
+                patMaternityArchive.getId(), patMaternityArchiveDetail.getId(),
+                patMaternityArchiveDetail.getFollowupStatus());
         return patMaternityArchive.getId().intValue();
     }
+
+    /**
+     * 澶勭悊妗f闅忚鐘舵�併��
+     *
+     * <p>浜哄伐淇濆瓨/纭锛氭。妗堣繘鍏ラ殢璁夸腑锛屽苟璁板綍棣栨纭鏃堕棿/纭浜猴紱
+     * HIS 鑷姩寤烘。锛氭柊妗f杩涘叆寰呯‘璁わ紝鏇存柊鏃朵笉鏀瑰姩宸叉湁鐘舵�侊紝涔熶笉瑕嗙洊浜哄伐缁存姢鐨�
+     * plannedFollowTime / followupPeriod / followupCycleTimes銆�</p>
+     */
+    private void applyFollowupState(PatMaternityArchiveDetail detail,
+                                    PatMaternityArchiveDetail existing,
+                                    boolean confirmFollowup) {
+        if (confirmFollowup) {
+            boolean alreadyActive = existing != null
+                    && MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE.equals(existing.getFollowupStatus())
+                    && existing.getFollowupConfirmTime() != null;
+            detail.setFollowupStatus(MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE);
+            if (alreadyActive) {
+                // 宸茬‘璁よ繃鐨勬。妗堥噸澶嶄繚瀛樻椂锛屼繚鐣欓娆$‘璁ゆ椂闂�/纭浜�
+                detail.setFollowupConfirmTime(null);
+                detail.setFollowupConfirmBy(null);
+            } else {
+                detail.setFollowupConfirmTime(DateUtils.getNowDate());
+                String confirmBy = detail.getUpdateBy();
+                if (StringUtils.isEmpty(confirmBy)) {
+                    confirmBy = detail.getCreateBy();
+                }
+                detail.setFollowupConfirmBy(confirmBy);
+            }
+            return;
+        }
+
+        // HIS 鑷姩寤烘。锛氭柊澧炲彧杩涘叆寰呯‘璁わ紝涓嶇敓鎴愯鍒�
+        if (existing == null) {
+            detail.setFollowupStatus(MchFollowupConstants.FOLLOWUP_STATUS_PENDING);
+            detail.setFollowupConfirmTime(null);
+            detail.setFollowupConfirmBy(null);
+            return;
+        }
+
+        // 鏇存柊鏃朵繚鎸佸師鐘舵�侊紝閬垮厤 HIS 閲嶅鎺ㄩ�佹妸宸茬‘璁ゆ。妗堥��鍥炲緟纭
+        detail.setFollowupStatus(null);
+        detail.setFollowupConfirmTime(null);
+        detail.setFollowupConfirmBy(null);
+        // 宸茬‘璁�/鍘嗗彶宸茬敓鏁堟。妗堢殑闅忚鏃ユ湡涓庡懆鏈熺敱浜哄伐缁存姢锛孒IS 鍚屾涓嶈鐩�
+        if (StringUtils.isEmpty(existing.getFollowupStatus())
+                || MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE.equals(existing.getFollowupStatus())) {
+            detail.setPlannedFollowTime(null);
+            detail.setFollowupPeriod(null);
+            detail.setFollowupCycleTimes(null);
+        }
+    }
 }
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 c0e895c..904b49e 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatSpecificArchiveGenerateServiceImpl.java
@@ -166,12 +166,14 @@
                 if (SpecificArchiveConstants.DEPT_CATEGORY_GYNECOLOGY.equals(deptCategory)) {
                     PatMaternityArchiveDetail detail =
                             buildMaternityDetail(patMedOuthosp, targetArchive, config, campusid);
-                    patMaternityArchiveService.insertOrUpdateMaternityArchive(detail);
+                    // 鎺ヨ瘖瀹屾垚鑷姩寤烘。锛氬彧寤鸿崏绋匡紝绛変汉宸ヤ繚瀛樻。妗堝悗鍐嶇敓鎴愰殢璁胯鍒�
+                    patMaternityArchiveService.insertOrUpdateMaternityArchive(detail, false);
                     generatedCount++;
                 } else if (SpecificArchiveConstants.DEPT_CATEGORY_PEDIATRICS.equals(deptCategory)) {
                     PatChildArchiveDetail detail =
                             buildChildDetail(patMedOuthosp, targetArchive, config, campusid);
-                    patChildArchiveService.insertOrUpdateChildArchive(detail);
+                    // 鎺ヨ瘖瀹屾垚鑷姩寤烘。锛氬彧寤鸿崏绋匡紝绛変汉宸ヤ繚瀛樻。妗堝悗鍐嶇敓鎴愰殢璁胯鍒�
+                    patChildArchiveService.insertOrUpdateChildArchive(detail, false);
                     generatedCount++;
                 } else {
                     log.warn("鐢熸垚涓撶妗f璺宠繃锛氭湭鐭ラ儴闂ㄥ垎绫伙紝configId={}锛宒eptCategory={}",
@@ -329,10 +331,12 @@
                 Long archiveId;
                 if (SpecificArchiveConstants.DEPT_CATEGORY_GYNECOLOGY.equals(deptCategory)) {
                     PatMaternityArchiveDetail detail = buildInhospMaternityDetail(context, config);
-                    archiveId = (long) patMaternityArchiveService.insertOrUpdateMaternityArchive(detail);
+                    // 浣忛櫌闅忚瀹屾垚鑷姩寤烘。锛氬彧寤鸿崏绋匡紝绛変汉宸ヤ繚瀛樻。妗堝悗鍐嶇敓鎴愰殢璁胯鍒�
+                    archiveId = (long) patMaternityArchiveService.insertOrUpdateMaternityArchive(detail, false);
                 } else if (SpecificArchiveConstants.DEPT_CATEGORY_PEDIATRICS.equals(deptCategory)) {
                     PatChildArchiveDetail detail = buildInhospChildDetail(context, config);
-                    archiveId = (long) patChildArchiveService.insertOrUpdateChildArchive(detail);
+                    // 浣忛櫌闅忚瀹屾垚鑷姩寤烘。锛氬彧寤鸿崏绋匡紝绛変汉宸ヤ繚瀛樻。妗堝悗鍐嶇敓鎴愰殢璁胯鍒�
+                    archiveId = (long) patChildArchiveService.insertOrUpdateChildArchive(detail, false);
                 } else {
                     log.warn("浣忛櫌闅忚鐢熸垚涓撶妗f璺宠繃锛氭湭鐭ラ儴闂ㄥ垎绫伙紝configId={}锛宒eptCategory={}",
                             config.getId(), deptCategory);
diff --git a/smartor/src/main/java/com/smartor/service/mch/IMchFollowupPlanService.java b/smartor/src/main/java/com/smartor/service/mch/IMchFollowupPlanService.java
index 8c52781..cb14bb0 100644
--- a/smartor/src/main/java/com/smartor/service/mch/IMchFollowupPlanService.java
+++ b/smartor/src/main/java/com/smartor/service/mch/IMchFollowupPlanService.java
@@ -1,5 +1,11 @@
 package com.smartor.service.mch;
 
+import com.smartor.domain.MchFollowupPlanItem;
+import com.smartor.domain.MchFollowupTaskQuery;
+import com.smartor.domain.MchFollowupTaskVO;
+
+import java.util.List;
+
 /**
  * 濡囧辜闅忚璁″垝鏈嶅姟銆�
  */
@@ -22,4 +28,30 @@
      * @return 鏂扮敓鎴愮殑鍙戦�佽妭鐐规暟閲�
      */
     int rebuildAll(int limit);
+
+    /**
+     * 鍥炲~闅忚鑺傜偣鐨勫疄闄呴殢璁挎棩鏈熴�侀殢璁夸汉鍛樸�侀殢璁挎儏鍐靛拰闅忚鐘舵�併��
+     *
+     * <p>鍙洿鏂颁汉宸ラ殢璁跨粨鏋滐紝涓嶅奖鍝� send_status 鍙戦�佺姸鎬併��</p>
+     *
+     * @param item 鑷冲皯鍖呭惈 id 鍜� followupStatus
+     * @return 鏇存柊琛屾暟
+     */
+    int updateItemFollowupResult(MchFollowupPlanItem item);
+
+    /**
+     * 鏌ヨ鏌愪釜璁″垝涓嬬殑鎵�鏈夐殢璁胯妭鐐广��
+     *
+     * @param planId 璁″垝ID
+     * @return 鑺傜偣鍒楄〃锛堝惈鍙戦�佺姸鎬佸拰浜哄伐闅忚缁撴灉锛�
+     */
+    List<MchFollowupPlanItem> listItems(Long planId);
+
+    /**
+     * 鏌ヨ濡囧辜闅忚浠诲姟鍒楄〃銆�
+     *
+     * <p>杩斿洖闂ㄨ瘖鏃ユ湡銆佽鍒�/瀹為檯闅忚鏃ユ湡銆侀殢璁夸汉銆乻endname銆乸atid 绛夊瓧娈碉紱
+     * taskid 鍥哄畾涓虹┖锛宼askname 涓烘。妗堢被鍨�+闅忚銆�</p>
+     */
+    List<MchFollowupTaskVO> listTasks(MchFollowupTaskQuery query);
 }
diff --git a/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanAssembler.java b/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanAssembler.java
index 2295a5e..e83a66b 100644
--- a/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanAssembler.java
+++ b/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanAssembler.java
@@ -36,6 +36,7 @@
             item.setTemplateId(node.getTemplateId());
             item.setUrl(node.getUrl());
             item.setSendStatus(MchFollowupConstants.ITEM_STATUS_PENDING);
+            item.setFollowupStatus(MchFollowupConstants.ITEM_FOLLOWUP_STATUS_PENDING);
             item.setRetryCount(0);
             item.setCreateTime(now);
             item.setUpdateTime(now);
diff --git a/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java b/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java
index 63064f5..991c900 100644
--- a/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java
@@ -1,5 +1,6 @@
 package com.smartor.service.mch;
 
+import com.ruoyi.common.exception.base.BaseException;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.system.service.ISysConfigService;
@@ -9,6 +10,8 @@
 import com.smartor.domain.MchFollowupNode;
 import com.smartor.domain.MchFollowupPlan;
 import com.smartor.domain.MchFollowupPlanItem;
+import com.smartor.domain.MchFollowupTaskQuery;
+import com.smartor.domain.MchFollowupTaskVO;
 import com.smartor.domain.PatChildArchiveDetail;
 import com.smartor.domain.PatMaternityArchiveDetail;
 import com.smartor.mapper.MchFollowupPlanItemMapper;
@@ -84,6 +87,12 @@
         if (!SpecificArchiveConstants.LISHUI_MCH_ORG_ID.equals(snapshot.orgid)) {
             return 0;
         }
+        // 妗f蹇呴』缁忚繃浜哄伐淇濆瓨/纭鍚庢墠鍏佽鐢熸垚璁″垝锛涙帴璇婂畬鎴愯嚜鍔ㄥ缓妗e彧鏄崏绋裤��
+        if (!isFollowupActive(snapshot.followupStatus)) {
+            log.debug("銆愬骞奸殢璁裤�戞。妗堟湭纭闅忚锛岃烦杩囪鍒掗噸寤猴紝archiveType={}锛宎rchiveId={}锛宒etailId={}锛宖ollowupStatus={}",
+                    snapshot.archiveType, snapshot.archiveId, snapshot.archiveDetailId, snapshot.followupStatus);
+            return 0;
+        }
 
         List<MchFollowupPlan> actives = planMapper.selectActiveByArchive(
                 snapshot.archiveType, snapshot.archiveId, snapshot.archiveDetailId);
@@ -91,7 +100,10 @@
             actives = Collections.emptyList();
         }
         for (MchFollowupPlan active : actives) {
-            if (sameTime(active.getPlannedFollowTime(), snapshot.plannedFollowTime)
+            // 鍙湁鈥滄湁鏁堚�濊鍒掓墠鍋氬箓绛夊垽鏂紱寰呰ˉ鍏呰鍒掑嵆浣挎棩鏈�/鍛ㄦ湡瀛楃涓茬浉鍚岋紝
+            // 涔熷彲鑳芥槸鍥犱负涔嬪墠閰嶇疆闈炴硶鑰屾寕璧凤紝浜哄伐纭鍚庡繀椤婚噸鏂拌В鏋愬苟鐢熸垚鑺傜偣銆�
+            if (MchFollowupConstants.PLAN_STATUS_ACTIVE.equals(active.getPlanStatus())
+                    && sameTime(active.getPlannedFollowTime(), snapshot.plannedFollowTime)
                     && StringUtils.equals(active.getFollowupPeriod(), snapshot.followupPeriod)) {
                 MchFollowupPlan contactUpdate = new MchFollowupPlan();
                 contactUpdate.setId(active.getId());
@@ -194,6 +206,50 @@
         return generated;
     }
 
+    @Override
+    public int updateItemFollowupResult(MchFollowupPlanItem item) {
+        if (item == null || item.getId() == null) {
+            throw new BaseException("闅忚鑺傜偣ID涓嶈兘涓虹┖");
+        }
+        String followupStatus = item.getFollowupStatus();
+        if (StringUtils.isEmpty(followupStatus)) {
+            throw new BaseException("闅忚鐘舵�佷笉鑳戒负绌�");
+        }
+        if (!isValidItemFollowupStatus(followupStatus)) {
+            throw new BaseException("涓嶆敮鎸佺殑闅忚鐘舵�侊細" + followupStatus);
+        }
+        MchFollowupPlanItem existing = itemMapper.selectMchFollowupPlanItemById(item.getId());
+        if (existing == null) {
+            throw new BaseException("闅忚鑺傜偣涓嶅瓨鍦細" + item.getId());
+        }
+        item.setUpdateTime(DateUtils.getNowDate());
+        return itemMapper.updateFollowupResult(item);
+    }
+
+    @Override
+    public List<MchFollowupPlanItem> listItems(Long planId) {
+        if (planId == null) {
+            throw new BaseException("璁″垝ID涓嶈兘涓虹┖");
+        }
+        return itemMapper.selectByPlanId(planId);
+    }
+
+    @Override
+    public List<MchFollowupTaskVO> listTasks(MchFollowupTaskQuery query) {
+        if (query == null || StringUtils.isEmpty(query.getOrgid())) {
+            throw new BaseException("鏈烘瀯ID涓嶈兘涓虹┖");
+        }
+        return itemMapper.selectTaskList(query);
+    }
+
+    private boolean isValidItemFollowupStatus(String status) {
+        return MchFollowupConstants.ITEM_FOLLOWUP_STATUS_PENDING.equals(status)
+                || MchFollowupConstants.ITEM_FOLLOWUP_STATUS_DONE.equals(status)
+                || MchFollowupConstants.ITEM_FOLLOWUP_STATUS_LOST.equals(status)
+                || MchFollowupConstants.ITEM_FOLLOWUP_STATUS_REFUSED.equals(status)
+                || MchFollowupConstants.ITEM_FOLLOWUP_STATUS_BAD_NUMBER.equals(status);
+    }
+
     private ArchiveSnapshot loadSnapshot(String archiveType, Long archiveId, Long archiveDetailId) {
         if (MchFollowupConstants.ARCHIVE_TYPE_MATERNITY.equals(archiveType)) {
             return loadMaternitySnapshot(archiveId, archiveDetailId);
@@ -237,6 +293,7 @@
         snapshot.plannedFollowTime = detail.getPlannedFollowTime();
         snapshot.followupPeriod = detail.getFollowupPeriod();
         snapshot.followupCycleTimes = detail.getFollowupCycleTimes();
+        snapshot.followupStatus = detail.getFollowupStatus();
         return snapshot;
     }
 
@@ -271,7 +328,16 @@
         snapshot.idcardno = detail.getIdcardno();
         snapshot.plannedFollowTime = detail.getPlannedFollowTime();
         snapshot.followupPeriod = detail.getFollowupPeriod();
+        snapshot.followupStatus = detail.getFollowupStatus();
         return snapshot;
+    }
+
+    /**
+     * 鍘嗗彶鏁版嵁娌℃湁鐘舵�佹椂鎸夊凡纭澶勭悊锛屼繚璇佸凡鏈夋。妗堢殑璁″垝涓嶅彈褰卞搷銆�
+     */
+    private boolean isFollowupActive(String followupStatus) {
+        return StringUtils.isEmpty(followupStatus)
+                || MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE.equals(followupStatus);
     }
 
     private boolean isEnabled() {
@@ -317,5 +383,6 @@
         private Date plannedFollowTime;
         private String followupPeriod;
         private String followupCycleTimes;
+        private String followupStatus;
     }
 }
diff --git a/smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml b/smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml
index 1bac046..24082b1 100644
--- a/smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml
@@ -18,15 +18,53 @@
         <result property="retryCount" column="retry_count"/>
         <result property="nextRetryTime" column="next_retry_time"/>
         <result property="sendTimeActual" column="send_time_actual"/>
+        <result property="followupDate" column="followup_date"/>
+        <result property="followupUserId" column="followup_user_id"/>
+        <result property="followupUserName" column="followup_user_name"/>
+        <result property="followupSituation" column="followup_situation"/>
+        <result property="followupStatus" column="followup_status"/>
         <result property="resultMsg" column="result_msg"/>
         <result property="providerMsgId" column="provider_msg_id"/>
         <result property="createTime" column="create_time"/>
         <result property="updateTime" column="update_time"/>
     </resultMap>
 
+    <resultMap id="MchFollowupTaskResult" type="com.smartor.domain.MchFollowupTaskVO">
+        <result property="itemId" column="item_id"/>
+        <result property="planId" column="plan_id"/>
+        <result property="taskid" column="taskid"/>
+        <result property="taskType" column="task_type"/>
+        <result property="taskname" column="task_name"/>
+        <result property="archiveType" column="archive_type"/>
+        <result property="archiveTypeName" column="archive_type_name"/>
+        <result property="archiveId" column="archive_id"/>
+        <result property="archiveDetailId" column="archive_detail_id"/>
+        <result property="sourceType" column="source_type"/>
+        <result property="sourceBizNo" column="source_biz_no"/>
+        <result property="patid" column="patid"/>
+        <result property="patname" column="patname"/>
+        <result property="sendname" column="sendname"/>
+        <result property="phone" column="phone"/>
+        <result property="idcardno" column="idcardno"/>
+        <result property="seq" column="seq"/>
+        <result property="outpatientDate" column="outpatient_date"/>
+        <result property="plannedFollowTime" column="planned_follow_time"/>
+        <result property="plannedFollowDate" column="planned_follow_date"/>
+        <result property="followupDate" column="followup_date"/>
+        <result property="followupUserId" column="followup_user_id"/>
+        <result property="followupUserName" column="followup_user_name"/>
+        <result property="followupSituation" column="followup_situation"/>
+        <result property="followupStatus" column="followup_status"/>
+        <result property="sendStatus" column="send_status"/>
+        <result property="sendTimeActual" column="send_time_actual"/>
+        <result property="orgid" column="orgid"/>
+        <result property="campusid" column="campusid"/>
+    </resultMap>
+
     <sql id="selectItemVo">
         select id, plan_id, seq, send_type, send_time, title_name, content, template_id, url,
                send_status, retry_count, next_retry_time, send_time_actual,
+               followup_date, followup_user_id, followup_user_name, followup_situation, followup_status,
                result_msg, provider_msg_id, create_time, update_time
         from mch_followup_plan_item
     </sql>
@@ -36,10 +74,13 @@
         insert into mch_followup_plan_item
         (plan_id, seq, send_type, send_time, title_name, content, template_id, url,
          send_status, retry_count, next_retry_time, send_time_actual,
+         followup_date, followup_user_id, followup_user_name, followup_situation, followup_status,
          result_msg, provider_msg_id, create_time, update_time)
         values
         (#{planId}, #{seq}, #{sendType}, #{sendTime}, #{titleName}, #{content}, #{templateId}, #{url},
          #{sendStatus}, #{retryCount}, #{nextRetryTime}, #{sendTimeActual},
+         #{followupDate}, #{followupUserId}, #{followupUserName}, #{followupSituation},
+         COALESCE(#{followupStatus,jdbcType=CHAR}, '0'),
          #{resultMsg}, #{providerMsgId}, #{createTime}, #{updateTime})
     </insert>
 
@@ -56,6 +97,11 @@
             <if test="retryCount != null">retry_count = #{retryCount},</if>
             <if test="nextRetryTime != null">next_retry_time = #{nextRetryTime},</if>
             <if test="sendTimeActual != null">send_time_actual = #{sendTimeActual},</if>
+            <if test="followupDate != null">followup_date = #{followupDate},</if>
+            <if test="followupUserId != null">followup_user_id = #{followupUserId},</if>
+            <if test="followupUserName != null">followup_user_name = #{followupUserName},</if>
+            <if test="followupSituation != null">followup_situation = #{followupSituation},</if>
+            <if test="followupStatus != null">followup_status = #{followupStatus},</if>
             <if test="resultMsg != null">result_msg = #{resultMsg},</if>
             <if test="providerMsgId != null">provider_msg_id = #{providerMsgId},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
@@ -75,6 +121,17 @@
         where id = #{id}
     </update>
 
+    <update id="updateFollowupResult" parameterType="com.smartor.domain.MchFollowupPlanItem">
+        update mch_followup_plan_item
+        set followup_date = #{followupDate,jdbcType=TIMESTAMP},
+            followup_user_id = #{followupUserId,jdbcType=VARCHAR},
+            followup_user_name = #{followupUserName,jdbcType=VARCHAR},
+            followup_situation = #{followupSituation,jdbcType=VARCHAR},
+            followup_status = #{followupStatus,jdbcType=CHAR},
+            update_time = #{updateTime,jdbcType=TIMESTAMP}
+        where id = #{id}
+    </update>
+
     <select id="selectMchFollowupPlanItemById" resultMap="MchFollowupPlanItemResult">
         <include refid="selectItemVo"/>
         where id = #{id}
@@ -89,7 +146,9 @@
     <select id="selectDueItems" resultMap="MchFollowupPlanItemResult">
         select i.id, i.plan_id, i.seq, i.send_type, i.send_time, i.title_name, i.content,
                i.template_id, i.url, i.send_status, i.retry_count, i.next_retry_time,
-               i.send_time_actual, i.result_msg, i.provider_msg_id, i.create_time, i.update_time
+               i.send_time_actual, i.followup_date, i.followup_user_id, i.followup_user_name,
+               i.followup_situation, i.followup_status,
+               i.result_msg, i.provider_msg_id, i.create_time, i.update_time
         from mch_followup_plan_item i
         inner join mch_followup_plan p on p.id = i.plan_id
         where p.orgid = #{orgid}
@@ -125,4 +184,86 @@
           and send_status in ('0', '1')
     </select>
 
+    <select id="selectTaskList" parameterType="com.smartor.domain.MchFollowupTaskQuery"
+            resultMap="MchFollowupTaskResult">
+        select
+            i.id as item_id,
+            i.plan_id as plan_id,
+            cast(null as signed) as taskid,
+            'MCH' as task_type,
+            case
+                when p.archive_type = '1' and m.archive_type = '1' then '鏃╁瓡鍏崇埍闅忚'
+                when p.archive_type = '1' and m.archive_type = '2' then '鍥寸粷缁忔湡MHI闅忚'
+                when p.archive_type = '2' and c.archive_type = '1' then '钀ュ吇鎬х柧鐥呴殢璁�'
+                when p.archive_type = '2' and c.archive_type = '2' then '瀛︿範鍥伴毦闅忚'
+                when p.archive_type = '2' and c.archive_type = '3' then '楂樺嵄鍎夸笓妗堥殢璁�'
+                when p.archive_type = '1' then '濡囦繚闅忚'
+                when p.archive_type = '2' then '鍎夸繚闅忚'
+                else '濡囧辜闅忚'
+            end as task_name,
+            p.archive_type as archive_type,
+            case
+                when p.archive_type = '1' and m.archive_type = '1' then '鏃╁瓡鍏崇埍'
+                when p.archive_type = '1' and m.archive_type = '2' then '鍥寸粷缁忔湡MHI'
+                when p.archive_type = '2' and c.archive_type = '1' then '钀ュ吇鎬х柧鐥�'
+                when p.archive_type = '2' and c.archive_type = '2' then '瀛︿範鍥伴毦'
+                when p.archive_type = '2' and c.archive_type = '3' then '楂樺嵄鍎夸笓妗�'
+                when p.archive_type = '1' then '濡囦繚'
+                when p.archive_type = '2' then '鍎夸繚'
+                else '濡囧辜'
+            end as archive_type_name,
+            p.archive_id as archive_id,
+            p.archive_detail_id as archive_detail_id,
+            p.source_type as source_type,
+            p.source_biz_no as source_biz_no,
+            p.patid as patid,
+            p.patname as patname,
+            p.patname as sendname,
+            p.phone as phone,
+            p.idcardno as idcardno,
+            i.seq as seq,
+            o.admitdate as outpatient_date,
+            p.planned_follow_time as planned_follow_time,
+            i.send_time as planned_follow_date,
+            i.followup_date as followup_date,
+            i.followup_user_id as followup_user_id,
+            i.followup_user_name as followup_user_name,
+            i.followup_situation as followup_situation,
+            i.followup_status as followup_status,
+            i.send_status as send_status,
+            i.send_time_actual as send_time_actual,
+            p.orgid as orgid,
+            p.campusid as campusid
+        from mch_followup_plan_item i
+        inner join mch_followup_plan p on p.id = i.plan_id
+        left join pat_maternity_archive_detail m
+            on p.archive_type = '1' and m.id = p.archive_detail_id
+        left join pat_child_archive_detail c
+            on p.archive_type = '2' and c.id = p.archive_detail_id
+        left join pat_med_outhosp o
+            on p.source_type = '1'
+           and o.orgid = p.orgid
+           and o.outhospno = p.source_biz_no
+        where p.orgid = #{orgid}
+          and p.plan_status &lt;&gt; '1'
+          and i.send_status &lt;&gt; '5'
+          <if test="campusid != null and campusid != ''">and p.campusid = #{campusid}</if>
+          <if test="planId != null">and p.id = #{planId}</if>
+          <if test="itemId != null">and i.id = #{itemId}</if>
+          <if test="archiveType != null and archiveType != ''">and p.archive_type = #{archiveType}</if>
+          <if test="sourceType != null and sourceType != ''">and p.source_type = #{sourceType}</if>
+          <if test="sendStatus != null and sendStatus != ''">and i.send_status = #{sendStatus}</if>
+          <if test="followupStatus != null and followupStatus != ''">and i.followup_status = #{followupStatus}</if>
+          <if test="patid != null">and p.patid = #{patid}</if>
+          <if test="keyword != null and keyword != ''">
+              and (p.patname like concat('%', #{keyword}, '%')
+                   or p.phone like concat('%', #{keyword}, '%')
+                   or p.idcardno like concat('%', #{keyword}, '%')
+                   or p.source_biz_no like concat('%', #{keyword}, '%'))
+          </if>
+          <if test="beginDate != null">and i.send_time &gt;= #{beginDate}</if>
+          <if test="endDate != null">and i.send_time &lt;= #{endDate}</if>
+        order by i.send_time asc, i.seq asc, i.id asc
+    </select>
+
 </mapper>
diff --git a/smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml b/smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml
index f19893f..6a8e512 100644
--- a/smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml
@@ -107,19 +107,33 @@
         from pat_maternity_archive_detail d
         where d.orgid = #{orgid}
           and (d.del_flag is null or d.del_flag = '0')
+          and d.followup_status = '1'
           and d.planned_follow_time is not null
           and d.followup_period is not null
           and d.followup_period &lt;&gt; ''
           and d.archiveid is not null
+          and not exists (
+              select 1 from mch_followup_plan p
+              where p.archive_type = '1'
+                and p.archive_detail_id = d.id
+                and p.plan_status in ('0', '3')
+          )
         union all
         select '2' as archiveType, d.archiveid as archiveId, d.id as archiveDetailId
         from pat_child_archive_detail d
         where d.orgid = #{orgid}
           and (d.del_flag is null or d.del_flag = '0')
+          and d.followup_status = '1'
           and d.planned_follow_time is not null
           and d.followup_period is not null
           and d.followup_period &lt;&gt; ''
           and d.archiveid is not null
+          and not exists (
+              select 1 from mch_followup_plan p
+              where p.archive_type = '2'
+                and p.archive_detail_id = d.id
+                and p.plan_status in ('0', '3')
+          )
         limit #{limit}
     </select>
 
diff --git a/smartor/src/main/resources/mapper/smartor/PatChildArchiveDetailMapper.xml b/smartor/src/main/resources/mapper/smartor/PatChildArchiveDetailMapper.xml
index bd865d7..653e430 100644
--- a/smartor/src/main/resources/mapper/smartor/PatChildArchiveDetailMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatChildArchiveDetailMapper.xml
@@ -55,6 +55,9 @@
         <result property="hrcNeurologicalEvaluation" column="hrc_neurological_evaluation"/>
         <result property="hrcInterventionRecords" column="hrc_intervention_records"/>
         <result property="closeStatus" column="close_status"/>
+        <result property="followupStatus" column="followup_status"/>
+        <result property="followupConfirmTime" column="followup_confirm_time"/>
+        <result property="followupConfirmBy" column="followup_confirm_by"/>
         <result property="gestationalWeek" column="gestational_week"/>
         <result property="birthWeight" column="birth_weight"/>
         <result property="registerUser" column="register_user"/>
@@ -119,6 +122,9 @@
                hrc_neurological_evaluation,
                hrc_intervention_records,
                close_status,
+               followup_status,
+               followup_confirm_time,
+               followup_confirm_by,
                gestational_week,
                birth_weight,
                register_user,
@@ -170,6 +176,7 @@
             <if test="highRiskChildType != null and highRiskChildType != ''">and high_risk_child_type = #{highRiskChildType}</if>
             <if test="highRiskChildName != null and highRiskChildName != ''">and high_risk_child_name like concat('%', #{highRiskChildName}, '%')</if>
             <if test="closeStatus != null and closeStatus != ''">and close_status = #{closeStatus}</if>
+            <if test="followupStatus != null and followupStatus != ''">and followup_status = #{followupStatus}</if>
             <if test="gestationalWeek != null">and gestational_week = #{gestationalWeek}</if>
             <if test="birthWeight != null">and birth_weight = #{birthWeight}</if>
             <if test="registerUser != null and registerUser != ''">and register_user = #{registerUser}</if>
@@ -242,6 +249,9 @@
             <if test="hrcNeurologicalEvaluation != null">hrc_neurological_evaluation,</if>
             <if test="hrcInterventionRecords != null">hrc_intervention_records,</if>
             <if test="closeStatus != null">close_status,</if>
+            <if test="followupStatus != null">followup_status,</if>
+            <if test="followupConfirmTime != null">followup_confirm_time,</if>
+            <if test="followupConfirmBy != null">followup_confirm_by,</if>
             <if test="gestationalWeek != null">gestational_week,</if>
             <if test="birthWeight != null">birth_weight,</if>
             <if test="registerUser != null">register_user,</if>
@@ -304,6 +314,9 @@
             <if test="hrcNeurologicalEvaluation != null">#{hrcNeurologicalEvaluation},</if>
             <if test="hrcInterventionRecords != null">#{hrcInterventionRecords},</if>
             <if test="closeStatus != null">#{closeStatus},</if>
+            <if test="followupStatus != null">#{followupStatus},</if>
+            <if test="followupConfirmTime != null">#{followupConfirmTime},</if>
+            <if test="followupConfirmBy != null">#{followupConfirmBy},</if>
             <if test="gestationalWeek != null">#{gestationalWeek},</if>
             <if test="birthWeight != null">#{birthWeight},</if>
             <if test="registerUser != null">#{registerUser},</if>
@@ -370,6 +383,9 @@
             <if test="hrcNeurologicalEvaluation != null">hrc_neurological_evaluation = #{hrcNeurologicalEvaluation},</if>
             <if test="hrcInterventionRecords != null">hrc_intervention_records = #{hrcInterventionRecords},</if>
             <if test="closeStatus != null">close_status = #{closeStatus},</if>
+            <if test="followupStatus != null">followup_status = #{followupStatus},</if>
+            <if test="followupConfirmTime != null">followup_confirm_time = #{followupConfirmTime},</if>
+            <if test="followupConfirmBy != null">followup_confirm_by = #{followupConfirmBy},</if>
             <if test="gestationalWeek != null">gestational_week = #{gestationalWeek},</if>
             <if test="birthWeight != null">birth_weight = #{birthWeight},</if>
             <if test="registerUser != null">register_user = #{registerUser},</if>
diff --git a/smartor/src/main/resources/mapper/smartor/PatMaternityArchiveDetailMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMaternityArchiveDetailMapper.xml
index 7c2ba79..6e056cd 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMaternityArchiveDetailMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMaternityArchiveDetailMapper.xml
@@ -38,6 +38,9 @@
         <result property="specificSituation" column="specific_situation"/>
         <result property="handleSuggestion" column="handle_suggestion"/>
         <result property="closeStatus" column="close_status"/>
+        <result property="followupStatus" column="followup_status"/>
+        <result property="followupConfirmTime" column="followup_confirm_time"/>
+        <result property="followupConfirmBy" column="followup_confirm_by"/>
         <result property="isRecordEstablished" column="is_record_established"/>
         <result property="dueDate" column="due_date"/>
         <result property="registerUser" column="register_user"/>
@@ -99,6 +102,9 @@
                specific_situation,
                handle_suggestion,
                close_status,
+               followup_status,
+               followup_confirm_time,
+               followup_confirm_by,
                is_record_established,
                due_date,
                register_user,
@@ -158,6 +164,7 @@
             <if test="icd10code != null and icd10code != ''">and icd10code = #{icd10code}</if>
             <if test="diagname != null and diagname != ''">and diagname like concat('%', #{diagname}, '%')</if>
             <if test="closeStatus != null and closeStatus != ''">and close_status = #{closeStatus}</if>
+            <if test="followupStatus != null and followupStatus != ''">and followup_status = #{followupStatus}</if>
             <if test="isRecordEstablished != null and isRecordEstablished != ''">and is_record_established = #{isRecordEstablished}</if>
             <if test="registerUser != null and registerUser != ''">and register_user = #{registerUser}</if>
             <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if>
@@ -212,6 +219,9 @@
             <if test="specificSituation != null">specific_situation,</if>
             <if test="handleSuggestion != null">handle_suggestion,</if>
             <if test="closeStatus != null">close_status,</if>
+            <if test="followupStatus != null">followup_status,</if>
+            <if test="followupConfirmTime != null">followup_confirm_time,</if>
+            <if test="followupConfirmBy != null">followup_confirm_by,</if>
             <if test="isRecordEstablished != null">is_record_established,</if>
             <if test="dueDate != null">due_date,</if>
             <if test="registerUser != null">register_user,</if>
@@ -271,6 +281,9 @@
             <if test="specificSituation != null">#{specificSituation},</if>
             <if test="handleSuggestion != null">#{handleSuggestion},</if>
             <if test="closeStatus != null">#{closeStatus},</if>
+            <if test="followupStatus != null">#{followupStatus},</if>
+            <if test="followupConfirmTime != null">#{followupConfirmTime},</if>
+            <if test="followupConfirmBy != null">#{followupConfirmBy},</if>
             <if test="isRecordEstablished != null">#{isRecordEstablished},</if>
             <if test="dueDate != null">#{dueDate},</if>
             <if test="registerUser != null">#{registerUser},</if>
@@ -334,6 +347,9 @@
             <if test="specificSituation != null">specific_situation = #{specificSituation},</if>
             <if test="handleSuggestion != null">handle_suggestion = #{handleSuggestion},</if>
             <if test="closeStatus != null">close_status = #{closeStatus},</if>
+            <if test="followupStatus != null">followup_status = #{followupStatus},</if>
+            <if test="followupConfirmTime != null">followup_confirm_time = #{followupConfirmTime},</if>
+            <if test="followupConfirmBy != null">followup_confirm_by = #{followupConfirmBy},</if>
             <if test="isRecordEstablished != null">is_record_established = #{isRecordEstablished},</if>
             <if test="dueDate != null">due_date = #{dueDate},</if>
             <if test="registerUser != null">register_user = #{registerUser},</if>
diff --git a/smartor/src/test/java/com/smartor/service/mch/MchFollowupPlanServiceCheck.java b/smartor/src/test/java/com/smartor/service/mch/MchFollowupPlanServiceCheck.java
index 028eef8..001ec7f 100644
--- a/smartor/src/test/java/com/smartor/service/mch/MchFollowupPlanServiceCheck.java
+++ b/smartor/src/test/java/com/smartor/service/mch/MchFollowupPlanServiceCheck.java
@@ -5,6 +5,8 @@
 import com.smartor.common.SpecificArchiveConstants;
 import com.smartor.domain.MchFollowupPlan;
 import com.smartor.domain.MchFollowupPlanItem;
+import com.smartor.domain.MchFollowupTaskQuery;
+import com.smartor.domain.MchFollowupTaskVO;
 import com.smartor.domain.PatChildArchiveDetail;
 import com.smartor.domain.PatMaternityArchiveDetail;
 import com.smartor.mapper.MchFollowupPlanItemMapper;
@@ -111,6 +113,7 @@
         detail.setPhone("13800000000");
         detail.setIdcardno("330102199001010000");
         detail.setPlannedFollowTime(plannedTime);
+        detail.setFollowupStatus(MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE);
         detail.setFollowupPeriod("{\"items\":["
                 + "{\"dayOffset\":0,\"sendTime\":\"09:00\",\"sendType\":\"sms\",\"content\":\"鐭俊1\"},"
                 + "{\"dayOffset\":3,\"sendType\":\"wechat\",\"templateId\":16,\"content\":\"寰俊2\"},"
@@ -132,6 +135,7 @@
         detail.setParentPhone("13700000000");
         detail.setIdcardno("330102199202020000");
         detail.setPlannedFollowTime(plannedTime);
+        detail.setFollowupStatus(MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE);
         detail.setFollowupPeriod("{\"items\":[{\"dayOffset\":1,\"sendType\":\"sms\",\"content\":\"鍎夸繚鐭俊\"}]}");
         return detail;
     }
@@ -170,6 +174,7 @@
             return defaultValue(method.getReturnType());
         });
 
+        MchFollowupPlanItem[] updatedFollowupItem = new MchFollowupPlanItem[1];
         MchFollowupPlanItemMapper itemMapper = proxy(MchFollowupPlanItemMapper.class, (p, method, a) -> {
             String name = method.getName();
             if ("insertMchFollowupPlanItem".equals(name)) {
@@ -184,12 +189,46 @@
             if ("countPendingByPlanId".equals(name)) {
                 return 1;
             }
+            if ("selectMchFollowupPlanItemById".equals(name)) {
+                MchFollowupPlanItem item = new MchFollowupPlanItem();
+                item.setId((Long) a[0]);
+                return item;
+            }
+            if ("updateFollowupResult".equals(name)) {
+                updatedFollowupItem[0] = (MchFollowupPlanItem) a[0];
+                return 1;
+            }
+            if ("selectByPlanId".equals(name)) {
+                Long queryPlanId = (Long) a[0];
+                List<MchFollowupPlanItem> list = new ArrayList<>();
+                for (MchFollowupPlanItem item : insertedItems) {
+                    if (queryPlanId.equals(item.getPlanId())) {
+                        list.add(item);
+                    }
+                }
+                return list;
+            }
+            if ("selectTaskList".equals(name)) {
+                MchFollowupTaskVO vo = new MchFollowupTaskVO();
+                vo.setItemId(1L);
+                vo.setPlanId(1L);
+                vo.setTaskname("鏃╁瓡鍏崇埍闅忚");
+                vo.setPatid(100L);
+                vo.setPatname("寮犱笁");
+                vo.setSendname("寮犱笁");
+                List<MchFollowupTaskVO> list = new ArrayList<>();
+                list.add(vo);
+                return list;
+            }
             return defaultValue(method.getReturnType());
         });
 
         Map<Long, PatMaternityArchiveDetail> maternityMap = new HashMap<>();
         maternityMap.put(20L, maternityDetail(20L, 10L, date("2026-11-20 14:30:00")));
         maternityMap.put(21L, maternityDetail(21L, 11L, null));
+        PatMaternityArchiveDetail pendingDetail = maternityDetail(22L, 13L, date("2026-11-25 10:00:00"));
+        pendingDetail.setFollowupStatus(MchFollowupConstants.FOLLOWUP_STATUS_PENDING);
+        maternityMap.put(22L, pendingDetail);
         PatMaternityArchiveDetailMapper maternityMapper = proxy(PatMaternityArchiveDetailMapper.class, (p, method, a) -> {
             String name = method.getName();
             if ("selectPatMaternityArchiveDetailById".equals(name)) {
@@ -254,6 +293,13 @@
         check("璁″垝鏁颁笉鍙�", 1, activePlans.size());
         check("鑺傜偣鏁颁笉鍙�", 3, insertedItems.size());
 
+        System.out.println("-- 2.1) 寰呯‘璁ゆ。妗堜笉鐢熸垚 --");
+        int pendingGenerated = service.rebuildForArchive(
+                MchFollowupConstants.ARCHIVE_TYPE_MATERNITY, 13L, 22L);
+        check("寰呯‘璁や笉鐢熸垚", 0, pendingGenerated);
+        check("寰呯‘璁よ鍒掓暟涓嶅彉", 1, activePlans.size());
+        check("寰呯‘璁よ妭鐐规暟涓嶅彉", 3, insertedItems.size());
+
         System.out.println("-- 3) 鎷熼殢璁挎椂闂翠负绌� --");
         int waiting = service.rebuildForArchive(MchFollowupConstants.ARCHIVE_TYPE_MATERNITY, 11L, 21L);
         check("绛夊緟璁″垝涓嶇敓鎴愯妭鐐�", 0, waiting);
@@ -275,6 +321,32 @@
         int otherGenerated = service.rebuildForArchive(MchFollowupConstants.ARCHIVE_TYPE_MATERNITY, 20L, 40L);
         check("鍏朵粬鏈烘瀯涓嶇敓鎴�", 0, otherGenerated);
 
+        System.out.println("-- 6) 鍥炲~浜哄伐闅忚缁撴灉 --");
+        MchFollowupPlanItem feedback = new MchFollowupPlanItem();
+        feedback.setId(1L);
+        feedback.setFollowupDate(date("2026-11-24 10:00:00"));
+        feedback.setFollowupUserId("U001");
+        feedback.setFollowupUserName("鐜嬫姢澹�");
+        feedback.setFollowupSituation("鐢佃瘽闅忚锛屾儏鍐电ǔ瀹�");
+        feedback.setFollowupStatus(MchFollowupConstants.ITEM_FOLLOWUP_STATUS_DONE);
+        int feedbackUpdated = service.updateItemFollowupResult(feedback);
+        check("鍥炲~鏇存柊琛屾暟", 1, feedbackUpdated);
+        check("鍥炲~鐘舵��", MchFollowupConstants.ITEM_FOLLOWUP_STATUS_DONE,
+                updatedFollowupItem[0].getFollowupStatus());
+        check("鍥炲~浜哄憳", "鐜嬫姢澹�", updatedFollowupItem[0].getFollowupUserName());
+        check("鍥炲~鏃堕棿闈炵┖", true, updatedFollowupItem[0].getUpdateTime() != null);
+        check("鑺傜偣鍒楄〃鏁�", 3, service.listItems(1L).size());
+
+        System.out.println("-- 7) 濡囧辜浠诲姟鍒楄〃瀛楁 --");
+        MchFollowupTaskQuery taskQuery = new MchFollowupTaskQuery();
+        taskQuery.setOrgid(SpecificArchiveConstants.LISHUI_MCH_ORG_ID);
+        List<MchFollowupTaskVO> taskList = service.listTasks(taskQuery);
+        check("浠诲姟鍒楄〃鏁�", 1, taskList.size());
+        check("taskid涓虹┖", null, taskList.get(0).getTaskid());
+        check("taskname", "鏃╁瓡鍏崇埍闅忚", taskList.get(0).getTaskname());
+        check("sendname", "寮犱笁", taskList.get(0).getSendname());
+        check("patid", 100L, taskList.get(0).getPatid());
+
         System.out.println("========== 缁撴灉锛歅ASS=" + passed + "锛孎AIL=" + failed + " ==========");
         if (failed > 0) {
             System.exit(1);

--
Gitblit v1.9.3