use of com.usthe.manager.pojo.dto.AppCount in project hertzbeat by dromara.
the class MonitorServiceImpl method getAllAppMonitorsCount.
@Override
public List<AppCount> getAllAppMonitorsCount() {
List<AppCount> appCounts = monitorDao.findAppsStatusCount();
if (appCounts == null) {
return null;
}
// Statistical category information, calculate the number of corresponding states for each monitor
// 统计类别信息,计算每个监控分别对应状态的数量
Map<String, AppCount> appCountMap = new HashMap<>(appCounts.size());
for (AppCount item : appCounts) {
AppCount appCount = appCountMap.getOrDefault(item.getApp(), new AppCount());
appCount.setApp(item.getApp());
switch(item.getStatus()) {
case CommonConstants.AVAILABLE_CODE:
appCount.setAvailableSize(appCount.getAvailableSize() + item.getSize());
break;
case CommonConstants.UN_AVAILABLE_CODE:
appCount.setUnAvailableSize(appCount.getUnAvailableSize() + item.getSize());
break;
case CommonConstants.UN_MANAGE_CODE:
appCount.setUnManageSize(appCount.getUnManageSize() + item.getSize());
break;
case CommonConstants.UN_REACHABLE_CODE:
appCount.setUnReachableSize(appCount.getUnReachableSize() + item.getSize());
break;
default:
break;
}
appCountMap.put(item.getApp(), appCount);
}
// 遍历统计得到的map,转换成List<App Count>结果集
return appCountMap.values().stream().peek(item -> {
item.setSize(item.getAvailableSize() + item.getUnManageSize() + item.getUnReachableSize() + item.getUnAvailableSize());
Job job = appService.getAppDefine(item.getApp());
if (job != null) {
item.setCategory(job.getCategory());
}
}).collect(Collectors.toList());
}
use of com.usthe.manager.pojo.dto.AppCount in project hertzbeat by dromara.
the class SummaryController method appMonitors.
@GetMapping
@ApiOperation(value = "Query all application category monitoring statistics", notes = "查询所有应用类别监控统计信息")
public ResponseEntity<Message<Dashboard>> appMonitors() {
List<AppCount> appsCount = monitorService.getAllAppMonitorsCount();
Message<Dashboard> message = new Message<>(new Dashboard(appsCount));
return ResponseEntity.ok(message);
}
Aggregations