From e2432b5942afcde1f1971d198349c1bfb00e15d4 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Sat, 18 Dec 2021 17:23:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=80=9A=E7=9F=A5=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E4=BC=9A=E5=8D=A1=E4=B8=BB=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=A4=8D=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E5=99=A8=E7=8A=B6=E6=80=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yutou/qqbot/QQBotApplication.java | 3 ++- .../yutou/qqbot/models/XiaoMi/MiRouter.java | 8 ++++++-- .../yutou/qqbot/utlis/ApplicationInit.java | 20 ++++++++++--------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/yutou/qqbot/QQBotApplication.java b/src/main/java/com/yutou/qqbot/QQBotApplication.java index 38e025a..f225b0f 100644 --- a/src/main/java/com/yutou/qqbot/QQBotApplication.java +++ b/src/main/java/com/yutou/qqbot/QQBotApplication.java @@ -6,8 +6,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class QQBotApplication { - public static final String version="QQBot v.1.2.0"; + public static final String version="QQBot v.1.2.1"; public static void main(String[] args) { + System.out.println("version = " + version); SpringApplication.run(QQBotApplication.class, args); RedisTools.initRedisPoolSub(); QQBotManager.getInstance(); diff --git a/src/main/java/com/yutou/qqbot/models/XiaoMi/MiRouter.java b/src/main/java/com/yutou/qqbot/models/XiaoMi/MiRouter.java index b3a4455..a2d368c 100644 --- a/src/main/java/com/yutou/qqbot/models/XiaoMi/MiRouter.java +++ b/src/main/java/com/yutou/qqbot/models/XiaoMi/MiRouter.java @@ -39,10 +39,14 @@ public class MiRouter extends Model { QQBotManager.getInstance().sendMessage(qq,"点击该删除设备:\n"+url); } } - + private static boolean isRunTime=false; @Override public void onTime(String time) { super.onTime(time); + if(isRunTime){ + return; + } + isRunTime=true; String url = XiaoMiRouter.getDeviceListUrl(); JSONObject json = JSONObject.parseObject(HttpTools.get(url)); if (json.getInteger("code") == 0) { @@ -91,7 +95,7 @@ public class MiRouter extends Model { } } RedisTools.set(redis_key, devs.toJSONString()); - + isRunTime=false; } } diff --git a/src/main/java/com/yutou/qqbot/utlis/ApplicationInit.java b/src/main/java/com/yutou/qqbot/utlis/ApplicationInit.java index e559c6c..6da4736 100644 --- a/src/main/java/com/yutou/qqbot/utlis/ApplicationInit.java +++ b/src/main/java/com/yutou/qqbot/utlis/ApplicationInit.java @@ -23,19 +23,21 @@ public class ApplicationInit implements ApplicationRunner { if (time.equals(oldTime)) { return; } - oldTime=time; + oldTime = time; for (Class model : Model.classList) { - try { - Model useModel= (Model) model.getDeclaredConstructor().newInstance(); - useModel.onTime(time); - } catch (Exception e) { - e.printStackTrace(); - } + new Thread(() -> { + try { + Model useModel = (Model) model.getDeclaredConstructor().newInstance(); + useModel.onTime(time); + } catch (Exception e) { + e.printStackTrace(); + } + }).start(); } - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } } - },0, 1000); + }, 0, 300); } }