Commit 37adc5903ee3b026c44342434c0b6186e7a746c2

Authored by 王明元
2 parents afed589e ffd4b675

Merge branch 'main' into dev

# Conflicts:
#	fw-dalaran-server/src/main/java/cn/fw/dalaran/server/task/TodoTask.java
#	fw-dalaran-server/src/main/resources/application-local.yml
fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/db/TodoHistory.java
... ... @@ -46,4 +46,11 @@ public class TodoHistory extends BaseAuditableTimeEntity<TodoHistory, Long> {
46 46 * 附加信息
47 47 */
48 48 private String extra;
  49 +
  50 + /**
  51 + * 自定义去重条件
  52 + */
  53 + public String getRemoveDuplicatesCondition() {
  54 + return this.getUserId() + "-->" + this.getDataId();
  55 + }
49 56 }
... ...
fw-dalaran-server/pom.xml
... ... @@ -70,6 +70,10 @@
70 70 <artifactId>spring-boot-starter-actuator</artifactId>
71 71 </dependency>
72 72 <dependency>
  73 + <groupId>io.micrometer</groupId>
  74 + <artifactId>micrometer-registry-prometheus</artifactId>
  75 + </dependency>
  76 + <dependency>
73 77 <groupId>org.springframework.boot</groupId>
74 78 <artifactId>spring-boot-starter-undertow</artifactId>
75 79 </dependency>
... ...
fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/app/OtherController.java
... ... @@ -5,6 +5,8 @@ import cn.fw.common.web.auth.LoginAuthBean;
5 5 import cn.fw.common.web.auth.annotation.CurrentUser;
6 6 import cn.fw.dalaran.domain.param.LiveCheckParams;
7 7 import cn.fw.dalaran.domain.vo.LiveCheckVo;
  8 +import cn.fw.dalaran.rpc.erp.UserRoleRpcService;
  9 +import cn.fw.dalaran.server.task.TodoTask;
8 10 import cn.fw.dalaran.service.Common;
9 11 import cn.fw.dalaran.service.biz.OtherBizService;
10 12 import cn.fw.data.base.domain.common.Message;
... ... @@ -41,6 +43,8 @@ public class OtherController {
41 43  
42 44 private final OtherBizService otherBizService;
43 45 private final Common common;
  46 + private final UserRoleRpcService userRoleRpcService;
  47 + private final TodoTask todoTask;// 定时任务
44 48  
45 49 /**
46 50 * 获取直播审计页面
... ... @@ -104,4 +108,16 @@ public class OtherController {
104 108 return success(result);
105 109 }
106 110  
  111 + /**
  112 + * 重发直播审计待办
  113 + *
  114 + * @param timestamp 时间戳
  115 + * @return
  116 + */
  117 + @GetMapping("/resendLiveCheckBacklog")
  118 + public Message<Void> test(@NotNull(message = "请必须指定时间戳") Long timestamp) {
  119 + todoTask.sendLiveCheckBacklog(timestamp);
  120 + return Message.success();
  121 + }
  122 +
107 123 }
... ...
fw-dalaran-server/src/main/java/cn/fw/dalaran/server/task/TodoTask.java
... ... @@ -136,12 +136,21 @@ public class TodoTask {
136 136 */
137 137 @Scheduled(fixedRate = 15 * 60 * 1000, initialDelay = 5 * 1000)
138 138 public void sendLiveCheckBacklog() {
  139 + this.sendLiveCheckBacklog(System.currentTimeMillis());
  140 + }
  141 +
  142 + /**
  143 + * 发送直播审计待办
  144 + *
  145 + * @param timeStamp 指定时间
  146 + */
  147 + public void sendLiveCheckBacklog(Long timeStamp) {
139 148 final List<ActivityTheme> themeList = activityThemeService.lambdaQuery()
140   - .gt(ActivityTheme::getEndTime, new Date(System.currentTimeMillis() - 7 * 24 * 3600 * 1000))
  149 + .gt(ActivityTheme::getEndTime, new Date(timeStamp - 7 * 24 * 3600 * 1000))
141 150 .list()
142 151 .stream()
143 152 .filter(item -> {
144   - final long timeSub = System.currentTimeMillis() - item.getEndTime().getTime();
  153 + final long timeSub = timeStamp - item.getEndTime().getTime();
145 154 return 24 * 3600 * 1000 < timeSub && timeSub < 2 * 24 * 3600 * 1000;
146 155 })
147 156 .collect(Collectors.toList());// 找到(理论上)需要审计的主题
... ... @@ -205,7 +214,7 @@ public class TodoTask {
205 214 })
206 215 .filter(item -> Objects.nonNull(item.getTodoCode()))
207 216 .collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
208   - new TreeSet<>(Comparator.comparing(TodoHistory::getDataId))), ArrayList::new)
  217 + new TreeSet<>(Comparator.comparing(TodoHistory::getRemoveDuplicatesCondition))), ArrayList::new)
209 218 );
210 219 if (!Objects.equals(hasSaveTodo.size(), 0) && Objects.equals(collect.size(), hasSaveTodo.size()))
211 220 return;
... ...
fw-dalaran-server/src/main/resources/application-local.yml
... ... @@ -14,6 +14,10 @@ spring:
14 14 name: fw-dalaran-local
15 15 banner:
16 16 location: "classpath:banner.txt"
  17 + redis:
  18 + host: 172.26.154.169
  19 + password: fw@test@redis
  20 + port: 6378
17 21 rocketmq:
18 22 # name-server: 192.168.0.230:9876
19 23 name-server: 172.26.154.169:9876
... ...
fw-dalaran-server/src/main/resources/application.yml
... ... @@ -114,3 +114,20 @@ logbook:
114 114 task:
115 115 switch: 'on'
116 116 todocode: 'xiOMX9KlMg'
  117 +
  118 +management:
  119 + endpoints:
  120 + web:
  121 + exposure:
  122 + include: '*'
  123 + # 监控路径前缀
  124 + base-path: /actuator
  125 + endpoint:
  126 + # 开启允许远程shutdown,通过post请求。
  127 + shutdown:
  128 + enabled: true
  129 + health:
  130 + show-details: always
  131 + metrics:
  132 + tags:
  133 + application: ${spring.application.name}
... ...