From c247e1f3d0b19f7c6db74165650a29f0539f4b10 Mon Sep 17 00:00:00 2001
From: BAOLH <baolh@yhzhg.cn>
Date: Fri, 24 Oct 2025 10:14:44 +0000
Subject: [PATCH] 企微通信redis锁问题修改
---
eladmin-master/eladmin-system/src/main/java/me/zhengjie/config/WxCpConfig.java | 6 ++----
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java | 12 ++++--------
eladmin-master/eladmin-system/src/main/resources/config/application.yml | 14 +++++++-------
3 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/config/WxCpConfig.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/config/WxCpConfig.java
index db9d710..e7ebc17 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/config/WxCpConfig.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/config/WxCpConfig.java
@@ -34,15 +34,13 @@
@Bean
public WxCpService wxCpService() {
-// // 默认缓存配置
-// WxCpDefaultConfigImpl configStorage = new WxCpDefaultConfigImpl();
-
WxCpDefaultConfigImpl configStorage;
if (wxCpProperties.getConfigStorage().getType().equals(WxCpProperties.StorageType.redistemplate)) {
// redis缓存配置
StringRedisTemplate redisTemplate = applicationContext.getBean(StringRedisTemplate.class);
configStorage = new WxCpRedisTemplateConfigImpl(redisTemplate, wxCpProperties.getConfigStorage().getKeyPrefix());
} else if (wxCpProperties.getConfigStorage().getType().equals(WxCpProperties.StorageType.jedis)) {
+ // jedis配置
WxCpRedisProperties wxCpRedisProperties = wxCpProperties.getConfigStorage().getRedis();
JedisPool jedisPool;
if (wxCpRedisProperties != null && StringUtils.isNotEmpty(wxCpRedisProperties.getHost())) {
@@ -52,7 +50,7 @@
}
configStorage = new WxCpJedisConfigImpl(jedisPool, wxCpProperties.getConfigStorage().getKeyPrefix());
} else {
- // 默认配置
+ // 默认缓存配置
configStorage = new WxCpDefaultConfigImpl();
}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java
index 4364299..e30a80f 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java
@@ -1167,10 +1167,8 @@
Map<String, String> robotParamMap = dictDetailRepository.findByDictName(Constant.WECOM_ROBOT_PARAM).stream().collect(Collectors.toMap(DictDetail::getLabel, DictDetail::getValue));
if (robotParamMap.containsKey(Constant.REMIND_REPORT_WEBHOOK_KEY) && robotParamMap.containsKey(Constant.REMIND_REPORT_MSG)) {
// 发送消息
- WxCpDefaultConfigImpl wxCpDefaultConfig = new WxCpDefaultConfigImpl();
- wxCpDefaultConfig.setWebhookKey(robotParamMap.get(Constant.REMIND_REPORT_WEBHOOK_KEY));
- wxCpService.setWxCpConfigStorage(wxCpDefaultConfig);
- wxCpService.getGroupRobotService().sendText(robotParamMap.get(Constant.REMIND_REPORT_MSG), Arrays.asList("@all"), Arrays.asList());
+ String webhookUrl = wxCpService.getWxCpConfigStorage().getApiUrl("/cgi-bin/webhook/send?key=") + robotParamMap.get(Constant.REMIND_REPORT_WEBHOOK_KEY);
+ wxCpService.getGroupRobotService().sendText(webhookUrl, robotParamMap.get(Constant.REMIND_REPORT_MSG), Arrays.asList("@all"), Arrays.asList());
}
} catch (WxErrorException wxErrorException) {
wxErrorException.printStackTrace();
@@ -1223,10 +1221,8 @@
Map<String, String> robotParamMap = dictDetailRepository.findByDictName(Constant.WECOM_ROBOT_PARAM).stream().collect(Collectors.toMap(DictDetail::getLabel, DictDetail::getValue));
if (robotParamMap.containsKey(Constant.REMIND_REPORT_WEBHOOK_KEY) && robotParamMap.containsKey(Constant.REMIND_REPORT_SUCCESS_MSG)) {
// 发送周报生成成功消息
- WxCpDefaultConfigImpl wxCpDefaultConfig = new WxCpDefaultConfigImpl();
- wxCpDefaultConfig.setWebhookKey(robotParamMap.get(Constant.REMIND_REPORT_WEBHOOK_KEY));
- wxCpService.setWxCpConfigStorage(wxCpDefaultConfig);
- wxCpService.getGroupRobotService().sendText(robotParamMap.get(Constant.REMIND_REPORT_SUCCESS_MSG), Arrays.asList("@all"), Arrays.asList());
+ String webhookUrl = wxCpService.getWxCpConfigStorage().getApiUrl("/cgi-bin/webhook/send?key=") + robotParamMap.get(Constant.REMIND_REPORT_WEBHOOK_KEY);
+ wxCpService.getGroupRobotService().sendText(webhookUrl, robotParamMap.get(Constant.REMIND_REPORT_SUCCESS_MSG), Arrays.asList("@all"), Arrays.asList());
}
} catch (WxErrorException wxErrorException) {
wxErrorException.printStackTrace();
diff --git a/eladmin-master/eladmin-system/src/main/resources/config/application.yml b/eladmin-master/eladmin-system/src/main/resources/config/application.yml
index afccebb..e5fb944 100644
--- a/eladmin-master/eladmin-system/src/main/resources/config/application.yml
+++ b/eladmin-master/eladmin-system/src/main/resources/config/application.yml
@@ -80,14 +80,14 @@
# 应用凭证
corp-secret: ${CORP_SECRET:nDCq9I6tSWAP-l2lbvgtK8_V5l1DpqFq88Gf67TK_-I}
config-storage:
- type: jedis
+ type: redistemplate
redis:
database: ${REDIS_DB:0}
- host: ${WXCP_REDIS_HOST:localhost}
+ host: ${REDIS_HOST:localhost}
port: ${REDIS_PORT:6379}
password: ${REDIS_PWD:}
- timeout: 2000
- max-active: 50
- max-idle: 20
- max-wait-millis: 1000
- min-idle: 10
+ timeout: 5000
+# max-active: 50
+# max-idle: 20
+# max-wait-millis: 1000
+# min-idle: 10
--
Gitblit v1.9.3