From 3cc02d185227daee7cd738ca9f713aab5025ec9b Mon Sep 17 00:00:00 2001 From: liusheng <337615773@qq.com> Date: 星期五, 09 五月 2025 16:21:47 +0800 Subject: [PATCH] 代码提交 --- ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java | 326 ++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 218 insertions(+), 108 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 ae1e75b..595000b 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 @@ -1,26 +1,32 @@ package com.ruoyi.web.component; -import com.alibaba.fastjson.JSON; +import afu.org.checkerframework.checker.oigj.qual.O; import com.alibaba.fastjson2.JSONObject; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.common.enums.MsgLSEnum; import com.ruoyi.common.enums.ServiceFromEnum; +import com.ruoyi.common.enums.WxGZHEnum; +import com.ruoyi.common.exception.base.BaseException; import com.ruoyi.common.utils.HttpUtil; +import com.ruoyi.common.utils.OkHttpExample; 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.config.RobotPhoneUtils; +import com.smartor.common.LSHospTokenUtil; import com.smartor.domain.*; +import com.smartor.mapper.PatArchiveMapper; import com.smartor.mapper.ServiceSubtaskMapper; import com.smartor.mapper.ServiceTaskMapper; import com.smartor.service.IBaseSmsaccountService; import com.smartor.service.IServiceOutPathService; import com.smartor.service.IServiceSubtaskRecordService; -import com.smartor.service.ISvyTaskTemplateService; +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; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.connection.Message; @@ -28,12 +34,15 @@ import org.springframework.data.redis.listener.RedisMessageListenerContainer; import org.springframework.stereotype.Component; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; +import java.io.IOException; +import java.security.MessageDigest; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; + +import static cn.hutool.core.convert.Convert.numberToWord; +import static cn.hutool.core.convert.Convert.toHex; @Slf4j @Component//鐩戝惉姝ら槦鍒� @@ -51,9 +60,6 @@ @Value("${req_path}") private String req_path; - @Value("${thirdWXUrl}") - private String thirdWXUrl; - @Autowired private IServiceOutPathService iServiceOutPathService; @@ -64,22 +70,16 @@ private ServiceTaskMapper ivrTaskMapper; @Autowired - private SendService sendService; + private PatArchiveMapper patArchiveMapper; @Autowired private RedisCache redisCache; - - @Autowired - private RobotPhoneUtils robotPhoneUtils; @Autowired private ServiceTaskMapper svyTaskMapper; @Autowired private ServiceSubtaskMapper serviceSubtaskMapper; - - @Autowired - private ISvyTaskTemplateService iSvyTaskTemplateService; @Autowired private IServiceSubtaskRecordService serviceSubtaskRecordService; @@ -89,6 +89,9 @@ @Value("${xhsmsPath}") private String xhsmsPath; + + @Value("${visitHosp}") + private Integer visitHosp; // 鍒涘缓鍥哄畾澶у皬鐨勭嚎绋嬫睜 private static final ExecutorService executorService = Executors.newFixedThreadPool(10); @@ -154,10 +157,11 @@ log.error("杩涗换鍔′簡鍚楋紵{}", commonTaskcallMQ); //鍒ゆ柇涓�涓媍ommonTaskcallMQ涓殑stopstate鏄惁涓巌vr_task涓殑涓�鑷达紝涓嶄竴鑷达紝鍒欒鏄庢槸鏆傚仠浜� ServiceTask ivrTask1 = ivrTaskMapper.selectServiceTaskByTaskid(commonTaskcallMQ.getTaskid()); - if (ivrTask1.getStopState() != commonTaskcallMQ.getStopState()) { - //灏嗘秷鎭粠闃熷垪涓墧闄� - return; - } + +// if (ivrTask1.getStopState() != commonTaskcallMQ.getStopState()) { +// //灏嗘秷鎭粠闃熷垪涓墧闄� +// return; +// } if (StringUtils.isNotEmpty(commonTaskcallMQ.getPreachform())) { //濡備綍浠诲姟鍙戦�佹柟寮忎笉涓虹┖ @@ -183,6 +187,9 @@ ivrTaskcall.setTaskid(commonTaskcallMQ.getTaskid()); ivrTaskcall.setSendstate(1L); List<ServiceSubtask> selectServiceSubtaskList = ivrTaskcallMapper.selectServiceSubtaskList(ivrTaskcall); + if (CollectionUtils.isEmpty(selectServiceSubtaskList)) { + continue; + } if (descByCode.equals("鐢佃瘽")) { for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) { //鍏堝垽鏂竴涓嬶紝subIds鏄惁涓虹┖锛屽鏋滀笉涓虹┖锛屽彧鎵цsubIds閲岀殑鎮h�� @@ -348,10 +355,40 @@ sendMagParam.setContent("銆愭柊鍗庡尰闄€�戞偍濂斤紝閭�璇锋偍濉啓鍑洪櫌瀹f暀璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "鏌ョ湅銆傛劅璋㈡偍閰嶅悎锛�"); } //鐭俊杩橀渶瑕佹ā鏉� - Map<String, String> req = new HashMap<>(); - req.put("phone", sendMagParam.getPhone()); - req.put("content", sendMagParam.getContent()); - String s = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(req)); + String s = null; + if (visitHosp == 1) { + //鏂板崕鐨勭煭淇″彂閫佹柟寮� + Map<String, String> req = new HashMap<>(); + req.put("phone", sendMagParam.getPhone()); + req.put("content", sendMagParam.getContent()); + s = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(req)); + } else if (visitHosp == 2) { + //涓芥按鐨勭煭淇″彂閫佹柟寮� + String address = MsgLSEnum.getAddressByCode(serviceSubtask.getOrgid()); + String token = LSHospTokenUtil.getToken(serviceSubtask.getOrgid()); + log.error("-----------token鐨勫�间负锛歿}",token); + 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("---------mq涓芥按鐭俊鍙戦�佸叆鍙俛ddress锛歿}, sendMagParam:{}, orgid:{}-------", address, sendMagParam, serviceSubtask.getOrgid()); + String dxCode = getDXCode(address, sendMagParam.getPhone(), sendMagParam.getContent(), "", "", MsgLSEnum.getHeaderByCode(serviceSubtask.getOrgid()),token); + 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")) { + s = "true"; + } else { + throw new BaseException(null); + } + } if (s.equals("true")) { ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString()); @@ -419,87 +456,100 @@ try { SendMagParam sendMagParam = new SendMagParam(); sendMagParam.setType("5"); - sendMagParam.setUrl(ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName() + "¶m5=false"); - log.info("閾炬帴瀹屾暣璺緞锛歿}", ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName() + "¶m5=false"); - //杩欎釜妯℃澘ID鍏堝啓姝伙紝鍚庨潰鍋氭垚鍙�� - sendMagParam.setTmpCode("oG3pJHPVWpE81DmZsua_2tKwgJ97r0qz37z56ns7NB4"); - Map map = new HashMap(); - map.put("first", ivrTask1.getTaskName()); - sendMagParam.setContent(JSON.toJSONString(map)); - sendMagParam.setOpenid(serviceSubtask.getOpenid()); - Boolean aBoolean = sendService.sendMsg(sendMagParam); String url = null; - -//// if (type == 1) { -//// url = ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"; -//// } else if (type == 2) { -//// url = ip + ":" + req_path + "/outsideChainwt?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"; -//// } else if (type == 3) { -//// url = ip + ":" + req_path + "/outsideChainxj?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"; -//// } -// if (type == 1) { -// //闅忚 -// ServiceOutPath serviceOutPath = new ServiceOutPath(); -// serviceOutPath.setParam1(taskId); -// serviceOutPath.setParam2(patid); -// serviceOutPath.setCreateTime(new Date()); -// iServiceOutPathService.insertServiceOutPath(serviceOutPath); -// String format = String.format("%03X", serviceOutPath.getId()); -// serviceOutPath.setRadix(format); -// serviceOutPath.setUpdateTime(new Date()); -// iServiceOutPathService.updateServiceOutPath(serviceOutPath); -//// sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid + "¶m5=false"); -// url = ip + ":" + req_path + "/sf?p=" + format; -// } else if (type == 2) { -// //闂埜 -// ServiceOutPath serviceOutPath = new ServiceOutPath(); -// serviceOutPath.setParam1(taskId); -// serviceOutPath.setParam2(patid); -//// serviceOutPath.setParam3(URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString())); -// serviceOutPath.setParam3(ivrTask1.getTaskName()); -// serviceOutPath.setCreateTime(new Date()); -// iServiceOutPathService.insertServiceOutPath(serviceOutPath); -// String format = String.format("%03X", serviceOutPath.getId()); -// serviceOutPath.setRadix(format); -// serviceOutPath.setUpdateTime(new Date()); -// iServiceOutPathService.updateServiceOutPath(serviceOutPath); -//// sendMagParam.setUrl(ip + ":" + req_path + "/outsideChainwt?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"); -// url = ip + ":" + req_path + "/wt?p=" + format; -// } else if (type == 3) { -// //瀹f暀 -// ServiceOutPath serviceOutPath = new ServiceOutPath(); -// serviceOutPath.setParam1(taskId); -// serviceOutPath.setParam2(patid); -//// serviceOutPath.setParam3(URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString())); -// serviceOutPath.setParam3(ivrTask1.getTaskName()); -// serviceOutPath.setCreateTime(new Date()); -// iServiceOutPathService.insertServiceOutPath(serviceOutPath); -// String format = String.format("%03X", serviceOutPath.getId()); -// serviceOutPath.setRadix(format); -// serviceOutPath.setUpdateTime(new Date()); -// iServiceOutPathService.updateServiceOutPath(serviceOutPath); -// url = ip + ":" + req_path + "/xj?p=" + format; -// } -// -// String wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskDesc(), "鏃�"); -// Map<String, Object> map = JSONObject.parseObject(wxCode, Map.class); -// if (!map.isEmpty()) { - serviceSubtask.setResult("success"); - serviceSubtask.setSendstate(3L); - if (aBoolean == false) { - ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); - serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString()); - serviceSubtaskRecord.setSubtaskId(serviceSubtask.getId()); - serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); - serviceSubtaskRecord.setTasktype(serviceSubtask.getType()); - serviceSubtaskRecord.setPreachform("5"); - serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); - serviceSubtaskRecord.setRemark(map.get("msg").toString()); - lssubIds.add(serviceSubtask.getId()); - serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); + Boolean aBoolean = false; + if (type == 1) { + //闅忚 + ServiceOutPath serviceOutPath = new ServiceOutPath(); + serviceOutPath.setParam1(taskId); + serviceOutPath.setParam2(patid); + serviceOutPath.setCreateTime(new Date()); + iServiceOutPathService.insertServiceOutPath(serviceOutPath); + String format = String.format("%03X", serviceOutPath.getId()); + serviceOutPath.setRadix(format); + serviceOutPath.setUpdateTime(new Date()); + iServiceOutPathService.updateServiceOutPath(serviceOutPath); + url = ip + ":" + req_path + "/sf?p=" + format; + } else if (type == 2) { + //闂埜 + ServiceOutPath serviceOutPath = new ServiceOutPath(); + serviceOutPath.setParam1(taskId); + serviceOutPath.setParam2(patid); +// serviceOutPath.setParam3(URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString())); + serviceOutPath.setParam3(ivrTask1.getTaskName()); + serviceOutPath.setCreateTime(new Date()); + iServiceOutPathService.insertServiceOutPath(serviceOutPath); + String format = String.format("%03X", serviceOutPath.getId()); + serviceOutPath.setRadix(format); + serviceOutPath.setUpdateTime(new Date()); + iServiceOutPathService.updateServiceOutPath(serviceOutPath); + url = ip + ":" + req_path + "/wt?p=" + format; + } else if (type == 3) { + //瀹f暀 + ServiceOutPath serviceOutPath = new ServiceOutPath(); + serviceOutPath.setParam1(taskId); + serviceOutPath.setParam2(patid); + serviceOutPath.setParam3(ivrTask1.getTaskName()); + serviceOutPath.setCreateTime(new Date()); + iServiceOutPathService.insertServiceOutPath(serviceOutPath); + String format = String.format("%03X", serviceOutPath.getId()); + serviceOutPath.setRadix(format); + serviceOutPath.setUpdateTime(new Date()); + iServiceOutPathService.updateServiceOutPath(serviceOutPath); + url = ip + ":" + req_path + "/xj?p=" + format; + } + PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(serviceSubtask.getPatid()); + 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; } -// } + + //鑾峰彇寰俊鍏紬鍙疯姹備俊鎭牴鎹満鏋処D + log.error("鑾峰彇寰俊鍏紬鍙疯姹備俊鎭牴鎹満鏋処D锛歿}", patArchive.getOrgid()); + 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; + } + + + String wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskName(), patArchive.getTelcode(), patArchive.getName(), patArchive.getPatidHis(), wxqqxx); + log.error("wxCode鐨勫�间负:{}", wxCode); + Map<String, Object> map = JSONObject.parseObject(wxCode, Map.class); + log.error("map鐨勫�间负:{}", map); + if (!map.isEmpty()) { + serviceSubtask.setResult("success"); + serviceSubtask.setSendstate(3L); + log.error("aBoolean鐨勫�间负:{}", aBoolean); + if (map.get("succ").toString().equals("true")) { + aBoolean = true; + } + if (aBoolean == false) { + ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); + serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString()); + serviceSubtaskRecord.setSubtaskId(serviceSubtask.getId()); + serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); + serviceSubtaskRecord.setTasktype(serviceSubtask.getType()); + serviceSubtaskRecord.setPreachform("5"); + serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); + serviceSubtaskRecord.setRemark(ObjectUtils.isNotEmpty(map.get("msg")) ? map.get("msg").toString() : null); + lssubIds.add(serviceSubtask.getId()); + serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); + continue; + } + } } catch (Exception e) { ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString()); @@ -625,19 +675,79 @@ return key; } - private String getWXCode(String idcard, String url, String taskName, String taskDesc, String submitprompt) { + private String getWXCode(String idcard, String url, String taskName, String taskDesc, String phone, String patientname, String setPatientid, List<String> wxqqxx) { XinHuaWXReq xinHuaWXReq = new XinHuaWXReq(); xinHuaWXReq.setIdcard(idcard); xinHuaWXReq.setUrl(url); - xinHuaWXReq.setKeyword1("娴欎腑鍖诲ぇ浜岄櫌鍑洪櫌闅忚"); - xinHuaWXReq.setKeyword2(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); - xinHuaWXReq.setKeyword3(taskName); - xinHuaWXReq.setKeyword4("鐤剧梾搴峰娉ㄦ剰浜嬮」"); + xinHuaWXReq.setPatientid(setPatientid); + xinHuaWXReq.setPatientname(patientname); + xinHuaWXReq.setMobile(phone); + xinHuaWXReq.setMedcardno(null); + xinHuaWXReq.setTitlename(taskName); + xinHuaWXReq.setContent(taskDesc); + xinHuaWXReq.setAppid(wxqqxx.get(1)); + log.error("-----寰俊鍏紬鍙风殑鍑哄弬涓�----锛歿}", xinHuaWXReq); +// new Gson().toJson(xinHuaWXReq); + GsonBuilder gb = new GsonBuilder(); + gb.disableHtmlEscaping(); + String body = gb.create().toJson(xinHuaWXReq); - String result = HttpUtils.sendPost(thirdWXUrl, new Gson().toJson(xinHuaWXReq)); + log.error("encode鐨勫叆鍙備负wxqqxx 锛歿}, body:{}", wxqqxx.get(2), body); + String encode = encode(wxqqxx.get(2).concat(body)); + log.error("--------encode鐨勫�间负锛歿}-----", encode); + Map<String, String> headerMap = new HashMap<>(); + headerMap.put("sign", encode); + String result = HttpUtils.sendPostByHeader(wxqqxx.get(3), body, headerMap); + log.error("--------result鐨勫�间负锛歿}-----", result); + JSONObject jsonObject = JSONObject.parseObject(result); String code = (String) jsonObject.toString(); return code; } + + private String getDXCode(String address, String ShouJiHM, String FaSongNR, String FaSongRID, String FaSongRXM, Map<String, Object> headerMap,String token) { + 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); + String result = null; + try { + result = OkHttpExample.sendPostRequest(address, body, token); + } catch (IOException e) { + e.printStackTrace(); + } + log.error("--------result鐨勫�间负锛歿}-----", 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