From 017d81089780c46a5e30489b1eb2e4cb8ffaf944 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 22 九月 2026 11:08:22 +0800
Subject: [PATCH] 【丽水】中医院短信推送->微信推送

---
 smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java |  125 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 125 insertions(+), 0 deletions(-)

diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
index bccc1e4..7afbcc6 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -10,9 +10,11 @@
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.core.service.IConfigService;
 import com.ruoyi.common.dx.MessageSend;
+import com.ruoyi.common.enums.WxGZHEnum;
 import com.ruoyi.common.exception.base.BaseException;
 import com.ruoyi.common.utils.*;
 import com.ruoyi.common.utils.http.HttpUtils;
+import com.ruoyi.common.utils.sms.smsUtils;
 import com.ruoyi.common.utils.spring.SpringUtils;
 import com.ruoyi.system.domain.SysConfig;
 import com.ruoyi.system.mapper.SysConfigMapper;
@@ -46,6 +48,9 @@
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.time.*;
@@ -56,6 +61,8 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
+
+import static cn.hutool.core.convert.Convert.toHex;
 
 /**
  * 鍗曚竴浠诲姟锛堥殢璁匡級Service涓氬姟灞傚鐞�
@@ -5096,6 +5103,12 @@
         String subId = rsaPublicKeyExample.encryptedData(serviceSubtask.getId().toString(), pub_key);
         String taskId = rsaPublicKeyExample.encryptedData(serviceSubtask.getTaskid().toString(), pub_key);
 
+        //涓芥按涓尰闄㈠彂閫佺殑鏄井淇″叕浼楀彿
+        if (StringUtils.isNotEmpty(serviceSubtask.getOrgid()) && serviceSubtask.getOrgid().equals("47231022633110211A2101")) {
+            resultMap = wechatSubTask(subid);
+            return resultMap;
+        }
+
         //鍙戦�佹暟鎹殑灏佽
         ServiceOutPath serviceOutPath = new ServiceOutPath();
         serviceOutPath.setParam1(taskId);
@@ -5140,6 +5153,82 @@
         return resultMap;
     }
 
+    public Map<String,Object> wechatSubTask(Long subid){
+        log.info("wechatSubTask鐨勫叆鍙備负锛歿}", subid);
+        Map<String, Object> resultMap = new HashMap<>();
+        resultMap.put("code", "500");
+        resultMap.put("msg", "鍙戦�佸け璐�");
+        try{
+            //鑾峰彇闅忚鐨勫熀鏈俊鎭�
+            ServiceSubtask serviceSubtask = selectServiceSubtaskById(subid);
+            //鑾峰彇鎮h�呬俊鎭�
+            PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(serviceSubtask.getPatid());
+
+            RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
+            String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key);
+            String subId = rsaPublicKeyExample.encryptedData(serviceSubtask.getId().toString(), pub_key);
+            String taskId = rsaPublicKeyExample.encryptedData(serviceSubtask.getTaskid().toString(), pub_key);
+            String url = localIP + ":" + req_path + "/outsideChainwt?param1=" + taskId + "&param2=" + patid + "&param3="
+                    + URLEncoder.encode(serviceSubtask.getTaskName(), StandardCharsets.UTF_8.toString()) + "&param5=false"
+                    + "$param6=" + subId;
+
+            ServiceOutPath serviceOutPath = new ServiceOutPath();
+            serviceOutPath.setParam1(taskId);
+            serviceOutPath.setParam2(patid);
+            serviceOutPath.setParam3(serviceSubtask.getTaskName());
+            serviceOutPath.setParam6(subId);
+            serviceOutPath.setCreateTime(new Date());
+            serviceOutPath.setOrgid(serviceSubtask.getOrgid());
+            iServiceOutPathService.insertServiceOutPath(serviceOutPath);
+            String format = String.format("%03X", serviceOutPath.getId());
+            serviceOutPath.setRadix(format);
+            serviceOutPath.setUpdateTime(new Date());
+            serviceOutPath.setUrl(url);
+            iServiceOutPathService.updateServiceOutPath(serviceOutPath);
+
+
+            //鑾峰彇寰俊鍏紬鍙疯姹備俊鎭牴鎹満鏋処D
+            List<String> wxqqxx = WxGZHEnum.getDescByCode(serviceSubtask.getOrgid());
+            if (CollectionUtils.isEmpty(wxqqxx) || wxqqxx.size() < 4) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "鍙戦�佸紓甯革細" + "銆愬叕浼楀彿銆戣鏈烘瀯鐨勫叕浼楀彿閰嶇疆淇℃伅涓嶅叏锛屾棤娉曢�氳繃鍏紬鍙峰彂閫�");
+                return resultMap;
+            }
+
+            if (StringUtils.isEmpty(serviceSubtask.getPatidHis())) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "鍙戦�佸紓甯革細" + "銆愬叕浼楀彿銆戝叕浼楀彿鍙戦�佸け璐�,his绯荤粺鐨勬偅鑰卛d涓虹┖");
+                return resultMap;
+            }
+            String wxCode = "";
+            wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskDesc(), patArchive.getTelcode(), serviceSubtask.getSendname(), patArchive.getPatidHis(), wxqqxx);
+            Map map = JSONObject.parseObject(wxCode, Map.class);
+            Boolean wxCodeSuccess = false;
+            if (!map.isEmpty() && map.get("succ") != null) {
+                wxCodeSuccess = (boolean) map.get("succ");
+            }
+
+            //鍙戦�佸畬鎴愬悗锛屼慨鏀圭姸鎬�
+            serviceSubtask.setSendstate(3L);
+            if (wxCodeSuccess) {
+                serviceSubtask.setResult("success");
+                resultMap.put("code", "200");
+                resultMap.put("msg", "鍙戦�佹垚鍔�");
+            } else {
+                log.error("銆恠fHandlle銆戝叕浼楀彿鍙戦�佸け璐ワ紝鎮h�呬俊鎭細{}锛岄敊璇俊鎭細{}", serviceSubtask, map.get("msg"));
+                resultMap.put("code", -1);
+                resultMap.put("message", "銆愬叕浼楀彿銆戝叕浼楀彿鍙戦�佸け璐�");
+                return resultMap;
+            }
+        } catch (Exception e) {
+            String guid = UUID.randomUUID().toString();
+            log.error("銆恠fHandlle銆戦暱鏈熶换鍔″叕浼楀彿鍙戦�佸け璐ワ紝鍘熷洜锛歿}锛孏UID锛歿}", e.getMessage(), guid);
+            resultMap.put("code", -1);
+            resultMap.put("message", "銆愬叕浼楀彿銆戦暱鏈熶换鍔″叕浼楀彿鍙戦�佸け璐ワ紝鍘熷洜锛�" + e.getMessage());
+            return resultMap;
+        }
+        return resultMap;
+    }
     @Override
     public List<ServiceSubtaskDetailRatioExport> statQuestionOption(List<Long> taskIds, Date startFinishTime, Date endFinishTime, Date startOutHospTime, Date endOutHospTime, String scriptContent, Double scoreStart, Double scoreEnd, String valueType) {
         //鍏堟竻鐞嗕竴涓嬮噸澶嶆暟鎹�
@@ -6447,4 +6536,40 @@
         }
         return list;
     }
+
+    private String getWXCode(String idcard, String url, String taskName, String taskDesc, String phone, String setPatientname, String setPatientid, List<String> wxqqxx) {
+        XinHuaWXReq xinHuaWXReq = new XinHuaWXReq();
+        xinHuaWXReq.setIdcard(idcard);
+        xinHuaWXReq.setUrl(url);
+        xinHuaWXReq.setPatientid(setPatientid);
+        xinHuaWXReq.setPatientname(setPatientname);
+        xinHuaWXReq.setMobile(phone);
+        xinHuaWXReq.setMedcardno(null);
+        xinHuaWXReq.setTitlename(taskName);
+        xinHuaWXReq.setContent(taskDesc);
+        xinHuaWXReq.setAppid(wxqqxx.get(1));
+        log.info("銆恎etWXCode銆戝井淇″叕浼楀彿璇锋眰鍙傛暟锛歿}", xinHuaWXReq);
+        String body = new Gson().toJson(xinHuaWXReq);
+        String encode = encode(wxqqxx.get(2).concat(body));
+        Map<String, String> headerMap = new HashMap<>();
+        headerMap.put("sign", encode);
+        String result = HttpUtils.sendPostByHeader(wxqqxx.get(3), body, headerMap);
+        log.info("銆恎etWXCode銆戝井淇″叕浼楀彿杩斿洖鍙傛暟锛歿}", result);
+        JSONObject jsonObject = JSONObject.parseObject(result);
+        String code = (String) jsonObject.toString();
+        return code;
+    }
+    public String encode(String arg) {
+        if (arg == null) {
+            arg = "";
+        }
+        MessageDigest md5 = null;
+        try {
+            md5 = MessageDigest.getInstance("MD5");
+            md5.update(arg.getBytes("UTF-8"));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return toHex(md5.digest());
+    }
 }

--
Gitblit v1.9.3