From 74e6cbf2114a6af1715921f087da0f7fdfd634a8 Mon Sep 17 00:00:00 2001 From: Wang Chen Chen <932560435@qq.com> Date: Mon, 30 Oct 2023 15:03:16 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=20=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=86=85=E5=AE=B9=202.=E4=BF=AE=E6=94=B9=20w?= =?UTF-8?q?eb-ui=20=E6=8E=A8=E9=80=81=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xaaef/molly/MollyApplicationTests.java | 11 +---- .../molly/system/cron/TestCronAsync.java | 42 +++++++++++++++---- web-ui/src/components/Notify/NotifyList.vue | 24 +++++------ web-ui/src/components/Notify/index.vue | 13 +++--- web-ui/src/components/SearchProject/index.vue | 3 +- web-ui/src/components/SearchTenant/index.vue | 3 +- web-ui/src/config/white-list.ts | 2 +- web-ui/src/hooks/usePagination.ts | 7 +++- web-ui/src/hooks/useTenantAndProject.ts | 10 ++--- web-ui/src/store/modules/notice.ts | 11 +++-- web-ui/src/types/base.ts | 12 ++++++ 11 files changed, 88 insertions(+), 50 deletions(-) diff --git a/server/molly-service/src/test/java/com/xaaef/molly/MollyApplicationTests.java b/server/molly-service/src/test/java/com/xaaef/molly/MollyApplicationTests.java index 9eac3bb..0718a1e 100644 --- a/server/molly-service/src/test/java/com/xaaef/molly/MollyApplicationTests.java +++ b/server/molly-service/src/test/java/com/xaaef/molly/MollyApplicationTests.java @@ -21,6 +21,8 @@ import org.springframework.security.core.context.SecurityContextHolder; import java.time.LocalDateTime; import java.util.Set; +import static com.xaaef.molly.system.cron.TestCronAsync.randomChinese; + @SpringBootTest public class MollyApplicationTests { @@ -75,13 +77,4 @@ public class MollyApplicationTests { } } - - private String randomChinese(int len) { - var chars = new char[len]; - for (int i = 0; i < len; i++) { - chars[i] = RandomUtil.randomChinese(); - } - return new String(chars); - } - } diff --git a/server/molly-sys/src/main/java/com/xaaef/molly/system/cron/TestCronAsync.java b/server/molly-sys/src/main/java/com/xaaef/molly/system/cron/TestCronAsync.java index 418995d..433188a 100644 --- a/server/molly-sys/src/main/java/com/xaaef/molly/system/cron/TestCronAsync.java +++ b/server/molly-sys/src/main/java/com/xaaef/molly/system/cron/TestCronAsync.java @@ -3,6 +3,7 @@ package com.xaaef.molly.system.cron; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import com.xaaef.molly.auth.service.JwtTokenService; +import com.xaaef.molly.common.util.IdUtils; import com.xaaef.molly.common.util.JsonUtils; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -10,8 +11,10 @@ import org.springframework.messaging.simp.SimpMessagingTemplate; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import java.time.LocalDateTime; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; /** *
@@ -40,35 +43,58 @@ public class TestCronAsync { "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"); + private final static AtomicInteger count1 = new AtomicInteger(8760); - @Scheduled(fixedRate = 5000) + @Scheduled(fixedRate = 30000) public void cron1() { if (!tokenService.listLoginIds().isEmpty()) { + var ind = count1.decrementAndGet(); var map = Map.of( - "id", RandomUtil.randomInt(10000, 99999), - "msg", RandomUtil.randomString(12), - "dataArr", RandomUtil.randomEleSet(arrs, 3) + "id", IdUtils.getStandaloneId(), + "title", String.format("广播消息=>%d", RandomUtil.randomInt(10000, 99999)), + "message", randomChinese(20), + "createTime", LocalDateTime.now().minusHours(ind) ); var json = JsonUtils.toJson(map); // 广播通知 给所有用户 messagingTemplate.convertAndSend("/topic/broadcast/notice", json); + if (ind == 1) { + count2.set(8760); + } } } - @Scheduled(fixedRate = 8000) + private final static AtomicInteger count2 = new AtomicInteger(8760); + + + @Scheduled(fixedRate = 60000) public void cron2() { + var ind = count2.decrementAndGet(); tokenService.listLoginUsers().forEach(user -> { var map = Map.of( - "id", RandomUtil.randomInt(10000, 99999), - "msg", StrUtil.format("hello : {} => {}", user.getUsername(), RandomUtil.randomString(15)), - "dataArr", RandomUtil.randomEleSet(arrs, 3) + "id", IdUtils.getStandaloneId(), + "title", String.format("推送消息=>%d", RandomUtil.randomInt(10000, 99999)), + "message", randomChinese(20), + "createTime", LocalDateTime.now().minusHours(ind) ); var json = JsonUtils.toJson(map); // 推送给指定用户 , /user/queue/single/push messagingTemplate.convertAndSendToUser(user.getLoginId(), "/queue/single/push", json); + if (ind == 1) { + count2.set(8760); + } }); } + public static String randomChinese(int len) { + var chars = new char[len]; + for (int i = 0; i < len; i++) { + chars[i] = RandomUtil.randomChinese(); + } + return new String(chars); + } + + } diff --git a/web-ui/src/components/Notify/NotifyList.vue b/web-ui/src/components/Notify/NotifyList.vue index bf1cb42..3b06e38 100644 --- a/web-ui/src/components/Notify/NotifyList.vue +++ b/web-ui/src/components/Notify/NotifyList.vue @@ -1,8 +1,8 @@