修改页面弹窗全屏
This commit is contained in:
@@ -0,0 +1,72 @@
|
|||||||
|
package com.jeesite.modules.app.Job.biz;
|
||||||
|
|
||||||
|
import com.jeesite.modules.app.utils.KeyUtil;
|
||||||
|
import com.jeesite.modules.app.utils.LoggerUtils;
|
||||||
|
import com.jeesite.modules.app.utils.MyUtils;
|
||||||
|
import com.jeesite.modules.app.utils.NetworkUtils;
|
||||||
|
import com.jeesite.modules.biz.entity.BizQuickLogin;
|
||||||
|
import com.jeesite.modules.biz.entity.BizWarningAlert;
|
||||||
|
import com.jeesite.modules.biz.service.BizQuickLoginService;
|
||||||
|
import com.jeesite.modules.biz.service.BizWarningAlertService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class appJob {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BizQuickLoginService quickLoginService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BizWarningAlertService bizWarningAlertService;
|
||||||
|
|
||||||
|
|
||||||
|
@Resource(name = "hostMonitorExecutor")
|
||||||
|
private ThreadPoolTaskExecutor hostMonitorExecutor;
|
||||||
|
|
||||||
|
private static final LoggerUtils logger = LoggerUtils.getInstance();
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0/10 * * * ?")
|
||||||
|
public void initJob() {
|
||||||
|
try {
|
||||||
|
checkAppUrl();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void checkAppUrl() {
|
||||||
|
BizQuickLogin quickLogin = new BizQuickLogin();
|
||||||
|
quickLogin.setIsEnabled(1L);
|
||||||
|
quickLogin.setSystemType("2");
|
||||||
|
List<BizQuickLogin> quickLoginList = quickLoginService.findList(quickLogin);
|
||||||
|
List<CompletableFuture<Void>> futures = new ArrayList<>(quickLoginList.size());
|
||||||
|
for (BizQuickLogin bizQuickLogin : quickLoginList) {
|
||||||
|
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
||||||
|
Map<String, Object> objectMap = MyUtils.checkUrlStatus(bizQuickLogin.getHomepageUrl());
|
||||||
|
if (!objectMap.get("isReachable").equals(true)) {
|
||||||
|
BizWarningAlert warningAlert = new BizWarningAlert("ZJ_" + KeyUtil.ObjKey(12, 2), "URL预警", 2, bizQuickLogin.getSystemName() + "URL预警", "当前系统URL:" + bizQuickLogin.getHomepageUrl() + "探测失败,请及时处理,错误信息:" + objectMap.get("errorMessage"), "业务系统", "0");
|
||||||
|
bizWarningAlertService.save(warningAlert);
|
||||||
|
}
|
||||||
|
}, hostMonitorExecutor);
|
||||||
|
futures.add(future);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
|
||||||
|
.get(60, TimeUnit.SECONDS); // 超时时间可根据业务调整
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,11 @@
|
|||||||
package com.jeesite.modules.app.Job.biz;
|
package com.jeesite.modules.app.Job.biz;
|
||||||
|
|
||||||
import com.jeesite.modules.app.utils.LoggerUtils;
|
import com.jeesite.modules.app.utils.LoggerUtils;
|
||||||
import com.jeesite.modules.biz.service.BizListItemService;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class msgJob {
|
public class msgJob {
|
||||||
|
|
||||||
@Resource
|
|
||||||
private BizListItemService bizListItemService;
|
|
||||||
|
|
||||||
|
|
||||||
private static final LoggerUtils logger = LoggerUtils.getInstance();
|
private static final LoggerUtils logger = LoggerUtils.getInstance();
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,14 @@ package com.jeesite.modules.app;
|
|||||||
|
|
||||||
public class Test {
|
public class Test {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.jeesite.modules.app.utils;
|
|||||||
|
|
||||||
import com.jeesite.modules.biz.entity.BizFolders;
|
import com.jeesite.modules.biz.entity.BizFolders;
|
||||||
|
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -9,6 +11,12 @@ import java.util.Map;
|
|||||||
public class MyUtils {
|
public class MyUtils {
|
||||||
|
|
||||||
|
|
||||||
|
// 默认连接超时时间(毫秒)
|
||||||
|
private static final int DEFAULT_CONNECT_TIMEOUT = 5000;
|
||||||
|
// 默认读取超时时间(毫秒)
|
||||||
|
private static final int DEFAULT_READ_TIMEOUT = 5000;
|
||||||
|
|
||||||
|
|
||||||
public static String concatParams(String... args) {
|
public static String concatParams(String... args) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (String param : args) {
|
for (String param : args) {
|
||||||
@@ -46,4 +54,50 @@ public class MyUtils {
|
|||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Map<String, Object> checkUrlStatus(String urlStr) {
|
||||||
|
// 初始化返回结果
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("isReachable", false);
|
||||||
|
result.put("statusCode", -1);
|
||||||
|
result.put("errorMessage", null);
|
||||||
|
|
||||||
|
HttpURLConnection connection = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. 创建URL对象
|
||||||
|
URL url = new URL(urlStr);
|
||||||
|
// 2. 打开连接
|
||||||
|
connection = (HttpURLConnection) url.openConnection();
|
||||||
|
// 3. 设置连接参数
|
||||||
|
connection.setRequestMethod("HEAD"); // 使用HEAD方法,只获取响应头(减少数据传输)
|
||||||
|
connection.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT); // 连接超时
|
||||||
|
connection.setReadTimeout(DEFAULT_READ_TIMEOUT); // 读取超时
|
||||||
|
connection.setInstanceFollowRedirects(true); // 自动跟随重定向
|
||||||
|
|
||||||
|
// 4. 获取响应状态码
|
||||||
|
int statusCode = connection.getResponseCode();
|
||||||
|
result.put("statusCode", statusCode);
|
||||||
|
// 5. 判断是否可达(2xx、3xx状态码视为可达)
|
||||||
|
result.put("isReachable", (statusCode >= 200 && statusCode < 400));
|
||||||
|
} catch (java.net.MalformedURLException e) {
|
||||||
|
// URL格式错误
|
||||||
|
result.put("errorMessage", "URL格式错误:" + e.getMessage());
|
||||||
|
} catch (java.net.SocketTimeoutException e) {
|
||||||
|
// 连接/读取超时
|
||||||
|
result.put("errorMessage", "连接超时:" + e.getMessage());
|
||||||
|
} catch (java.io.IOException e) {
|
||||||
|
// 其他IO异常(如网络不可用、服务器无响应)
|
||||||
|
result.put("errorMessage", "网络异常:" + e.getMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 其他未知异常
|
||||||
|
result.put("errorMessage", "未知错误:" + e.getMessage());
|
||||||
|
} finally {
|
||||||
|
// 6. 关闭连接,释放资源
|
||||||
|
if (connection != null) {
|
||||||
|
connection.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
:showCancelBtn="false"
|
:showCancelBtn="false"
|
||||||
defaultFullscreen="true"
|
defaultFullscreen="true"
|
||||||
width="100%"
|
width="100%"
|
||||||
v-if="isModalVisible"
|
|
||||||
>
|
>
|
||||||
<div class="server-detail-container">
|
<div class="server-detail-container">
|
||||||
<div class="server-info-top">
|
<div class="server-info-top">
|
||||||
@@ -42,36 +41,19 @@ export default defineComponent({
|
|||||||
const FormValues = ref<Record<string, any>>({
|
const FormValues = ref<Record<string, any>>({
|
||||||
hostId: '-1'
|
hostId: '-1'
|
||||||
});
|
});
|
||||||
|
|
||||||
const isModalVisible = ref(false);
|
|
||||||
|
|
||||||
const [register, { closeModal }] = useModalInner(async (data: any) => {
|
const [register, { closeModal }] = useModalInner(async (data: any) => {
|
||||||
FormValues.value = { hostId: '-1' };
|
|
||||||
isModalVisible.value = false;
|
|
||||||
|
|
||||||
if (!data || !data.hostId) {
|
if (!data || !data.hostId) {
|
||||||
closeModal();
|
closeModal();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FormValues.value.hostId = data.hostId;
|
FormValues.value.hostId = data.hostId;
|
||||||
isModalVisible.value = true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
|
||||||
() => isModalVisible.value,
|
|
||||||
(newVal) => {
|
|
||||||
if (!newVal) {
|
|
||||||
FormValues.value = { hostId: '-1' };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
register,
|
register,
|
||||||
closeModal,
|
closeModal,
|
||||||
FormValues,
|
FormValues,
|
||||||
isModalVisible
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user