This commit is contained in:
Leo
2026-01-05 22:02:15 +08:00
parent e9747e6af2
commit 81203488c8
5 changed files with 375 additions and 21 deletions

View File

@@ -6,6 +6,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.framework.web.domain.Server;
import com.ruoyi.jarvis.service.ILogisticsService;
import com.ruoyi.jarvis.service.IWxSendService;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
* 服务器监控
@@ -16,6 +22,12 @@ import com.ruoyi.framework.web.domain.Server;
@RequestMapping("/monitor/server")
public class ServerController
{
@Resource
private ILogisticsService logisticsService;
@Resource
private IWxSendService wxSendService;
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
@GetMapping()
public AjaxResult getInfo() throws Exception
@@ -24,4 +36,52 @@ public class ServerController
server.copyTo();
return AjaxResult.success(server);
}
/**
* 获取服务健康度检测
*/
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
@GetMapping("/health")
public AjaxResult getHealth() throws Exception
{
Map<String, Object> healthMap = new HashMap<>();
// 物流服务健康检测
try {
ILogisticsService.HealthCheckResult logisticsHealth = logisticsService.checkHealth();
Map<String, Object> logisticsMap = new HashMap<>();
logisticsMap.put("healthy", logisticsHealth.isHealthy());
logisticsMap.put("status", logisticsHealth.getStatus());
logisticsMap.put("message", logisticsHealth.getMessage());
logisticsMap.put("serviceUrl", logisticsHealth.getServiceUrl());
healthMap.put("logistics", logisticsMap);
} catch (Exception e) {
Map<String, Object> logisticsMap = new HashMap<>();
logisticsMap.put("healthy", false);
logisticsMap.put("status", "异常");
logisticsMap.put("message", "健康检测异常: " + e.getMessage());
logisticsMap.put("serviceUrl", "");
healthMap.put("logistics", logisticsMap);
}
// 微信推送服务健康检测
try {
IWxSendService.HealthCheckResult wxSendHealth = wxSendService.checkHealth();
Map<String, Object> wxSendMap = new HashMap<>();
wxSendMap.put("healthy", wxSendHealth.isHealthy());
wxSendMap.put("status", wxSendHealth.getStatus());
wxSendMap.put("message", wxSendHealth.getMessage());
wxSendMap.put("serviceUrl", wxSendHealth.getServiceUrl());
healthMap.put("wxSend", wxSendMap);
} catch (Exception e) {
Map<String, Object> wxSendMap = new HashMap<>();
wxSendMap.put("healthy", false);
wxSendMap.put("status", "异常");
wxSendMap.put("message", "健康检测异常: " + e.getMessage());
wxSendMap.put("serviceUrl", "");
healthMap.put("wxSend", wxSendMap);
}
return AjaxResult.success(healthMap);
}
}