From 27df1079c1d230fab29f565f5209f2a02e0def8a Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期一, 20 七月 2026 16:56:51 +0800
Subject: [PATCH] 省立同德的功能

---
 ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java |  138 +++++++++++++++++++++++++++++++++++----------
 1 files changed, 107 insertions(+), 31 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java b/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java
index b74dd0e..b9a4adb 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java
@@ -21,6 +21,7 @@
 import com.ruoyi.common.utils.sign.Md5Utils;
 import com.ruoyi.common.utils.sms.smsUtils;
 import com.ruoyi.system.domain.SysConfig;
+import com.ruoyi.system.mapper.SysConfigMapper;
 import com.ruoyi.system.service.ISysConfigService;
 import com.smartor.common.LSHospTokenUtil;
 import com.smartor.common.MtSubmitSmUtil;
@@ -41,6 +42,7 @@
 import org.springframework.stereotype.Component;
 
 import java.io.IOException;
+import java.net.URLEncoder;
 import java.security.MessageDigest;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
@@ -109,6 +111,9 @@
 
     @Value("${xhsmsPwd}")
     private String xhsmsPwd;
+    // 铏氭嫙鎺ュ叆鐮�
+    @Value("${xhsmsjrm}")
+    private String xhsmsjrm;
 
     @Value("${server.port}")
     private String port;
@@ -121,6 +126,8 @@
 
     @Autowired
     private ISysConfigService configService;
+    @Autowired
+    private SysConfigMapper sysConfigMapper;
 
     public RedisMqReceiver(RedisMessageListenerContainer listenerContainer) {
         super(listenerContainer);
@@ -302,21 +309,33 @@
                         serviceOutPath.setParam2(patid);
                         serviceOutPath.setParam6(subId);
                         serviceOutPath.setCreateTime(new Date());
+                        serviceOutPath.setOrgid(serviceSubtask.getOrgid());
+                        serviceOutPath.setDeptCode(serviceSubtask.getDeptcode());
+                        serviceOutPath.setWardCode(serviceSubtask.getLeavehospitaldistrictcode());
+                        serviceOutPath.setDeptName(serviceSubtask.getDeptname());
+                        serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname());
                         iServiceOutPathService.insertServiceOutPath(serviceOutPath);
 //                                sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "&param2=" + patid + "&param5=false");
                         //杞垚16杩涘埗
                         String format = String.format("%03X", serviceOutPath.getId());
                         serviceOutPath.setRadix(format);
                         serviceOutPath.setUpdateTime(new Date());
+                        serviceOutPath.setUrl(ip + ":" + req_path + "/sf?p=" + format);
                         iServiceOutPathService.updateServiceOutPath(serviceOutPath);
                         sendMagParam.setPhone(serviceSubtask.getPhone());
                         sendMagParam.setUrl(ip + ":" + req_path + "/sf?p=" + format);
-                        if (active.equals("ls") || active.equals("sltd") || active.equals("nhfy")) {
-                            sendMagParam.setContent("鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌闅忚璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "鏌ョ湅銆傛劅璋㈡偍閰嶅悎锛�");
-                        } else if (active.equals("xh")) {
-                            sendMagParam.setContent("銆愭柊鍗庡尰闄€�戞偍濂斤紝閭�璇锋偍濉啓鍑洪櫌闅忚璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "濉啓銆傛劅璋㈡偍閰嶅悎锛�");
-                        } else if (active.equals("hzszlyy")) {
-                            sendMagParam.setContent("銆愭澀宸炲競绗竴浜烘皯鍖婚櫌銆戞偍濂斤紝閭�璇锋偍濉啓鍑洪櫌璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "濉啓銆傛劅璋㈡偍閰嶅悎锛�");
+                        SysConfig sysConfig = new SysConfig();
+                        if (StringUtils.isNotEmpty(serviceSubtask.getServiceType()) && serviceSubtask.getServiceType().equals("6")) {
+                            sysConfig = sysConfigMapper.checkConfigKeyUnique("zymyd.sms.template");
+                        } else if (StringUtils.isNotEmpty(serviceSubtask.getServiceType()) && serviceSubtask.getServiceType().equals("14")) {
+                            sysConfig = sysConfigMapper.checkConfigKeyUnique("mzmyd.sms.template");
+                        } else {
+                            sysConfig = sysConfigMapper.checkConfigKeyUnique("wj.sms.template");
+                        }
+                        if (!Objects.isNull(sysConfig)) {
+                            String smsContemt = sysConfig.getConfigValue();
+//                          sendMagParam.setContent("鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌闅忚璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "鏌ョ湅銆傛劅璋㈡偍閰嶅悎锛�");
+                            sendMagParam.setContent(smsContemt.replace("${wjurl}", sendMagParam.getUrl()));
                         }
 
                     } else if (type == 2) {
@@ -328,10 +347,16 @@
 //                                serviceOutPath.setParam3(URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()));
                         serviceOutPath.setParam3(ivrTask1.getTaskName());
                         serviceOutPath.setCreateTime(new Date());
+                        serviceOutPath.setOrgid(serviceSubtask.getOrgid());
+                        serviceOutPath.setDeptCode(serviceSubtask.getDeptcode());
+                        serviceOutPath.setWardCode(serviceSubtask.getLeavehospitaldistrictcode());
+                        serviceOutPath.setDeptName(serviceSubtask.getDeptname());
+                        serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname());
                         iServiceOutPathService.insertServiceOutPath(serviceOutPath);
                         String format = String.format("%03X", serviceOutPath.getId());
                         serviceOutPath.setRadix(format);
                         serviceOutPath.setUpdateTime(new Date());
+                        serviceOutPath.setUrl(StringUtils.isNotEmpty(req_path) ? ip + ":" + req_path + "/wt?p=" + format : ip + "/wt?p=" + format);
                         iServiceOutPathService.updateServiceOutPath(serviceOutPath);
 //                                sendMagParam.setUrl(ip + ":" + req_path + "/outsideChainwt?param1=" + taskId + "&param2=" + patid + "&param3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "&param5=false");
                         sendMagParam.setPhone(serviceSubtask.getPhone());
@@ -340,14 +365,19 @@
                         //濡傛灉type鏄闊抽殢璁跨殑璇濓紙璇存槑琛ュ伩鍙戦�佹柟寮忎腑鏈夌數璇濋殢璁跨殑鏂瑰紡锛岃繖閲岀殑澶栭摼灏卞湴鍧�鍙兘鐢�/sf锛�
                         if (serviceSubtask.getType().equals("1"))
                             sendMagParam.setUrl(StringUtils.isNotEmpty(req_path) ? ip + ":" + req_path + "/sf?p=" + format : ip + "/sf?p=" + format);
-                        if (active.equals("ls") || active.equals("sltd") || active.equals("nhfy")) {
-                            sendMagParam.setContent("鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "鏌ョ湅銆傛劅璋㈡偍閰嶅悎锛�");
-                        } else if (active.equals("xh")) {
-                            sendMagParam.setContent("銆愭柊鍗庡尰闄€�戞偍濂斤紝閭�璇锋偍濉啓鍑洪櫌璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "濉啓銆傛劅璋㈡偍閰嶅悎锛�");
-                        } else if (active.equals("druid")) {
-                            sendMagParam.setContent("鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "濉啓銆傛劅璋㈡偍閰嶅悎锛�");
-                        } else if (active.equals("hzszlyy")) {
-                            sendMagParam.setContent("銆愭澀宸炲競绗竴浜烘皯鍖婚櫌銆戞偍濂斤紝閭�璇锋偍濉啓鍑洪櫌璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "濉啓銆傛劅璋㈡偍閰嶅悎锛�");
+
+                        SysConfig sysConfig = new SysConfig();
+                        if (StringUtils.isNotEmpty(serviceSubtask.getServiceType()) && serviceSubtask.getServiceType().equals("6")) {
+                            sysConfig = sysConfigMapper.checkConfigKeyUnique("zymyd.sms.template");
+                        } else if (StringUtils.isNotEmpty(serviceSubtask.getServiceType()) && serviceSubtask.getServiceType().equals("14")) {
+                            sysConfig = sysConfigMapper.checkConfigKeyUnique("mzmyd.sms.template");
+                        } else {
+                            sysConfig = sysConfigMapper.checkConfigKeyUnique("wj.sms.template");
+                        }
+                        if (!Objects.isNull(sysConfig)) {
+                            String smsContemt = sysConfig.getConfigValue();
+//                          sendMagParam.setContent("鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌闅忚璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "鏌ョ湅銆傛劅璋㈡偍閰嶅悎锛�");
+                            sendMagParam.setContent(smsContemt.replace("${wjurl}", sendMagParam.getUrl()));
                         }
                     } else if (type == 3) {
                         //瀹f暀
@@ -357,6 +387,11 @@
                         serviceOutPath.setParam6(subId);
                         serviceOutPath.setParam3(ivrTask1.getTaskName());
                         serviceOutPath.setCreateTime(new Date());
+                        serviceOutPath.setOrgid(serviceSubtask.getOrgid());
+                        serviceOutPath.setDeptCode(serviceSubtask.getDeptcode());
+                        serviceOutPath.setWardCode(serviceSubtask.getLeavehospitaldistrictcode());
+                        serviceOutPath.setDeptName(serviceSubtask.getDeptname());
+                        serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname());
                         iServiceOutPathService.insertServiceOutPath(serviceOutPath);
                         String format = String.format("%03X", serviceOutPath.getId());
                         serviceOutPath.setRadix(format);
@@ -367,13 +402,22 @@
                         if (heLibrary.getHetype().equals("1")) {
                             sendMagParam.setPhone(serviceSubtask.getPhone());
                             sendMagParam.setUrl(StringUtils.isNotEmpty(req_path) ? ip + ":" + req_path + "/xj?p=" + format : ip + "/xj?p=" + format);
-                            if (active.equals("ls") || active.equals("sltd") || active.equals("nhfy")) {
-                                sendMagParam.setContent("鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌瀹f暀璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "鏌ョ湅銆傛劅璋㈡偍閰嶅悎锛�");
-                            } else if (active.equals("xh")) {
-                                sendMagParam.setContent("銆愭柊鍗庡尰闄€�戞偍濂斤紝閭�璇锋偍濉啓鍑洪櫌瀹f暀璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "鏌ョ湅銆傛劅璋㈡偍閰嶅悎锛�");
-                            } else if (active.equals("hzszlyy")) {
-                                sendMagParam.setContent("銆愭澀宸炲競绗竴浜烘皯鍖婚櫌銆戞偍濂斤紝閭�璇锋偍濉啓鍑洪櫌瀹f暀璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "濉啓銆傛劅璋㈡偍閰嶅悎锛�");
+
+
+                            SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique("xj.sms.template");
+                            if (!Objects.isNull(sysConfig)) {
+                                String smsContemt = sysConfig.getConfigValue();
+//                              sendMagParam.setContent("鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌瀹f暀璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "鏌ョ湅銆傛劅璋㈡偍閰嶅悎锛�");
+                                sendMagParam.setContent(smsContemt.replace("${xjurl}", sendMagParam.getUrl()));
+
                             }
+//                            if (active.equals("ls") || active.equals("sltd") || active.equals("nhfy")) {
+//                                sendMagParam.setContent("鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌瀹f暀璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "鏌ョ湅銆傛劅璋㈡偍閰嶅悎锛�");
+//                            } else if (active.equals("xh")) {
+//                                sendMagParam.setContent("銆愭柊鍗庡尰闄€�戞偍濂斤紝閭�璇锋偍濉啓鍑洪櫌瀹f暀璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "鏌ョ湅銆傛劅璋㈡偍閰嶅悎锛�");
+//                            } else if (active.equals("hzszlyy")) {
+//                                sendMagParam.setContent("銆愭澀宸炲競绗竴浜烘皯鍖婚櫌銆戞偍濂斤紝閭�璇锋偍濉啓鍑洪櫌瀹f暀璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "濉啓銆傛劅璋㈡偍閰嶅悎锛�");
+//                            }
                         } else if (heLibrary.getHetype().equals("2")) {
                             //閫氱煡
                             String sc = getSC(serviceSubtask, heLibrary.getPreachcontent());
@@ -386,15 +430,28 @@
                     String s = null;
                     if (active.equals("xh")) {
                         //鏂板崕鐨勭煭淇″彂閫佹柟寮�
-                        Map<String, String> req = new HashMap<>();
-                        req.put("phone", sendMagParam.getPhone());
-                        req.put("content", sendMagParam.getContent());
-                        log.info("content杩斿洖鍊肩殑鍐呭鏄細{}", sendMagParam.getContent());
-                        s = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(req));
-                    } else if (active.equals("ls")) {
-//                        String url = configService.selectConfigByKey("token.360", serviceSubtask.getOrgid());
-//                        log.info("-------00token.360鐨刄RL涓猴細{}", url);
+                        Map<String, String> map2 = new HashMap<String, String>();
+                        map2.put("action", "send");
+                        map2.put("account", xhsmsAccount);
+                        map2.put("password", xhsmsPwd);
+                        map2.put("mobile", sendMagParam.getPhone());
+                        map2.put("content", sendMagParam.getContent());
+                        map2.put("extno", xhsmsjrm);
+                        map2.put("rt", "json");
+                        StringBuilder encodedParams = new StringBuilder();
 
+                        for (Map.Entry<String, String> entry : map2.entrySet()) {
+                            if (encodedParams.length() > 0) {
+                                encodedParams.append("&");
+                            }
+                            // 瀵归敭鍜屽�艰繘琛孶RL缂栫爜
+                            String encodedKey = URLEncoder.encode(entry.getKey(), "UTF-8");
+                            String encodedValue = URLEncoder.encode(entry.getValue(), "UTF-8");
+                            encodedParams.append(encodedKey).append("=").append(encodedValue);
+                        }
+                        Boolean isSuccess = HttpUtil.postJsonRequest(xhsmsPath, encodedParams.toString());
+                        if (isSuccess) s = "true";
+                    } else if (active.equals("ls")) {
                         //涓芥按鐨勭煭淇″彂閫佹柟寮�
                         SysConfig config = new SysConfig();
                         config.setConfigKey("ls.msg.info");
@@ -466,7 +523,8 @@
                         String sign = Md5Utils.hash(xhsmsAccount + timestamp + Md5Utils.hash(xhsmsPwd));
                         String content = sendMagParam.getContent();
                         String jsonMsg = "{" + "\"userName\": \"" + xhsmsAccount + "\"," + "\"content\": \"" + content + "\"," + "\"phoneList\": [" + sendMagParam.getPhone() + "]," + "\"timestamp\": " + timestamp + "," + "\"sign\": \"" + sign + "\"" + "}";
-                        s = HttpUtil.postJsonRequest(xhsmsPath, jsonMsg);
+                        Boolean b = HttpUtil.postJsonRequest(xhsmsPath, jsonMsg);
+                        if (b) s = "true";
                         log.info("------甯備竴鐭俊鍙戦�佺殑鍊间负锛歿}", s);
                         if (StringUtils.isNotEmpty(s)) {
                             JSONObject jsonObject = JSONObject.parseObject(s);
@@ -519,7 +577,7 @@
                 RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
                 String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key);
                 String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key);
-
+                String subId = rsaPublicKeyExample.encryptedData(serviceSubtask.getId().toString(), pub_key);
                 try {
                     SendMagParam sendMagParam = new SendMagParam();
                     sendMagParam.setType("5");
@@ -530,7 +588,13 @@
                         ServiceOutPath serviceOutPath = new ServiceOutPath();
                         serviceOutPath.setParam1(taskId);
                         serviceOutPath.setParam2(patid);
+                        serviceOutPath.setParam6(subId);
                         serviceOutPath.setCreateTime(new Date());
+                        serviceOutPath.setOrgid(serviceSubtask.getOrgid());
+                        serviceOutPath.setDeptCode(serviceSubtask.getDeptcode());
+                        serviceOutPath.setWardCode(serviceSubtask.getLeavehospitaldistrictcode());
+                        serviceOutPath.setDeptName(serviceSubtask.getDeptname());
+                        serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname());
                         iServiceOutPathService.insertServiceOutPath(serviceOutPath);
                         String format = String.format("%03X", serviceOutPath.getId());
                         serviceOutPath.setRadix(format);
@@ -543,7 +607,13 @@
                         serviceOutPath.setParam1(taskId);
                         serviceOutPath.setParam2(patid);
                         serviceOutPath.setParam3(ivrTask1.getTaskName());
+                        serviceOutPath.setParam6(subId);
                         serviceOutPath.setCreateTime(new Date());
+                        serviceOutPath.setOrgid(serviceSubtask.getOrgid());
+                        serviceOutPath.setDeptCode(serviceSubtask.getDeptcode());
+                        serviceOutPath.setWardCode(serviceSubtask.getLeavehospitaldistrictcode());
+                        serviceOutPath.setDeptName(serviceSubtask.getDeptname());
+                        serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname());
                         iServiceOutPathService.insertServiceOutPath(serviceOutPath);
                         String format = String.format("%03X", serviceOutPath.getId());
                         serviceOutPath.setRadix(format);
@@ -559,7 +629,13 @@
                         serviceOutPath.setParam1(taskId);
                         serviceOutPath.setParam2(patid);
                         serviceOutPath.setParam3(ivrTask1.getTaskName());
+                        serviceOutPath.setParam6(subId);
                         serviceOutPath.setCreateTime(new Date());
+                        serviceOutPath.setDeptCode(serviceSubtask.getDeptcode());
+                        serviceOutPath.setWardCode(serviceSubtask.getLeavehospitaldistrictcode());
+                        serviceOutPath.setDeptName(serviceSubtask.getDeptname());
+                        serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname());
+                        serviceOutPath.setOrgid(serviceSubtask.getOrgid());
                         iServiceOutPathService.insertServiceOutPath(serviceOutPath);
                         String format = String.format("%03X", serviceOutPath.getId());
                         serviceOutPath.setRadix(format);
@@ -610,7 +686,7 @@
                     String wxCode = "";
                     if (active.equals("hzszlyy")) {
                         wxCode = smsUtils.sendChat(url, patArchive.getTelcode(), serviceSubtask.getSfzh());
-                        log.info(wxCode);
+                        log.info("wxCode鐨勫�间负:{}", wxCode);
                     } else {
                         wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskName(), patArchive.getTelcode(), patArchive.getName(), patArchive.getPatidHis(), wxqqxx);
                         log.error("wxCode鐨勫�间负:{}", wxCode);

--
Gitblit v1.9.3