BAOLH
2025-10-24 c247e1f3d0b19f7c6db74165650a29f0539f4b10
企微通信redis锁问题修改
3 files modified
32 ■■■■■ changed files
eladmin-master/eladmin-system/src/main/java/me/zhengjie/config/WxCpConfig.java 6 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java 12 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/resources/config/application.yml 14 ●●●●● patch | view | raw | blame | history
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();
        }
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();
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