mirror of https://gitee.com/stylefeng/roses
【7.1.6】【statistics】更新首页常用功能的统计
parent
01a9efd795
commit
1ada004265
|
@ -35,7 +35,7 @@ public class SysStatisticsUrl extends BaseEntity {
|
||||||
* 被统计菜单ID
|
* 被统计菜单ID
|
||||||
*/
|
*/
|
||||||
@TableField("stat_menu_id")
|
@TableField("stat_menu_id")
|
||||||
private String statMenuId;
|
private Long statMenuId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 被统计的URL
|
* 被统计的URL
|
||||||
|
|
|
@ -2,6 +2,9 @@ package cn.stylefeng.roses.kernel.system.modular.home.mapper;
|
||||||
|
|
||||||
import cn.stylefeng.roses.kernel.system.modular.home.entity.SysStatisticsUrl;
|
import cn.stylefeng.roses.kernel.system.modular.home.entity.SysStatisticsUrl;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 常用功能列表 Mapper 接口
|
* 常用功能列表 Mapper 接口
|
||||||
|
@ -11,4 +14,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
*/
|
*/
|
||||||
public interface SysStatisticsUrlMapper extends BaseMapper<SysStatisticsUrl> {
|
public interface SysStatisticsUrlMapper extends BaseMapper<SysStatisticsUrl> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据统计urlId集合获取菜单id集合
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2022/2/12 18:55
|
||||||
|
*/
|
||||||
|
List<Long> getMenuIdsByStatUrlIdList(@Param("statUrlIds") List<Long> statUrlIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="cn.stylefeng.roses.kernel.system.modular.statistic.mapper.SysStatisticsCountMapper">
|
<mapper namespace="cn.stylefeng.roses.kernel.system.modular.home.mapper.SysStatisticsCountMapper">
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
|
@ -1,5 +1,21 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="cn.stylefeng.roses.kernel.system.modular.statistic.mapper.SysStatisticsUrlMapper">
|
<mapper namespace="cn.stylefeng.roses.kernel.system.modular.home.mapper.SysStatisticsUrlMapper">
|
||||||
|
|
||||||
|
<select id="getMenuIdsByStatUrlIdList" resultType="java.lang.Long">
|
||||||
|
select stat_menu_id as statMenuId from sys_statistics_url stat
|
||||||
|
<where>
|
||||||
|
<if test="statUrlIds != null and statUrlIds.size() > 0">
|
||||||
|
stat.stat_url_id in
|
||||||
|
<foreach item="item" collection="statUrlIds" index="index" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by field(stat_url_id,
|
||||||
|
<foreach item="item" collection="statUrlIds" index="index" open="" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
|
@ -34,7 +34,7 @@ public class SysStatisticsUrlRequest extends BaseRequest {
|
||||||
* 被统计菜单ID
|
* 被统计菜单ID
|
||||||
*/
|
*/
|
||||||
@ChineseDescription("被统计菜单ID")
|
@ChineseDescription("被统计菜单ID")
|
||||||
private String statMenuId;
|
private Long statMenuId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 被统计的URL
|
* 被统计的URL
|
||||||
|
|
|
@ -19,11 +19,12 @@ 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.api.pojo.user.request.SysUserRequest;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.home.entity.SysStatisticsCount;
|
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.entity.SysStatisticsUrl;
|
||||||
|
import cn.stylefeng.roses.kernel.system.modular.home.mapper.SysStatisticsUrlMapper;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.home.service.HomePageService;
|
import cn.stylefeng.roses.kernel.system.modular.home.service.HomePageService;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.home.service.SysStatisticsCountService;
|
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.home.service.SysStatisticsUrlService;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.menu.entity.SysMenu;
|
import cn.stylefeng.roses.kernel.system.modular.menu.entity.SysMenu;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.menu.service.SysMenuService;
|
import cn.stylefeng.roses.kernel.system.modular.menu.mapper.SysMenuMapper;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrOrganization;
|
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrOrganization;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.organization.service.HrOrganizationService;
|
import cn.stylefeng.roses.kernel.system.modular.organization.service.HrOrganizationService;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.statistic.pojo.OnlineUserStat;
|
import cn.stylefeng.roses.kernel.system.modular.statistic.pojo.OnlineUserStat;
|
||||||
|
@ -75,7 +76,10 @@ public class HomePageServiceImpl implements HomePageService, HomePageServiceApi
|
||||||
private SysStatisticsUrlService sysStatisticsUrlService;
|
private SysStatisticsUrlService sysStatisticsUrlService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SysMenuService sysMenuService;
|
private SysStatisticsUrlMapper sysStatisticsUrlMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SysMenuMapper sysMenuMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LogRecordDTO> getRecentLogs() {
|
public List<LogRecordDTO> getRecentLogs() {
|
||||||
|
@ -156,24 +160,29 @@ public class HomePageServiceImpl implements HomePageService, HomePageServiceApi
|
||||||
LoginUser loginUser = LoginContext.me().getLoginUser();
|
LoginUser loginUser = LoginContext.me().getLoginUser();
|
||||||
List<SysStatisticsCount> statList = sysStatisticsCountService.list(
|
List<SysStatisticsCount> statList = sysStatisticsCountService.list(
|
||||||
Wrappers.lambdaQuery(SysStatisticsCount.class).eq(SysStatisticsCount::getUserId, loginUser.getUserId()).orderByDesc(SysStatisticsCount::getStatCount));
|
Wrappers.lambdaQuery(SysStatisticsCount.class).eq(SysStatisticsCount::getUserId, loginUser.getUserId()).orderByDesc(SysStatisticsCount::getStatCount));
|
||||||
List<Long> statUrlId = statList.stream().map(SysStatisticsCount::getStatUrlId).collect(Collectors.toList());
|
List<Long> statUrlIdList = statList.stream().map(SysStatisticsCount::getStatUrlId).collect(Collectors.toList());
|
||||||
|
|
||||||
// 获取系统常驻常用功能
|
// 获取系统常驻常用功能
|
||||||
LambdaQueryWrapper<SysStatisticsUrl> wrapper = Wrappers.lambdaQuery(SysStatisticsUrl.class)
|
LambdaQueryWrapper<SysStatisticsUrl> wrapper = Wrappers.lambdaQuery(SysStatisticsUrl.class)
|
||||||
.eq(SysStatisticsUrl::getAlwaysShow, YesOrNotEnum.Y)
|
.eq(SysStatisticsUrl::getAlwaysShow, YesOrNotEnum.Y)
|
||||||
.or()
|
.select(SysStatisticsUrl::getStatUrlId);
|
||||||
.in(ObjectUtil.isNotEmpty(statUrlId), SysStatisticsUrl::getStatUrlId, statUrlId)
|
|
||||||
.select(SysStatisticsUrl::getStatMenuId);
|
|
||||||
List<SysStatisticsUrl> alwaysShowList = sysStatisticsUrlService.list(wrapper);
|
List<SysStatisticsUrl> alwaysShowList = sysStatisticsUrlService.list(wrapper);
|
||||||
|
|
||||||
// 获取菜单
|
// 将常驻功能放在统计的常用功能最前边
|
||||||
List<String> usualMenuIds = alwaysShowList.stream().map(SysStatisticsUrl::getStatMenuId).collect(Collectors.toList());
|
if (ObjectUtil.isNotEmpty(alwaysShowList)) {
|
||||||
|
statUrlIdList.addAll(0, alwaysShowList.stream().map(SysStatisticsUrl::getStatUrlId).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果statUrlId大于8,则只截取8个
|
||||||
|
if (statUrlIdList.size() > 8) {
|
||||||
|
statUrlIdList = statUrlIdList.subList(0, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取菜单id集合
|
||||||
|
List<Long> usualMenuIds = sysStatisticsUrlMapper.getMenuIdsByStatUrlIdList(statUrlIdList);
|
||||||
|
|
||||||
// 获取菜单对应的图标和名称信息
|
// 获取菜单对应的图标和名称信息
|
||||||
LambdaQueryWrapper<SysMenu> sysMenuLambdaQueryWrapper = Wrappers.lambdaQuery(SysMenu.class)
|
List<SysMenu> list = sysMenuMapper.getMenuStatInfoByMenuIds(usualMenuIds);
|
||||||
.in(SysMenu::getMenuId, usualMenuIds)
|
|
||||||
.select(SysMenu::getMenuName, SysMenu::getAntdvIcon, SysMenu::getAntdvRouter);
|
|
||||||
List<SysMenu> list = sysMenuService.list(sysMenuLambdaQueryWrapper);
|
|
||||||
|
|
||||||
// 菜单的icon需要转为大写驼峰
|
// 菜单的icon需要转为大写驼峰
|
||||||
for (SysMenu sysMenu : list) {
|
for (SysMenu sysMenu : list) {
|
||||||
|
@ -182,6 +191,7 @@ public class HomePageServiceImpl implements HomePageService, HomePageServiceApi
|
||||||
sysMenu.setAntdvIcon(StrUtil.upperFirst(StrUtil.toCamelCase(replace)));
|
sysMenu.setAntdvIcon(StrUtil.upperFirst(StrUtil.toCamelCase(replace)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,13 +90,13 @@ public class SysStatisticsUrlServiceImpl extends ServiceImpl<SysStatisticsUrlMap
|
||||||
|
|
||||||
Long statUrlId = sysStatisticsUrlRequest.getStatUrlId();
|
Long statUrlId = sysStatisticsUrlRequest.getStatUrlId();
|
||||||
String statName = sysStatisticsUrlRequest.getStatName();
|
String statName = sysStatisticsUrlRequest.getStatName();
|
||||||
String statMenuId = sysStatisticsUrlRequest.getStatMenuId();
|
Long statMenuId = sysStatisticsUrlRequest.getStatMenuId();
|
||||||
String statUrl = sysStatisticsUrlRequest.getStatUrl();
|
String statUrl = sysStatisticsUrlRequest.getStatUrl();
|
||||||
String alwaysShow = sysStatisticsUrlRequest.getAlwaysShow();
|
String alwaysShow = sysStatisticsUrlRequest.getAlwaysShow();
|
||||||
|
|
||||||
queryWrapper.eq(ObjectUtil.isNotNull(statUrlId), SysStatisticsUrl::getStatUrlId, statUrlId);
|
queryWrapper.eq(ObjectUtil.isNotNull(statUrlId), SysStatisticsUrl::getStatUrlId, statUrlId);
|
||||||
queryWrapper.like(ObjectUtil.isNotEmpty(statName), SysStatisticsUrl::getStatName, statName);
|
queryWrapper.like(ObjectUtil.isNotEmpty(statName), SysStatisticsUrl::getStatName, statName);
|
||||||
queryWrapper.like(ObjectUtil.isNotEmpty(statMenuId), SysStatisticsUrl::getStatMenuId, statMenuId);
|
queryWrapper.eq(ObjectUtil.isNotEmpty(statMenuId), SysStatisticsUrl::getStatMenuId, statMenuId);
|
||||||
queryWrapper.like(ObjectUtil.isNotEmpty(statUrl), SysStatisticsUrl::getStatUrl, statUrl);
|
queryWrapper.like(ObjectUtil.isNotEmpty(statUrl), SysStatisticsUrl::getStatUrl, statUrl);
|
||||||
queryWrapper.like(ObjectUtil.isNotEmpty(alwaysShow), SysStatisticsUrl::getAlwaysShow, alwaysShow);
|
queryWrapper.like(ObjectUtil.isNotEmpty(alwaysShow), SysStatisticsUrl::getAlwaysShow, alwaysShow);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,9 @@ package cn.stylefeng.roses.kernel.system.modular.menu.mapper;
|
||||||
|
|
||||||
import cn.stylefeng.roses.kernel.system.modular.menu.entity.SysMenu;
|
import cn.stylefeng.roses.kernel.system.modular.menu.entity.SysMenu;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统菜单mapper接口
|
* 系统菜单mapper接口
|
||||||
|
@ -35,4 +38,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
*/
|
*/
|
||||||
public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取一些菜单的统计信息(只返回名称,路径,图标)
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2022/2/12 19:07
|
||||||
|
*/
|
||||||
|
List<SysMenu> getMenuStatInfoByMenuIds(@Param("menuIds") List<Long> menuIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,20 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="cn.stylefeng.roses.kernel.system.modular.menu.mapper.SysMenuMapper">
|
<mapper namespace="cn.stylefeng.roses.kernel.system.modular.menu.mapper.SysMenuMapper">
|
||||||
|
|
||||||
|
<select id="getMenuStatInfoByMenuIds" resultType="cn.stylefeng.roses.kernel.system.modular.menu.entity.SysMenu">
|
||||||
|
select menu_name as menuName, antdv_icon as antdvIcon , antdv_router as antdvRouter from sys_menu menu
|
||||||
|
<where>
|
||||||
|
<if test="menuIds != null and menuIds.size() > 0">
|
||||||
|
menu.menu_id in
|
||||||
|
<foreach item="item" collection="menuIds" index="index" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by field(menu_id,
|
||||||
|
<foreach item="item" collection="menuIds" index="index" open="" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue