mirror of https://gitee.com/stylefeng/roses
【7.1.6】【statistics】更新首页统计数字的方法
parent
384bade526
commit
55bcdc8a99
|
@ -14,6 +14,6 @@ public interface PositionServiceApi {
|
|||
* @author xixiaowei
|
||||
* @date 2022/2/9 9:37
|
||||
*/
|
||||
Integer PositionNum();
|
||||
Integer positionNum();
|
||||
|
||||
}
|
||||
|
|
|
@ -71,40 +71,32 @@
|
|||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>system-business-user</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!--定时任务-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>timer-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--首页信息缓存-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>cache-sdk-memory</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>cache-sdk-redis</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!--用户业务-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>system-business-user</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--菜单业务-->
|
||||
|
@ -120,6 +112,13 @@
|
|||
<artifactId>system-business-organization</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 拦截接口,记录常用功能 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -6,12 +6,9 @@ import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
|||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.home.HomeCompanyInfo;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.resource.ResourceRequest;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.user.OnlineUserDTO;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.user.request.OnlineUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.menu.entity.SysMenu;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import cn.stylefeng.roses.kernel.system.modular.home.service.HomePageService;
|
||||
import cn.stylefeng.roses.kernel.system.modular.menu.entity.SysMenu;
|
||||
import cn.stylefeng.roses.kernel.system.modular.statistic.pojo.OnlineUserStat;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
@ -70,7 +67,7 @@ public class HomePageController {
|
|||
* @author xixiaowei
|
||||
* @date 2022/2/10 11:34
|
||||
*/
|
||||
@GetResource(name = "获取常用功能接口", path = "/homePage/getCommonFunctions")
|
||||
@GetResource(name = "获取常用功能接口", path = "/homePage/getCommonFunctions", requiredPermission = false)
|
||||
public ResponseData<List<SysMenu>> getCommonFunctions() {
|
||||
return new SuccessResponseData<>(homePageService.getCommonFunctions());
|
||||
}
|
||||
|
|
|
@ -3,40 +3,40 @@ package cn.stylefeng.roses.kernel.system.modular.home.service;
|
|||
import cn.stylefeng.roses.kernel.log.api.pojo.record.LogRecordDTO;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.home.HomeCompanyInfo;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.user.request.OnlineUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.statistic.pojo.OnlineUserStat;
|
||||
import cn.stylefeng.roses.kernel.system.modular.menu.entity.SysMenu;
|
||||
import cn.stylefeng.roses.kernel.system.modular.statistic.pojo.OnlineUserStat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页服务接口
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2022/1/25 9:43
|
||||
* @author fengshuonan
|
||||
* @date 2022/2/11 20:41
|
||||
*/
|
||||
public interface HomePageService {
|
||||
|
||||
/**
|
||||
* 查询动态列表
|
||||
* 查询本用户最近操作记录
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2022/1/25 14:48
|
||||
* @author fengshuonan
|
||||
* @date 2022/2/11 20:40
|
||||
*/
|
||||
List<LogRecordDTO> getRecentLogs();
|
||||
|
||||
/**
|
||||
* 获取在线用户列表
|
||||
* 获取在线用户统计
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2022/1/25 14:06
|
||||
* @author fengshuonan
|
||||
* @date 2022/2/11 20:40
|
||||
*/
|
||||
OnlineUserStat getOnlineUserList(OnlineUserRequest onlineUserRequest);
|
||||
|
||||
/**
|
||||
* 获取首页企业和公司信息
|
||||
* 获取首页公司部门人员信息统计
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2022/1/25 15:31
|
||||
* @author fengshuonan
|
||||
* @date 2022/2/11 21:03
|
||||
*/
|
||||
HomeCompanyInfo getHomeCompanyInfo();
|
||||
|
||||
|
|
|
@ -8,15 +8,16 @@ import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
|||
import cn.stylefeng.roses.kernel.log.api.LogManagerApi;
|
||||
import cn.stylefeng.roses.kernel.log.api.pojo.manage.LogManagerRequest;
|
||||
import cn.stylefeng.roses.kernel.log.api.pojo.record.LogRecordDTO;
|
||||
import cn.stylefeng.roses.kernel.system.api.*;
|
||||
import cn.stylefeng.roses.kernel.system.api.HomePageServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.api.PositionServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.api.UserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.home.HomeCompanyInfo;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrOrganizationDTO;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.user.OnlineUserDTO;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.user.request.OnlineUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.user.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.home.entity.SysStatisticsCount;
|
||||
import cn.stylefeng.roses.kernel.system.modular.home.entity.SysStatisticsUrl;
|
||||
import cn.stylefeng.roses.kernel.system.modular.home.service.HomePageService;
|
||||
import cn.stylefeng.roses.kernel.system.modular.home.entity.SysStatisticsCount;
|
||||
import cn.stylefeng.roses.kernel.system.modular.home.service.SysStatisticsCountService;
|
||||
import cn.stylefeng.roses.kernel.system.modular.home.service.SysStatisticsUrlService;
|
||||
import cn.stylefeng.roses.kernel.system.modular.menu.entity.SysMenu;
|
||||
|
@ -26,6 +27,7 @@ import cn.stylefeng.roses.kernel.system.modular.organization.service.HrOrganizat
|
|||
import cn.stylefeng.roses.kernel.system.modular.statistic.pojo.OnlineUserStat;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserOrg;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserOrgService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -33,11 +35,14 @@ import javax.annotation.Resource;
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.stylefeng.roses.kernel.rule.constants.SymbolConstant.LEFT_SQUARE_BRACKETS;
|
||||
import static cn.stylefeng.roses.kernel.rule.constants.SymbolConstant.RIGHT_SQUARE_BRACKETS;
|
||||
|
||||
/**
|
||||
* 首页服务实现类
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2022/1/25 9:45
|
||||
* @author fengshuonan
|
||||
* @date 2022/2/11 20:41
|
||||
*/
|
||||
@Service
|
||||
public class HomePageServiceImpl implements HomePageService, HomePageServiceApi {
|
||||
|
@ -88,7 +93,7 @@ public class HomePageServiceImpl implements HomePageService, HomePageServiceApi
|
|||
// 获取在线总人数
|
||||
List<OnlineUserDTO> onlineUserDTOS = userServiceApi.onlineUserList(onlineUserRequest);
|
||||
|
||||
// 去重
|
||||
// 同一用户多个会话去重
|
||||
HashSet<String> onlineUserList = new HashSet<>();
|
||||
for (OnlineUserDTO onlineUserDTO : onlineUserDTOS) {
|
||||
if (ObjectUtil.isNotEmpty(onlineUserDTO.getRealName())) {
|
||||
|
@ -108,49 +113,35 @@ public class HomePageServiceImpl implements HomePageService, HomePageServiceApi
|
|||
public HomeCompanyInfo getHomeCompanyInfo() {
|
||||
HomeCompanyInfo homeCompanyInfo = new HomeCompanyInfo();
|
||||
|
||||
// 获取组织机构数量
|
||||
List<HrOrganization> hrOrganizationList = hrOrganizationService.list();
|
||||
homeCompanyInfo.setOrganizationNum(hrOrganizationList.size());
|
||||
// 获取组织机构总数量
|
||||
homeCompanyInfo.setOrganizationNum(hrOrganizationService.count());
|
||||
|
||||
// 获取企业人员总数
|
||||
// 获取企业人员总数量
|
||||
SysUserRequest sysUserRequest = new SysUserRequest();
|
||||
List<Long> allUserIdList = userServiceApi.queryAllUserIdList(sysUserRequest);
|
||||
homeCompanyInfo.setEnterprisePersonNum(allUserIdList.size());
|
||||
|
||||
// 获取职位总数
|
||||
int positionNum = positionServiceApi.PositionNum();
|
||||
// 获取所有职位总数
|
||||
int positionNum = positionServiceApi.positionNum();
|
||||
homeCompanyInfo.setPositionNum(positionNum);
|
||||
|
||||
// 获取当前登录用户
|
||||
// 获取当前登录人的组织机构id
|
||||
LoginUser loginUser = LoginContext.me().getLoginUser();
|
||||
|
||||
// 获取组织公司ID
|
||||
Long organizationId = loginUser.getOrganizationId();
|
||||
|
||||
// 设置公司部门数
|
||||
int sectionNum = 1;
|
||||
List<Long> orgIds = new ArrayList<>();
|
||||
// 添加当前用户部门ID
|
||||
orgIds.add(organizationId);
|
||||
for (HrOrganization hrOrganization : hrOrganizationList) {
|
||||
String[] orgPids = hrOrganization.getOrgPids().split(",");
|
||||
for (String orgPid : orgPids) {
|
||||
orgPid = orgPid.substring(1, orgPid.length() - 1);
|
||||
if (organizationId.toString().equals(orgPid)) {
|
||||
orgIds.add(hrOrganization.getOrgId());
|
||||
sectionNum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
homeCompanyInfo.setCurrentDeptNum(sectionNum);
|
||||
// 获取当前公司的所有子公司数量(含当前公司)
|
||||
LambdaQueryWrapper<HrOrganization> wrapper = Wrappers.lambdaQuery(HrOrganization.class)
|
||||
.like(HrOrganization::getOrgPids, LEFT_SQUARE_BRACKETS + organizationId + RIGHT_SQUARE_BRACKETS)
|
||||
.or()
|
||||
.eq(HrOrganization::getOrgId, organizationId)
|
||||
.select(HrOrganization::getOrgId);
|
||||
List<HrOrganization> organizations = hrOrganizationService.list(wrapper);
|
||||
homeCompanyInfo.setCurrentDeptNum(organizations.size());
|
||||
|
||||
// 设置当前公司人数
|
||||
int currentCompanyPersonNum = 0;
|
||||
for (Long orgId : orgIds) {
|
||||
List<SysUserOrg> sysUserOrgs = sysUserOrgService.list(Wrappers.<SysUserOrg>lambdaQuery().eq(SysUserOrg::getOrgId, orgId));
|
||||
currentCompanyPersonNum += sysUserOrgs.size();
|
||||
}
|
||||
homeCompanyInfo.setCurrentCompanyPersonNum(currentCompanyPersonNum);
|
||||
// 设置当前所属机构和所有子机构的人数
|
||||
List<Long> orgIds = organizations.stream().map(HrOrganization::getOrgId).collect(Collectors.toList());
|
||||
int currentOrgPersonNum = sysUserOrgService.count(Wrappers.lambdaQuery(SysUserOrg.class).in(SysUserOrg::getOrgId, orgIds));
|
||||
homeCompanyInfo.setCurrentCompanyPersonNum(currentOrgPersonNum);
|
||||
|
||||
return homeCompanyInfo;
|
||||
}
|
||||
|
|
|
@ -127,6 +127,11 @@ public class HrPositionServiceImpl extends ServiceImpl<HrPositionMapper, HrPosit
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer positionNum() {
|
||||
return this.count();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主键id获取对象信息
|
||||
*
|
||||
|
@ -172,9 +177,4 @@ public class HrPositionServiceImpl extends ServiceImpl<HrPositionMapper, HrPosit
|
|||
return queryWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer PositionNum() {
|
||||
return this.count();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue