From 56f75efb1c55a6b40955af3067556bf797b54b4f Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期六, 15 八月 2026 15:31:06 +0800
Subject: [PATCH] 【丽水】随访超时处理
---
ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java | 133 +++++++++++++++++++++++++++++++++++---------
1 files changed, 105 insertions(+), 28 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 7895fd3..3968974 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
@@ -13,10 +13,7 @@
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.*;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.common.utils.sign.Md5Utils;
import com.ruoyi.common.utils.sms.smsUtils;
@@ -42,6 +39,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;
@@ -110,6 +108,9 @@
@Value("${xhsmsPwd}")
private String xhsmsPwd;
+ // 铏氭嫙鎺ュ叆鐮�
+ @Value("${xhsmsjrm}")
+ private String xhsmsjrm;
@Value("${server.port}")
private String port;
@@ -305,21 +306,27 @@
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 + "¶m2=" + patid + "¶m5=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);
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")) {
+ } else if (StringUtils.isNotEmpty(serviceSubtask.getServiceType()) && serviceSubtask.getServiceType().equals("14")) {
sysConfig = sysConfigMapper.checkConfigKeyUnique("mzmyd.sms.template");
- }else {
+ } else {
sysConfig = sysConfigMapper.checkConfigKeyUnique("wj.sms.template");
}
if (!Objects.isNull(sysConfig)) {
@@ -337,10 +344,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 + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false");
sendMagParam.setPhone(serviceSubtask.getPhone());
@@ -353,9 +366,9 @@
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")) {
+ } else if (StringUtils.isNotEmpty(serviceSubtask.getServiceType()) && serviceSubtask.getServiceType().equals("14")) {
sysConfig = sysConfigMapper.checkConfigKeyUnique("mzmyd.sms.template");
- }else {
+ } else {
sysConfig = sysConfigMapper.checkConfigKeyUnique("wj.sms.template");
}
if (!Objects.isNull(sysConfig)) {
@@ -371,6 +384,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);
@@ -409,15 +427,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");
@@ -459,16 +490,18 @@
if (active.equals("sltd")) {
data = MessageSend.sendMsg(sendMagParam.getContent(), "6", sendMagParam.getPhone(), LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
if (StringUtils.isNotEmpty(data)) {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode root = mapper.readTree(data);
- String status = root.get("result").get(0).get("status").asText();
- if (status.equals("00000")) {
- s = "true";
- } else {
- setFailPreachForm(serviceSubtask, sendPreachform, "鐭俊鍙戦�佸け璐�: " + data, "5");
- throw new BaseException("鐭俊鍙戦�佸け璐�");
+ String[] pairs = data.split("&");
+ String resultVal = null;
+ for (String pair : pairs) {
+ String[] kv = pair.split("=", 2);
+ if ("result".equals(kv[0])) {
+ resultVal = kv.length > 1 ? kv[1] : null;
+ break;
+ }
}
-
+ if ("0".equals(resultVal)) {
+ s = "true";
+ }
} else {
setFailPreachForm(serviceSubtask, sendPreachform, "鐭俊鍙戦�佸け璐�: " + data, "5");
throw new BaseException("鐭俊鍙戦�佸け璐�");
@@ -489,7 +522,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);
@@ -542,7 +576,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");
@@ -553,7 +587,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);
@@ -566,7 +606,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);
@@ -582,7 +628,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);
@@ -882,7 +934,8 @@
serviceSubtaskPreachform1.setRemark(remark);
serviceSubtaskPreachformMapper.updateServiceSubtaskPreachform(serviceSubtaskPreachform1);
//濡傛灉褰撳墠鐨刾reachform宸茬粡鏄渶鍚庝竴涓簡,骞朵笖鏈杩樻槸鍙戦�佸け璐ワ紝閭g洿鎺ュ皢serviceSubtask鐨剆endstate鐘舵�佹敼鎴�5灏辫浜�(鍏ㄥけ璐ヤ簡)
- if (CollectionUtils.isNotEmpty(spSize) && serviceSubtaskPreachform1.getSort() == spSize.size()) {
+ if (CollectionUtils.isNotEmpty(spSize) && serviceSubtaskPreachform1.getSort() == spSize.size()
+ && isSubtaskDeadline(serviceSubtask, serviceSubtaskPreachforms)) {
if (serviceSubtaskPreachform1.getSort() == spSize.size()) {
if (failSendstate.equals("4") || failSendstate.equals("5")) {
serviceSubtask.setCurrentPreachform(preachform);
@@ -1034,4 +1087,28 @@
}
return toHex(md5.digest());
}
+
+ /**
+ * 闅忚浠诲姟鏄惁瓒呮椂
+ * @param serviceSubtask
+ * @param serviceSubtaskPreachforms
+ * @return
+ */
+ public boolean isSubtaskDeadline(ServiceSubtask serviceSubtask, List<ServiceSubtaskPreachform> serviceSubtaskPreachforms){
+ if (Objects.isNull(serviceSubtask) || CollectionUtils.isEmpty(serviceSubtaskPreachforms)) {
+ return false;
+ }
+ // 鍩哄噯鏃跺埢锛氬嚭闄㈡椂闂� + 鍙戦�佹棩锛坰endDay 缂虹渷鎸� 1锛夛紝骞跺厹搴曢伩鍏� NPE/鑴忔暟鎹�
+ ServiceTask serviceTask = serviceTaskMapper.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
+ int sendDay = serviceTask != null && serviceTask.getSendDay() != null ? serviceTask.getSendDay().intValue() : 1;
+ Date deadline = DateUtils.addDays(serviceSubtask.getEndtime(), sendDay);
+ int sumCompensateTime = CollectionUtils.isEmpty(serviceSubtaskPreachforms) ? 0 : serviceSubtaskPreachforms.stream()
+ .mapToInt(x -> x.getCompensateTime() == null ? 0 : Integer.parseInt(x.getCompensateTime()))
+ .sum();
+ sumCompensateTime = sumCompensateTime + 1;
+ // 鍙ˉ鍋挎渶鍚庝竴姝ヨ嚜韬殑琛ュ伩鏃堕棿锛堝ぉ锛夛紝鑴忓�间竴寰嬫寜 0 鍏滃簳
+ deadline = DateUtils.addDays(deadline, sumCompensateTime);
+ // 鍑洪櫌(鍙戦��)鏃堕棿 + 鏈琛ュ伩鏃堕棿 灏忎簬褰撳墠鏃堕棿 -> 瓒呮椂
+ return deadline.getTime() < new Date().getTime();
+ }
}
--
Gitblit v1.9.3