From c885a9c26e624f403e3d73beac8c6346657ad561 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期一, 23 十一月 2026 17:16:43 +0800
Subject: [PATCH] feat: 增加妇幼随访任务列表接口与随访结果字段

---
 smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java |   69 ++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 1 deletions(-)

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;
     }
 }

--
Gitblit v1.9.3