fuliqi
2024-10-12 98a45e34ab4a6740f95980040fa9207a779b2529
ycl-server/src/main/java/com/ycl/utils/CheckPointUtil.java
@@ -48,7 +48,7 @@
     */
    public TMonitorResult check(TMonitorResult monitor) {
        // 先检测能否访问该ip的网页
        ResponseEntity<Object> res = null;
        ResponseEntity<String> res = null;
        log.info("监测IP:" + monitor.getIp());
        String prefix = "http://";
        if ("127.0.0.1".equals(monitor.getIp())) {
@@ -115,9 +115,10 @@
        }
        boolean webReachable = false;
        try {
            ResponseEntity<Object> res = selfHttpUtil.get(prefix + checkUtil.getIp(), null, null);
            ResponseEntity<String> res = selfHttpUtil.get(prefix + checkUtil.getIp(), null, null);
            webReachable = Objects.nonNull(res) && HttpStatus.OK == res.getStatusCode();
        } catch (Exception e) {
            log.info("检测web异常"+e.getMessage());
            webReachable = Boolean.FALSE;
        }
        // ping
@@ -130,8 +131,8 @@
        } catch (IOException e) {
            e.printStackTrace();
        }
        String imgUrl = "";
        if(pingReachable || webReachable) {
        // 查出国标设备,就一条数据
        List<DeviceInfo> gbDevices = new LambdaQueryChainWrapper<>(deviceInfoMapper)
                .orderByDesc(DeviceInfo::getUpdateTime)
@@ -145,7 +146,7 @@
                e.printStackTrace();
            }
        }
        }
        String status = "";
        if (! webReachable) {
            status += "设备web访问失败;";
@@ -155,6 +156,9 @@
        }
        if (StringUtils.isEmpty(imgUrl)) {
            status += "未获取到图片";
        }
        if (StringUtils.isEmpty(status)) {
            status += "设备正常";
        }
        result.setStatus(status);
        return result;
@@ -187,6 +191,8 @@
        String status = "";
        if (! pingReachable) {
            status += "ip未ping通;";
        }else {
            status += "成功";
        }
        result.setStatus(status);
        return result;