From 67d0eef6ef56713345e03afdfd7e5badf4d4ad3d Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 24 十一月 2026 14:13:11 +0800
Subject: [PATCH] fix: 补提交妇幼随访 service_subtask 方案核心文件
---
smartor/src/test/java/com/smartor/service/mch/MchFollowupSubtaskLogicCheck.java | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 114 insertions(+), 0 deletions(-)
diff --git a/smartor/src/test/java/com/smartor/service/mch/MchFollowupSubtaskLogicCheck.java b/smartor/src/test/java/com/smartor/service/mch/MchFollowupSubtaskLogicCheck.java
new file mode 100644
index 0000000..144ce9b
--- /dev/null
+++ b/smartor/src/test/java/com/smartor/service/mch/MchFollowupSubtaskLogicCheck.java
@@ -0,0 +1,114 @@
+package com.smartor.service.mch;
+
+import com.smartor.common.MchFollowupConstants;
+import com.smartor.domain.MchFollowupNode;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 濡囧辜闅忚 service_subtask 鏂规鑷锛堢函 main锛屼笉渚濊禆鏁版嵁搴擄級銆�
+ *
+ * <p>瑕嗙洊锛歠ollowupPeriod 瑙f瀽銆佸彂閫佹椂闂磋绠椼�佸崰浣嶇娓叉煋銆丮apper XML銆丼QL 杩佺Щ鑴氭湰銆�</p>
+ */
+public final class MchFollowupSubtaskLogicCheck {
+
+ 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);
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("========== 濡囧辜闅忚 service_subtask 鏂规鑷 ==========");
+
+ System.out.println("-- 1) items 瑙f瀽 --");
+ MchFollowupPeriodParser parser = new MchFollowupPeriodParser();
+ List<MchFollowupNode> nodes = parser.parse("{\"items\":["
+ + "{\"seq\":1,\"dayOffset\":0,\"sendType\":\"sms\",\"content\":\"A\"},"
+ + "{\"seq\":2,\"dayOffset\":3,\"sendType\":\"wechat\",\"templateId\":16,\"content\":\"B\"}]}", null);
+ check("鑺傜偣鏁�", 2, nodes.size());
+ check("鑺傜偣1鍙戦�佹柟寮�", MchFollowupConstants.SEND_TYPE_SMS, nodes.get(0).getSendType());
+ check("鑺傜偣2妯℃澘ID", 16L, nodes.get(1).getTemplateId());
+
+ System.out.println("-- 2) intervalDays 瑙f瀽 --");
+ List<MchFollowupNode> interval = parser.parse(
+ "{\"intervalDays\":3,\"count\":3,\"sendType\":\"sms\",\"content\":\"X\"}", null);
+ check("闂撮殧鑺傜偣鏁�", 3, interval.size());
+ check("绗�3鑺傜偣鍋忕Щ", 6, interval.get(2).getDayOffset());
+
+ System.out.println("-- 3) 鍙戦�佹椂闂磋绠� --");
+ Date base = DATE_TIME.parse("2026-11-20 00:00:00");
+ MchFollowupTimeResolver resolver = new MchFollowupTimeResolver();
+ Date sendTime = resolver.resolve(base, interval.get(1));
+ check("绗�2鑺傜偣鏃堕棿", "2026-11-23 09:00:00", DATE_TIME.format(sendTime));
+
+ System.out.println("-- 4) 鍗犱綅绗︽覆鏌� --");
+ MchFollowupMessageSender sender = new MchFollowupMessageSender();
+ MchFollowupSendContext context = new MchFollowupSendContext();
+ context.setPatname("寮犱笁");
+ context.setPatid(100L);
+ context.setPhone("13800000000");
+ context.setIdcardno("330102199001010000");
+ context.setSourceBizNo("MZ001");
+ context.setArchiveType("1");
+ context.setOrgid("47226079133110211G1001");
+ context.setSeq(2);
+ context.setPlannedFollowTime(base);
+ String rendered = sender.renderContent(
+ "鎮ㄥソ${patname}锛孖D=${patid}锛岀數璇�=${phone}锛屽熀鍑�=${plannedFollowTime}锛屽簭鍙�=${seq}", context);
+ check("鍗犱綅绗�", "鎮ㄥソ寮犱笁锛孖D=100锛岀數璇�=13800000000锛屽熀鍑�=2026-11-20 00:00:00锛屽簭鍙�=2", rendered);
+
+ System.out.println("-- 5) Mapper XML 鍙В鏋� --");
+ check("MchFollowupSubtaskMapper.xml", true, xmlOk(
+ "smartor/src/main/resources/mapper/smartor/MchFollowupSubtaskMapper.xml"));
+
+ System.out.println("-- 6) SQL 杩佺Щ鑴氭湰 --");
+ String sql = new String(Files.readAllBytes(
+ Paths.get("sql/service_subtask_add_mch_fields_20261123.sql")), StandardCharsets.UTF_8);
+ check("鍚� mch_archive_detail_id", true, sql.contains("mch_archive_detail_id"));
+ check("鍚� mch_node_json", true, sql.contains("mch_node_json"));
+ check("鍚敮涓�閿�", true, sql.contains("uk_mch_node"));
+ check("鍚噿鐢熸垚娓告爣", true, sql.contains("mch_next_due_time"));
+ check("鍚鍒掑搱甯�", true, sql.contains("mch_plan_hash"));
+
+ System.out.println("========== 缁撴灉锛歅ASS=" + passed + "锛孎AIL=" + failed + " ==========");
+ if (failed > 0) {
+ System.exit(1);
+ }
+ }
+
+ private static boolean xmlOk(String path) {
+ try {
+ File file = new File(path);
+ if (!file.exists()) {
+ System.out.println(" [WARN] 鏂囦欢涓嶅瓨鍦�: " + path);
+ return false;
+ }
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setValidating(false);
+ factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ factory.newDocumentBuilder().parse(file);
+ return true;
+ } catch (Exception e) {
+ System.out.println(" [WARN] XML 瑙f瀽澶辫触: " + e.getMessage());
+ return false;
+ }
+ }
+}
--
Gitblit v1.9.3