1
This commit is contained in:
@@ -22,7 +22,7 @@ public class WxSendServiceImpl implements IWxSendService {
|
|||||||
@Value("${jarvis.server.wxsend.base-url:https://wxts.van333.cn}")
|
@Value("${jarvis.server.wxsend.base-url:https://wxts.van333.cn}")
|
||||||
private String wxSendBaseUrl;
|
private String wxSendBaseUrl;
|
||||||
|
|
||||||
@Value("${jarvis.server.wxsend.health-path:/wx/send/pdd}")
|
@Value("${jarvis.server.wxsend.health-path:/wx/send/jd}")
|
||||||
private String wxSendHealthPath;
|
private String wxSendHealthPath;
|
||||||
|
|
||||||
private String healthCheckUrl;
|
private String healthCheckUrl;
|
||||||
@@ -38,12 +38,10 @@ public class WxSendServiceImpl implements IWxSendService {
|
|||||||
try {
|
try {
|
||||||
logger.debug("开始检查微信推送服务健康状态 - URL: {}", healthCheckUrl);
|
logger.debug("开始检查微信推送服务健康状态 - URL: {}", healthCheckUrl);
|
||||||
|
|
||||||
// 构建一个测试请求(使用最小的有效请求体)
|
// 构建健康检查请求,发送一条真实的消息
|
||||||
|
// /send/jd 接口只需要 text 字段,vanToken 在 header 中传递
|
||||||
JSONObject testRequest = new JSONObject();
|
JSONObject testRequest = new JSONObject();
|
||||||
testRequest.put("title", "健康检查");
|
testRequest.put("text", "【系统健康检查】微信推送服务运行正常 - " + new java.util.Date());
|
||||||
testRequest.put("text", "健康检查测试消息");
|
|
||||||
testRequest.put("vanToken", PUSH_TOKEN);
|
|
||||||
testRequest.put("messageType", "PDD");
|
|
||||||
|
|
||||||
String jsonBody = testRequest.toJSONString();
|
String jsonBody = testRequest.toJSONString();
|
||||||
|
|
||||||
@@ -65,16 +63,16 @@ public class WxSendServiceImpl implements IWxSendService {
|
|||||||
|
|
||||||
// 检查是否成功(code为200或0,或者success为true)
|
// 检查是否成功(code为200或0,或者success为true)
|
||||||
if ((code != null && (code == 200 || code == 0)) || Boolean.TRUE.equals(success)) {
|
if ((code != null && (code == 200 || code == 0)) || Boolean.TRUE.equals(success)) {
|
||||||
logger.debug("微信推送服务健康检查通过");
|
logger.debug("微信推送服务健康检查通过,消息已发送");
|
||||||
return new IWxSendService.HealthCheckResult(true, "正常", "服务运行正常", healthCheckUrl);
|
return new IWxSendService.HealthCheckResult(true, "正常", "服务运行正常,健康检查消息已发送", healthCheckUrl);
|
||||||
} else {
|
} else {
|
||||||
// 检查是否是token验证失败(说明服务可用,只是token问题)
|
// 检查是否是token验证失败(说明服务可用,只是token问题)
|
||||||
if (msg != null && msg.contains("vanToken")) {
|
if (msg != null && (msg.contains("vanToken") || msg.contains("token"))) {
|
||||||
logger.debug("微信推送服务健康检查通过(服务可用,token验证失败是正常的)");
|
logger.debug("微信推送服务健康检查通过(服务可用,token验证失败)");
|
||||||
return new IWxSendService.HealthCheckResult(true, "正常", "服务运行正常(token验证失败是正常的)", healthCheckUrl);
|
return new IWxSendService.HealthCheckResult(true, "正常", "服务运行正常(token验证失败)", healthCheckUrl);
|
||||||
}
|
}
|
||||||
logger.warn("微信推送服务健康检查失败 - 响应: {}", healthResult);
|
logger.warn("微信推送服务健康检查失败 - 响应: {}", healthResult);
|
||||||
return new IWxSendService.HealthCheckResult(false, "异常", "健康检查返回异常状态: " + msg, healthCheckUrl);
|
return new IWxSendService.HealthCheckResult(false, "异常", "健康检查返回异常状态: " + (msg != null ? msg : healthResult), healthCheckUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user