feat(core): 调整生产环境MQTT配置及微信通知逻辑- 禁用生产环境MQTT服务
- GPS消息处理器中增加Redis缓存控制,2分钟内仅保存一次数据 - 更新推送模板消息的目标用户ID - 微信通知服务中动态获取公众号配置信息,替换原有硬编码方式 - 注入CMS网站字段服务以支持从数据库读取微信公众号凭证 - 增加对微信公众号配置项空值的判断处理,提高系统健壮性
This commit is contained in:
@@ -158,6 +158,8 @@ public class GpsMessageProcessor {
|
|||||||
log.setSpeed(gps.getSpeed());
|
log.setSpeed(gps.getSpeed());
|
||||||
|
|
||||||
if (!log.getSpeed().equals("0.000")) {
|
if (!log.getSpeed().equals("0.000")) {
|
||||||
|
// 使用Redis,key为GPS设备编号 2分钟内保存一次
|
||||||
|
redisUtil.set(gps.getImei(), "1", 2L, TimeUnit.MINUTES);
|
||||||
hjmGpsLogService.save(log);
|
hjmGpsLogService.save(log);
|
||||||
logger.debug("保存GPS轨迹日志成功: {}", gps.getImei());
|
logger.debug("保存GPS轨迹日志成功: {}", gps.getImei());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.gxwebsoft.hjm.service.impl;
|
|||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
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.core.utils.WxOfficialUtil;
|
||||||
import com.gxwebsoft.common.system.entity.Setting;
|
import com.gxwebsoft.common.system.entity.Setting;
|
||||||
import com.gxwebsoft.common.system.service.SettingService;
|
import com.gxwebsoft.common.system.service.SettingService;
|
||||||
@@ -39,6 +41,9 @@ public class WxNotificationServiceImpl implements WxNotificationService {
|
|||||||
@Resource
|
@Resource
|
||||||
private StringRedisTemplate stringRedisTemplate;
|
private StringRedisTemplate stringRedisTemplate;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CmsWebsiteFieldService cmsWebsiteFieldService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean sendTemplateMessage(Integer tenantId, TemplateMessageRequest request) {
|
public boolean sendTemplateMessage(Integer tenantId, TemplateMessageRequest request) {
|
||||||
try {
|
try {
|
||||||
@@ -137,7 +142,20 @@ public class WxNotificationServiceImpl implements WxNotificationService {
|
|||||||
throw new RuntimeException("微信公众号配置不完整");
|
throw new RuntimeException("微信公众号配置不完整");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调用微信API获取access_token
|
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="
|
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
|
||||||
+ appId + "&secret=" + appSecret;
|
+ appId + "&secret=" + appSecret;
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class PushTemplateMessageController extends BaseController {
|
|||||||
try {
|
try {
|
||||||
// 发送模板消息
|
// 发送模板消息
|
||||||
final TemplateMessageRequest templateMessageRequest = new TemplateMessageRequest();
|
final TemplateMessageRequest templateMessageRequest = new TemplateMessageRequest();
|
||||||
templateMessageRequest.setToUser("oKGr42CwRuc7xEFufHhYZF627XYA");
|
templateMessageRequest.setToUser("oKGr42It8OcS1Bl-KpiQj7MM43o8");
|
||||||
templateMessageRequest.setTemplateId("KxGoeBpHW60QFUIU7Vo3c_48g_3V55tWWr23tUUl8gI");
|
templateMessageRequest.setTemplateId("KxGoeBpHW60QFUIU7Vo3c_48g_3V55tWWr23tUUl8gI");
|
||||||
// templateMessageRequest.setUrl("https://mp.websoft.top");
|
// templateMessageRequest.setUrl("https://mp.websoft.top");
|
||||||
final TemplateMessageRequest.MiniProgram miniProgram = new TemplateMessageRequest.MiniProgram();
|
final TemplateMessageRequest.MiniProgram miniProgram = new TemplateMessageRequest.MiniProgram();
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ socketio:
|
|||||||
|
|
||||||
# MQTT配置
|
# MQTT配置
|
||||||
mqtt:
|
mqtt:
|
||||||
enabled: true # 启用MQTT服务
|
enabled: false # 启用MQTT服务
|
||||||
host: tcp://1.14.159.185:1883
|
host: tcp://1.14.159.185:1883
|
||||||
username: swdev
|
username: swdev
|
||||||
password: Sw20250523
|
password: Sw20250523
|
||||||
|
|||||||
Reference in New Issue
Block a user