feat: 注册用户数和在线用户数
This commit is contained in:
@@ -49,4 +49,8 @@ public class SysDashboardVo {
|
|||||||
private Integer wirelessClientNum = 0;
|
private Integer wirelessClientNum = 0;
|
||||||
|
|
||||||
private Integer guestNum = 0;
|
private Integer guestNum = 0;
|
||||||
|
|
||||||
|
private Long registerUserNum = 0L;
|
||||||
|
|
||||||
|
private Integer onlineUserNum = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,32 @@
|
|||||||
package org.wfc.system.service.impl;
|
package org.wfc.system.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.wfc.common.core.constant.CacheConstants;
|
||||||
import org.wfc.common.core.constant.HttpStatus;
|
import org.wfc.common.core.constant.HttpStatus;
|
||||||
|
import org.wfc.common.core.domain.LoginUser;
|
||||||
import org.wfc.common.core.web.page.TableDataInfo;
|
import org.wfc.common.core.web.page.TableDataInfo;
|
||||||
|
import org.wfc.common.redis.service.RedisService;
|
||||||
import org.wfc.omada.api.monitor.OmadaDashboardApi;
|
import org.wfc.omada.api.monitor.OmadaDashboardApi;
|
||||||
import org.wfc.omada.api.monitor.model.GetDashboardOverview;
|
import org.wfc.omada.api.monitor.model.GetDashboardOverview;
|
||||||
import org.wfc.omada.api.monitor.model.OperationResponseGetDashboardOverview;
|
import org.wfc.omada.api.monitor.model.OperationResponseGetDashboardOverview;
|
||||||
import org.wfc.omada.api.organization.OmadaSiteApi;
|
import org.wfc.omada.api.organization.OmadaSiteApi;
|
||||||
import org.wfc.omada.api.organization.model.OperationResponseGridVoSiteSummaryInfo;
|
import org.wfc.omada.api.organization.model.OperationResponseGridVoSiteSummaryInfo;
|
||||||
import org.wfc.omada.api.organization.model.SiteSummaryInfo;
|
import org.wfc.omada.api.organization.model.SiteSummaryInfo;
|
||||||
|
import org.wfc.system.api.domain.SysUser;
|
||||||
import org.wfc.system.domain.convert.SysDashboardConvert;
|
import org.wfc.system.domain.convert.SysDashboardConvert;
|
||||||
import org.wfc.system.domain.vo.SysDashboardSiteVo;
|
import org.wfc.system.domain.vo.SysDashboardSiteVo;
|
||||||
import org.wfc.system.domain.vo.SysDashboardVo;
|
import org.wfc.system.domain.vo.SysDashboardVo;
|
||||||
|
import org.wfc.system.mapper.UUserMapper;
|
||||||
import org.wfc.system.service.ISysDashboardService;
|
import org.wfc.system.service.ISysDashboardService;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -36,6 +43,12 @@ public class SysDashboardServiceImpl implements ISysDashboardService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private OmadaDashboardApi omadaDashboardApi;
|
private OmadaDashboardApi omadaDashboardApi;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisService redisService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UUserMapper userMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo getSiteList(String searchKey) {
|
public TableDataInfo getSiteList(String searchKey) {
|
||||||
ResponseEntity<OperationResponseGridVoSiteSummaryInfo> siteList = omadaSiteApi.getSiteList(PageHelper.getLocalPage().getPageNum(), PageHelper.getLocalPage().getPageSize(), searchKey);
|
ResponseEntity<OperationResponseGridVoSiteSummaryInfo> siteList = omadaSiteApi.getSiteList(PageHelper.getLocalPage().getPageNum(), PageHelper.getLocalPage().getPageSize(), searchKey);
|
||||||
@@ -96,6 +109,20 @@ public class SysDashboardServiceImpl implements ISysDashboardService {
|
|||||||
sysDashboardVo.setTotalGatewayNum(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getTotalGatewayNum())).mapToInt(GetDashboardOverview::getTotalGatewayNum).sum());
|
sysDashboardVo.setTotalGatewayNum(dashboardOverviews.stream().filter(c -> ObjectUtil.isNotNull(c.getTotalGatewayNum())).mapToInt(GetDashboardOverview::getTotalGatewayNum).sum());
|
||||||
sysDashboardVo.setSiteNum(sites.size());
|
sysDashboardVo.setSiteNum(sites.size());
|
||||||
|
|
||||||
|
// 注册用户数和在线用户数
|
||||||
|
Long registerUserNum = userMapper.selectCount(Wrappers.lambdaQuery());
|
||||||
|
Integer onlineUserNum = 0;
|
||||||
|
Collection<String> keys = redisService.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
|
||||||
|
for (String key : keys) {
|
||||||
|
LoginUser user = redisService.getCacheObject(key);
|
||||||
|
Object userObj = user.getUser();
|
||||||
|
if (!(userObj instanceof SysUser)) {
|
||||||
|
onlineUserNum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sysDashboardVo.setRegisterUserNum(registerUserNum);
|
||||||
|
sysDashboardVo.setOnlineUserNum(onlineUserNum);
|
||||||
|
|
||||||
return sysDashboardVo;
|
return sysDashboardVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user