From baed560033551773f244a1f16c81a4b5c9cca75c Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期五, 09 五月 2025 10:09:42 +0800
Subject: [PATCH] 代码提交

---
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java |  162 ++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 126 insertions(+), 36 deletions(-)

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 b163b85..d35f49d 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
@@ -1,8 +1,6 @@
 package com.ruoyi.quartz.task;
 
-import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
-import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.reflect.TypeToken;
@@ -10,19 +8,19 @@
 import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
 import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.enums.MsgLSEnum;
 import com.ruoyi.common.enums.ServiceFromEnum;
-import com.ruoyi.common.utils.DtoConversionUtils;
+import com.ruoyi.common.enums.WxGZHEnum;
+import com.ruoyi.common.exception.base.BaseException;
 import com.ruoyi.common.utils.HttpUtil;
 import com.ruoyi.common.utils.RSAPublicKeyExample;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.http.HttpUtils;
-import com.smartor.common.SendService;
 import com.smartor.domain.*;
 import com.smartor.mapper.ServiceSubtaskMapper;
 import com.smartor.mapper.ServiceTaskMapper;
 import com.smartor.mapper.SysUserImportMapper;
 import com.smartor.service.*;
-import com.sun.org.apache.bcel.internal.generic.NEW;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.ObjectUtils;
@@ -35,12 +33,12 @@
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Type;
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.security.MessageDigest;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
@@ -50,6 +48,8 @@
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
+
+import static cn.hutool.core.convert.Convert.toHex;
 
 /**
  * 瀹氭椂浠诲姟璋冨害娴嬭瘯
@@ -98,9 +98,6 @@
     @Value("${pub_key}")
     private String pub_key;
 
-    @Value("${thirdWXUrl}")
-    private String thirdWXUrl;
-
     @Value("${req_path}")
     private String req_path;
 
@@ -142,6 +139,9 @@
 
     @Value("${appid}")
     private String appid;
+
+    @Value("${server.port}")
+    private String port;
 
     public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
         System.out.println(StringUtils.format("鎵ц澶氬弬鏂规硶锛� 瀛楃涓茬被鍨媨}锛屽竷灏旂被鍨媨}锛岄暱鏁村瀷{}锛屾诞鐐瑰瀷{}锛屾暣褰}", s, b, l, d, i));
@@ -248,11 +248,13 @@
      * 澶勭悊鎮h�呬俊鎭紝杩涘叆瀛愪换鍔¤〃
      */
     public void dealOutHospInfo() {
-        //鍑洪櫌琛�
-        iPatMedInhospService.dealOutHospInfo();
-        //闂ㄨ瘖琛�
-        if (visitHosp != 1) {
-            iPatMedOuthospService.dealOutpatientInfo();
+        if (port.equals("8095")) {
+            //鍑洪櫌琛�
+            iPatMedInhospService.dealOutHospInfo();
+            //闂ㄨ瘖琛�
+            if (visitHosp != 1) {
+                iPatMedOuthospService.dealOutpatientInfo();
+            }
         }
     }
 
@@ -261,17 +263,19 @@
      * 澶勭悊鎵嬫湳淇℃伅锛岃繘鍏ュ瓙浠诲姟琛�
      */
     public void dealOperationInfo() {
-        iPatMedOperationService.dealOperationInfo();
+        if (port.equals("8095")) iPatMedOperationService.dealOperationInfo();
+
     }
 
     /**
      * 澶勭悊鎮h�呬俊鎭紝杩涘叆瀛愪换鍔¤〃(寰俊灏忕▼搴�)
      */
     public void dealOutHospInfoXHC() {
-        PatMedInhosp patMedInhosp = new PatMedInhosp();
-        //鑾峰彇鏈鐞嗙殑鏁版嵁
-        List<ServicePatientTemp> servicePatientTemps = iServicePatientTempService.selectServicePatientTempList(new ServicePatientTemp());
-
+        if (port.equals("8095")) {
+            PatMedInhosp patMedInhosp = new PatMedInhosp();
+            //鑾峰彇鏈鐞嗙殑鏁版嵁
+            List<ServicePatientTemp> servicePatientTemps = iServicePatientTempService.selectServicePatientTempList(new ServicePatientTemp());
+        }
     }
 
 
@@ -470,10 +474,35 @@
                                 sendMagParam.setPhone(serviceSubtask.getPhone());
                                 sendMagParam.setUrl(ip + ":" + req_path + "/wt?p=" + format);
                                 sendMagParam.setContent("銆愭柊鍗庡尰闄€�戞偍濂斤紝閭�璇锋偍濉啓鍑洪櫌璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "濉啓銆傛劅璋㈡偍閰嶅悎锛�");
-                                Map<String, String> req = new HashMap<>();
-                                req.put("phone", sendMagParam.getPhone());
-                                req.put("content", sendMagParam.getContent());
-                                String isSuccess = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(req));
+                                String isSuccess = null;
+                                if (visitHosp == 1) {
+                                    Map<String, String> req = new HashMap<>();
+                                    req.put("phone", sendMagParam.getPhone());
+                                    req.put("content", sendMagParam.getContent());
+                                    isSuccess = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(req));
+                                } else if (visitHosp == 2) {
+                                    //涓芥按鐨勭煭淇″彂閫佹柟寮�
+                                    String address = MsgLSEnum.getAddressByCode(serviceSubtask.getOrgid());
+                                    if (StringUtils.isEmpty(address)) {
+                                        ServiceSubtask ss = new ServiceSubtask();
+                                        ss.setResult("error");
+                                        ss.setRemark("鐭俊鍙戦�佸け璐�,璇ユ満鏋勬病鏈夐厤缃煭淇″湴鍧�");
+                                        ss.setSendstate(5L);
+                                        ss.setId(serviceSubtask.getId());
+                                        ss.setFinishtime(new Date());
+                                        serviceSubtaskMapper.updateServiceSubtask(ss);
+                                        continue;
+                                    }
+                                    log.error("---------涓芥按鐭俊鍙戦�佸叆鍙俛ddress锛歿},  sendMagParam:{},  orgid:{}-------", address,sendMagParam,serviceSubtask.getOrgid());
+                                    String dxCode = getDXCode(address, sendMagParam.getPhone(), sendMagParam.getContent(), "", "", MsgLSEnum.getHeaderByCode(serviceSubtask.getOrgid()));
+                                    log.error("---------涓芥按鐭俊鍙戦�佺粨鏋滐細{}-------", dxCode);
+                                    ObjectMapper objectMapper = new ObjectMapper();
+                                    Map<String, Object> textParam = objectMapper.readValue(dxCode, Map.class);
+                                    String code = textParam.get("code").toString();
+                                    if (code.equals("0")) {
+                                        isSuccess = "true";
+                                    }
+                                }
                                 //浠诲姟鍙戦�佽褰�
                                 ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord();
                                 serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString());
@@ -535,10 +564,32 @@
                                 url = ip + ":" + req_path + "/outsideChainwt?param1=" + taskId + "&param2=" + patid + "&param3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "&param5=false";
 //                                String wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskDesc(), "鏃�");
 
-                                String wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskDesc(), null, null, patArchive.getPatientno());
+                                //鑾峰彇寰俊鍏紬鍙疯姹備俊鎭牴鎹満鏋処D
+                                List<String> wxqqxx = WxGZHEnum.getDescByCode(patArchive.getOrgid());
+                                if (CollectionUtils.isEmpty(wxqqxx) || wxqqxx.size() < 4) {
+                                    ServiceSubtask ss = new ServiceSubtask();
+                                    ss.setResult("error");
+                                    ss.setRemark("璇ユ満鏋勭殑鍏紬鍙烽厤缃俊鎭笉鍏紝鏃犳硶閫氳繃鍏紬鍙峰彂閫�");
+                                    ss.setSendstate(5L);
+                                    ss.setId(serviceSubtask.getId());
+                                    ss.setFinishtime(new Date());
+                                    serviceSubtaskMapper.updateServiceSubtask(ss);
+                                    continue;
+                                }
+
+                                if (StringUtils.isEmpty(patArchive.getPatidHis())) {
+                                    ServiceSubtask ss = new ServiceSubtask();
+                                    ss.setResult("error");
+                                    ss.setRemark("鍏紬鍙峰彂閫佸け璐�,his绯荤粺鐨勬偅鑰卛d涓虹┖");
+                                    ss.setSendstate(5L);
+                                    ss.setId(serviceSubtask.getId());
+                                    ss.setFinishtime(new Date());
+                                    serviceSubtaskMapper.updateServiceSubtask(ss);
+                                    continue;
+                                }
+                                String wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskDesc(), patArchive.getTelcode(), serviceSubtask.getSendname(), patArchive.getPatidHis(), wxqqxx);
 
                                 Map<String, Object> map = JSONObject.parseObject(wxCode, Map.class);
-
                                 //浠诲姟鍙戦�佽褰�
                                 ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord();
                                 serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString());
@@ -792,27 +843,66 @@
         return key;
     }
 
-    private String getWXCode(String idcard, String url, String taskName, String taskDesc, String Medcardno, String setPatientname, String setPatientid) {
+    private String getDXCode(String address, String ShouJiHM, String FaSongNR, String FaSongRID, String FaSongRXM, Map<String, Object> headerMap) {
+        Map<String, Object> map = new LinkedHashMap<>();
+
+        Map<String, Object> YeWuXX = new LinkedHashMap<>();
+        Map<String, Object> DuanXinXX = new LinkedHashMap<>();
+        DuanXinXX.put("ShouJiHM", ShouJiHM);
+        DuanXinXX.put("FaSongNR", FaSongNR);
+        DuanXinXX.put("FaSongRID", FaSongRID);
+        DuanXinXX.put("FaSongRXM", FaSongRXM);
+        YeWuXX.put("DuanXinXX", DuanXinXX);
+
+        map.put("XiaoXiTou", headerMap);
+        map.put("DuanXinXX", DuanXinXX);
+
+        String body = new Gson().toJson(map);
+
+        String result = HttpUtils.sendPost(address, body);
+        log.error("--------result鐨勫�间负锛歿}-----", result);
+
+        JSONObject jsonObject = JSONObject.parseObject(result);
+        String code = (String) jsonObject.toString();
+        return code;
+    }
+
+
+    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(taskName);
-        xinHuaWXReq.setMedcardno(Medcardno);
+        xinHuaWXReq.setMobile(phone);
+        xinHuaWXReq.setMedcardno(null);
         xinHuaWXReq.setTitlename(taskName);
         xinHuaWXReq.setContent(taskDesc);
-        xinHuaWXReq.setAppid(appid);
+        xinHuaWXReq.setAppid(wxqqxx.get(1));
         log.error("----getWXCode---xinHuaWXReq鐨勫嚭鍙備负锛歿}", xinHuaWXReq);
-        String result = HttpUtils.sendPost(thirdWXUrl, new Gson().toJson(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);
+
         JSONObject jsonObject = JSONObject.parseObject(result);
         String code = (String) jsonObject.toString();
         return code;
     }
-//    public static void main(String[] args) {
-//        LocalDateTime originalDateTime = LocalDateTime.now();
-//        LocalDateTime startOfDay = originalDateTime.with(LocalTime.MIN);
-//        System.out.println("Original DateTime: " + originalDateTime);
-//        System.out.println("Start of Day: " + startOfDay);
-//    }
+
+
+    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