From a2101aa52a00ae103a26a950b54f985f46769239 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期一, 23 十一月 2026 17:50:56 +0800
Subject: [PATCH] 【丽水】妇幼随访发送
---
ruoyi-task/src/main/java/com/ruoyi/task/domain/ServiceSubtask.java | 12 ++
/dev/null | 24 ----
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java | 45 +++-----
smartor/src/main/java/com/smartor/service/mch/MchFollowupMessageSender.java | 68 ++++++-------
sql/pat_mch_archive_followup_status_20261123.sql | 28 -----
.gitignore | 4
smartor/src/main/java/com/smartor/common/MchFollowupConstants.java | 71 ++------------
smartor/src/main/java/com/smartor/domain/MchFollowupNode.java | 10 ++
smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java | 12 +-
smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java | 12 +-
10 files changed, 101 insertions(+), 185 deletions(-)
diff --git a/.gitignore b/.gitignore
index 10438f8..563ccec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,9 +37,9 @@
!/sql/quartz.sql
!/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/service_subtask_add_mch_fields_20261123.sql
+!/sql/drop_mch_followup_plan_tables_20261123.sql
sql/_probe/
*.log
_dbcheck.txt
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/MchFollowupPlanItemController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/MchFollowupPlanItemController.java
deleted file mode 100644
index 38ca75a..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/MchFollowupPlanItemController.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.ruoyi.web.controller.smartor;
-
-import com.ruoyi.common.annotation.AddOrgId;
-import com.ruoyi.common.annotation.Log;
-import com.ruoyi.common.core.controller.BaseController;
-import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.core.page.TableDataInfo;
-import com.ruoyi.common.enums.BusinessType;
-import com.ruoyi.common.utils.PageUtils;
-import com.smartor.domain.MchFollowupPlanItem;
-import com.smartor.domain.MchFollowupTaskQuery;
-import com.smartor.domain.MchFollowupTaskVO;
-import com.smartor.service.mch.IMchFollowupPlanService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.List;
-
-/**
- * 濡囧辜闅忚璁″垝鑺傜偣 Controller銆�
- *
- * <p>鐢ㄤ簬鏌ヨ璁″垝鑺傜偣鍜屽洖濉汉宸ラ殢璁跨粨鏋滐紙闅忚鏃ユ湡銆侀殢璁夸汉鍛樸�侀殢璁挎儏鍐点�侀殢璁跨姸鎬侊級銆�</p>
- */
-@Slf4j
-@Api(description = "濡囧辜闅忚鑺傜偣")
-@RestController
-@RequestMapping("/smartor/mchFollowupItem")
-public class MchFollowupPlanItemController extends BaseController {
-
- @Autowired
- private IMchFollowupPlanService mchFollowupPlanService;
-
- /**
- * 鏌ヨ鏌愪釜璁″垝涓嬬殑闅忚鑺傜偣銆�
- */
- @ApiOperation("鏌ヨ闅忚鑺傜偣鍒楄〃")
- @GetMapping("/list/{planId}")
- public AjaxResult list(@PathVariable Long planId) {
- return success(mchFollowupPlanService.listItems(planId));
- }
-
- /**
- * 鏌ヨ濡囧辜闅忚浠诲姟鍒楄〃銆�
- *
- * <p>杩斿洖闂ㄨ瘖鏃ユ湡銆佽鍒�/瀹為檯闅忚鏃ユ湡銆侀殢璁夸汉銆乻endname銆乸atid 绛夊瓧娈碉紱
- * taskid 涓虹┖锛宼askname 涓烘。妗堢被鍨�+闅忚銆�</p>
- */
- @ApiOperation("鏌ヨ濡囧辜闅忚浠诲姟鍒楄〃")
- @AddOrgId(field = "orgid", paramIndex = 0, campusField = "campusid", skipIfPresent = false)
- @PostMapping("/taskList")
- public TableDataInfo taskList(@RequestBody MchFollowupTaskQuery query) {
- PageUtils.startPageByPost(query.getPageNum(), query.getPageSize());
- List<MchFollowupTaskVO> list = mchFollowupPlanService.listTasks(query);
- return getDataTable(list);
- }
-
- /**
- * 鍥炲~浜哄伐闅忚缁撴灉銆�
- */
- @ApiOperation("鍥炲~闅忚缁撴灉")
- @Log(title = "濡囧辜闅忚鑺傜偣", businessType = BusinessType.UPDATE)
- @PostMapping("/updateFollowupResult")
- public AjaxResult updateFollowupResult(@RequestBody MchFollowupPlanItem item) {
- return toAjax(mchFollowupPlanService.updateItemFollowupResult(item));
- }
-}
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 109361b..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,14 +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.IMchFollowupPlanService;
-import com.smartor.service.mch.IMchFollowupSendService;
+import com.smartor.service.mch.IMchFollowupSubtaskService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
@@ -154,10 +154,7 @@
private IPatSpecificArchiveGenerateService patSpecificArchiveGenerateService;
@Autowired
- private IMchFollowupPlanService mchFollowupPlanService;
-
- @Autowired
- private IMchFollowupSendService mchFollowupSendService;
+ private IMchFollowupSubtaskService mchFollowupSubtaskService;
@Autowired
private com.ruoyi.task.event.FollowupCompletedEventPublisher followupCompletedEventPublisher;
@@ -1339,6 +1336,15 @@
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;
+ }
//杩欓噷闇�瑕佹牴鎹韩浠借瘉鍘婚噸(缁欏井淇″皬绋嬪簭鐨勫浐瀹氫换鍔$敤鐨�)
List<ServiceSubtask> serviceSubtaskListFilter = new ArrayList<>();
ServiceTask ivrTask1 = serviceTaskMapper.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
@@ -2382,30 +2388,17 @@
}
/**
- * 濡囧辜闅忚锛氫负宸叉湁濡囧辜妗f琛ュ缓璁″垝銆�
+ * 濡囧辜闅忚锛氭壂鎻忓凡纭妗f锛屾寜 plannedFollowTime + followupPeriod 鐢熸垚 service_subtask銆�
*
- * <p>妗f鏂板/淇敼鏃朵細鑷姩閲嶅缓璁″垝锛涙湰浠诲姟鐢ㄤ簬鍘嗗彶鏁版嵁琛ュ缓鍜屽紓甯歌ˉ鍋裤��</p>
+ * <p>瀹為檯鍙戦�佺敱 longTaskSend / compensateTask 璋冪敤 sfHandlle 鐨�
+ * service_type=21 鍒嗘敮瀹屾垚銆�</p>
*/
- public void generateMchFollowupPlan() {
+ public void generateMchFollowupSubtask() {
try {
- int generated = mchFollowupPlanService.rebuildAll(200);
- log.info("銆恎enerateMchFollowupPlan銆戝骞奸殢璁胯鍒掕ˉ寤哄畬鎴愶紝鐢熸垚鑺傜偣鏁�={}", generated);
+ int generated = mchFollowupSubtaskService.rebuildAll(200);
+ log.info("銆恎enerateMchFollowupSubtask銆戝骞奸殢璁夸换鍔$敓鎴愬畬鎴愶紝鐢熸垚鑺傜偣鏁�={}", generated);
} catch (Exception e) {
- log.error("銆恎enerateMchFollowupPlan銆戝骞奸殢璁胯鍒掕ˉ寤哄け璐�", e);
- }
- }
-
- /**
- * 濡囧辜闅忚锛氭壂鎻忓埌鏈熻妭鐐瑰苟鍙戦�併��
- *
- * <p>鍙ˉ鍙� 1 澶╁唴鍒版湡鐨勮妭鐐癸紱瓒呰繃 1 澶╂爣璁拌繃鏈熴�傜煭淇¤蛋浜慚AS锛屽井淇¤蛋 sendChatLs銆�</p>
- */
- public void sendMchFollowup() {
- try {
- int sent = mchFollowupSendService.sendDue(200);
- log.info("銆恠endMchFollowup銆戝骞奸殢璁垮彂閫佸畬鎴愶紝鎴愬姛鏁伴噺={}", sent);
- } catch (Exception e) {
- log.error("銆恠endMchFollowup銆戝骞奸殢璁垮彂閫佸け璐�", e);
+ log.error("銆恎enerateMchFollowupSubtask銆戝骞奸殢璁夸换鍔$敓鎴愬け璐�", e);
}
}
diff --git a/ruoyi-task/src/main/java/com/ruoyi/task/domain/ServiceSubtask.java b/ruoyi-task/src/main/java/com/ruoyi/task/domain/ServiceSubtask.java
index 22b84e2..59d9b19 100644
--- a/ruoyi-task/src/main/java/com/ruoyi/task/domain/ServiceSubtask.java
+++ b/ruoyi-task/src/main/java/com/ruoyi/task/domain/ServiceSubtask.java
@@ -164,6 +164,18 @@
@ApiModelProperty(value = "鏈嶅姟绫诲瀷闆嗗悎锛屾寜閫楀彿鍒嗗壊")
private String serviceTypes;
+ @ApiModelProperty(value = "濡囧辜妗f璇︽儏ID")
+ private Long mchArchiveDetailId;
+
+ @ApiModelProperty(value = "濡囧辜闅忚鑺傜偣搴忓彿")
+ private Integer mchNodeSeq;
+
+ @ApiModelProperty(value = "濡囧辜闅忚璁″垝鍝堝笇")
+ private String mchPlanHash;
+
+ @ApiModelProperty(value = "濡囧辜闅忚鑺傜偣JSON")
+ private String mchNodeJson;
+
/**
* 妯℃澘ID
*/
diff --git a/smartor/src/main/java/com/smartor/common/MchFollowupConstants.java b/smartor/src/main/java/com/smartor/common/MchFollowupConstants.java
index 8b3935c..48222e6 100644
--- a/smartor/src/main/java/com/smartor/common/MchFollowupConstants.java
+++ b/smartor/src/main/java/com/smartor/common/MchFollowupConstants.java
@@ -1,10 +1,10 @@
package com.smartor.common;
/**
- * 濡囧辜闅忚璁″垝鐩稿叧甯搁噺銆�
+ * 濡囧辜闅忚鐩稿叧甯搁噺銆�
*
- * <p>濡囧辜闅忚鍙�傜敤浜庝附姘村競濡囧辜淇濆仴闄紝涓斾娇鐢ㄧ嫭绔嬬殑璁″垝琛ㄥ拰鍙戦�佷换鍔★紝
- * 涓嶈繘鍏ユ櫘閫氶殢璁跨殑 {@code service_subtask_preachform} / {@code compensateTask} 琛ュ伩閾捐矾銆�</p>
+ * <p>濡囧辜闅忚鍙�傜敤浜庝附姘村競濡囧辜淇濆仴闄€�傞殢璁胯妭鐐硅惤 service_subtask锛�
+ * service_type=21锛岀敱 sfHandlle 鐨勫骞煎垎鏀彂閫侊紝涓嶈繘鍏ユ櫘閫氶殢璁胯ˉ鍋块摼璺��</p>
*/
public final class MchFollowupConstants {
@@ -18,64 +18,19 @@
* 妗f闅忚鐘舵�侊細寰呯‘璁ゃ��
*
* <p>闂ㄨ瘖鎺ヨ瘖瀹屾垚/浣忛櫌闅忚瀹屾垚鑷姩寤烘。鏃跺啓鍏ワ紝琛ㄧず妗f灏氭湭缁忚繃浜哄伐纭锛�
- * 涓嶇敓鎴愰殢璁胯鍒掞紝涔熶笉浼氬彂閫佹秷鎭��</p>
+ * 涓嶇敓鎴愰殢璁夸换鍔°��</p>
*/
public static final String FOLLOWUP_STATUS_PENDING = "0";
/**
* 妗f闅忚鐘舵�侊細闅忚涓��
*
- * <p>浜哄伐淇濆瓨/纭妗f鍚庡啓鍏ワ紝鍏佽鎸� plannedFollowTime + followupPeriod 鐢熸垚璁″垝銆�</p>
+ * <p>浜哄伐淇濆瓨/纭妗f鍚庡啓鍏ワ紝鍏佽鐢熸垚 service_subtask銆�</p>
*/
public static final String FOLLOWUP_STATUS_ACTIVE = "1";
- /** 璁″垝鐘舵�侊細鏈夋晥 */
- public static final String PLAN_STATUS_ACTIVE = "0";
-
- /** 璁″垝鐘舵�侊細宸插彇娑� */
- public static final String PLAN_STATUS_CANCELED = "1";
-
- /** 璁″垝鐘舵�侊細宸插畬鎴� */
- public static final String PLAN_STATUS_COMPLETED = "2";
-
- /** 璁″垝鐘舵�侊細寰呰ˉ鍏呭熀鍑嗘棩/閰嶇疆寮傚父 */
- public static final String PLAN_STATUS_WAITING = "3";
-
- /** 鑺傜偣鐘舵�侊細寰呭彂閫� */
- public static final String ITEM_STATUS_PENDING = "0";
-
- /** 鑺傜偣鐘舵�侊細鍙戦�佷腑 */
- public static final String ITEM_STATUS_SENDING = "1";
-
- /** 鑺傜偣鐘舵�侊細鎴愬姛 */
- public static final String ITEM_STATUS_SUCCESS = "2";
-
- /** 鑺傜偣鐘舵�侊細澶辫触锛堥噸璇曡�楀敖锛� */
- public static final String ITEM_STATUS_FAILED = "3";
-
- /** 鑺傜偣鐘舵�侊細杩囨湡锛堣秴杩囪ˉ鍙戠獥鍙o紝鏈彂閫侊級 */
- public static final String ITEM_STATUS_EXPIRED = "4";
-
- /** 鑺傜偣鐘舵�侊細鍙栨秷 */
- public static final String ITEM_STATUS_CANCELED = "5";
-
- /** 鑺傜偣鐘舵�侊細璺宠繃锛堟墜鏈哄彿涓虹┖绛夛級 */
- public static final String ITEM_STATUS_SKIPPED = "6";
-
- /** 鑺傜偣闅忚鐘舵�侊細鏈殢璁� */
- public static final String 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";
+ /** service_subtask.service_type锛氬骞奸殢璁� */
+ public static final String SERVICE_TYPE_MCH = "21";
/** 鍙戦�佹柟寮忥細鐭俊 */
public static final String SEND_TYPE_SMS = "sms";
@@ -83,18 +38,12 @@
/** 鍙戦�佹柟寮忥細寰俊鍏紬鍙� */
public static final String SEND_TYPE_WECHAT = "wechat";
- /** 琛ュ彂绐楀彛锛氬彧琛ュ彂 1 澶╁唴鍒版湡鐨勮妭鐐广�� */
- public static final long CATCHUP_MILLIS = 24L * 60L * 60L * 1000L;
-
- /** 榛樿鏈�澶ч噸璇曟鏁般�� */
- public static final int DEFAULT_MAX_RETRY = 3;
-
- /** 榛樿閲嶈瘯闂撮殧锛堝垎閽燂級銆� */
- public static final int DEFAULT_RETRY_DELAY_MINUTES = 10;
-
/** 鍗曟鎵弿榛樿涓婇檺銆� */
public static final int DEFAULT_BATCH_SIZE = 200;
+ /** 琛ュ彂绐楀彛锛氬彧琛ュ彂 1 澶╁唴鍒版湡鐨勮妭鐐广�� */
+ public static final long CATCHUP_MILLIS = 24L * 60L * 60L * 1000L;
+
/** 鍚敤寮�鍏筹紙sys_config锛屾寜鏈烘瀯璇诲彇锛涚己鐪佽涓哄惎鐢級銆� */
public static final String CONFIG_ENABLED = "mch.followup.enabled";
diff --git a/smartor/src/main/java/com/smartor/domain/MchFollowupNode.java b/smartor/src/main/java/com/smartor/domain/MchFollowupNode.java
index 5db2b3c..0091007 100644
--- a/smartor/src/main/java/com/smartor/domain/MchFollowupNode.java
+++ b/smartor/src/main/java/com/smartor/domain/MchFollowupNode.java
@@ -3,6 +3,7 @@
import lombok.Data;
import java.io.Serializable;
+import java.util.Date;
/**
* followupPeriod JSON 瑙f瀽鍚庣殑鍙戦�佽妭鐐瑰畾涔夛紙灏氭湭璁$畻缁濆鍙戦�佹椂闂达級銆�
@@ -29,4 +30,13 @@
private Long templateId;
private String url;
+
+ /** 妗f澶х被锛�1濡囦繚 2鍎夸繚锛堢敓鎴� subtask 鏃跺洖濉紝渚夸簬鍗犱綅绗︽覆鏌擄級 */
+ private String archiveType;
+
+ /** 妗f瀛愮被鍨嬶細鏃╁瓡鍏崇埍/鍥寸粷缁忔湡MHI/钀ュ吇鎬х柧鐥�/瀛︿範鍥伴毦/楂樺嵄鍎夸笓妗� */
+ private String archiveSubType;
+
+ /** 鍛ㄦ湡鍩哄噯鏃� */
+ private Date plannedFollowTime;
}
diff --git a/smartor/src/main/java/com/smartor/domain/MchFollowupPlan.java b/smartor/src/main/java/com/smartor/domain/MchFollowupPlan.java
deleted file mode 100644
index d4a2e30..0000000
--- a/smartor/src/main/java/com/smartor/domain/MchFollowupPlan.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.smartor.domain;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
-
-/**
- * 濡囧辜闅忚璁″垝涓昏〃 mch_followup_plan銆�
- *
- * <p>涓�涓。妗堣鎯呭搴斾竴鏉℃湁鏁堣鍒掞紱璁″垝涓嬫寕澶氫釜鍙戦�佽妭鐐广��
- * plannedFollowTime 鏄暣涓懆鏈熺殑鍩哄噯鏃ワ紝鑺傜偣鍙戦�佹椂闂� = 鍩哄噯鏃� + dayOffset銆�</p>
- */
-@Data
-@ApiModel(value = "濡囧辜闅忚璁″垝")
-public class MchFollowupPlan implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private Long id;
-
- @ApiModelProperty(value = "鏈烘瀯ID")
- private String orgid;
-
- @ApiModelProperty(value = "闄㈠尯ID")
- private String campusid;
-
- @ApiModelProperty(value = "妗f绫诲瀷锛�1濡囦繚 2鍎夸繚")
- private String archiveType;
-
- @ApiModelProperty(value = "妗f涓昏〃ID")
- private Long archiveId;
-
- @ApiModelProperty(value = "妗f璇︽儏ID")
- private Long archiveDetailId;
-
- @ApiModelProperty(value = "鏉ユ簮绫诲瀷锛�1闂ㄨ瘖 2浣忛櫌闅忚 3鎵嬪伐")
- private String sourceType;
-
- @ApiModelProperty(value = "鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙�")
- private String sourceBizNo;
-
- @ApiModelProperty(value = "鎮h�匢D")
- private Long patid;
-
- @ApiModelProperty(value = "鎮h�呭鍚�")
- private String patname;
-
- @ApiModelProperty(value = "鑱旂郴鐢佃瘽")
- private String phone;
-
- @ApiModelProperty(value = "璇佷欢鍙风爜")
- private String idcardno;
-
- @ApiModelProperty(value = "鍛ㄦ湡鍩哄噯鏃�")
- private Date plannedFollowTime;
-
- @ApiModelProperty(value = "闅忚鍛ㄦ湡 JSON 蹇収")
- private String followupPeriod;
-
- @ApiModelProperty(value = "璁″垝鐘舵�侊細0鏈夋晥 1鍙栨秷 2瀹屾垚 3寰呰ˉ鍏�/閰嶇疆寮傚父")
- private String planStatus;
-
- @ApiModelProperty(value = "澶囨敞")
- private String remark;
-
- private Date createTime;
-
- private Date updateTime;
-
- @ApiModelProperty(value = "鍙戦�佽妭鐐癸紙闈炶〃瀛楁锛�")
- private List<MchFollowupPlanItem> items;
-}
diff --git a/smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java b/smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java
deleted file mode 100644
index 27502c5..0000000
--- a/smartor/src/main/java/com/smartor/domain/MchFollowupPlanItem.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package com.smartor.domain;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * 濡囧辜闅忚璁″垝鍙戦�佽妭鐐� mch_followup_plan_item銆�
- */
-@Data
-@ApiModel(value = "濡囧辜闅忚璁″垝鍙戦�佽妭鐐�")
-public class MchFollowupPlanItem implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private Long id;
-
- @ApiModelProperty(value = "璁″垝ID")
- private Long planId;
-
- @ApiModelProperty(value = "鑺傜偣椤哄簭")
- private Integer seq;
-
- @ApiModelProperty(value = "鍙戦�佹柟寮忥細sms/wechat")
- private String sendType;
-
- @ApiModelProperty(value = "鍙戦�佹椂闂�")
- private Date sendTime;
-
- @ApiModelProperty(value = "寰俊鏍囬")
- private String titleName;
-
- @ApiModelProperty(value = "鍙戦�佸唴瀹�")
- private String content;
-
- @ApiModelProperty(value = "寰俊妯℃澘ID")
- private Long templateId;
-
- @ApiModelProperty(value = "寰俊璺宠浆鍦板潃")
- private String url;
-
- @ApiModelProperty(value = "鍙戦�佺姸鎬侊細0寰呭彂閫� 1鍙戦�佷腑 2鎴愬姛 3澶辫触 4杩囨湡 5鍙栨秷 6璺宠繃")
- private String sendStatus;
-
- @ApiModelProperty(value = "宸查噸璇曟鏁�")
- private Integer retryCount;
-
- @ApiModelProperty(value = "涓嬫閲嶈瘯鏃堕棿")
- private Date nextRetryTime;
-
- @ApiModelProperty(value = "瀹為檯鍙戦�佹椂闂�")
- private Date sendTimeActual;
-
- @ApiModelProperty(value = "闅忚鏃ユ湡")
- @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;
-
- @ApiModelProperty(value = "绗笁鏂规秷鎭疘D")
- private String providerMsgId;
-
- private Date createTime;
-
- private Date updateTime;
-}
diff --git a/smartor/src/main/java/com/smartor/domain/MchFollowupSendLog.java b/smartor/src/main/java/com/smartor/domain/MchFollowupSendLog.java
deleted file mode 100644
index 96f7635..0000000
--- a/smartor/src/main/java/com/smartor/domain/MchFollowupSendLog.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.smartor.domain;
-
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * 濡囧辜闅忚鍙戦�佹棩蹇� mch_followup_send_log銆�
- */
-@Data
-public class MchFollowupSendLog implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private Long id;
-
- private Long planId;
-
- private Long itemId;
-
- private String sendType;
-
- private String requestBody;
-
- private String responseBody;
-
- private String sendStatus;
-
- private String resultMsg;
-
- private Date createTime;
-}
diff --git a/smartor/src/main/java/com/smartor/domain/MchFollowupTaskQuery.java b/smartor/src/main/java/com/smartor/domain/MchFollowupTaskQuery.java
deleted file mode 100644
index 6eecaa9..0000000
--- a/smartor/src/main/java/com/smartor/domain/MchFollowupTaskQuery.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.smartor.domain;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * 濡囧辜闅忚浠诲姟鍒楄〃鏌ヨ鏉′欢銆�
- */
-@Data
-@ApiModel(value = "濡囧辜闅忚浠诲姟鏌ヨ")
-public class MchFollowupTaskQuery implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @ApiModelProperty(value = "鏈烘瀯ID锛岀敱鐧诲綍鐢ㄦ埛鑷姩娉ㄥ叆")
- private String orgid;
-
- @ApiModelProperty(value = "闄㈠尯ID锛岀敱鐧诲綍鐢ㄦ埛鑷姩娉ㄥ叆")
- private String campusid;
-
- @ApiModelProperty(value = "璁″垝ID")
- private Long planId;
-
- @ApiModelProperty(value = "闅忚鑺傜偣ID")
- private Long itemId;
-
- @ApiModelProperty(value = "妗f绫诲瀷锛�1濡囦繚 2鍎夸繚")
- private String archiveType;
-
- @ApiModelProperty(value = "鏉ユ簮绫诲瀷锛�1闂ㄨ瘖 2浣忛櫌闅忚 3鎵嬪伐")
- private String sourceType;
-
- @ApiModelProperty(value = "鍙戦�佺姸鎬侊細0寰呭彂閫� 1鍙戦�佷腑 2鎴愬姛 3澶辫触 4杩囨湡 5鍙栨秷 6璺宠繃")
- private String sendStatus;
-
- @ApiModelProperty(value = "闅忚鐘舵�侊細0鏈殢璁� 1宸查殢璁� 2澶辫 3鎷掕 4鍙风爜閿欒")
- private String followupStatus;
-
- @ApiModelProperty(value = "鎮h�匢D")
- private Long patid;
-
- @ApiModelProperty(value = "鍏抽敭瀛楋細濮撳悕/鐢佃瘽/璇佷欢鍙�/闂ㄨ瘖鍙�/浣忛櫌鍙�")
- private String keyword;
-
- @ApiModelProperty(value = "璁″垝闅忚寮�濮嬫棩鏈�")
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private Date beginDate;
-
- @ApiModelProperty(value = "璁″垝闅忚缁撴潫鏃ユ湡")
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private Date endDate;
-
- @ApiModelProperty(value = "椤电爜")
- private Integer pageNum;
-
- @ApiModelProperty(value = "姣忛〉鏉℃暟")
- private Integer pageSize;
-}
diff --git a/smartor/src/main/java/com/smartor/domain/MchFollowupTaskVO.java b/smartor/src/main/java/com/smartor/domain/MchFollowupTaskVO.java
deleted file mode 100644
index 6478e93..0000000
--- a/smartor/src/main/java/com/smartor/domain/MchFollowupTaskVO.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package com.smartor.domain;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * 濡囧辜闅忚浠诲姟鍒楄〃 VO銆�
- *
- * <p>鐢� mch_followup_plan_item + mch_followup_plan + 妗f璇︽儏 + 闂ㄨ瘖璁板綍缁勮锛�
- * 渚涘骞奸殢璁夸换鍔″垪琛ㄤ娇鐢ㄣ�傚骞间换鍔℃病鏈夐�氱敤 service_task.taskid锛宼askid 鍥哄畾涓虹┖锛�
- * taskname 鐢辨。妗堢被鍨� + 鈥滈殢璁库�濈敓鎴愩��</p>
- */
-@Data
-@ApiModel(value = "濡囧辜闅忚浠诲姟")
-public class MchFollowupTaskVO implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @ApiModelProperty(value = "闅忚鑺傜偣ID锛岃涓婚敭")
- private Long itemId;
-
- @ApiModelProperty(value = "闅忚璁″垝ID")
- private Long planId;
-
- @ApiModelProperty(value = "閫氱敤浠诲姟ID锛涘骞间换鍔″浐瀹氫负绌�")
- private Long taskid;
-
- @ApiModelProperty(value = "浠诲姟绫诲瀷锛歁CH")
- private String taskType;
-
- @ApiModelProperty(value = "浠诲姟鍚嶇О锛氭。妗堢被鍨�+闅忚")
- private String taskname;
-
- @ApiModelProperty(value = "妗f绫诲瀷锛�1濡囦繚 2鍎夸繚")
- private String archiveType;
-
- @ApiModelProperty(value = "妗f绫诲瀷鍚嶇О锛氭棭瀛曞叧鐖�/鍥寸粷缁忔湡MHI/钀ュ吇鎬х柧鐥�/瀛︿範鍥伴毦/楂樺嵄鍎夸笓妗�")
- private String archiveTypeName;
-
- @ApiModelProperty(value = "妗f涓昏〃ID")
- private Long archiveId;
-
- @ApiModelProperty(value = "妗f璇︽儏ID")
- private Long archiveDetailId;
-
- @ApiModelProperty(value = "鏉ユ簮绫诲瀷锛�1闂ㄨ瘖 2浣忛櫌闅忚 3鎵嬪伐")
- private String sourceType;
-
- @ApiModelProperty(value = "鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙�")
- private String sourceBizNo;
-
- @ApiModelProperty(value = "鎮h�匢D锛堟偅鑰呮。妗圛D锛�")
- private Long patid;
-
- @ApiModelProperty(value = "鎮h�呭鍚�")
- private String patname;
-
- @ApiModelProperty(value = "鍙戦�佷汉濮撳悕锛涘骞间换鍔″彇鎮h�呭鍚�")
- private String sendname;
-
- @ApiModelProperty(value = "鑱旂郴鐢佃瘽")
- private String phone;
-
- @ApiModelProperty(value = "璇佷欢鍙风爜")
- private String idcardno;
-
- @ApiModelProperty(value = "鑺傜偣椤哄簭")
- private Integer seq;
-
- @ApiModelProperty(value = "闂ㄨ瘖鏃ユ湡")
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private Date outpatientDate;
-
- @ApiModelProperty(value = "鍛ㄦ湡鍩哄噯鏃�")
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private Date plannedFollowTime;
-
- @ApiModelProperty(value = "璁″垝闅忚鏃ユ湡锛堣妭鐐瑰彂閫佹椂闂达級")
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private Date plannedFollowDate;
-
- @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 = "鍙戦�佺姸鎬侊細0寰呭彂閫� 1鍙戦�佷腑 2鎴愬姛 3澶辫触 4杩囨湡 5鍙栨秷 6璺宠繃")
- private String sendStatus;
-
- @ApiModelProperty(value = "瀹為檯鍙戦�佹椂闂�")
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private Date sendTimeActual;
-
- @ApiModelProperty(value = "鏈烘瀯ID")
- private String orgid;
-
- @ApiModelProperty(value = "闄㈠尯ID")
- private String campusid;
-}
diff --git a/smartor/src/main/java/com/smartor/mapper/MchFollowupPlanItemMapper.java b/smartor/src/main/java/com/smartor/mapper/MchFollowupPlanItemMapper.java
deleted file mode 100644
index 87f1bb5..0000000
--- a/smartor/src/main/java/com/smartor/mapper/MchFollowupPlanItemMapper.java
+++ /dev/null
@@ -1,50 +0,0 @@
-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;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * 濡囧辜闅忚璁″垝鑺傜偣 Mapper銆�
- */
-@Mapper
-public interface MchFollowupPlanItemMapper {
-
- int insertMchFollowupPlanItem(MchFollowupPlanItem item);
-
- int updateMchFollowupPlanItem(MchFollowupPlanItem item);
-
- int updateSendResult(MchFollowupPlanItem item);
-
- /**
- * 鍥炲~浜哄伐闅忚缁撴灉锛氶殢璁挎棩鏈熴�侀殢璁夸汉鍛樸�侀殢璁挎儏鍐点�侀殢璁跨姸鎬併��
- */
- int updateFollowupResult(MchFollowupPlanItem item);
-
- MchFollowupPlanItem selectMchFollowupPlanItemById(@Param("id") Long id);
-
- List<MchFollowupPlanItem> selectByPlanId(@Param("planId") Long planId);
-
- /**
- * 鏌ヨ鍒版湡鑺傜偣锛氳鍒掓湁鏁堛�佹満鏋勪负涓芥按濡囧辜銆佸緟鍙戦�併�佸埌杈惧彂閫佹椂闂淬�佷笖涓嶅湪閲嶈瘯绛夊緟涓��
- */
- List<MchFollowupPlanItem> selectDueItems(@Param("orgid") String orgid,
- @Param("now") Date now,
- @Param("limit") int limit);
-
- int claimItem(@Param("id") Long id, @Param("now") Date now);
-
- int cancelPendingByPlanId(@Param("planId") Long planId, @Param("now") Date now);
-
- int countPendingByPlanId(@Param("planId") Long planId);
-
- /**
- * 濡囧辜闅忚浠诲姟鍒楄〃锛歫oin 璁″垝銆佹。妗堣鎯呫�侀棬璇婅褰曘��
- */
- List<MchFollowupTaskVO> selectTaskList(MchFollowupTaskQuery query);
-}
diff --git a/smartor/src/main/java/com/smartor/mapper/MchFollowupPlanMapper.java b/smartor/src/main/java/com/smartor/mapper/MchFollowupPlanMapper.java
deleted file mode 100644
index 871f3ed..0000000
--- a/smartor/src/main/java/com/smartor/mapper/MchFollowupPlanMapper.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.smartor.mapper;
-
-import com.smartor.domain.MchFollowupArchiveCandidate;
-import com.smartor.domain.MchFollowupPlan;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * 濡囧辜闅忚璁″垝涓昏〃 Mapper銆�
- */
-@Mapper
-public interface MchFollowupPlanMapper {
-
- int insertMchFollowupPlan(MchFollowupPlan plan);
-
- int updateMchFollowupPlan(MchFollowupPlan plan);
-
- MchFollowupPlan selectMchFollowupPlanById(@Param("id") Long id);
-
- List<MchFollowupPlan> selectActiveByArchive(@Param("archiveType") String archiveType,
- @Param("archiveId") Long archiveId,
- @Param("archiveDetailId") Long archiveDetailId);
-
- int cancelById(@Param("id") Long id, @Param("updateTime") java.util.Date updateTime);
-
- int completeById(@Param("id") Long id, @Param("updateTime") java.util.Date updateTime);
-
- List<MchFollowupArchiveCandidate> selectCandidates(@Param("orgid") String orgid,
- @Param("limit") int limit);
-}
diff --git a/smartor/src/main/java/com/smartor/mapper/MchFollowupSendLogMapper.java b/smartor/src/main/java/com/smartor/mapper/MchFollowupSendLogMapper.java
deleted file mode 100644
index 8b1c924..0000000
--- a/smartor/src/main/java/com/smartor/mapper/MchFollowupSendLogMapper.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.smartor.mapper;
-
-import com.smartor.domain.MchFollowupSendLog;
-import org.apache.ibatis.annotations.Mapper;
-
-/**
- * 濡囧辜闅忚鍙戦�佹棩蹇� Mapper銆�
- */
-@Mapper
-public interface MchFollowupSendLogMapper {
-
- int insertMchFollowupSendLog(MchFollowupSendLog log);
-}
diff --git a/smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java
index 765cbdc..c8424dc 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatChildArchiveServiceImpl.java
@@ -10,7 +10,7 @@
import com.smartor.mapper.PatChildArchiveMapper;
import com.smartor.service.IPatChildArchiveDetailService;
import com.smartor.service.IPatChildArchiveService;
-import com.smartor.service.mch.IMchFollowupPlanService;
+import com.smartor.service.mch.IMchFollowupSubtaskService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -36,7 +36,7 @@
private IPatChildArchiveDetailService patChildArchiveDetailService;
@Autowired
- private IMchFollowupPlanService mchFollowupPlanService;
+ private IMchFollowupSubtaskService mchFollowupSubtaskService;
@Override
public PatChildArchive selectPatChildArchiveById(Long id)
@@ -208,16 +208,16 @@
patChildArchiveDetailService.insertPatChildArchiveDetail(patChildArchiveDetail);
}
- // 濡囧辜闅忚璁″垝锛氬彧鏈変汉宸ョ‘璁わ紙followup_status=1锛夌殑妗f鎵嶇敓鎴�/閲嶅缓锛�
+ // 濡囧辜闅忚浠诲姟锛氬彧鏈変汉宸ョ‘璁わ紙followup_status=1锛夌殑妗f鎵嶇敓鎴�/閲嶅缓 service_subtask锛�
// 鑷姩寤烘。涓哄緟纭锛宺ebuildForArchive 鍐呴儴浼氱洿鎺ヨ烦杩囥��
try {
- if (mchFollowupPlanService != null) {
- mchFollowupPlanService.rebuildForArchive(
+ if (mchFollowupSubtaskService != null) {
+ mchFollowupSubtaskService.rebuildForArchive(
MchFollowupConstants.ARCHIVE_TYPE_CHILD,
patChildArchive.getId(), patChildArchiveDetail.getId());
}
} catch (Exception e) {
- log.error("濡囧辜闅忚璁″垝閲嶅缓澶辫触锛宎rchiveId={}锛宒etailId={}",
+ log.error("濡囧辜闅忚浠诲姟鐢熸垚澶辫触锛宎rchiveId={}锛宒etailId={}",
patChildArchive.getId(), patChildArchiveDetail.getId(), e);
}
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 b3c106d..66c139f 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatMaternityArchiveServiceImpl.java
@@ -13,7 +13,7 @@
import com.smartor.mapper.PatMaternityArchiveMapper;
import com.smartor.service.IPatMaternityArchiveDetailService;
import com.smartor.service.IPatMaternityArchiveService;
-import com.smartor.service.mch.IMchFollowupPlanService;
+import com.smartor.service.mch.IMchFollowupSubtaskService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -41,7 +41,7 @@
private PatMaternityArchiveDetailMapper patMaternityArchiveDetailMapper;
@Autowired
- private IMchFollowupPlanService mchFollowupPlanService;
+ private IMchFollowupSubtaskService mchFollowupSubtaskService;
@Override
public PatMaternityArchive selectPatMaternityArchiveById(Long id)
@@ -232,16 +232,16 @@
patMaternityArchiveDetailService.insertPatMaternityArchiveDetail(patMaternityArchiveDetail);
}
- // 濡囧辜闅忚璁″垝锛氬彧鏈変汉宸ョ‘璁わ紙followup_status=1锛夌殑妗f鎵嶇敓鎴�/閲嶅缓锛�
+ // 濡囧辜闅忚浠诲姟锛氬彧鏈変汉宸ョ‘璁わ紙followup_status=1锛夌殑妗f鎵嶇敓鎴�/閲嶅缓 service_subtask锛�
// 鑷姩寤烘。涓哄緟纭锛宺ebuildForArchive 鍐呴儴浼氱洿鎺ヨ烦杩囥��
try {
- if (mchFollowupPlanService != null) {
- mchFollowupPlanService.rebuildForArchive(
+ if (mchFollowupSubtaskService != null) {
+ mchFollowupSubtaskService.rebuildForArchive(
MchFollowupConstants.ARCHIVE_TYPE_MATERNITY,
patMaternityArchive.getId(), patMaternityArchiveDetail.getId());
}
} catch (Exception e) {
- log.error("濡囧辜闅忚璁″垝閲嶅缓澶辫触锛宎rchiveId={}锛宒etailId={}",
+ log.error("濡囧辜闅忚浠诲姟鐢熸垚澶辫触锛宎rchiveId={}锛宒etailId={}",
patMaternityArchive.getId(), patMaternityArchiveDetail.getId(), e);
}
diff --git a/smartor/src/main/java/com/smartor/service/mch/IMchFollowupPlanService.java b/smartor/src/main/java/com/smartor/service/mch/IMchFollowupPlanService.java
deleted file mode 100644
index cb14bb0..0000000
--- a/smartor/src/main/java/com/smartor/service/mch/IMchFollowupPlanService.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.smartor.service.mch;
-
-import com.smartor.domain.MchFollowupPlanItem;
-import com.smartor.domain.MchFollowupTaskQuery;
-import com.smartor.domain.MchFollowupTaskVO;
-
-import java.util.List;
-
-/**
- * 濡囧辜闅忚璁″垝鏈嶅姟銆�
- */
-public interface IMchFollowupPlanService {
-
- /**
- * 鏍规嵁妗f璇︽儏閲嶅缓濡囧辜闅忚璁″垝銆�
- *
- * @param archiveType 1濡囦繚 2鍎夸繚
- * @param archiveId 妗f涓昏〃ID
- * @param archiveDetailId 妗f璇︽儏ID
- * @return 鏂扮敓鎴愮殑鍙戦�佽妭鐐规暟閲�
- */
- int rebuildForArchive(String archiveType, Long archiveId, Long archiveDetailId);
-
- /**
- * 琛ュ伩鎵弿锛氫负宸叉湁濡囧辜妗f琛ュ缓璁″垝銆�
- *
- * @param limit 鍗曟鎵弿涓婇檺
- * @return 鏂扮敓鎴愮殑鍙戦�佽妭鐐规暟閲�
- */
- int rebuildAll(int limit);
-
- /**
- * 鍥炲~闅忚鑺傜偣鐨勫疄闄呴殢璁挎棩鏈熴�侀殢璁夸汉鍛樸�侀殢璁挎儏鍐靛拰闅忚鐘舵�併��
- *
- * <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/IMchFollowupSendService.java b/smartor/src/main/java/com/smartor/service/mch/IMchFollowupSendService.java
deleted file mode 100644
index 8632f79..0000000
--- a/smartor/src/main/java/com/smartor/service/mch/IMchFollowupSendService.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.smartor.service.mch;
-
-/**
- * 濡囧辜闅忚鍙戦�佹湇鍔°��
- */
-public interface IMchFollowupSendService {
-
- /**
- * 鎵弿骞跺彂閫佸埌鏈熻妭鐐广��
- *
- * @param limit 鍗曟澶勭悊涓婇檺
- * @return 鏈瀹為檯鍙戦�佹垚鍔熸暟閲�
- */
- int sendDue(int limit);
-}
diff --git a/smartor/src/main/java/com/smartor/service/mch/MchFollowupMessageSender.java b/smartor/src/main/java/com/smartor/service/mch/MchFollowupMessageSender.java
index 4f20367..4332b20 100644
--- a/smartor/src/main/java/com/smartor/service/mch/MchFollowupMessageSender.java
+++ b/smartor/src/main/java/com/smartor/service/mch/MchFollowupMessageSender.java
@@ -6,8 +6,6 @@
import com.ruoyi.common.utils.sms.SmsUtils;
import com.ruoyi.system.service.ISysConfigService;
import com.smartor.common.MchFollowupConstants;
-import com.smartor.domain.MchFollowupPlan;
-import com.smartor.domain.MchFollowupPlanItem;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -19,7 +17,7 @@
*
* <p>鐭俊澶嶇敤 {@link SmsUtils#sendYunMasSms}锛屽井淇″鐢�
* {@link SmsUtils#sendChatLs}锛堝嵆 {@code /sms/sendChatFuyou} 鐨勫唴閮ㄥ疄鐜帮級銆�
- * 涓嶇粡杩囨櫘閫氶殢璁跨殑鍙戦�佹柟宸ュ巶涓庤ˉ鍋块摼璺��</p>
+ * 鍙戦�佷笂涓嬫枃鐢� service_subtask + mch_node_json 缁勮銆�</p>
*/
@Slf4j
@Component
@@ -28,9 +26,9 @@
@Autowired
private ISysConfigService configService;
- public MchFollowupSendOutcome sendSms(MchFollowupPlan plan, MchFollowupPlanItem item) {
- String phone = plan == null ? null : plan.getPhone();
- String content = item == null ? null : renderContent(item.getContent(), plan, item);
+ public MchFollowupSendOutcome sendSms(MchFollowupSendContext context) {
+ String phone = context == null ? null : context.getPhone();
+ String content = context == null ? null : renderContent(context.getContent(), context);
if (StringUtils.isBlank(phone)) {
return MchFollowupSendOutcome.skip("鎵嬫満鍙蜂负绌�");
}
@@ -39,7 +37,7 @@
}
try {
String configJson = configService.selectConfigByKey(
- MchFollowupConstants.CONFIG_YUNMAS, plan.getOrgid());
+ MchFollowupConstants.CONFIG_YUNMAS, context.getOrgid());
SmsUtils.YunMasConfig config = SmsUtils.YunMasConfig.of(configJson);
SmsUtils.SmsResult result = SmsUtils.sendYunMasSms(config, phone, content);
String requestBody = requestSummary("sms", phone, null);
@@ -50,34 +48,34 @@
String message = result == null ? "浜慚AS杩斿洖涓虹┖" : result.getMessage();
return MchFollowupSendOutcome.fail(message, requestBody, responseBody);
} catch (Exception e) {
- log.error("銆愬骞奸殢璁裤�戠煭淇″彂閫佸紓甯革紝planId={}锛宨temId={}", plan.getId(), item.getId(), e);
+ log.error("銆愬骞奸殢璁裤�戠煭淇″彂閫佸紓甯革紝subtaskId={}", context == null ? null : context.getSeq(), e);
return MchFollowupSendOutcome.fail("鐭俊鍙戦�佸紓甯革細" + e.getMessage(),
requestSummary("sms", phone, null), null);
}
}
- public MchFollowupSendOutcome sendWechat(MchFollowupPlan plan, MchFollowupPlanItem item) {
- String phone = plan == null ? null : plan.getPhone();
- if (StringUtils.isBlank(phone) && StringUtils.isBlank(plan == null ? null : plan.getIdcardno())) {
+ public MchFollowupSendOutcome sendWechat(MchFollowupSendContext context) {
+ String phone = context == null ? null : context.getPhone();
+ if (context == null || (StringUtils.isBlank(phone) && StringUtils.isBlank(context.getIdcardno()))) {
return MchFollowupSendOutcome.skip("鎵嬫満鍙峰拰璇佷欢鍙烽兘涓虹┖");
}
try {
String configJson = configService.selectConfigByKey(
- MchFollowupConstants.CONFIG_LS_WX, plan.getOrgid());
+ MchFollowupConstants.CONFIG_LS_WX, context.getOrgid());
SmsUtils.LsWxConfig config = SmsUtils.LsWxConfig.of(configJson);
SmsUtils.LsWxMessage message = new SmsUtils.LsWxMessage();
- message.setId(item.getTemplateId());
- message.setPatientId(plan.getPatid() == null ? null : String.valueOf(plan.getPatid()));
- message.setPatientName(plan.getPatname());
- message.setIdCard(plan.getIdcardno());
+ message.setId(context.getTemplateId());
+ message.setPatientId(context.getPatid() == null ? null : String.valueOf(context.getPatid()));
+ message.setPatientName(context.getPatname());
+ message.setIdCard(context.getIdcardno());
message.setMobile(phone);
- message.setMedCardNo(plan.getSourceBizNo());
- message.setTitleName(renderContent(item.getTitleName(), plan, item));
- message.setContent(renderContent(item.getContent(), plan, item));
- message.setUrl(item.getUrl());
+ message.setMedCardNo(context.getSourceBizNo());
+ message.setTitleName(renderContent(context.getTitleName(), context));
+ message.setContent(renderContent(context.getContent(), context));
+ message.setUrl(context.getUrl());
- String requestBody = requestSummary("wechat", phone, item.getTemplateId());
+ String requestBody = requestSummary("wechat", phone, context.getTemplateId());
String resp = SmsUtils.sendChatLs(config, message);
String messageText = parseWechatMessage(resp);
boolean ok = parseWechatOk(resp);
@@ -86,9 +84,9 @@
}
return MchFollowupSendOutcome.fail(messageText, requestBody, resp);
} catch (Exception e) {
- log.error("銆愬骞奸殢璁裤�戝井淇″彂閫佸紓甯革紝planId={}锛宨temId={}", plan.getId(), item.getId(), e);
+ log.error("銆愬骞奸殢璁裤�戝井淇″彂閫佸紓甯革紝subtaskSeq={}", context == null ? null : context.getSeq(), e);
return MchFollowupSendOutcome.fail("寰俊鍙戦�佸紓甯革細" + e.getMessage(),
- requestSummary("wechat", phone, item == null ? null : item.getTemplateId()), null);
+ requestSummary("wechat", phone, context == null ? null : context.getTemplateId()), null);
}
}
@@ -125,22 +123,22 @@
* ${patname}銆�${patid}銆�${phone}銆�${idcardno}銆�${plannedFollowTime}銆�
* ${sourceBizNo}銆�${archiveType}銆�${orgid}銆�${seq}銆�
*/
- String renderContent(String text, MchFollowupPlan plan, MchFollowupPlanItem item) {
- if (StringUtils.isBlank(text) || plan == null) {
+ String renderContent(String text, MchFollowupSendContext context) {
+ if (StringUtils.isBlank(text) || context == null) {
return text;
}
String result = text;
- result = result.replace("${patname}", nvl(plan.getPatname()));
- result = result.replace("${patid}", plan.getPatid() == null ? "" : String.valueOf(plan.getPatid()));
- result = result.replace("${phone}", nvl(plan.getPhone()));
- result = result.replace("${idcardno}", nvl(plan.getIdcardno()));
- result = result.replace("${sourceBizNo}", nvl(plan.getSourceBizNo()));
- result = result.replace("${archiveType}", nvl(plan.getArchiveType()));
- result = result.replace("${orgid}", nvl(plan.getOrgid()));
- result = result.replace("${seq}", item == null || item.getSeq() == null ? "" : String.valueOf(item.getSeq()));
- if (plan.getPlannedFollowTime() != null) {
+ result = result.replace("${patname}", nvl(context.getPatname()));
+ result = result.replace("${patid}", context.getPatid() == null ? "" : String.valueOf(context.getPatid()));
+ result = result.replace("${phone}", nvl(context.getPhone()));
+ result = result.replace("${idcardno}", nvl(context.getIdcardno()));
+ result = result.replace("${sourceBizNo}", nvl(context.getSourceBizNo()));
+ result = result.replace("${archiveType}", nvl(context.getArchiveType()));
+ result = result.replace("${orgid}", nvl(context.getOrgid()));
+ result = result.replace("${seq}", context.getSeq() == null ? "" : String.valueOf(context.getSeq()));
+ if (context.getPlannedFollowTime() != null) {
result = result.replace("${plannedFollowTime}",
- new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(plan.getPlannedFollowTime()));
+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(context.getPlannedFollowTime()));
} else {
result = result.replace("${plannedFollowTime}", "");
}
diff --git a/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanAssembler.java b/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanAssembler.java
deleted file mode 100644
index e83a66b..0000000
--- a/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanAssembler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.smartor.service.mch;
-
-import com.smartor.common.MchFollowupConstants;
-import com.smartor.domain.MchFollowupNode;
-import com.smartor.domain.MchFollowupPlanItem;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * 鎶婅В鏋愬悗鐨勮妭鐐瑰畾涔夌粍瑁呮垚鍙惤搴撶殑鍙戦�佽妭鐐广��
- */
-@Component
-public class MchFollowupPlanAssembler {
-
- @Autowired
- private MchFollowupTimeResolver timeResolver;
-
- public List<MchFollowupPlanItem> assemble(Long planId, Date plannedFollowTime, List<MchFollowupNode> nodes) {
- List<MchFollowupPlanItem> items = new ArrayList<>();
- if (nodes == null || nodes.isEmpty()) {
- return items;
- }
- Date now = new Date();
- for (MchFollowupNode node : nodes) {
- MchFollowupPlanItem item = new MchFollowupPlanItem();
- item.setPlanId(planId);
- item.setSeq(node.getSeq());
- item.setSendType(node.getSendType());
- item.setSendTime(timeResolver.resolve(plannedFollowTime, node));
- item.setTitleName(node.getTitleName());
- item.setContent(node.getContent());
- item.setTemplateId(node.getTemplateId());
- item.setUrl(node.getUrl());
- item.setSendStatus(MchFollowupConstants.ITEM_STATUS_PENDING);
- item.setFollowupStatus(MchFollowupConstants.ITEM_FOLLOWUP_STATUS_PENDING);
- item.setRetryCount(0);
- item.setCreateTime(now);
- item.setUpdateTime(now);
- items.add(item);
- }
- return items;
- }
-}
diff --git a/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java b/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java
deleted file mode 100644
index 991c900..0000000
--- a/smartor/src/main/java/com/smartor/service/mch/MchFollowupPlanServiceImpl.java
+++ /dev/null
@@ -1,388 +0,0 @@
-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;
-import com.smartor.common.MchFollowupConstants;
-import com.smartor.common.SpecificArchiveConstants;
-import com.smartor.domain.MchFollowupArchiveCandidate;
-import com.smartor.domain.MchFollowupNode;
-import com.smartor.domain.MchFollowupPlan;
-import com.smartor.domain.MchFollowupPlanItem;
-import com.smartor.domain.MchFollowupTaskQuery;
-import com.smartor.domain.MchFollowupTaskVO;
-import com.smartor.domain.PatChildArchiveDetail;
-import com.smartor.domain.PatMaternityArchiveDetail;
-import com.smartor.mapper.MchFollowupPlanItemMapper;
-import com.smartor.mapper.MchFollowupPlanMapper;
-import com.smartor.mapper.PatChildArchiveDetailMapper;
-import com.smartor.mapper.PatMaternityArchiveDetailMapper;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-
-/**
- * 濡囧辜闅忚璁″垝鏈嶅姟瀹炵幇銆�
- *
- * <p>鍙鐞嗕附姘村競濡囧辜淇濆仴闄€�傝鍒掔敓鎴愪笉鍙戦�佹秷鎭紝鍙戦�佺敱
- * {@link IMchFollowupSendService} 鐙珛瀹屾垚銆�</p>
- */
-@Slf4j
-@Service
-public class MchFollowupPlanServiceImpl implements IMchFollowupPlanService {
-
- @Autowired
- private MchFollowupPlanMapper planMapper;
-
- @Autowired
- private MchFollowupPlanItemMapper itemMapper;
-
- @Autowired
- private PatMaternityArchiveDetailMapper maternityDetailMapper;
-
- @Autowired
- private PatChildArchiveDetailMapper childDetailMapper;
-
- @Autowired
- private MchFollowupPeriodParser periodParser;
-
- @Autowired
- private MchFollowupPlanAssembler planAssembler;
-
- @Autowired
- private ISysConfigService configService;
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public int rebuildForArchive(String archiveType, Long archiveId, Long archiveDetailId) {
- try {
- return doRebuildForArchive(archiveType, archiveId, archiveDetailId);
- } catch (Exception e) {
- // 璁″垝鐢熸垚澶辫触涓嶈兘褰卞搷妗f涓绘祦绋嬶紝寮傚父鍦ㄤ簨鍔¤竟鐣屽唴娑堝寲
- log.error("銆愬骞奸殢璁裤�戣鍒掗噸寤哄紓甯革紝archiveType={}锛宎rchiveId={}锛宒etailId={}",
- archiveType, archiveId, archiveDetailId, e);
- return 0;
- }
- }
-
- private int doRebuildForArchive(String archiveType, Long archiveId, Long archiveDetailId) {
- if (!isEnabled()) {
- return 0;
- }
- ArchiveSnapshot snapshot = loadSnapshot(archiveType, archiveId, archiveDetailId);
- if (snapshot == null) {
- return 0;
- }
- if (snapshot.archiveId == null || snapshot.archiveDetailId == null) {
- log.warn("銆愬骞奸殢璁裤�戞。妗堜富閿垨璇︽儏涓婚敭涓虹┖锛岃烦杩囪鍒掗噸寤猴紝archiveType={}锛宎rchiveId={}锛宒etailId={}",
- archiveType, archiveId, archiveDetailId);
- return 0;
- }
- if (!SpecificArchiveConstants.LISHUI_MCH_ORG_ID.equals(snapshot.orgid)) {
- return 0;
- }
- // 妗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);
- if (actives == null) {
- actives = Collections.emptyList();
- }
- for (MchFollowupPlan active : actives) {
- // 鍙湁鈥滄湁鏁堚�濊鍒掓墠鍋氬箓绛夊垽鏂紱寰呰ˉ鍏呰鍒掑嵆浣挎棩鏈�/鍛ㄦ湡瀛楃涓茬浉鍚岋紝
- // 涔熷彲鑳芥槸鍥犱负涔嬪墠閰嶇疆闈炴硶鑰屾寕璧凤紝浜哄伐纭鍚庡繀椤婚噸鏂拌В鏋愬苟鐢熸垚鑺傜偣銆�
- 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());
- contactUpdate.setCampusid(snapshot.campusid);
- contactUpdate.setSourceBizNo(snapshot.sourceBizNo);
- contactUpdate.setPatname(snapshot.patname);
- contactUpdate.setPhone(snapshot.phone);
- contactUpdate.setIdcardno(snapshot.idcardno);
- contactUpdate.setUpdateTime(DateUtils.getNowDate());
- planMapper.updateMchFollowupPlan(contactUpdate);
- log.debug("銆愬骞奸殢璁裤�戣鍒掓湭鍙樺寲锛屼粎鍒锋柊鑱旂郴浜轰俊鎭紝archiveType={}锛宎rchiveId={}锛宒etailId={}",
- snapshot.archiveType, snapshot.archiveId, snapshot.archiveDetailId);
- return 0;
- }
- }
-
- Date now = DateUtils.getNowDate();
- for (MchFollowupPlan active : actives) {
- itemMapper.cancelPendingByPlanId(active.getId(), now);
- planMapper.cancelById(active.getId(), now);
- }
-
- MchFollowupPlan plan = new MchFollowupPlan();
- plan.setOrgid(snapshot.orgid);
- plan.setCampusid(snapshot.campusid);
- plan.setArchiveType(snapshot.archiveType);
- plan.setArchiveId(snapshot.archiveId);
- plan.setArchiveDetailId(snapshot.archiveDetailId);
- plan.setSourceType(snapshot.sourceType);
- plan.setSourceBizNo(snapshot.sourceBizNo);
- plan.setPatid(snapshot.patid);
- plan.setPatname(snapshot.patname);
- plan.setPhone(snapshot.phone);
- plan.setIdcardno(snapshot.idcardno);
- plan.setPlannedFollowTime(snapshot.plannedFollowTime);
- plan.setFollowupPeriod(snapshot.followupPeriod);
- plan.setCreateTime(now);
- plan.setUpdateTime(now);
-
- if (snapshot.plannedFollowTime == null) {
- plan.setPlanStatus(MchFollowupConstants.PLAN_STATUS_WAITING);
- plan.setRemark("鎷熼殢璁挎椂闂翠负绌猴紝寰呰ˉ鍏�");
- planMapper.insertMchFollowupPlan(plan);
- log.warn("銆愬骞奸殢璁裤�戞嫙闅忚鏃堕棿涓虹┖锛岀敓鎴愬緟琛ュ厖璁″垝锛宎rchiveType={}锛宒etailId={}",
- snapshot.archiveType, snapshot.archiveDetailId);
- return 0;
- }
-
- List<MchFollowupNode> nodes;
- try {
- nodes = periodParser.parse(snapshot.followupPeriod, snapshot.followupCycleTimes);
- } catch (Exception e) {
- plan.setPlanStatus(MchFollowupConstants.PLAN_STATUS_WAITING);
- plan.setRemark("闅忚鍛ㄦ湡JSON瑙f瀽澶辫触锛�" + truncate(e.getMessage(), 200));
- planMapper.insertMchFollowupPlan(plan);
- log.error("銆愬骞奸殢璁裤�戦殢璁垮懆鏈熻В鏋愬け璐ワ紝archiveType={}锛宒etailId={}锛宲eriod={}",
- snapshot.archiveType, snapshot.archiveDetailId, snapshot.followupPeriod, e);
- return 0;
- }
- if (nodes.isEmpty()) {
- plan.setPlanStatus(MchFollowupConstants.PLAN_STATUS_WAITING);
- plan.setRemark("闅忚鍛ㄦ湡鏈厤缃彂閫佽妭鐐�");
- planMapper.insertMchFollowupPlan(plan);
- return 0;
- }
-
- plan.setPlanStatus(MchFollowupConstants.PLAN_STATUS_ACTIVE);
- planMapper.insertMchFollowupPlan(plan);
- List<MchFollowupPlanItem> items = planAssembler.assemble(plan.getId(), snapshot.plannedFollowTime, nodes);
- for (MchFollowupPlanItem item : items) {
- itemMapper.insertMchFollowupPlanItem(item);
- }
- log.info("銆愬骞奸殢璁裤�戣鍒掗噸寤哄畬鎴愶紝archiveType={}锛宎rchiveId={}锛宒etailId={}锛岃妭鐐规暟={}",
- snapshot.archiveType, snapshot.archiveId, snapshot.archiveDetailId, items.size());
- return items.size();
- }
-
- @Override
- public int rebuildAll(int limit) {
- if (!isEnabled()) {
- return 0;
- }
- int batch = limit <= 0 ? MchFollowupConstants.DEFAULT_BATCH_SIZE : limit;
- List<MchFollowupArchiveCandidate> candidates =
- planMapper.selectCandidates(SpecificArchiveConstants.LISHUI_MCH_ORG_ID, batch);
- if (candidates == null || candidates.isEmpty()) {
- return 0;
- }
- int generated = 0;
- for (MchFollowupArchiveCandidate candidate : candidates) {
- try {
- generated += rebuildForArchive(candidate.getArchiveType(),
- candidate.getArchiveId(), candidate.getArchiveDetailId());
- } catch (Exception e) {
- log.error("銆愬骞奸殢璁裤�戣ˉ寤鸿鍒掑け璐ワ紝archiveType={}锛宎rchiveId={}锛宒etailId={}",
- candidate.getArchiveType(), candidate.getArchiveId(),
- candidate.getArchiveDetailId(), e);
- }
- }
- return generated;
- }
-
- @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);
- }
- if (MchFollowupConstants.ARCHIVE_TYPE_CHILD.equals(archiveType)) {
- return loadChildSnapshot(archiveId, archiveDetailId);
- }
- log.warn("銆愬骞奸殢璁裤�戞湭鐭ユ。妗堢被鍨嬶細{}", archiveType);
- return null;
- }
-
- private ArchiveSnapshot loadMaternitySnapshot(Long archiveId, Long archiveDetailId) {
- PatMaternityArchiveDetail detail = null;
- if (archiveDetailId != null) {
- detail = maternityDetailMapper.selectPatMaternityArchiveDetailById(archiveDetailId);
- }
- if (detail == null && archiveId != null) {
- PatMaternityArchiveDetail query = new PatMaternityArchiveDetail();
- query.setArchiveid(archiveId);
- List<PatMaternityArchiveDetail> list =
- maternityDetailMapper.selectPatMaternityArchiveDetailList(query);
- if (list != null && !list.isEmpty()) {
- detail = list.get(0);
- }
- }
- if (detail == null) {
- return null;
- }
- ArchiveSnapshot snapshot = new ArchiveSnapshot();
- snapshot.archiveType = MchFollowupConstants.ARCHIVE_TYPE_MATERNITY;
- snapshot.archiveId = detail.getArchiveid() == null ? archiveId : detail.getArchiveid();
- snapshot.archiveDetailId = detail.getId();
- snapshot.orgid = detail.getOrgid();
- snapshot.campusid = detail.getCampusid();
- snapshot.sourceType = detail.getSourceType();
- snapshot.sourceBizNo = detail.getSourceBizNo();
- snapshot.patid = detail.getPatid();
- snapshot.patname = detail.getPatname();
- snapshot.phone = detail.getPhone();
- snapshot.idcardno = detail.getIdcardno();
- snapshot.plannedFollowTime = detail.getPlannedFollowTime();
- snapshot.followupPeriod = detail.getFollowupPeriod();
- snapshot.followupCycleTimes = detail.getFollowupCycleTimes();
- snapshot.followupStatus = detail.getFollowupStatus();
- return snapshot;
- }
-
- private ArchiveSnapshot loadChildSnapshot(Long archiveId, Long archiveDetailId) {
- PatChildArchiveDetail detail = null;
- if (archiveDetailId != null) {
- detail = childDetailMapper.selectPatChildArchiveDetailById(archiveDetailId);
- }
- if (detail == null && archiveId != null) {
- PatChildArchiveDetail query = new PatChildArchiveDetail();
- query.setArchiveid(archiveId);
- List<PatChildArchiveDetail> list =
- childDetailMapper.selectPatChildArchiveDetailList(query);
- if (list != null && !list.isEmpty()) {
- detail = list.get(0);
- }
- }
- if (detail == null) {
- return null;
- }
- ArchiveSnapshot snapshot = new ArchiveSnapshot();
- snapshot.archiveType = MchFollowupConstants.ARCHIVE_TYPE_CHILD;
- snapshot.archiveId = detail.getArchiveid() == null ? archiveId : detail.getArchiveid();
- snapshot.archiveDetailId = detail.getId();
- snapshot.orgid = detail.getOrgid();
- snapshot.campusid = detail.getCampusid();
- snapshot.sourceType = detail.getSourceType();
- snapshot.sourceBizNo = detail.getSourceBizNo();
- snapshot.patid = detail.getPatid();
- snapshot.patname = detail.getPatname();
- snapshot.phone = firstNotBlank(detail.getParentPhone(), detail.getPhone());
- snapshot.idcardno = detail.getIdcardno();
- snapshot.plannedFollowTime = detail.getPlannedFollowTime();
- snapshot.followupPeriod = detail.getFollowupPeriod();
- snapshot.followupStatus = detail.getFollowupStatus();
- return snapshot;
- }
-
- /**
- * 鍘嗗彶鏁版嵁娌℃湁鐘舵�佹椂鎸夊凡纭澶勭悊锛屼繚璇佸凡鏈夋。妗堢殑璁″垝涓嶅彈褰卞搷銆�
- */
- private boolean isFollowupActive(String followupStatus) {
- return StringUtils.isEmpty(followupStatus)
- || MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE.equals(followupStatus);
- }
-
- private boolean isEnabled() {
- try {
- String value = configService.selectConfigByKey(MchFollowupConstants.CONFIG_ENABLED);
- return value == null || !"false".equalsIgnoreCase(value.trim());
- } catch (Exception e) {
- log.warn("銆愬骞奸殢璁裤�戣鍙栧惎鐢ㄥ紑鍏冲け璐ワ紝鎸夊惎鐢ㄥ鐞嗭細{}", e.getMessage());
- return true;
- }
- }
-
- private static boolean sameTime(Date left, Date right) {
- if (left == null || right == null) {
- return left == right;
- }
- return Math.abs(left.getTime() - right.getTime()) < 1000L;
- }
-
- private static String firstNotBlank(String first, String second) {
- return StringUtils.isNotBlank(first) ? first : second;
- }
-
- private static String truncate(String text, int maxLength) {
- if (text == null || text.length() <= maxLength) {
- return text;
- }
- return text.substring(0, maxLength);
- }
-
- private static class ArchiveSnapshot {
- private String archiveType;
- private Long archiveId;
- private Long archiveDetailId;
- private String orgid;
- private String campusid;
- private String sourceType;
- private String sourceBizNo;
- private Long patid;
- private String patname;
- private String phone;
- private String idcardno;
- private Date plannedFollowTime;
- private String followupPeriod;
- private String followupCycleTimes;
- private String followupStatus;
- }
-}
diff --git a/smartor/src/main/java/com/smartor/service/mch/MchFollowupSendServiceImpl.java b/smartor/src/main/java/com/smartor/service/mch/MchFollowupSendServiceImpl.java
deleted file mode 100644
index b2b3698..0000000
--- a/smartor/src/main/java/com/smartor/service/mch/MchFollowupSendServiceImpl.java
+++ /dev/null
@@ -1,210 +0,0 @@
-package com.smartor.service.mch;
-
-import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.system.service.ISysConfigService;
-import com.smartor.common.MchFollowupConstants;
-import com.smartor.common.SpecificArchiveConstants;
-import com.smartor.domain.MchFollowupPlan;
-import com.smartor.domain.MchFollowupPlanItem;
-import com.smartor.domain.MchFollowupSendLog;
-import com.smartor.mapper.MchFollowupPlanItemMapper;
-import com.smartor.mapper.MchFollowupPlanMapper;
-import com.smartor.mapper.MchFollowupSendLogMapper;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * 濡囧辜闅忚鍙戦�佹湇鍔″疄鐜般��
- *
- * <p>鍙彂閫佷附姘村骞肩殑璁″垝鑺傜偣锛涗笉杩涘叆鏅�氶殢璁跨殑琛ュ伩鍙戦�侀摼璺��</p>
- */
-@Slf4j
-@Service
-public class MchFollowupSendServiceImpl implements IMchFollowupSendService {
-
- @Autowired
- private MchFollowupPlanMapper planMapper;
-
- @Autowired
- private MchFollowupPlanItemMapper itemMapper;
-
- @Autowired
- private MchFollowupSendLogMapper sendLogMapper;
-
- @Autowired
- private MchFollowupMessageSender messageSender;
-
- @Autowired
- private MchFollowupSendWindow sendWindow;
-
- @Autowired
- private ISysConfigService configService;
-
- @Override
- public int sendDue(int limit) {
- if (!isEnabled()) {
- return 0;
- }
- int batch = limit <= 0 ? MchFollowupConstants.DEFAULT_BATCH_SIZE : limit;
- Date now = new Date();
- List<MchFollowupPlanItem> dueItems = itemMapper.selectDueItems(
- SpecificArchiveConstants.LISHUI_MCH_ORG_ID, now, batch);
- if (dueItems == null || dueItems.isEmpty()) {
- return 0;
- }
-
- int success = 0;
- for (MchFollowupPlanItem item : dueItems) {
- try {
- MchFollowupDueDecision decision = sendWindow.decide(item.getSendTime(), now);
- if (decision == MchFollowupDueDecision.PENDING) {
- continue;
- }
- if (decision == MchFollowupDueDecision.EXPIRED) {
- markExpired(item, now);
- refreshPlanStatus(item.getPlanId());
- continue;
- }
- if (itemMapper.claimItem(item.getId(), now) != 1) {
- continue;
- }
-
- MchFollowupPlan plan = planMapper.selectMchFollowupPlanById(item.getPlanId());
- if (plan == null || !MchFollowupConstants.PLAN_STATUS_ACTIVE.equals(plan.getPlanStatus())) {
- markCanceled(item, now, "璁″垝涓嶅瓨鍦ㄦ垨宸插け鏁�");
- refreshPlanStatus(item.getPlanId());
- continue;
- }
-
- MchFollowupSendOutcome outcome = send(plan, item);
- Date finishTime = new Date();
- if (outcome.isSkipped()) {
- markSkipped(item, finishTime, outcome.getMessage());
- } else if (outcome.isOk()) {
- markSuccess(item, finishTime, outcome);
- success++;
- } else {
- markFailureOrRetry(item, finishTime, outcome);
- }
- writeLog(item, outcome, now);
- refreshPlanStatus(plan.getId());
- } catch (Exception e) {
- log.error("銆愬骞奸殢璁裤�戝彂閫佽妭鐐瑰紓甯革紝itemId={}锛宲lanId={}",
- item.getId(), item.getPlanId(), e);
- try {
- markFailureOrRetry(item, new Date(),
- MchFollowupSendOutcome.fail("鍙戦�佸紓甯革細" + e.getMessage(), null, null));
- refreshPlanStatus(item.getPlanId());
- } catch (Exception ignore) {
- log.error("銆愬骞奸殢璁裤�戝紓甯稿洖鍐欏け璐ワ紝itemId={}", item.getId(), ignore);
- }
- }
- }
- return success;
- }
-
- private MchFollowupSendOutcome send(MchFollowupPlan plan, MchFollowupPlanItem item) {
- if (MchFollowupConstants.SEND_TYPE_SMS.equals(item.getSendType())) {
- return messageSender.sendSms(plan, item);
- }
- if (MchFollowupConstants.SEND_TYPE_WECHAT.equals(item.getSendType())) {
- return messageSender.sendWechat(plan, item);
- }
- return MchFollowupSendOutcome.fail("涓嶆敮鎸佺殑鍙戦�佹柟寮忥細" + item.getSendType(), null, null);
- }
-
- private void markExpired(MchFollowupPlanItem item, Date now) {
- item.setSendStatus(MchFollowupConstants.ITEM_STATUS_EXPIRED);
- item.setNextRetryTime(null);
- item.setSendTimeActual(null);
- item.setProviderMsgId(null);
- item.setResultMsg("瓒呰繃琛ュ彂绐楀彛锛�1澶╋級锛屾爣璁拌繃鏈�");
- item.setUpdateTime(now);
- itemMapper.updateSendResult(item);
- writeLog(item, MchFollowupSendOutcome.fail(item.getResultMsg(), null, null), now);
- }
-
- private void markCanceled(MchFollowupPlanItem item, Date now, String message) {
- item.setSendStatus(MchFollowupConstants.ITEM_STATUS_CANCELED);
- item.setNextRetryTime(null);
- item.setResultMsg(message);
- item.setUpdateTime(now);
- itemMapper.updateSendResult(item);
- }
-
- private void markSkipped(MchFollowupPlanItem item, Date now, String message) {
- item.setSendStatus(MchFollowupConstants.ITEM_STATUS_SKIPPED);
- item.setNextRetryTime(null);
- item.setResultMsg(message);
- item.setUpdateTime(now);
- itemMapper.updateSendResult(item);
- }
-
- private void markSuccess(MchFollowupPlanItem item, Date now, MchFollowupSendOutcome outcome) {
- item.setSendStatus(MchFollowupConstants.ITEM_STATUS_SUCCESS);
- item.setNextRetryTime(null);
- item.setSendTimeActual(now);
- item.setProviderMsgId(outcome.getProviderMsgId());
- item.setResultMsg("鍙戦�佹垚鍔�");
- item.setUpdateTime(now);
- itemMapper.updateSendResult(item);
- }
-
- private void markFailureOrRetry(MchFollowupPlanItem item, Date now, MchFollowupSendOutcome outcome) {
- int retryCount = item.getRetryCount() == null ? 0 : item.getRetryCount();
- retryCount++;
- item.setRetryCount(retryCount);
- item.setSendTimeActual(now);
- item.setProviderMsgId(outcome.getProviderMsgId());
- if (retryCount < MchFollowupConstants.DEFAULT_MAX_RETRY) {
- item.setSendStatus(MchFollowupConstants.ITEM_STATUS_PENDING);
- item.setNextRetryTime(new Date(now.getTime()
- + MchFollowupConstants.DEFAULT_RETRY_DELAY_MINUTES * 60L * 1000L));
- item.setResultMsg((outcome.getMessage() == null ? "鍙戦�佸け璐�" : outcome.getMessage())
- + "锛岀" + retryCount + "娆¢噸璇曞悗杩涘叆绛夊緟");
- } else {
- item.setSendStatus(MchFollowupConstants.ITEM_STATUS_FAILED);
- item.setNextRetryTime(null);
- item.setResultMsg((outcome.getMessage() == null ? "鍙戦�佸け璐�" : outcome.getMessage())
- + "锛岄噸璇曟鏁板凡杈句笂闄�");
- }
- item.setUpdateTime(now);
- itemMapper.updateSendResult(item);
- }
-
- private void writeLog(MchFollowupPlanItem item, MchFollowupSendOutcome outcome, Date now) {
- MchFollowupSendLog sendLog = new MchFollowupSendLog();
- sendLog.setPlanId(item.getPlanId());
- sendLog.setItemId(item.getId());
- sendLog.setSendType(item.getSendType());
- sendLog.setRequestBody(outcome.getRequestBody());
- sendLog.setResponseBody(outcome.getResponseBody());
- sendLog.setSendStatus(item.getSendStatus());
- sendLog.setResultMsg(item.getResultMsg());
- sendLog.setCreateTime(now);
- sendLogMapper.insertMchFollowupSendLog(sendLog);
- }
-
- private void refreshPlanStatus(Long planId) {
- if (planId == null) {
- return;
- }
- if (itemMapper.countPendingByPlanId(planId) == 0) {
- planMapper.completeById(planId, new Date());
- }
- }
-
- private boolean isEnabled() {
- try {
- String value = configService.selectConfigByKey(MchFollowupConstants.CONFIG_ENABLED);
- return value == null || !"false".equalsIgnoreCase(value.trim());
- } catch (Exception e) {
- log.warn("銆愬骞奸殢璁裤�戣鍙栧惎鐢ㄥ紑鍏冲け璐ワ紝鎸夊惎鐢ㄥ鐞嗭細{}", e.getMessage());
- return true;
- }
- }
-}
diff --git a/smartor/src/main/java/com/smartor/service/mch/MchFollowupSendWindow.java b/smartor/src/main/java/com/smartor/service/mch/MchFollowupSendWindow.java
deleted file mode 100644
index 3632f02..0000000
--- a/smartor/src/main/java/com/smartor/service/mch/MchFollowupSendWindow.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.smartor.service.mch;
-
-import com.smartor.common.MchFollowupConstants;
-import org.springframework.stereotype.Component;
-
-import java.util.Date;
-
-/**
- * 濡囧辜闅忚琛ュ彂绐楀彛鍒ゆ柇銆�
- *
- * <p>鍙ˉ鍙� 1 澶╁唴鍒版湡鐨勮妭鐐癸紱瓒呰繃 1 澶╂爣璁拌繃鏈燂紝閬垮厤缁欐偅鑰呭彂杩囨椂娑堟伅銆�</p>
- */
-@Component
-public class MchFollowupSendWindow {
-
- public MchFollowupDueDecision decide(Date sendTime, Date now) {
- if (sendTime == null) {
- return MchFollowupDueDecision.PENDING;
- }
- Date current = now == null ? new Date() : now;
- if (sendTime.after(current)) {
- return MchFollowupDueDecision.PENDING;
- }
- Date expireBefore = new Date(current.getTime() - MchFollowupConstants.CATCHUP_MILLIS);
- if (sendTime.before(expireBefore)) {
- return MchFollowupDueDecision.EXPIRED;
- }
- return MchFollowupDueDecision.SEND;
- }
-}
diff --git a/smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml b/smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml
deleted file mode 100644
index 24082b1..0000000
--- a/smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml
+++ /dev/null
@@ -1,269 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.smartor.mapper.MchFollowupPlanItemMapper">
-
- <resultMap id="MchFollowupPlanItemResult" type="com.smartor.domain.MchFollowupPlanItem">
- <id property="id" column="id"/>
- <result property="planId" column="plan_id"/>
- <result property="seq" column="seq"/>
- <result property="sendType" column="send_type"/>
- <result property="sendTime" column="send_time"/>
- <result property="titleName" column="title_name"/>
- <result property="content" column="content"/>
- <result property="templateId" column="template_id"/>
- <result property="url" column="url"/>
- <result property="sendStatus" column="send_status"/>
- <result property="retryCount" column="retry_count"/>
- <result property="nextRetryTime" column="next_retry_time"/>
- <result property="sendTimeActual" column="send_time_actual"/>
- <result property="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>
-
- <insert id="insertMchFollowupPlanItem" parameterType="com.smartor.domain.MchFollowupPlanItem"
- useGeneratedKeys="true" keyProperty="id">
- insert into mch_followup_plan_item
- (plan_id, seq, send_type, send_time, title_name, content, template_id, url,
- send_status, retry_count, next_retry_time, send_time_actual,
- 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>
-
- <update id="updateMchFollowupPlanItem" parameterType="com.smartor.domain.MchFollowupPlanItem">
- update mch_followup_plan_item
- <set>
- <if test="sendType != null">send_type = #{sendType},</if>
- <if test="sendTime != null">send_time = #{sendTime},</if>
- <if test="titleName != null">title_name = #{titleName},</if>
- <if test="content != null">content = #{content},</if>
- <if test="templateId != null">template_id = #{templateId},</if>
- <if test="url != null">url = #{url},</if>
- <if test="sendStatus != null">send_status = #{sendStatus},</if>
- <if test="retryCount != null">retry_count = #{retryCount},</if>
- <if test="nextRetryTime != null">next_retry_time = #{nextRetryTime},</if>
- <if test="sendTimeActual != null">send_time_actual = #{sendTimeActual},</if>
- <if test="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>
- </set>
- where id = #{id}
- </update>
-
- <update id="updateSendResult" parameterType="com.smartor.domain.MchFollowupPlanItem">
- update mch_followup_plan_item
- set send_status = #{sendStatus,jdbcType=CHAR},
- retry_count = #{retryCount,jdbcType=INTEGER},
- next_retry_time = #{nextRetryTime,jdbcType=TIMESTAMP},
- send_time_actual = #{sendTimeActual,jdbcType=TIMESTAMP},
- result_msg = #{resultMsg,jdbcType=VARCHAR},
- provider_msg_id = #{providerMsgId,jdbcType=VARCHAR},
- update_time = #{updateTime,jdbcType=TIMESTAMP}
- where id = #{id}
- </update>
-
- <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}
- </select>
-
- <select id="selectByPlanId" resultMap="MchFollowupPlanItemResult">
- <include refid="selectItemVo"/>
- where plan_id = #{planId}
- order by seq asc, id asc
- </select>
-
- <select id="selectDueItems" resultMap="MchFollowupPlanItemResult">
- select i.id, i.plan_id, i.seq, i.send_type, i.send_time, i.title_name, i.content,
- i.template_id, i.url, i.send_status, i.retry_count, i.next_retry_time,
- i.send_time_actual, i.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}
- and p.plan_status = '0'
- and i.send_status = '0'
- and i.send_time <= #{now}
- and (i.next_retry_time is null or i.next_retry_time <= #{now})
- order by i.send_time asc, i.seq asc, i.id asc
- limit #{limit}
- </select>
-
- <update id="claimItem">
- update mch_followup_plan_item
- set send_status = '1',
- update_time = #{now}
- where id = #{id}
- and send_status = '0'
- </update>
-
- <update id="cancelPendingByPlanId">
- update mch_followup_plan_item
- set send_status = '5',
- result_msg = '璁″垝閲嶅缓锛屽彇娑堟湭鍙戦�佽妭鐐�',
- update_time = #{now}
- where plan_id = #{planId}
- and send_status = '0'
- </update>
-
- <select id="countPendingByPlanId" resultType="int">
- select count(1)
- from mch_followup_plan_item
- where plan_id = #{planId}
- and send_status in ('0', '1')
- </select>
-
- <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 <> '1'
- and i.send_status <> '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 >= #{beginDate}</if>
- <if test="endDate != null">and i.send_time <= #{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
deleted file mode 100644
index 6a8e512..0000000
--- a/smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml
+++ /dev/null
@@ -1,140 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.smartor.mapper.MchFollowupPlanMapper">
-
- <resultMap id="MchFollowupPlanResult" type="com.smartor.domain.MchFollowupPlan">
- <id property="id" column="id"/>
- <result property="orgid" column="orgid"/>
- <result property="campusid" column="campusid"/>
- <result property="archiveType" column="archive_type"/>
- <result property="archiveId" column="archive_id"/>
- <result property="archiveDetailId" column="archive_detail_id"/>
- <result property="sourceType" column="source_type"/>
- <result property="sourceBizNo" column="source_biz_no"/>
- <result property="patid" column="patid"/>
- <result property="patname" column="patname"/>
- <result property="phone" column="phone"/>
- <result property="idcardno" column="idcardno"/>
- <result property="plannedFollowTime" column="planned_follow_time"/>
- <result property="followupPeriod" column="followup_period"/>
- <result property="planStatus" column="plan_status"/>
- <result property="remark" column="remark"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- </resultMap>
-
- <sql id="selectPlanVo">
- select id, orgid, campusid, archive_type, archive_id, archive_detail_id,
- source_type, source_biz_no, patid, patname, phone, idcardno,
- planned_follow_time, followup_period, plan_status, remark,
- create_time, update_time
- from mch_followup_plan
- </sql>
-
- <insert id="insertMchFollowupPlan" parameterType="com.smartor.domain.MchFollowupPlan"
- useGeneratedKeys="true" keyProperty="id">
- insert into mch_followup_plan
- (orgid, campusid, archive_type, archive_id, archive_detail_id,
- source_type, source_biz_no, patid, patname, phone, idcardno,
- planned_follow_time, followup_period, plan_status, remark,
- create_time, update_time)
- values
- (#{orgid}, #{campusid}, #{archiveType}, #{archiveId}, #{archiveDetailId},
- #{sourceType}, #{sourceBizNo}, #{patid}, #{patname}, #{phone}, #{idcardno},
- #{plannedFollowTime}, #{followupPeriod}, #{planStatus}, #{remark},
- #{createTime}, #{updateTime})
- </insert>
-
- <update id="updateMchFollowupPlan" parameterType="com.smartor.domain.MchFollowupPlan">
- update mch_followup_plan
- <set>
- <if test="orgid != null">orgid = #{orgid},</if>
- <if test="campusid != null">campusid = #{campusid},</if>
- <if test="archiveType != null">archive_type = #{archiveType},</if>
- <if test="archiveId != null">archive_id = #{archiveId},</if>
- <if test="archiveDetailId != null">archive_detail_id = #{archiveDetailId},</if>
- <if test="sourceType != null">source_type = #{sourceType},</if>
- <if test="sourceBizNo != null">source_biz_no = #{sourceBizNo},</if>
- <if test="patid != null">patid = #{patid},</if>
- <if test="patname != null">patname = #{patname},</if>
- <if test="phone != null">phone = #{phone},</if>
- <if test="idcardno != null">idcardno = #{idcardno},</if>
- <if test="plannedFollowTime != null">planned_follow_time = #{plannedFollowTime},</if>
- <if test="followupPeriod != null">followup_period = #{followupPeriod},</if>
- <if test="planStatus != null">plan_status = #{planStatus},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- </set>
- where id = #{id}
- </update>
-
- <select id="selectMchFollowupPlanById" resultMap="MchFollowupPlanResult">
- <include refid="selectPlanVo"/>
- where id = #{id}
- </select>
-
- <select id="selectActiveByArchive" resultMap="MchFollowupPlanResult">
- <include refid="selectPlanVo"/>
- where archive_type = #{archiveType}
- and archive_id = #{archiveId}
- <if test="archiveDetailId != null">
- and archive_detail_id = #{archiveDetailId}
- </if>
- and plan_status in ('0', '3')
- order by id desc
- </select>
-
- <update id="cancelById">
- update mch_followup_plan
- set plan_status = '1',
- update_time = #{updateTime}
- where id = #{id}
- and plan_status in ('0', '3')
- </update>
-
- <update id="completeById">
- update mch_followup_plan
- set plan_status = '2',
- update_time = #{updateTime}
- where id = #{id}
- and plan_status = '0'
- </update>
-
- <select id="selectCandidates" resultType="com.smartor.domain.MchFollowupArchiveCandidate">
- select '1' as archiveType, d.archiveid as archiveId, d.id as archiveDetailId
- from pat_maternity_archive_detail d
- where d.orgid = #{orgid}
- and (d.del_flag is null or d.del_flag = '0')
- and d.followup_status = '1'
- and d.planned_follow_time is not null
- and d.followup_period is not null
- and d.followup_period <> ''
- 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 <> ''
- 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>
-
-</mapper>
diff --git a/smartor/src/main/resources/mapper/smartor/MchFollowupSendLogMapper.xml b/smartor/src/main/resources/mapper/smartor/MchFollowupSendLogMapper.xml
deleted file mode 100644
index f4a9c1a..0000000
--- a/smartor/src/main/resources/mapper/smartor/MchFollowupSendLogMapper.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.smartor.mapper.MchFollowupSendLogMapper">
-
- <insert id="insertMchFollowupSendLog" parameterType="com.smartor.domain.MchFollowupSendLog"
- useGeneratedKeys="true" keyProperty="id">
- insert into mch_followup_send_log
- (plan_id, item_id, send_type, request_body, response_body, send_status, result_msg, create_time)
- values
- (#{planId}, #{itemId}, #{sendType}, #{requestBody}, #{responseBody}, #{sendStatus}, #{resultMsg}, #{createTime})
- </insert>
-
-</mapper>
diff --git a/smartor/src/test/java/com/smartor/service/mch/MchFollowupLogicCheck.java b/smartor/src/test/java/com/smartor/service/mch/MchFollowupLogicCheck.java
deleted file mode 100644
index 25688c7..0000000
--- a/smartor/src/test/java/com/smartor/service/mch/MchFollowupLogicCheck.java
+++ /dev/null
@@ -1,200 +0,0 @@
-package com.smartor.service.mch;
-
-import com.smartor.common.MchFollowupConstants;
-import com.smartor.domain.MchFollowupNode;
-import com.smartor.domain.MchFollowupPlan;
-import com.smartor.domain.MchFollowupPlanItem;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import java.io.File;
-import java.lang.reflect.Field;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
-/**
- * 濡囧辜闅忚閫昏緫鑷锛堢函 main锛屼笉渚濊禆 JUnit / Spring / 鏁版嵁搴擄級銆�
- *
- * 瑕嗙洊锛歠ollowupPeriod JSON 瑙f瀽銆佽鍒掑熀鍑嗘棩鏃堕棿璁$畻銆�1 澶╄ˉ鍙戠獥鍙c��
- * 鑺傜偣缁勮銆丮apper XML 鍙В鏋愭�с��
- */
-public final class MchFollowupLogicCheck {
-
- private static int passed = 0;
- private static int failed = 0;
-
- private static final SimpleDateFormat DATE_TIME = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
- private static void check(String key, Object expected, Object actual) {
- boolean ok = expected == null ? actual == null : expected.equals(actual);
- if (ok) {
- passed++;
- System.out.println(" [OK] " + key + " = " + actual);
- } else {
- failed++;
- System.out.println(" [FAIL] " + key + " 鏈熸湜=" + expected + " 瀹為檯=" + actual);
- }
- }
-
- private static void expectFail(String key, Runnable action) {
- try {
- action.run();
- failed++;
- System.out.println(" [FAIL] " + key + " 鏈熸湜鎶涘紓甯革紝瀹為檯鏈姏");
- } catch (Exception e) {
- passed++;
- System.out.println(" [OK] " + key + " 鎶涘紓甯革細" + e.getMessage());
- }
- }
-
- private static Date date(String text) throws Exception {
- return DATE_TIME.parse(text);
- }
-
- private static MchFollowupPlanAssembler assembler() throws Exception {
- MchFollowupPlanAssembler assembler = new MchFollowupPlanAssembler();
- Field field = MchFollowupPlanAssembler.class.getDeclaredField("timeResolver");
- field.setAccessible(true);
- field.set(assembler, new MchFollowupTimeResolver());
- return assembler;
- }
-
- private static MchFollowupNode node(int seq, int dayOffset, String sendTime, String sendType) {
- MchFollowupNode node = new MchFollowupNode();
- node.setSeq(seq);
- node.setDayOffset(dayOffset);
- node.setSendTime(sendTime);
- node.setSendType(sendType);
- node.setContent("鍐呭" + seq);
- return node;
- }
-
- public static void main(String[] args) throws Exception {
- System.out.println("========== 濡囧辜闅忚閫昏緫鑷 ==========");
- MchFollowupPeriodParser parser = new MchFollowupPeriodParser();
- MchFollowupTimeResolver resolver = new MchFollowupTimeResolver();
- MchFollowupSendWindow window = new MchFollowupSendWindow();
-
- System.out.println("-- 1) items JSON 瑙f瀽 --");
- String itemsJson = "{"
- + "\"version\":1,"
- + "\"items\":["
- + "{\"seq\":1,\"dayOffset\":0,\"sendTime\":\"09:00\",\"sendType\":\"sms\",\"content\":\"鐭俊1\"},"
- + "{\"seq\":2,\"dayOffset\":3,\"sendType\":\"5\",\"templateId\":16,\"titleName\":\"鎻愰啋\",\"content\":\"寰俊2\"},"
- + "{\"seq\":3,\"dayOffset\":7,\"sendType\":\"鐭俊\",\"content\":\"鐭俊3\"}"
- + "]}";
- List<MchFollowupNode> itemNodes = parser.parse(itemsJson, null);
- check("鑺傜偣鏁�", 3, itemNodes.size());
- check("seq1", 1, itemNodes.get(0).getSeq());
- check("dayOffset1", 0, itemNodes.get(0).getDayOffset());
- check("sendType1", "sms", itemNodes.get(0).getSendType());
- check("sendType2", "wechat", itemNodes.get(1).getSendType());
- check("templateId2", 16L, itemNodes.get(1).getTemplateId());
- check("sendTime1", "09:00", itemNodes.get(0).getSendTime());
-
- System.out.println("-- 2) intervalDays + count 瑙f瀽 --");
- String intervalJson = "{\"intervalDays\":3,\"count\":4,\"sendType\":\"sms\",\"content\":\"闂撮殧鐭俊\",\"sendTime\":\"08:30\"}";
- List<MchFollowupNode> intervalNodes = parser.parse(intervalJson, null);
- check("闂撮殧鑺傜偣鏁�", 4, intervalNodes.size());
- check("鑺傜偣1鍋忕Щ", 0, intervalNodes.get(0).getDayOffset());
- check("鑺傜偣2鍋忕Щ", 3, intervalNodes.get(1).getDayOffset());
- check("鑺傜偣3鍋忕Щ", 6, intervalNodes.get(2).getDayOffset());
- check("鑺傜偣4鍋忕Щ", 9, intervalNodes.get(3).getDayOffset());
- check("闂撮殧sendTime", "08:30", intervalNodes.get(0).getSendTime());
-
- System.out.println("-- 3) intervalDays + followupCycleTimes 鍏滃簳 --");
- List<MchFollowupNode> cycleNodes = parser.parse(
- "{\"intervalDays\":2,\"sendType\":\"wechat\",\"content\":\"寰俊\"}", "3");
- check("鍏滃簳娆℃暟", 3, cycleNodes.size());
- check("鍏滃簳鑺傜偣3鍋忕Щ", 4, cycleNodes.get(2).getDayOffset());
-
- System.out.println("-- 4) days 鏁扮粍瑙f瀽 --");
- List<MchFollowupNode> dayNodes = parser.parse(
- "{\"days\":[0,7,14],\"sendType\":\"sms\",\"content\":\"鎸夊ぉ\"}", null);
- check("days鑺傜偣鏁�", 3, dayNodes.size());
- check("days鑺傜偣2鍋忕Щ", 7, dayNodes.get(1).getDayOffset());
-
- System.out.println("-- 5) 闈炴硶 JSON / 闈炴硶瀛楁 --");
- expectFail("闈炴硶JSON", () -> parser.parse("{bad", null));
- expectFail("绌鸿妭鐐�", () -> parser.parse("{\"items\":[]}", null));
- expectFail("闈炴硶sendType", () -> parser.parse(
- "{\"items\":[{\"dayOffset\":0,\"sendType\":\"phone\",\"content\":\"x\"}]}", null));
- expectFail("鐭俊缂篶ontent", () -> parser.parse(
- "{\"items\":[{\"dayOffset\":0,\"sendType\":\"sms\"}]}", null));
- expectFail("闈炴硶sendTime", () -> parser.parse(
- "{\"items\":[{\"dayOffset\":0,\"sendTime\":\"25:00\",\"sendType\":\"sms\",\"content\":\"x\"}]}", null));
-
- System.out.println("-- 6) 鍩哄噯鏃ユ椂闂磋绠� --");
- Date baseline = date("2026-11-20 14:30:00");
- check("day0娌跨敤14:30", "2026-11-20 14:30:00",
- DATE_TIME.format(resolver.resolve(baseline, node(1, 0, null, "sms"))));
- check("day3娌跨敤14:30", "2026-11-23 14:30:00",
- DATE_TIME.format(resolver.resolve(baseline, node(2, 3, null, "sms"))));
- check("day7鏄惧紡09:00", "2026-11-27 09:00:00",
- DATE_TIME.format(resolver.resolve(baseline, node(3, 7, "09:00", "wechat"))));
- Date midnight = date("2026-11-20 00:00:00");
- check("鍩哄噯鏃�00:00榛樿09:00", "2026-11-20 09:00:00",
- DATE_TIME.format(resolver.resolve(midnight, node(1, 0, null, "sms"))));
-
- System.out.println("-- 7) 1 澶╄ˉ鍙戠獥鍙� --");
- Date now = date("2026-11-20 12:00:00");
- check("鏈潵鑺傜偣寰呭彂閫�", MchFollowupDueDecision.PENDING,
- window.decide(date("2026-11-20 12:01:00"), now));
- check("1灏忔椂鍐呰ˉ鍙�", MchFollowupDueDecision.SEND,
- window.decide(date("2026-11-20 11:00:00"), now));
- check("鎭板ソ24灏忔椂琛ュ彂", MchFollowupDueDecision.SEND,
- window.decide(date("2026-11-19 12:00:00"), now));
- check("瓒呰繃24灏忔椂杩囨湡", MchFollowupDueDecision.EXPIRED,
- window.decide(date("2026-11-19 11:59:59"), now));
-
- System.out.println("-- 8) 鑺傜偣缁勮 --");
- List<MchFollowupPlanItem> items = assembler().assemble(99L, baseline, itemNodes);
- check("缁勮鑺傜偣鏁�", 3, items.size());
- check("planId", 99L, items.get(0).getPlanId());
- check("鍒濆鐘舵��", MchFollowupConstants.ITEM_STATUS_PENDING, items.get(0).getSendStatus());
- check("閲嶈瘯娆℃暟", 0, items.get(0).getRetryCount());
- check("缁勮鏃堕棿1", "2026-11-20 09:00:00", DATE_TIME.format(items.get(0).getSendTime()));
- check("缁勮鏃堕棿3娌跨敤鍩哄噯鏃�14:30", "2026-11-27 14:30:00", DATE_TIME.format(items.get(2).getSendTime()));
-
- System.out.println("-- 8.1) 鍐呭鍗犱綅绗︽覆鏌� --");
- MchFollowupPlan plan = new MchFollowupPlan();
- plan.setPatid(100L);
- plan.setPatname("寮犱笁");
- plan.setPhone("13800000000");
- plan.setOrgid("47226079133110211G1001");
- plan.setPlannedFollowTime(baseline);
- MchFollowupPlanItem seqItem = new MchFollowupPlanItem();
- seqItem.setSeq(2);
- MchFollowupMessageSender messageSender = new MchFollowupMessageSender();
- check("鍗犱綅绗︽覆鏌�",
- "鎮ㄥソ寮犱笁锛孖D=100锛岀數璇�=13800000000锛屽熀鍑�=2026-11-20 14:30:00锛屽簭鍙�=2锛屾満鏋�=47226079133110211G1001",
- messageSender.renderContent(
- "鎮ㄥソ${patname}锛孖D=${patid}锛岀數璇�=${phone}锛屽熀鍑�=${plannedFollowTime}锛屽簭鍙�=${seq}锛屾満鏋�=${orgid}",
- plan, seqItem));
-
- System.out.println("-- 9) Mapper XML 鍙В鏋愭�� --");
- String[] xmlFiles = new String[]{
- "smartor/src/main/resources/mapper/smartor/MchFollowupPlanMapper.xml",
- "smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml",
- "smartor/src/main/resources/mapper/smartor/MchFollowupSendLogMapper.xml"
- };
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
- for (String xmlFile : xmlFiles) {
- try {
- factory.newDocumentBuilder().parse(new File(xmlFile));
- check(xmlFile, "OK", "OK");
- } catch (Exception e) {
- check(xmlFile, "OK", e.getClass().getSimpleName() + ":" + e.getMessage());
- }
- }
-
- System.out.println("-- 10) SQL 鑴氭湰瀛樺湪鎬� --");
- check("DDL鑴氭湰", true, new File("sql/mch_followup_plan_20261117.sql").isFile());
-
- System.out.println("========== 缁撴灉锛歅ASS=" + passed + "锛孎AIL=" + failed + " ==========");
- if (failed > 0) {
- System.exit(1);
- }
- }
-}
diff --git a/smartor/src/test/java/com/smartor/service/mch/MchFollowupPlanServiceCheck.java b/smartor/src/test/java/com/smartor/service/mch/MchFollowupPlanServiceCheck.java
deleted file mode 100644
index 001ec7f..0000000
--- a/smartor/src/test/java/com/smartor/service/mch/MchFollowupPlanServiceCheck.java
+++ /dev/null
@@ -1,355 +0,0 @@
-package com.smartor.service.mch;
-
-import com.ruoyi.system.service.ISysConfigService;
-import com.smartor.common.MchFollowupConstants;
-import com.smartor.common.SpecificArchiveConstants;
-import com.smartor.domain.MchFollowupPlan;
-import com.smartor.domain.MchFollowupPlanItem;
-import com.smartor.domain.MchFollowupTaskQuery;
-import com.smartor.domain.MchFollowupTaskVO;
-import com.smartor.domain.PatChildArchiveDetail;
-import com.smartor.domain.PatMaternityArchiveDetail;
-import com.smartor.mapper.MchFollowupPlanItemMapper;
-import com.smartor.mapper.MchFollowupPlanMapper;
-import com.smartor.mapper.PatChildArchiveDetailMapper;
-import com.smartor.mapper.PatMaternityArchiveDetailMapper;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 濡囧辜闅忚璁″垝鏈嶅姟鑷锛堢函 main锛屼娇鐢ㄥ姩鎬佷唬鐞嗘ā鎷� Mapper锛屼笉渚濊禆鏁版嵁搴擄級銆�
- *
- * 瑕嗙洊锛氳鍒掔敓鎴愩�佽妭鐐规椂闂淬�佸箓绛夐噸寤恒�佹嫙闅忚鏃堕棿涓虹┖銆佸効淇濆闀跨數璇濆厹搴曘��
- */
-public final class MchFollowupPlanServiceCheck {
-
- private static int passed = 0;
- private static int failed = 0;
-
- private static final SimpleDateFormat DATE_TIME = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
- private static void check(String key, Object expected, Object actual) {
- boolean ok = expected == null ? actual == null : expected.equals(actual);
- if (ok) {
- passed++;
- System.out.println(" [OK] " + key + " = " + actual);
- } else {
- failed++;
- System.out.println(" [FAIL] " + key + " 鏈熸湜=" + expected + " 瀹為檯=" + actual);
- }
- }
-
- private static Date date(String text) throws Exception {
- return DATE_TIME.parse(text);
- }
-
- private static void setField(Object target, String name, Object value) throws Exception {
- Field field = target.getClass().getDeclaredField(name);
- field.setAccessible(true);
- field.set(target, value);
- }
-
- private static Object defaultValue(Class<?> type) {
- if (!type.isPrimitive()) {
- return null;
- }
- if (type == boolean.class) {
- return false;
- }
- if (type == byte.class) {
- return (byte) 0;
- }
- if (type == short.class) {
- return (short) 0;
- }
- if (type == int.class) {
- return 0;
- }
- if (type == long.class) {
- return 0L;
- }
- if (type == float.class) {
- return 0F;
- }
- if (type == double.class) {
- return 0D;
- }
- if (type == char.class) {
- return '\0';
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- private static <T> T proxy(Class<T> type, InvocationHandler handler) {
- return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class[]{type}, handler);
- }
-
- private static MchFollowupPlanAssembler assembler() throws Exception {
- MchFollowupPlanAssembler assembler = new MchFollowupPlanAssembler();
- setField(assembler, "timeResolver", new MchFollowupTimeResolver());
- return assembler;
- }
-
- private static PatMaternityArchiveDetail maternityDetail(Long detailId, Long archiveId, Date plannedTime) {
- PatMaternityArchiveDetail detail = new PatMaternityArchiveDetail();
- detail.setId(detailId);
- detail.setArchiveid(archiveId);
- detail.setOrgid(SpecificArchiveConstants.LISHUI_MCH_ORG_ID);
- detail.setCampusid("1");
- detail.setSourceType("1");
- detail.setSourceBizNo("MZ001");
- detail.setPatid(100L);
- detail.setPatname("寮犱笁");
- detail.setPhone("13800000000");
- detail.setIdcardno("330102199001010000");
- detail.setPlannedFollowTime(plannedTime);
- detail.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\"},"
- + "{\"dayOffset\":7,\"sendType\":\"sms\",\"content\":\"鐭俊3\"}]}");
- return detail;
- }
-
- private static PatChildArchiveDetail childDetail(Long detailId, Long archiveId, Date plannedTime) {
- PatChildArchiveDetail detail = new PatChildArchiveDetail();
- detail.setId(detailId);
- detail.setArchiveid(archiveId);
- detail.setOrgid(SpecificArchiveConstants.LISHUI_MCH_ORG_ID);
- detail.setCampusid("1");
- detail.setSourceType("1");
- detail.setSourceBizNo("MZ002");
- detail.setPatid(200L);
- detail.setPatname("鏉庡洓");
- detail.setPhone("13900000000");
- detail.setParentPhone("13700000000");
- detail.setIdcardno("330102199202020000");
- detail.setPlannedFollowTime(plannedTime);
- detail.setFollowupStatus(MchFollowupConstants.FOLLOWUP_STATUS_ACTIVE);
- detail.setFollowupPeriod("{\"items\":[{\"dayOffset\":1,\"sendType\":\"sms\",\"content\":\"鍎夸繚鐭俊\"}]}");
- return detail;
- }
-
- public static void main(String[] args) throws Exception {
- System.out.println("========== 濡囧辜闅忚璁″垝鏈嶅姟鑷 ==========");
-
- List<MchFollowupPlan> activePlans = new ArrayList<>();
- List<MchFollowupPlanItem> insertedItems = new ArrayList<>();
- long[] planId = {1L};
- long[] itemId = {1L};
-
- MchFollowupPlanMapper planMapper = proxy(MchFollowupPlanMapper.class, (p, method, a) -> {
- String name = method.getName();
- if ("selectActiveByArchive".equals(name)) {
- return new ArrayList<>(activePlans);
- }
- if ("insertMchFollowupPlan".equals(name)) {
- MchFollowupPlan plan = (MchFollowupPlan) a[0];
- plan.setId(planId[0]++);
- activePlans.add(plan);
- return 1;
- }
- if ("cancelById".equals(name)) {
- Long id = (Long) a[0];
- for (MchFollowupPlan plan : activePlans) {
- if (id.equals(plan.getId())) {
- plan.setPlanStatus(MchFollowupConstants.PLAN_STATUS_CANCELED);
- }
- }
- return 1;
- }
- if ("completeById".equals(name)) {
- return 1;
- }
- return defaultValue(method.getReturnType());
- });
-
- MchFollowupPlanItem[] updatedFollowupItem = new MchFollowupPlanItem[1];
- MchFollowupPlanItemMapper itemMapper = proxy(MchFollowupPlanItemMapper.class, (p, method, a) -> {
- String name = method.getName();
- if ("insertMchFollowupPlanItem".equals(name)) {
- MchFollowupPlanItem item = (MchFollowupPlanItem) a[0];
- item.setId(itemId[0]++);
- insertedItems.add(item);
- return 1;
- }
- if ("cancelPendingByPlanId".equals(name)) {
- return 1;
- }
- if ("countPendingByPlanId".equals(name)) {
- return 1;
- }
- 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)) {
- return maternityMap.get((Long) a[0]);
- }
- if ("selectPatMaternityArchiveDetailList".equals(name)) {
- PatMaternityArchiveDetail query = (PatMaternityArchiveDetail) a[0];
- List<PatMaternityArchiveDetail> list = new ArrayList<>();
- for (PatMaternityArchiveDetail detail : maternityMap.values()) {
- if (query.getArchiveid() == null || query.getArchiveid().equals(detail.getArchiveid())) {
- list.add(detail);
- }
- }
- return list;
- }
- return defaultValue(method.getReturnType());
- });
-
- Map<Long, PatChildArchiveDetail> childMap = new HashMap<>();
- childMap.put(30L, childDetail(30L, 12L, date("2026-12-01 08:00:00")));
- PatChildArchiveDetailMapper childMapper = proxy(PatChildArchiveDetailMapper.class, (p, method, a) -> {
- String name = method.getName();
- if ("selectPatChildArchiveDetailById".equals(name)) {
- return childMap.get((Long) a[0]);
- }
- if ("selectPatChildArchiveDetailList".equals(name)) {
- return new ArrayList<>(childMap.values());
- }
- return defaultValue(method.getReturnType());
- });
-
- ISysConfigService configService = proxy(ISysConfigService.class, (p, method, a) -> {
- if ("selectConfigByKey".equals(method.getName())) {
- return null;
- }
- return defaultValue(method.getReturnType());
- });
-
- MchFollowupPlanServiceImpl service = new MchFollowupPlanServiceImpl();
- setField(service, "planMapper", planMapper);
- setField(service, "itemMapper", itemMapper);
- setField(service, "maternityDetailMapper", maternityMapper);
- setField(service, "childDetailMapper", childMapper);
- setField(service, "periodParser", new MchFollowupPeriodParser());
- setField(service, "planAssembler", assembler());
- setField(service, "configService", configService);
-
- System.out.println("-- 1) 濡囦繚璁″垝鐢熸垚 --");
- int generated = service.rebuildForArchive(MchFollowupConstants.ARCHIVE_TYPE_MATERNITY, 10L, 20L);
- check("鐢熸垚鑺傜偣鏁�", 3, generated);
- check("璁″垝鏁�", 1, activePlans.size());
- check("璁″垝鐘舵��", MchFollowupConstants.PLAN_STATUS_ACTIVE, activePlans.get(0).getPlanStatus());
- check("璁″垝鏈烘瀯", SpecificArchiveConstants.LISHUI_MCH_ORG_ID, activePlans.get(0).getOrgid());
- check("鑺傜偣鏁�", 3, insertedItems.size());
- check("鑺傜偣1鏃堕棿", "2026-11-20 09:00:00", DATE_TIME.format(insertedItems.get(0).getSendTime()));
- check("鑺傜偣2鏃堕棿", "2026-11-23 14:30:00", DATE_TIME.format(insertedItems.get(1).getSendTime()));
- check("鑺傜偣3鏃堕棿", "2026-11-27 14:30:00", DATE_TIME.format(insertedItems.get(2).getSendTime()));
-
- System.out.println("-- 2) 鐩稿悓鍩哄噯鏃�/鍛ㄦ湡骞傜瓑 --");
- int again = service.rebuildForArchive(MchFollowupConstants.ARCHIVE_TYPE_MATERNITY, 10L, 20L);
- check("骞傜瓑杩斿洖", 0, again);
- check("璁″垝鏁颁笉鍙�", 1, activePlans.size());
- check("鑺傜偣鏁颁笉鍙�", 3, insertedItems.size());
-
- System.out.println("-- 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);
- check("绛夊緟璁″垝鏁�", 2, activePlans.size());
- check("绛夊緟璁″垝鐘舵��", MchFollowupConstants.PLAN_STATUS_WAITING, activePlans.get(1).getPlanStatus());
-
- System.out.println("-- 4) 鍎夸繚瀹堕暱鐢佃瘽鍏滃簳 --");
- int childGenerated = service.rebuildForArchive(MchFollowupConstants.ARCHIVE_TYPE_CHILD, 12L, 30L);
- check("鍎夸繚鑺傜偣鏁�", 1, childGenerated);
- check("鍎夸繚璁″垝鏁�", 3, activePlans.size());
- check("鍎夸繚鐢佃瘽", "13700000000", activePlans.get(2).getPhone());
- check("鍎夸繚鑺傜偣鏃堕棿", "2026-12-02 08:00:00",
- DATE_TIME.format(insertedItems.get(insertedItems.size() - 1).getSendTime()));
-
- System.out.println("-- 5) 闈炰附姘村骞间笉鐢熸垚 --");
- PatMaternityArchiveDetail other = maternityDetail(40L, 20L, date("2026-11-20 14:30:00"));
- other.setOrgid("OTHER_ORG");
- maternityMap.put(40L, other);
- int otherGenerated = service.rebuildForArchive(MchFollowupConstants.ARCHIVE_TYPE_MATERNITY, 20L, 40L);
- check("鍏朵粬鏈烘瀯涓嶇敓鎴�", 0, otherGenerated);
-
- System.out.println("-- 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);
- }
- }
-}
diff --git a/smartor/src/test/java/com/smartor/service/mch/MchFollowupSendServiceCheck.java b/smartor/src/test/java/com/smartor/service/mch/MchFollowupSendServiceCheck.java
deleted file mode 100644
index be59015..0000000
--- a/smartor/src/test/java/com/smartor/service/mch/MchFollowupSendServiceCheck.java
+++ /dev/null
@@ -1,198 +0,0 @@
-package com.smartor.service.mch;
-
-import com.ruoyi.system.service.ISysConfigService;
-import com.smartor.common.MchFollowupConstants;
-import com.smartor.domain.MchFollowupPlan;
-import com.smartor.domain.MchFollowupPlanItem;
-import com.smartor.domain.MchFollowupSendLog;
-import com.smartor.mapper.MchFollowupPlanItemMapper;
-import com.smartor.mapper.MchFollowupPlanMapper;
-import com.smartor.mapper.MchFollowupSendLogMapper;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * 濡囧辜闅忚鍙戦�佹湇鍔¤嚜妫�锛堢函 main锛屽姩鎬佷唬鐞嗘ā鎷� Mapper锛屼笉渚濊禆鏁版嵁搴�/绗笁鏂规帴鍙o級銆�
- */
-public final class MchFollowupSendServiceCheck {
-
- private static int passed = 0;
- private static int failed = 0;
-
- private static void check(String key, Object expected, Object actual) {
- boolean ok = expected == null ? actual == null : expected.equals(actual);
- if (ok) {
- passed++;
- System.out.println(" [OK] " + key + " = " + actual);
- } else {
- failed++;
- System.out.println(" [FAIL] " + key + " 鏈熸湜=" + expected + " 瀹為檯=" + actual);
- }
- }
-
- private static void setField(Object target, String name, Object value) throws Exception {
- Field field = target.getClass().getDeclaredField(name);
- field.setAccessible(true);
- field.set(target, value);
- }
-
- private static Object defaultValue(Class<?> type) {
- if (!type.isPrimitive()) {
- return null;
- }
- if (type == boolean.class) {
- return false;
- }
- if (type == int.class) {
- return 0;
- }
- if (type == long.class) {
- return 0L;
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- private static <T> T proxy(Class<T> type, InvocationHandler handler) {
- return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class[]{type}, handler);
- }
-
- private static MchFollowupPlanItem item(String sendType, long sendTimeMillis) {
- MchFollowupPlanItem item = new MchFollowupPlanItem();
- item.setId(1L);
- item.setPlanId(10L);
- item.setSeq(1);
- item.setSendType(sendType);
- item.setSendTime(new Date(sendTimeMillis));
- item.setContent("鍐呭");
- item.setSendStatus(MchFollowupConstants.ITEM_STATUS_PENDING);
- item.setRetryCount(0);
- return item;
- }
-
- private static MchFollowupPlan plan() {
- MchFollowupPlan plan = new MchFollowupPlan();
- plan.setId(10L);
- plan.setOrgid("47226079133110211G1001");
- plan.setPlanStatus(MchFollowupConstants.PLAN_STATUS_ACTIVE);
- plan.setPhone("13800000000");
- return plan;
- }
-
- private static int run(MchFollowupPlanItem targetItem, MchFollowupMessageSender sender,
- boolean expectClaim) throws Exception {
- List<MchFollowupPlanItem> dueItems = new ArrayList<>();
- dueItems.add(targetItem);
- List<MchFollowupSendLog> logs = new ArrayList<>();
- boolean[] claimed = {false};
- boolean[] planCompleted = {false};
-
- MchFollowupPlanItemMapper itemMapper = proxy(MchFollowupPlanItemMapper.class, (p, method, a) -> {
- String name = method.getName();
- if ("selectDueItems".equals(name)) {
- return dueItems;
- }
- if ("claimItem".equals(name)) {
- claimed[0] = true;
- return 1;
- }
- if ("updateSendResult".equals(name)) {
- return 1;
- }
- if ("countPendingByPlanId".equals(name)) {
- return 0;
- }
- return defaultValue(method.getReturnType());
- });
-
- MchFollowupPlanMapper planMapper = proxy(MchFollowupPlanMapper.class, (p, method, a) -> {
- String name = method.getName();
- if ("selectMchFollowupPlanById".equals(name)) {
- return plan();
- }
- if ("completeById".equals(name)) {
- planCompleted[0] = true;
- return 1;
- }
- return defaultValue(method.getReturnType());
- });
-
- MchFollowupSendLogMapper logMapper = proxy(MchFollowupSendLogMapper.class, (p, method, a) -> {
- if ("insertMchFollowupSendLog".equals(method.getName())) {
- logs.add((MchFollowupSendLog) a[0]);
- return 1;
- }
- return defaultValue(method.getReturnType());
- });
-
- ISysConfigService configService = proxy(ISysConfigService.class, (p, method, a) -> {
- if ("selectConfigByKey".equals(method.getName())) {
- return null;
- }
- return defaultValue(method.getReturnType());
- });
-
- MchFollowupSendServiceImpl service = new MchFollowupSendServiceImpl();
- setField(service, "planMapper", planMapper);
- setField(service, "itemMapper", itemMapper);
- setField(service, "sendLogMapper", logMapper);
- setField(service, "messageSender", sender);
- setField(service, "sendWindow", new MchFollowupSendWindow());
- setField(service, "configService", configService);
-
- int sent = service.sendDue(10);
- check("claimItem璋冪敤", expectClaim, claimed[0]);
- check("璁″垝瀹屾垚鏇存柊", true, planCompleted[0]);
- check("鍙戦�佹棩蹇楁暟", 1, logs.size());
- return sent;
- }
-
- public static void main(String[] args) throws Exception {
- System.out.println("========== 濡囧辜闅忚鍙戦�佹湇鍔¤嚜妫� ==========");
- long now = System.currentTimeMillis();
-
- System.out.println("-- 1) 鐭俊鍙戦�佹垚鍔� --");
- MchFollowupPlanItem smsItem = item(MchFollowupConstants.SEND_TYPE_SMS, now - 60L * 60L * 1000L);
- MchFollowupMessageSender okSender = new MchFollowupMessageSender() {
- @Override
- public MchFollowupSendOutcome sendSms(MchFollowupPlan plan, MchFollowupPlanItem item) {
- return MchFollowupSendOutcome.ok("MSG-1", "req", "resp");
- }
-
- @Override
- public MchFollowupSendOutcome sendWechat(MchFollowupPlan plan, MchFollowupPlanItem item) {
- return MchFollowupSendOutcome.fail("寰俊澶辫触", "req", "resp");
- }
- };
- int success = run(smsItem, okSender, true);
- check("鎴愬姛鏁伴噺", 1, success);
- check("鑺傜偣鐘舵��", MchFollowupConstants.ITEM_STATUS_SUCCESS, smsItem.getSendStatus());
- check("绗笁鏂笽D", "MSG-1", smsItem.getProviderMsgId());
-
- System.out.println("-- 2) 瓒呰繃 1 澶╂爣璁拌繃鏈� --");
- MchFollowupPlanItem expiredItem = item(
- MchFollowupConstants.SEND_TYPE_SMS, now - 25L * 60L * 60L * 1000L);
- int expiredSent = run(expiredItem, okSender, false);
- check("杩囨湡涓嶅彂閫�", 0, expiredSent);
- check("杩囨湡鐘舵��", MchFollowupConstants.ITEM_STATUS_EXPIRED, expiredItem.getSendStatus());
-
- System.out.println("-- 3) 寰俊澶辫触杩涘叆閲嶈瘯 --");
- MchFollowupPlanItem retryItem = item(
- MchFollowupConstants.SEND_TYPE_WECHAT, now - 60L * 60L * 1000L);
- int retrySent = run(retryItem, okSender, true);
- check("澶辫触涓嶈鏁�", 0, retrySent);
- check("閲嶈瘯鐘舵��", MchFollowupConstants.ITEM_STATUS_PENDING, retryItem.getSendStatus());
- check("閲嶈瘯娆℃暟", 1, retryItem.getRetryCount());
- check("涓嬫閲嶈瘯鏃堕棿闈炵┖", true, retryItem.getNextRetryTime() != null);
-
- System.out.println("========== 缁撴灉锛歅ASS=" + passed + "锛孎AIL=" + failed + " ==========");
- if (failed > 0) {
- System.exit(1);
- }
- }
-}
diff --git a/sql/mch_followup_plan_20261117.sql b/sql/mch_followup_plan_20261117.sql
deleted file mode 100644
index 4b5ce24..0000000
--- a/sql/mch_followup_plan_20261117.sql
+++ /dev/null
@@ -1,81 +0,0 @@
--- =============================================================================
--- 濡囧辜闅忚鎸夊懆鏈熷彂閫侊細璁″垝琛� + 鑺傜偣琛� + 鍙戦�佹棩蹇楄〃
--- 閫傜敤鏈烘瀯锛氫附姘村競濡囧辜淇濆仴闄� orgid = 47226079133110211G1001
--- 鏃ユ湡锛�2026-11-17
--- =============================================================================
-
--- 1. followup_period 鏀逛负 TEXT锛屽绾� JSON锛堝師 varchar(100) 鏀句笉涓嬪彂閫佸唴瀹癸級
-ALTER TABLE pat_maternity_archive_detail
- MODIFY COLUMN followup_period TEXT NULL COMMENT '闅忚鍛ㄦ湡JSON';
-
-ALTER TABLE pat_child_archive_detail
- MODIFY COLUMN followup_period TEXT NULL COMMENT '闅忚鍛ㄦ湡JSON';
-
-ALTER TABLE pat_specific_archive_generate_config
- MODIFY COLUMN followup_period TEXT NULL COMMENT '闅忚鍛ㄦ湡JSON';
-
--- 2. 濡囧辜闅忚璁″垝涓昏〃
-CREATE TABLE IF NOT EXISTS mch_followup_plan (
- id BIGINT NOT NULL AUTO_INCREMENT COMMENT '涓婚敭',
- orgid VARCHAR(64) NOT NULL COMMENT '鏈烘瀯ID',
- campusid VARCHAR(64) DEFAULT NULL COMMENT '闄㈠尯ID',
- archive_type VARCHAR(8) NOT NULL COMMENT '妗f绫诲瀷锛�1濡囦繚 2鍎夸繚',
- archive_id BIGINT NOT NULL COMMENT '妗f涓昏〃ID',
- archive_detail_id BIGINT NOT NULL COMMENT '妗f璇︽儏ID',
- source_type VARCHAR(8) DEFAULT NULL COMMENT '鏉ユ簮绫诲瀷锛�1闂ㄨ瘖 2浣忛櫌闅忚 3鎵嬪伐',
- source_biz_no VARCHAR(128) DEFAULT NULL COMMENT '鏉ユ簮涓氬姟缂栧彿锛氶棬璇婂彿/浣忛櫌鍙�',
- patid BIGINT DEFAULT NULL COMMENT '鎮h�匢D',
- patname VARCHAR(255) DEFAULT NULL COMMENT '鎮h�呭鍚�',
- phone VARCHAR(32) DEFAULT NULL COMMENT '鑱旂郴鐢佃瘽',
- idcardno VARCHAR(64) DEFAULT NULL COMMENT '璇佷欢鍙风爜',
- planned_follow_time DATETIME DEFAULT NULL COMMENT '鍛ㄦ湡鍩哄噯鏃�',
- followup_period TEXT DEFAULT NULL COMMENT '闅忚鍛ㄦ湡JSON蹇収',
- plan_status CHAR(1) NOT NULL DEFAULT '0' COMMENT '鐘舵�侊細0鏈夋晥 1鍙栨秷 2瀹屾垚 3寰呰ˉ鍏�/閰嶇疆寮傚父',
- remark VARCHAR(500) DEFAULT NULL COMMENT '澶囨敞',
- create_time DATETIME DEFAULT NULL,
- update_time DATETIME DEFAULT NULL,
- PRIMARY KEY (id),
- KEY idx_mch_plan_archive (archive_type, archive_id, archive_detail_id),
- KEY idx_mch_plan_status (orgid, plan_status)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='濡囧辜闅忚璁″垝涓昏〃';
-
--- 3. 濡囧辜闅忚璁″垝鍙戦�佽妭鐐�
-CREATE TABLE IF NOT EXISTS mch_followup_plan_item (
- id BIGINT NOT NULL AUTO_INCREMENT COMMENT '涓婚敭',
- plan_id BIGINT NOT NULL COMMENT '璁″垝ID',
- seq INT NOT NULL COMMENT '鑺傜偣椤哄簭',
- send_type VARCHAR(16) NOT NULL COMMENT '鍙戦�佹柟寮忥細sms/wechat',
- send_time DATETIME NOT NULL COMMENT '鍙戦�佹椂闂�',
- title_name VARCHAR(255) DEFAULT NULL COMMENT '寰俊鏍囬',
- content TEXT DEFAULT NULL COMMENT '鍙戦�佸唴瀹�',
- template_id BIGINT DEFAULT NULL COMMENT '寰俊妯℃澘ID',
- url VARCHAR(1000) DEFAULT NULL COMMENT '寰俊璺宠浆鍦板潃',
- send_status CHAR(1) NOT NULL DEFAULT '0' COMMENT '鐘舵�侊細0寰呭彂閫� 1鍙戦�佷腑 2鎴愬姛 3澶辫触 4杩囨湡 5鍙栨秷 6璺宠繃',
- retry_count INT NOT NULL DEFAULT 0 COMMENT '宸查噸璇曟鏁�',
- next_retry_time DATETIME DEFAULT NULL COMMENT '涓嬫閲嶈瘯鏃堕棿',
- send_time_actual DATETIME DEFAULT NULL COMMENT '瀹為檯鍙戦�佹椂闂�',
- result_msg VARCHAR(1000) DEFAULT NULL COMMENT '缁撴灉璇存槑',
- provider_msg_id VARCHAR(255) DEFAULT NULL COMMENT '绗笁鏂规秷鎭疘D',
- create_time DATETIME DEFAULT NULL,
- update_time DATETIME DEFAULT NULL,
- PRIMARY KEY (id),
- UNIQUE KEY uk_mch_plan_seq (plan_id, seq),
- KEY idx_mch_item_due (send_status, send_time),
- KEY idx_mch_item_plan (plan_id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='濡囧辜闅忚璁″垝鍙戦�佽妭鐐�';
-
--- 4. 濡囧辜闅忚鍙戦�佹棩蹇�
-CREATE TABLE IF NOT EXISTS mch_followup_send_log (
- id BIGINT NOT NULL AUTO_INCREMENT COMMENT '涓婚敭',
- plan_id BIGINT DEFAULT NULL COMMENT '璁″垝ID',
- item_id BIGINT DEFAULT NULL COMMENT '鑺傜偣ID',
- send_type VARCHAR(16) DEFAULT NULL COMMENT '鍙戦�佹柟寮�',
- request_body TEXT DEFAULT NULL COMMENT '璇锋眰鎽樿锛堟墜鏈哄彿鑴辨晱锛�',
- response_body TEXT DEFAULT NULL COMMENT '绗笁鏂瑰搷搴�',
- send_status CHAR(1) DEFAULT NULL COMMENT '鍙戦�佸悗鐘舵��',
- result_msg VARCHAR(1000) DEFAULT NULL COMMENT '缁撴灉璇存槑',
- create_time DATETIME DEFAULT NULL,
- PRIMARY KEY (id),
- KEY idx_mch_log_item (item_id),
- KEY idx_mch_log_plan (plan_id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='濡囧辜闅忚鍙戦�佹棩蹇�';
diff --git a/sql/mch_followup_plan_item_add_followup_fields_20261123.sql b/sql/mch_followup_plan_item_add_followup_fields_20261123.sql
deleted file mode 100644
index a6e637b..0000000
--- a/sql/mch_followup_plan_item_add_followup_fields_20261123.sql
+++ /dev/null
@@ -1,24 +0,0 @@
--- =============================================================================
--- 濡囧辜闅忚鑺傜偣澧炲姞浜哄伐闅忚缁撴灉瀛楁
--- 鏃ユ湡锛�2026-11-23
--- 鍓嶇疆锛氬凡鎵ц sql/mch_followup_plan_20261117.sql
--- 璇存槑锛�
--- send_status 琛ㄧず鐭俊/寰俊鍙戦�佺姸鎬侊紱
--- followup_status 琛ㄧず浜哄伐闅忚缁撴灉鐘舵�侊紝涓よ�呭垎寮�銆�
--- =============================================================================
-
-ALTER TABLE mch_followup_plan_item
- ADD COLUMN followup_date DATETIME NULL
- COMMENT '闅忚鏃ユ湡' AFTER send_time_actual,
- ADD COLUMN followup_user_id VARCHAR(64) NULL
- COMMENT '闅忚浜哄憳ID' AFTER followup_date,
- ADD COLUMN followup_user_name VARCHAR(64) NULL
- COMMENT '闅忚浜哄憳濮撳悕' AFTER followup_user_id,
- ADD COLUMN followup_situation VARCHAR(500) NULL
- COMMENT '闅忚鎯呭喌' AFTER followup_user_name,
- ADD COLUMN followup_status CHAR(1) NOT NULL DEFAULT '0'
- COMMENT '闅忚鐘舵�侊細0鏈殢璁� 1宸查殢璁� 2澶辫 3鎷掕 4鍙风爜閿欒' AFTER followup_situation;
-
--- 闅忚缁撴灉鍒楄〃/缁熻杩囨护
-ALTER TABLE mch_followup_plan_item
- ADD INDEX idx_mch_item_followup (followup_status, followup_date);
diff --git a/sql/pat_mch_archive_followup_status_20261123.sql b/sql/pat_mch_archive_followup_status_20261123.sql
index d60281c..e606d63 100644
--- a/sql/pat_mch_archive_followup_status_20261123.sql
+++ b/sql/pat_mch_archive_followup_status_20261123.sql
@@ -1,11 +1,10 @@
-- =============================================================================
--- 濡囧辜妗f闅忚鐘舵�侊細鎺ヨ瘖瀹屾垚鑷姩寤烘。鍙啓寰呯‘璁わ紝浜哄伐淇濆瓨鍚庡啀鐢熸垚闅忚璁″垝
+-- 濡囧辜妗f闅忚鐘舵�侊細鎺ヨ瘖瀹屾垚鑷姩寤烘。鍙啓寰呯‘璁わ紝浜哄伐淇濆瓨鍚庡啀鐢熸垚闅忚浠诲姟
-- 鏃ユ湡锛�2026-11-23
-- 閫傜敤锛氫附姘村競濡囧辜淇濆仴闄㈠骞间笓绉戞。妗堬紙濡囦繚/鍎夸繚锛�
--- 鍓嶇疆锛氬凡鎵ц sql/mch_followup_plan_20261117.sql
-- 璇存槑锛�
--- 1. followup_status=0 寰呯‘璁わ細闂ㄨ瘖鎺ヨ瘖/浣忛櫌闅忚鑷姩寤烘。锛屼笉鐢熸垚闅忚璁″垝锛�
--- 2. followup_status=1 闅忚涓細浜哄伐淇濆瓨妗f鍚庡啓鍏ワ紝鍏佽鐢熸垚/閲嶅缓闅忚璁″垝锛�
+-- 1. followup_status=0 寰呯‘璁わ細闂ㄨ瘖鎺ヨ瘖/浣忛櫌闅忚鑷姩寤烘。锛屼笉鐢熸垚 service_subtask锛�
+-- 2. followup_status=1 闅忚涓細浜哄伐淇濆瓨妗f鍚庡啓鍏ワ紝鍏佽鐢熸垚/閲嶅缓 service_subtask锛�
-- 3. 瀛橀噺鏁版嵁涓凡鏈夋嫙闅忚鏃堕棿鍜岄殢璁垮懆鏈熺殑妗f鍥炲~涓� 1锛屼繚鎸佸師鏈夊彂閫佽涓恒��
-- =============================================================================
@@ -41,30 +40,9 @@
AND followup_period IS NOT NULL
AND followup_period <> '';
--- 宸叉湁鏈夋晥璁″垝鐨勬。妗堝繀椤讳繚鎸佲�滈殢璁夸腑鈥濓紝閬垮厤鍘嗗彶璁″垝浠嶅湪鍙戦�佷絾妗f琚爣鎴愬緟纭
-UPDATE pat_maternity_archive_detail d
- INNER JOIN mch_followup_plan p
- ON p.archive_type = '1'
- AND p.archive_detail_id = d.id
- AND p.plan_status = '0'
-SET d.followup_status = '1'
-WHERE d.followup_status = '0';
-
-UPDATE pat_child_archive_detail d
- INNER JOIN mch_followup_plan p
- ON p.archive_type = '2'
- AND p.archive_detail_id = d.id
- AND p.plan_status = '0'
-SET d.followup_status = '1'
-WHERE d.followup_status = '0';
-
-- 琛ュ缓鎵弿涓庡垪琛ㄨ繃婊�
ALTER TABLE pat_maternity_archive_detail
ADD INDEX idx_maternity_followup_status (orgid, followup_status);
ALTER TABLE pat_child_archive_detail
ADD INDEX idx_child_followup_status (orgid, followup_status);
-
--- 琛ュ缓鎵弿涓殑 not exists 瀛愭煡璇娇鐢�
-ALTER TABLE mch_followup_plan
- ADD INDEX idx_mch_plan_detail_status (archive_type, archive_detail_id, plan_status);
--
Gitblit v1.9.3