feat(core): 调整生产环境MQTT配置及微信通知逻辑- 禁用生产环境MQTT服务

- GPS消息处理器中增加Redis缓存控制,2分钟内仅保存一次数据
- 更新推送模板消息的目标用户ID
- 微信通知服务中动态获取公众号配置信息,替换原有硬编码方式
- 注入CMS网站字段服务以支持从数据库读取微信公众号凭证
- 增加对微信公众号配置项空值的判断处理,提高系统健壮性
This commit is contained in:
2025-11-10 12:04:47 +08:00
parent 495409a961
commit bf1a54e520
4 changed files with 23 additions and 3 deletions

View File

@@ -158,6 +158,8 @@ public class GpsMessageProcessor {
log.setSpeed(gps.getSpeed());
if (!log.getSpeed().equals("0.000")) {
// 使用Rediskey为GPS设备编号 2分钟内保存一次
redisUtil.set(gps.getImei(), "1", 2L, TimeUnit.MINUTES);
hjmGpsLogService.save(log);
logger.debug("保存GPS轨迹日志成功: {}", gps.getImei());
}

View File

@@ -3,6 +3,8 @@ package com.gxwebsoft.hjm.service.impl;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.gxwebsoft.cms.entity.CmsWebsiteField;
import com.gxwebsoft.cms.service.CmsWebsiteFieldService;
import com.gxwebsoft.common.core.utils.WxOfficialUtil;
import com.gxwebsoft.common.system.entity.Setting;
import com.gxwebsoft.common.system.service.SettingService;
@@ -39,6 +41,9 @@ public class WxNotificationServiceImpl implements WxNotificationService {
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource
private CmsWebsiteFieldService cmsWebsiteFieldService;
@Override
public boolean sendTemplateMessage(Integer tenantId, TemplateMessageRequest request) {
try {
@@ -137,6 +142,19 @@ public class WxNotificationServiceImpl implements WxNotificationService {
throw new RuntimeException("微信公众号配置不完整");
}
final CmsWebsiteField officialAppId = cmsWebsiteFieldService.getByCodeRel("OfficialAppId");
final CmsWebsiteField officialAppSecret = cmsWebsiteFieldService.getByCodeRel("OfficialAppSecret");
System.out.println("officialAppSecret = " + officialAppSecret);
System.out.println("officialAppId = " + officialAppId);
if(officialAppId != null){
appId = officialAppId.getValue();
}
if(officialAppSecret != null){
appSecret = officialAppSecret.getValue();
}
// 调用微信API获取access_token
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
+ appId + "&secret=" + appSecret;

View File

@@ -83,7 +83,7 @@ public class PushTemplateMessageController extends BaseController {
try {
// 发送模板消息
final TemplateMessageRequest templateMessageRequest = new TemplateMessageRequest();
templateMessageRequest.setToUser("oKGr42CwRuc7xEFufHhYZF627XYA");
templateMessageRequest.setToUser("oKGr42It8OcS1Bl-KpiQj7MM43o8");
templateMessageRequest.setTemplateId("KxGoeBpHW60QFUIU7Vo3c_48g_3V55tWWr23tUUl8gI");
// templateMessageRequest.setUrl("https://mp.websoft.top");
final TemplateMessageRequest.MiniProgram miniProgram = new TemplateMessageRequest.MiniProgram();

View File

@@ -32,7 +32,7 @@ socketio:
# MQTT配置
mqtt:
enabled: true # 启用MQTT服务
enabled: false # 启用MQTT服务
host: tcp://1.14.159.185:1883
username: swdev
password: Sw20250523