1
|
package com.sunyo.wlpt.message.bus.service.service.view;
|
1
|
package com.sunyo.wlpt.message.bus.service.service.view;
|
2
|
|
2
|
|
3
|
-import com.rabbitmq.http.client.domain.QueueInfo;
|
|
|
4
|
import com.sunyo.wlpt.message.bus.service.domain.BusServer;
|
3
|
import com.sunyo.wlpt.message.bus.service.domain.BusServer;
|
5
|
import com.sunyo.wlpt.message.bus.service.domain.VirtualHost;
|
4
|
import com.sunyo.wlpt.message.bus.service.domain.VirtualHost;
|
|
|
5
|
+import com.sunyo.wlpt.message.bus.service.domain.view.ViewQueueInfo;
|
6
|
import com.sunyo.wlpt.message.bus.service.mapper.BusServerMapper;
|
6
|
import com.sunyo.wlpt.message.bus.service.mapper.BusServerMapper;
|
7
|
import com.sunyo.wlpt.message.bus.service.mapper.VirtualHostMapper;
|
7
|
import com.sunyo.wlpt.message.bus.service.mapper.VirtualHostMapper;
|
8
|
import com.sunyo.wlpt.message.bus.service.rabbit.utils.ClientUtils;
|
8
|
import com.sunyo.wlpt.message.bus.service.rabbit.utils.ClientUtils;
|
|
@@ -32,17 +32,16 @@ public class ViewQueueFactory { |
|
@@ -32,17 +32,16 @@ public class ViewQueueFactory { |
32
|
@Resource
|
32
|
@Resource
|
33
|
private VirtualHostMapper virtualHostMapper;
|
33
|
private VirtualHostMapper virtualHostMapper;
|
34
|
|
34
|
|
35
|
- public ResultJson getViewQueueList(String serverName, String virtualHostName, Integer pageNum, Integer pageSize) throws IOException,
|
|
|
36
|
- URISyntaxException
|
35
|
+ public ResultJson getViewQueueList(String serverName, String virtualHostName, Integer pageNum, Integer pageSize) throws IOException, URISyntaxException
|
37
|
{
|
36
|
{
|
38
|
- List<QueueInfo> list = new ArrayList<>();
|
37
|
+ List<ViewQueueInfo> list = new ArrayList<>();
|
39
|
|
38
|
|
40
|
// 服务器名称、虚拟主机名称,均为空
|
39
|
// 服务器名称、虚拟主机名称,均为空
|
41
|
if (StringUtil.isNullOrEmpty(serverName) && StringUtil.isNullOrEmpty(virtualHostName)) {
|
40
|
if (StringUtil.isNullOrEmpty(serverName) && StringUtil.isNullOrEmpty(virtualHostName)) {
|
42
|
List<BusServer> serverList = busServerMapper.getServerList();
|
41
|
List<BusServer> serverList = busServerMapper.getServerList();
|
43
|
for (BusServer busServer : serverList) {
|
42
|
for (BusServer busServer : serverList) {
|
44
|
- List<QueueInfo> queueInfoList = ClientUtils.getViewQueues(busServer);
|
|
|
45
|
- list.addAll(queueInfoList);
|
43
|
+ List<ViewQueueInfo> viewQueueInfoList = ClientUtils.getViewQueues(busServer);
|
|
|
44
|
+ list.addAll(viewQueueInfoList);
|
46
|
}
|
45
|
}
|
47
|
}
|
46
|
}
|
48
|
|
47
|
|
|
@@ -52,8 +51,8 @@ public class ViewQueueFactory { |
|
@@ -52,8 +51,8 @@ public class ViewQueueFactory { |
52
|
if (busServer == null) {
|
51
|
if (busServer == null) {
|
53
|
return new ResultJson("400", "该服务器名称不存在,请仔细检查");
|
52
|
return new ResultJson("400", "该服务器名称不存在,请仔细检查");
|
54
|
}
|
53
|
}
|
55
|
- List<QueueInfo> queueInfoList = ClientUtils.getViewQueues(busServer);
|
|
|
56
|
- list.addAll(queueInfoList);
|
54
|
+ List<ViewQueueInfo> viewQueueInfoList = ClientUtils.getViewQueues(busServer);
|
|
|
55
|
+ list.addAll(viewQueueInfoList);
|
57
|
}
|
56
|
}
|
58
|
|
57
|
|
59
|
// 仅,虚拟主机名称不为空
|
58
|
// 仅,虚拟主机名称不为空
|
|
@@ -63,8 +62,8 @@ public class ViewQueueFactory { |
|
@@ -63,8 +62,8 @@ public class ViewQueueFactory { |
63
|
return new ResultJson("400", "该虚拟主机名称不存在,请仔细检查");
|
62
|
return new ResultJson("400", "该虚拟主机名称不存在,请仔细检查");
|
64
|
}
|
63
|
}
|
65
|
BusServer busServer = busServerMapper.selectByPrimaryKey(virtualHost.getServerId());
|
64
|
BusServer busServer = busServerMapper.selectByPrimaryKey(virtualHost.getServerId());
|
66
|
- List<QueueInfo> queueInfoList = ClientUtils.getViewQueues(busServer, virtualHostName);
|
|
|
67
|
- list.addAll(queueInfoList);
|
65
|
+ List<ViewQueueInfo> viewQueueInfoList = ClientUtils.getViewQueues(busServer, virtualHostName);
|
|
|
66
|
+ list.addAll(viewQueueInfoList);
|
68
|
}
|
67
|
}
|
69
|
|
68
|
|
70
|
// 服务器名称、虚拟主机名称,均不为空
|
69
|
// 服务器名称、虚拟主机名称,均不为空
|
|
@@ -80,13 +79,13 @@ public class ViewQueueFactory { |
|
@@ -80,13 +79,13 @@ public class ViewQueueFactory { |
80
|
if (!virtualHost.getServerId().equals(busServer.getId())) {
|
79
|
if (!virtualHost.getServerId().equals(busServer.getId())) {
|
81
|
return new ResultJson("400", "该虚拟主机不属于该服务器,请仔细检查");
|
80
|
return new ResultJson("400", "该虚拟主机不属于该服务器,请仔细检查");
|
82
|
}
|
81
|
}
|
83
|
- List<QueueInfo> queueInfoList = ClientUtils.getViewQueues(busServer, virtualHostName);
|
|
|
84
|
- list.addAll(queueInfoList);
|
82
|
+ List<ViewQueueInfo> viewQueueInfoList = ClientUtils.getViewQueues(busServer, virtualHostName);
|
|
|
83
|
+ list.addAll(viewQueueInfoList);
|
85
|
}
|
84
|
}
|
86
|
Integer total = list.size();
|
85
|
Integer total = list.size();
|
87
|
|
86
|
|
88
|
// 达到分页与排序效果
|
87
|
// 达到分页与排序效果
|
89
|
- List<QueueInfo> resultList = subList(pageNum, pageSize, list);
|
88
|
+ List<ViewQueueInfo> resultList = subAndSortList(pageNum, pageSize, list);
|
90
|
return resultList.size() > 0
|
89
|
return resultList.size() > 0
|
91
|
? new ResultJson<>("200", "查询队列监控,成功!", resultList, total)
|
90
|
? new ResultJson<>("200", "查询队列监控,成功!", resultList, total)
|
92
|
: new ResultJson<>("500", "查询队列监控,失败!");
|
91
|
: new ResultJson<>("500", "查询队列监控,失败!");
|
|
@@ -100,7 +99,7 @@ public class ViewQueueFactory { |
|
@@ -100,7 +99,7 @@ public class ViewQueueFactory { |
100
|
* @param list 全部的数据
|
99
|
* @param list 全部的数据
|
101
|
* @return List<QueueInfo>
|
100
|
* @return List<QueueInfo>
|
102
|
*/
|
101
|
*/
|
103
|
- public List<QueueInfo> subList(Integer pageNum, Integer pageSize, List<QueueInfo> list)
|
102
|
+ public List<ViewQueueInfo> subAndSortList(Integer pageNum, Integer pageSize, List<ViewQueueInfo> list)
|
104
|
{
|
103
|
{
|
105
|
Integer total = list.size();
|
104
|
Integer total = list.size();
|
106
|
Integer start = (pageNum - 1) * pageSize;
|
105
|
Integer start = (pageNum - 1) * pageSize;
|
|
@@ -112,10 +111,11 @@ public class ViewQueueFactory { |
|
@@ -112,10 +111,11 @@ public class ViewQueueFactory { |
112
|
if (end > total) {
|
111
|
if (end > total) {
|
113
|
end = total;
|
112
|
end = total;
|
114
|
}
|
113
|
}
|
115
|
- List<QueueInfo> pageList = list.subList(start, end);
|
|
|
116
|
- // 对总信息数,进行降序排序
|
|
|
117
|
- List<QueueInfo> resultList =
|
|
|
118
|
- pageList.stream().sorted(Comparator.comparing(QueueInfo::getTotalMessages).reversed()).collect(Collectors.toList());
|
114
|
+ List<ViewQueueInfo> pageList = list.subList(start, end);
|
|
|
115
|
+ // 对积压数,进行降序排序
|
|
|
116
|
+ List<ViewQueueInfo> resultList =
|
|
|
117
|
+ pageList.stream().sorted(Comparator.comparing(ViewQueueInfo::getMessageReady).reversed())
|
|
|
118
|
+ .collect(Collectors.toList());
|
119
|
return resultList;
|
119
|
return resultList;
|
120
|
}
|
120
|
}
|
121
|
} |
121
|
} |