From 9242fef137d6626bb63326cd69cc7fd488e7d760 Mon Sep 17 00:00:00 2001 From: fanyuhui <852221040@qq.com> Date: Mon, 30 Dec 2024 18:32:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yohann/ocihelper/task/OciTask.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/yohann/ocihelper/task/OciTask.java b/src/main/java/com/yohann/ocihelper/task/OciTask.java index 567560d..d1261d2 100644 --- a/src/main/java/com/yohann/ocihelper/task/OciTask.java +++ b/src/main/java/com/yohann/ocihelper/task/OciTask.java @@ -55,6 +55,8 @@ public class OciTask implements ApplicationRunner { @Resource private IOciCreateTaskService createTaskService; + private static volatile boolean isPushLatestVersion = false; + @Value("${web.account}") private String account; @Value("${web.password}") @@ -137,15 +139,21 @@ private void saveVersion() { } private void pushVersionUpdateMsg() { - addTask("pushVersionUpdateMsg", () -> { - String nowVersion = kvService.getObj(new LambdaQueryWrapper() - .eq(OciKv::getCode, SysCfgEnum.SYS_INFO_VERSION.getCode()) - .eq(OciKv::getType, SysCfgTypeEnum.SYS_INFO.getCode()) - .select(OciKv::getValue), String::valueOf); - String latestVersion = CommonUtils.getLatestVersion(); - if (!nowVersion.equals(latestVersion)) { - sysService.sendMessage(String.format("【oci-helper】版本更新啦!!!\n当前版本:%s\n最新版本:%s", - nowVersion, latestVersion)); + String taskId = "pushVersionUpdateMsg"; + addTask(taskId, () -> { + if (isPushLatestVersion) { + stopTask(taskId); + } else { + String nowVersion = kvService.getObj(new LambdaQueryWrapper() + .eq(OciKv::getCode, SysCfgEnum.SYS_INFO_VERSION.getCode()) + .eq(OciKv::getType, SysCfgTypeEnum.SYS_INFO.getCode()) + .select(OciKv::getValue), String::valueOf); + String latestVersion = CommonUtils.getLatestVersion(); + if (!nowVersion.equals(latestVersion)) { + sysService.sendMessage(String.format("【oci-helper】版本更新啦!!!\n当前版本:%s\n最新版本:%s", + nowVersion, latestVersion)); + isPushLatestVersion = true; + } } }, 0, 1, TimeUnit.MINUTES); }