From 2356e2b48faa185026fa777b7e218ab5a7c99114 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 24 十一月 2026 10:43:08 +0800
Subject: [PATCH] 【丽水】妇幼随访发送
---
smartor/src/main/java/com/smartor/service/mch/MchFollowupMessageSender.java | 77 +++++++++++++++++++++++++++-----------
1 files changed, 54 insertions(+), 23 deletions(-)
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 8784bfd..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,18 +6,18 @@
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;
+
+import java.text.SimpleDateFormat;
/**
* 濡囧辜闅忚娑堟伅鍙戦�佸櫒銆�
*
* <p>鐭俊澶嶇敤 {@link SmsUtils#sendYunMasSms}锛屽井淇″鐢�
* {@link SmsUtils#sendChatLs}锛堝嵆 {@code /sms/sendChatFuyou} 鐨勫唴閮ㄥ疄鐜帮級銆�
- * 涓嶇粡杩囨櫘閫氶殢璁跨殑鍙戦�佹柟宸ュ巶涓庤ˉ鍋块摼璺��</p>
+ * 鍙戦�佷笂涓嬫枃鐢� service_subtask + mch_node_json 缁勮銆�</p>
*/
@Slf4j
@Component
@@ -26,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 : item.getContent();
+ 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("鎵嬫満鍙蜂负绌�");
}
@@ -37,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);
@@ -48,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(item.getTitleName());
- message.setContent(item.getContent());
- 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);
@@ -84,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);
}
}
@@ -118,6 +118,37 @@
}
}
+ /**
+ * 娓叉煋濡囧辜闅忚鍐呭鍗犱綅绗︺�傚綋鍓嶆敮鎸侊細
+ * ${patname}銆�${patid}銆�${phone}銆�${idcardno}銆�${plannedFollowTime}銆�
+ * ${sourceBizNo}銆�${archiveType}銆�${orgid}銆�${seq}銆�
+ */
+ String renderContent(String text, MchFollowupSendContext context) {
+ if (StringUtils.isBlank(text) || context == null) {
+ return text;
+ }
+ String result = text;
+ 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(context.getPlannedFollowTime()));
+ } else {
+ result = result.replace("${plannedFollowTime}", "");
+ }
+ return result;
+ }
+
+ private String nvl(String value) {
+ return value == null ? "" : value;
+ }
+
private String requestSummary(String sendType, String phone, Long templateId) {
return "sendType=" + sendType
+ "锛沺hone=" + maskPhone(phone)
--
Gitblit v1.9.3