feat: dashboard 接口
This commit is contained in:
@@ -279,6 +279,11 @@ public interface OmadaSiteApi {
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<OperationResponseGridVoSiteSummaryInfo> getSiteList(@NotNull @ApiParam(value = "Start page number. Start from 1.", required = true) @Valid @RequestParam(value = "page", required = true) Integer page,@NotNull @ApiParam(value = "Number of entries per page. It should be within the range of 1–1000.", required = true) @Valid @RequestParam(value = "pageSize", required = true) Integer pageSize);
|
||||
|
||||
@RequestMapping(value = "/openapi/v1/${omada.omadac-id}/sites",
|
||||
produces = "*/*",
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<OperationResponseGridVoSiteSummaryInfo> getSiteList(@NotNull @ApiParam(value = "Start page number. Start from 1.", required = true) @Valid @RequestParam(value = "page", required = true) Integer page,@NotNull @ApiParam(value = "Number of entries per page. It should be within the range of 1–1000.", required = true) @Valid @RequestParam(value = "pageSize", required = true) Integer pageSize, @ApiParam(value = "Fuzzy query parameters, support field name") @Valid @RequestParam(value = "searchKey", required = false) String searchKey);
|
||||
|
||||
|
||||
/**
|
||||
* GET /openapi/v1/{omadacId}/sites/tags : Get site tag list
|
||||
|
||||
@@ -84,6 +84,11 @@
|
||||
<groupId>org.wfc</groupId>
|
||||
<artifactId>wfc-common-mybatis</artifactId>
|
||||
</dependency>
|
||||
<!-- mapstruct -->
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.wfc.system.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.wfc.common.core.web.controller.BaseController;
|
||||
import org.wfc.common.core.web.domain.AjaxResult;
|
||||
import org.wfc.common.core.web.page.TableDataInfo;
|
||||
import org.wfc.system.service.ISysDashboardService;
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @author: cyc
|
||||
* @since: 2025-01-07
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/dashboard")
|
||||
public class SysDashboardController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ISysDashboardService sysDashboardService;
|
||||
|
||||
|
||||
@GetMapping("/page")
|
||||
public TableDataInfo page(@RequestParam(value = "searchKey", required = false) String searchKey) {
|
||||
startPage();
|
||||
return sysDashboardService.getSiteList(searchKey);
|
||||
}
|
||||
|
||||
@GetMapping("/overview")
|
||||
public AjaxResult overview() {
|
||||
return success(sysDashboardService.overview());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.wfc.system.domain.convert;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import org.wfc.omada.api.organization.model.SiteSummaryInfo;
|
||||
import org.wfc.system.domain.vo.SysDashboardSiteVo;
|
||||
|
||||
/**
|
||||
* @description: OmadaMapping
|
||||
* @author: cyc
|
||||
* @since: 2024-12-30
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysDashboardConvert {
|
||||
|
||||
SysDashboardConvert INSTANCE = Mappers.getMapper(SysDashboardConvert.class);
|
||||
|
||||
SysDashboardSiteVo toSysDashboardSiteVo(SiteSummaryInfo siteSummaryInfo);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package org.wfc.system.domain.vo;
|
||||
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: cyc
|
||||
* @since: 2025-01-07
|
||||
*/
|
||||
@Data
|
||||
public class SysDashboardSiteVo {
|
||||
private String siteId;
|
||||
|
||||
private String name;
|
||||
|
||||
private List<String> tagIds = null;
|
||||
|
||||
private String region;
|
||||
|
||||
private String timeZone;
|
||||
|
||||
private String scenario;
|
||||
|
||||
private Double longitude;
|
||||
|
||||
private Double latitude;
|
||||
|
||||
private String address;
|
||||
|
||||
private Integer type;
|
||||
|
||||
private Boolean supportES;
|
||||
|
||||
private Boolean supportL2;
|
||||
|
||||
private Integer totalGatewayNum;
|
||||
|
||||
private Integer connectedGatewayNum;
|
||||
|
||||
private Integer disconnectedGatewayNum;
|
||||
|
||||
private Integer netCapacity;
|
||||
|
||||
private Double netUsage;
|
||||
|
||||
private Integer totalSwitchNum;
|
||||
|
||||
private Integer connectedSwitchNum;
|
||||
|
||||
private Integer disconnectedSwitchNum;
|
||||
|
||||
private Integer totalPorts;
|
||||
|
||||
private Integer availablePorts;
|
||||
|
||||
private Double powerConsumption;
|
||||
|
||||
private Integer totalApNum;
|
||||
|
||||
private Integer connectedApNum;
|
||||
|
||||
private Integer isolatedApNum;
|
||||
|
||||
private Integer disconnectedApNum;
|
||||
|
||||
private Integer totalClientNum;
|
||||
|
||||
private Integer wiredClientNum;
|
||||
|
||||
private Integer wirelessClientNum;
|
||||
|
||||
private Integer guestNum;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package org.wfc.system.domain.vo;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author: cyc
|
||||
* @since: 2025-01-07
|
||||
*/
|
||||
@Data
|
||||
public class SysDashboardVo {
|
||||
|
||||
private Integer SiteNum = 0;
|
||||
|
||||
private Integer totalGatewayNum = 0;
|
||||
|
||||
private Integer connectedGatewayNum = 0;
|
||||
|
||||
private Integer disconnectedGatewayNum = 0;
|
||||
|
||||
private Integer netCapacity = 0;
|
||||
|
||||
private Double netUsage = 0.0;
|
||||
|
||||
private Integer totalSwitchNum = 0;
|
||||
|
||||
private Integer connectedSwitchNum = 0;
|
||||
|
||||
private Integer disconnectedSwitchNum = 0;
|
||||
|
||||
private Integer totalPorts = 0;
|
||||
|
||||
private Integer availablePorts = 0;
|
||||
|
||||
private Double powerConsumption = 0.0;
|
||||
|
||||
private Integer totalApNum = 0;
|
||||
|
||||
private Integer connectedApNum = 0;
|
||||
|
||||
private Integer isolatedApNum = 0;
|
||||
|
||||
private Integer disconnectedApNum = 0;
|
||||
|
||||
private Integer totalClientNum = 0;
|
||||
|
||||
private Integer wiredClientNum = 0;
|
||||
|
||||
private Integer wirelessClientNum = 0;
|
||||
|
||||
private Integer guestNum = 0;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.wfc.system.service;
|
||||
|
||||
import org.wfc.common.core.web.page.TableDataInfo;
|
||||
import org.wfc.system.domain.vo.SysDashboardVo;
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @author: cyc
|
||||
* @since: 2025-01-07
|
||||
*/
|
||||
public interface ISysDashboardService {
|
||||
|
||||
TableDataInfo getSiteList(String searchKey);
|
||||
|
||||
SysDashboardVo overview();
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package org.wfc.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.wfc.common.core.constant.HttpStatus;
|
||||
import org.wfc.common.core.web.page.TableDataInfo;
|
||||
import org.wfc.omada.api.monitor.OmadaDashboardApi;
|
||||
import org.wfc.omada.api.monitor.model.GetDashboardOverview;
|
||||
import org.wfc.omada.api.monitor.model.OperationResponseGetDashboardOverview;
|
||||
import org.wfc.omada.api.organization.OmadaSiteApi;
|
||||
import org.wfc.omada.api.organization.model.OperationResponseGridVoSiteSummaryInfo;
|
||||
import org.wfc.omada.api.organization.model.SiteSummaryInfo;
|
||||
import org.wfc.system.domain.convert.SysDashboardConvert;
|
||||
import org.wfc.system.domain.vo.SysDashboardSiteVo;
|
||||
import org.wfc.system.domain.vo.SysDashboardVo;
|
||||
import org.wfc.system.service.ISysDashboardService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @author: cyc
|
||||
* @since: 2025-01-07
|
||||
*/
|
||||
@Service
|
||||
public class SysDashboardServiceImpl implements ISysDashboardService {
|
||||
@Autowired
|
||||
private OmadaSiteApi omadaSiteApi;
|
||||
|
||||
@Autowired
|
||||
private OmadaDashboardApi omadaDashboardApi;
|
||||
|
||||
@Override
|
||||
public TableDataInfo getSiteList(String searchKey) {
|
||||
ResponseEntity<OperationResponseGridVoSiteSummaryInfo> siteList = omadaSiteApi.getSiteList(PageHelper.getLocalPage().getPageNum(), PageHelper.getLocalPage().getPageSize(), searchKey);
|
||||
if (siteList.getBody() == null) {
|
||||
return getDataTable(Collections.emptyList(), 0L);
|
||||
}
|
||||
List<SiteSummaryInfo> sites = siteList.getBody().getResult().getData();
|
||||
List<SysDashboardSiteVo> siteVos = new ArrayList<>();
|
||||
for (SiteSummaryInfo site : sites) {
|
||||
SysDashboardSiteVo siteVo = SysDashboardConvert.INSTANCE.toSysDashboardSiteVo(site);
|
||||
ResponseEntity<OperationResponseGetDashboardOverview> overview = omadaDashboardApi.getOverview(site.getSiteId());
|
||||
if (overview.getBody() == null) {
|
||||
continue;
|
||||
}
|
||||
GetDashboardOverview dashboardOverview = overview.getBody().getResult();
|
||||
BeanUtils.copyProperties(dashboardOverview, siteVo);
|
||||
siteVos.add(siteVo);
|
||||
}
|
||||
return getDataTable(siteVos, siteList.getBody().getResult().getTotalRows());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysDashboardVo overview() {
|
||||
ResponseEntity<OperationResponseGridVoSiteSummaryInfo> siteList = omadaSiteApi.getSiteList(1, 1000);
|
||||
SysDashboardVo sysDashboardVo = new SysDashboardVo();
|
||||
if (siteList.getBody() == null) {
|
||||
return sysDashboardVo;
|
||||
}
|
||||
List<SiteSummaryInfo> sites = siteList.getBody().getResult().getData();
|
||||
|
||||
List<GetDashboardOverview> dashboardOverviews = new ArrayList<>();
|
||||
for (SiteSummaryInfo site : sites) {
|
||||
ResponseEntity<OperationResponseGetDashboardOverview> overview = omadaDashboardApi.getOverview(site.getSiteId());
|
||||
if (overview.getBody() == null) {
|
||||
continue;
|
||||
}
|
||||
GetDashboardOverview dashboardOverview = overview.getBody().getResult();
|
||||
dashboardOverviews.add(dashboardOverview);
|
||||
}
|
||||
sysDashboardVo.setAvailablePorts(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getAvailablePorts())).mapToInt(GetDashboardOverview::getAvailablePorts).sum());
|
||||
sysDashboardVo.setConnectedGatewayNum(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getConnectedGatewayNum())).mapToInt(GetDashboardOverview::getConnectedGatewayNum).sum());
|
||||
sysDashboardVo.setConnectedApNum(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getConnectedApNum())).mapToInt(GetDashboardOverview::getConnectedApNum).sum());
|
||||
sysDashboardVo.setConnectedSwitchNum(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getConnectedSwitchNum())).mapToInt(GetDashboardOverview::getConnectedSwitchNum).sum());
|
||||
sysDashboardVo.setGuestNum(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getGuestNum())).mapToInt(GetDashboardOverview::getGuestNum).sum());
|
||||
sysDashboardVo.setDisconnectedApNum(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getDisconnectedApNum())).mapToInt(GetDashboardOverview::getDisconnectedApNum).sum());
|
||||
sysDashboardVo.setNetCapacity(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getNetCapacity())).mapToInt(GetDashboardOverview::getNetCapacity).sum());
|
||||
sysDashboardVo.setIsolatedApNum(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getIsolatedApNum())).mapToInt(GetDashboardOverview::getIsolatedApNum).sum());
|
||||
sysDashboardVo.setNetUsage(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getNetUsage())).mapToDouble(GetDashboardOverview::getNetUsage).sum());
|
||||
sysDashboardVo.setDisconnectedGatewayNum(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getDisconnectedGatewayNum())).mapToInt(GetDashboardOverview::getDisconnectedGatewayNum).sum());
|
||||
sysDashboardVo.setTotalApNum(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getTotalApNum())).mapToInt(GetDashboardOverview::getTotalApNum).sum());
|
||||
sysDashboardVo.setTotalPorts(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getTotalPorts())).mapToInt(GetDashboardOverview::getTotalPorts).sum());
|
||||
sysDashboardVo.setTotalClientNum(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getTotalClientNum())).mapToInt(GetDashboardOverview::getTotalClientNum).sum());
|
||||
sysDashboardVo.setTotalSwitchNum(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getTotalSwitchNum())).mapToInt(GetDashboardOverview::getTotalSwitchNum).sum());
|
||||
sysDashboardVo.setPowerConsumption(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getPowerConsumption())).mapToDouble(GetDashboardOverview::getPowerConsumption).sum());
|
||||
sysDashboardVo.setWirelessClientNum(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getWirelessClientNum())).mapToInt(GetDashboardOverview::getWirelessClientNum).sum());
|
||||
sysDashboardVo.setWiredClientNum(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getWiredClientNum())).mapToInt(GetDashboardOverview::getWiredClientNum).sum());
|
||||
sysDashboardVo.setDisconnectedApNum(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getDisconnectedApNum())).mapToInt(GetDashboardOverview::getDisconnectedApNum).sum());
|
||||
sysDashboardVo.setTotalGatewayNum(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getTotalGatewayNum())).mapToInt(GetDashboardOverview::getTotalGatewayNum).sum());
|
||||
sysDashboardVo.setSiteNum(sites.size());
|
||||
|
||||
return sysDashboardVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应请求分页数据
|
||||
*/
|
||||
protected TableDataInfo getDataTable(List<?> list, Long total) {
|
||||
TableDataInfo rspData = new TableDataInfo(list, total);
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
|
||||
return rspData;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user