Commit 4a60f7d1 authored by duanruiming's avatar duanruiming

[update] 信号服务优化

parent be18693d
...@@ -10,13 +10,11 @@ import net.wanji.web.common.util.date.DateStyle; ...@@ -10,13 +10,11 @@ import net.wanji.web.common.util.date.DateStyle;
import net.wanji.web.websocket.WebSocketServer; import net.wanji.web.websocket.WebSocketServer;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.*;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -37,7 +35,8 @@ public class SystemServiceStatusTask { ...@@ -37,7 +35,8 @@ public class SystemServiceStatusTask {
@Scheduled(fixedRate = 1 * 60 * 1000) @Scheduled(fixedRate = 1 * 60 * 1000)
public void telnetStatus() throws Exception { public void telnetStatus() throws Exception {
Set<WebSocketServer> webSocketSet = WebSocketServer.getWebSocketSet(Constant.WEBSOCKET_TOPIC_SYS_SERVICE_STATUS);
if (!CollectionUtils.isEmpty(webSocketSet)) {
for (SystemServiceStatusDTO dto : sysList) { for (SystemServiceStatusDTO dto : sysList) {
String ip = dto.getIp(); String ip = dto.getIp();
int port = dto.getPort(); int port = dto.getPort();
...@@ -56,7 +55,8 @@ public class SystemServiceStatusTask { ...@@ -56,7 +55,8 @@ public class SystemServiceStatusTask {
} }
} }
List<SystemServiceStatusDTO> sort = sysList.stream().sorted(Comparator.comparing(SystemServiceStatusDTO::getStartDate)).collect(Collectors.toList()); List<SystemServiceStatusDTO> sort = sysList.stream().sorted(Comparator.comparing(SystemServiceStatusDTO::getStartDate)).collect(Collectors.toList());
WebSocketServer.sendInfo2All(JSON.toJSONString(sort), Constant.WEBSOCKET_TOPIC_SYS_SERVICE_STATUS); WebSocketServer.sendTopicInfo2All(JSON.toJSONString(sort), Constant.WEBSOCKET_TOPIC_SYS_SERVICE_STATUS);
}
} }
} }
...@@ -170,7 +170,7 @@ public class WebSocketServer { ...@@ -170,7 +170,7 @@ public class WebSocketServer {
* @param topic * @param topic
* @throws IOException * @throws IOException
*/ */
public static void sendInfo2All(String message, String topic) throws IOException { public static void sendTopicInfo2All(String message, String topic) throws IOException {
if (StringUtils.isNotBlank(topic) && webSocketMap.containsKey(topic)) { if (StringUtils.isNotBlank(topic) && webSocketMap.containsKey(topic)) {
try { try {
Set<WebSocketServer> socketSets = webSocketMap.get(topic); Set<WebSocketServer> socketSets = webSocketMap.get(topic);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment