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

---
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

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..f784099 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
@@ -32,12 +32,14 @@
 import com.ruoyi.system.service.ISysDeptService;
 import com.ruoyi.system.service.ISysUserService;
 import com.ruoyi.message.sms.provider.sltd.ws.MessageSend;
+import com.smartor.common.MchFollowupConstants;
 import com.smartor.common.QwenLLMUtil;
 import com.smartor.common.SpecificArchiveConstants;
 import com.smartor.domain.*;
 import com.ruoyi.task.domain.VO.ServiceSubtaskDetailTraceVO;
 import com.smartor.mapper.*;
 import com.smartor.service.*;
+import com.smartor.service.mch.IMchFollowupSubtaskService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.ObjectUtils;
@@ -147,6 +149,15 @@
 
     @Autowired
     private ICollectHISService ichService;
+
+    @Autowired
+    private IPatSpecificArchiveGenerateService patSpecificArchiveGenerateService;
+
+    @Autowired
+    private IMchFollowupSubtaskService mchFollowupSubtaskService;
+
+    @Autowired
+    private com.ruoyi.task.event.FollowupCompletedEventPublisher followupCompletedEventPublisher;
 
     @Autowired
     private ISysConfigService configService;
@@ -1220,6 +1231,7 @@
                 if (finishState) {
                     serviceSubtask.setSendstate(6L);
                     serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
+                    followupCompletedEventPublisher.publish(serviceSubtask.getId());
                     continue;
                 }
 
@@ -1322,6 +1334,15 @@
     private void doSfHandlle(ServiceSubtask serviceSubtask) {
         if (serviceSubtask == null) {
             log.error("銆恠fHandlle銆戝瓙浠诲姟涓虹┖锛岃烦杩囧鐞�");
+            return;
+        }
+        // 濡囧辜闅忚锛歴ervice_type=21锛岃蛋濡囧辜涓撶敤鍙戦�侀�昏緫锛屼笉渚濊禆 service_task.preachform_desc
+        if (MchFollowupConstants.SERVICE_TYPE_MCH.equals(serviceSubtask.getServiceType())) {
+            try {
+                mchFollowupSubtaskService.sendSubtask(serviceSubtask);
+            } catch (Exception e) {
+                log.error("銆愬骞奸殢璁裤�憇fHandlle 鍙戦�佸紓甯革紝subid={}", serviceSubtask.getId(), e);
+            }
             return;
         }
         //杩欓噷闇�瑕佹牴鎹韩浠借瘉鍘婚噸(缁欏井淇″皬绋嬪簭鐨勫浐瀹氫换鍔$敤鐨�)
@@ -1832,6 +1853,7 @@
                 //璇存槑锛屽湪鏌愮鏂瑰紡鍙戦�佸け璐ュ悗锛屽張鎴愬姛浜嗭紙渚嬪鐭俊鎴栧叕浼楀彿锛屽湪瑙勫畾鏃堕棿澶栨偅鑰呭仛瀹屼簡锛岃繖涓椂鍊欙紝鐘舵�佹敼鎴愪簡9锛�
                 serviceSubtask.setSendstate(6L);
                 serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
+                followupCompletedEventPublisher.publish(serviceSubtask.getId());
                 return "-1";
             }
             // 褰搒ort绛変簬鍒楄〃size鏃讹紝骞朵笖鎵�鏈塻endstate閮戒笉绛変簬9锛屽垯杩斿洖-1
@@ -2093,6 +2115,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 +2373,33 @@
         }
     }
 
+    /**
+     * 浣忛櫌闅忚瀹屾垚鐢熸垚涓撶妗f琛ュ伩浠诲姟銆�
+     *
+     * <p>鎵弿杩� 7 澶╁凡瀹屾垚浣嗘湭鐢熸垚鏃ュ織鐨勪綇闄㈤殢璁匡紝鎸夐厤缃ˉ鐢熸垚濡囩/鍎跨妗f銆�</p>
+     */
+    public void generateInhospFollowupArchive() {
+        try {
+            int generated = patSpecificArchiveGenerateService.compensateInhospFollowups();
+            log.info("銆恎enerateInhospFollowupArchive銆戜綇闄㈤殢璁夸笓绉戞。妗堣ˉ鍋垮畬鎴愶紝鐢熸垚鏁伴噺={}", generated);
+        } catch (Exception e) {
+            log.error("銆恎enerateInhospFollowupArchive銆戜綇闄㈤殢璁夸笓绉戞。妗堣ˉ鍋垮け璐�", e);
+        }
+    }
+
+    /**
+     * 濡囧辜闅忚锛氭壂鎻忓凡纭妗f锛屾寜 plannedFollowTime + followupPeriod 鐢熸垚 service_subtask銆�
+     *
+     * <p>瀹為檯鍙戦�佺敱 longTaskSend / compensateTask 璋冪敤 sfHandlle 鐨�
+     * service_type=21 鍒嗘敮瀹屾垚銆�</p>
+     */
+    public void generateMchFollowupSubtask() {
+        try {
+            int generated = mchFollowupSubtaskService.rebuildAll(200);
+            log.info("銆恎enerateMchFollowupSubtask銆戝骞奸殢璁夸换鍔$敓鎴愬畬鎴愶紝鐢熸垚鑺傜偣鏁�={}", generated);
+        } catch (Exception e) {
+            log.error("銆恎enerateMchFollowupSubtask銆戝骞奸殢璁夸换鍔$敓鎴愬け璐�", e);
+        }
+    }
+
 }

--
Gitblit v1.9.3