From cb415813de667096290d6bd0f924f5b523104117 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期一, 10 十一月 2025 17:41:04 +0800
Subject: [PATCH] 报备工单bug修改,定时任务在线问题修改新增导出扣分明细功能
---
ycl-server/src/main/java/com/ycl/utils/CheckPointUtil.java | 34 ++++++++++++++++++++++++++--------
1 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/ycl-server/src/main/java/com/ycl/utils/CheckPointUtil.java b/ycl-server/src/main/java/com/ycl/utils/CheckPointUtil.java
index 9f873da..cc25556 100644
--- a/ycl-server/src/main/java/com/ycl/utils/CheckPointUtil.java
+++ b/ycl-server/src/main/java/com/ycl/utils/CheckPointUtil.java
@@ -49,11 +49,18 @@
* @return
*/
public TMonitorResult check(TMonitorResult monitor,Integer times) {
+ // TMonitorResult(deptId=202, ip=51.95.48.18, online=0,
+// onlineStr=null, pingOnline=true, pingOnlineStr=null,
+// checkCount=1, offLineCount=0, offLineTimeStr=null,
+// monitorType=3, name=DX_R涓変腑澶ч棬鍓嶈矾娈靛乏渚т汉琛岄亾2_鍏ㄦ櫙,
+// workOrder=null, pointId=null, createWorkOrder=null, dynamicColumnList=null),
+
// 鍏堟娴嬭兘鍚﹁闂ip鐨勭綉椤�
ResponseEntity<String> res = null;
String prefix = "http://";
if ("127.0.0.1".equals(monitor.getIp())) {
monitor.setPingOnline(Boolean.FALSE);
+ log.error("ip鏈夎"+monitor.getIp());
return monitor;
}
try {
@@ -84,11 +91,7 @@
map = new HashMap<>();
}
if (!monitor.getPingOnline()) {
- try {
- reachable = InetAddress.getByName(monitor.getIp()).isReachable(5000);
- } catch (IOException e) {
- e.printStackTrace();
- }
+ reachable = checkPing(monitor, reachable);
monitor.setPingOnline(reachable);
}
if (!monitor.getPingOnline()) {
@@ -98,19 +101,17 @@
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
offTimeList.add(dateFormat.format(now));
+ monitor.setOffLineTimeStr(offTimeList);
//鍒拌揪浜х敓宸ュ崟鐨勯槇鍊兼鏁�
if (continueOffTimes>=times) {
//浜х敓浜嗗伐鍗曟墠浼氬瓨鍌ㄧ绾挎椂闂�,瀛樺偍鏈�杩戜竴娆′骇鐢熷伐鍗曠殑杩欏嚑涓绾挎椂闂寸偣
- monitor.setOffLineTimeStr(offTimeList);
monitor.setCreateWorkOrder(Boolean.TRUE);
//浜х敓浜嗕竴娆″伐鍗曞垯娓呴櫎
continueOffTimes = 0;
- offTimeList = new ArrayList<>();
}
}else {
//濡傛灉鍦ㄧ嚎浜嗭紝娓呯┖杩炵画绂荤嚎娆℃暟锛屾竻绌虹绾挎椂闂�
continueOffTimes = 0;
- offTimeList = new ArrayList<>();
}
map.put("checkTimes", checkTimes);
map.put("offLineTimes", offLineTimes);
@@ -119,9 +120,26 @@
redisTemplate.opsForHash().put(RedisConstant.ONLINE_KEY, monitor.getNo(), map);
monitor.setCheckCount(checkTimes);
monitor.setOffLineCount(offLineTimes);
+
return monitor;
}
+ private boolean checkPing(TMonitorResult monitor, boolean reachable) {
+ try {
+ int[] sleepTimes = {5000, 15000, 30000};
+ for (int sleepTime : sleepTimes) {
+ reachable = InetAddress.getByName(monitor.getIp()).isReachable(5000);
+ if (reachable) {
+ break;
+ }
+ Thread.sleep(sleepTime);
+ }
+ } catch (Exception e) {
+ log.error("Ping寮傚父",e);
+ }
+ return reachable;
+ }
+
/**
* 鐩戞祴鐐逛綅鍦ㄧ嚎
--
Gitblit v1.8.0