From dea8dbe131867a564f7e151a6484db5be6effaa3 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Fri, 18 Oct 2024 00:19:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E4=BB=AA=E8=A1=A8?= =?UTF-8?q?=E7=9B=98=E5=88=86=E6=9E=90=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=AE=BF=E9=97=AE=E6=97=B6=E6=AE=B5=E5=88=86=E6=9E=90?= =?UTF-8?q?=E3=80=81=E6=9F=A5=E8=AF=A2=E6=A8=A1=E5=9D=97=E5=88=86=E6=9E=90?= =?UTF-8?q?=E3=80=81=E6=9F=A5=E8=AF=A2=E7=BB=88=E7=AB=AF=E5=88=86=E6=9E=90?= =?UTF-8?q?=E3=80=81=E6=9F=A5=E8=AF=A2=E6=B5=8F=E8=A7=88=E5=99=A8=E5=88=86?= =?UTF-8?q?=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/system/mapper/LogMapper.java | 44 +++++++++--- .../admin/system/mapper/NoticeMapper.java | 2 +- .../resp/DashboardPopularModuleResp.java | 69 ------------------- .../DashboardAccessTrendResp.java | 2 +- .../DashboardChartCommonResp.java} | 28 ++++---- .../{ => dashboard}/DashboardNoticeResp.java | 2 +- .../{ => dashboard}/DashboardTotalResp.java | 2 +- .../system/service/DashboardService.java | 41 ++++++++--- .../admin/system/service/LogService.java | 44 +++++++++--- .../admin/system/service/NoticeService.java | 2 +- .../service/impl/DashboardServiceImpl.java | 47 +++++++------ .../system/service/impl/LogServiceImpl.java | 66 +++++++++++++++--- .../service/impl/NoticeServiceImpl.java | 2 +- .../src/main/resources/mapper/LogMapper.xml | 60 ++++++++++++---- .../main/resources/mapper/NoticeMapper.xml | 2 +- .../common/DashboardController.java | 63 ++++++++++++----- 16 files changed, 294 insertions(+), 182 deletions(-) delete mode 100644 continew-admin-system/src/main/java/top/continew/admin/system/model/resp/DashboardPopularModuleResp.java rename continew-admin-system/src/main/java/top/continew/admin/system/model/resp/{ => dashboard}/DashboardAccessTrendResp.java (96%) rename continew-admin-system/src/main/java/top/continew/admin/system/model/resp/{DashboardGeoDistributionResp.java => dashboard/DashboardChartCommonResp.java} (55%) rename continew-admin-system/src/main/java/top/continew/admin/system/model/resp/{ => dashboard}/DashboardNoticeResp.java (96%) rename continew-admin-system/src/main/java/top/continew/admin/system/model/resp/{ => dashboard}/DashboardTotalResp.java (96%) diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/mapper/LogMapper.java b/continew-admin-system/src/main/java/top/continew/admin/system/mapper/LogMapper.java index 17af1a4e0..afcc73d30 100644 --- a/continew-admin-system/src/main/java/top/continew/admin/system/mapper/LogMapper.java +++ b/continew-admin-system/src/main/java/top/continew/admin/system/mapper/LogMapper.java @@ -21,14 +21,13 @@ import com.baomidou.mybatisplus.core.toolkit.Constants; import org.apache.ibatis.annotations.Param; import top.continew.admin.system.model.entity.LogDO; -import top.continew.admin.system.model.resp.DashboardAccessTrendResp; -import top.continew.admin.system.model.resp.DashboardPopularModuleResp; -import top.continew.admin.system.model.resp.DashboardTotalResp; +import top.continew.admin.system.model.resp.dashboard.DashboardAccessTrendResp; +import top.continew.admin.system.model.resp.dashboard.DashboardChartCommonResp; +import top.continew.admin.system.model.resp.dashboard.DashboardTotalResp; import top.continew.admin.system.model.resp.log.LogResp; import top.continew.starter.data.mp.base.BaseMapper; import java.util.List; -import java.util.Map; /** * 系统日志 Mapper @@ -72,16 +71,41 @@ IPage selectLogPage(@Param("page") IPage page, List selectListDashboardAccessTrend(@Param("days") Integer days); /** - * 查询仪表盘热门模块列表 + * 查询仪表盘访问时段分析信息 * - * @return 仪表盘热门模块列表 + * @return 仪表盘访问时段分析信息 */ - List selectListDashboardPopularModule(); + List selectListDashboardAnalysisTimeslot(); /** - * 查询仪表盘访客地域分布信息 + * 查询仪表盘地域分析信息 * - * @return 仪表盘访客地域分布信息 + * @param top 显示数量 + * @return 仪表盘地域分析信息 */ - List> selectListDashboardGeoDistribution(); + List selectListDashboardAnalysisGeo(@Param("top") Integer top); + + /** + * 查询仪表盘模块分析信息 + * + * @param top 显示数量 + * @return 仪表盘模块分析信息 + */ + List selectListDashboardAnalysisModule(@Param("top") Integer top); + + /** + * 查询仪表盘终端分析信息 + * + * @param top 显示数量 + * @return 仪表盘终端分析信息 + */ + List selectListDashboardAnalysisOs(@Param("top") Integer top); + + /** + * 查询仪表盘浏览器分析信息 + * + * @param top 显示数量 + * @return 仪表盘浏览器分析信息 + */ + List selectListDashboardAnalysisBrowser(@Param("top") Integer top); } diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/mapper/NoticeMapper.java b/continew-admin-system/src/main/java/top/continew/admin/system/mapper/NoticeMapper.java index d40a6302f..56ccfe64f 100644 --- a/continew-admin-system/src/main/java/top/continew/admin/system/mapper/NoticeMapper.java +++ b/continew-admin-system/src/main/java/top/continew/admin/system/mapper/NoticeMapper.java @@ -17,7 +17,7 @@ package top.continew.admin.system.mapper; import top.continew.admin.system.model.entity.NoticeDO; -import top.continew.admin.system.model.resp.DashboardNoticeResp; +import top.continew.admin.system.model.resp.dashboard.DashboardNoticeResp; import top.continew.starter.data.mp.base.BaseMapper; import java.util.List; diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/DashboardPopularModuleResp.java b/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/DashboardPopularModuleResp.java deleted file mode 100644 index 4b4e02447..000000000 --- a/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/DashboardPopularModuleResp.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package top.continew.admin.system.model.resp; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.io.Serial; -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * 仪表盘-热门模块信息 - * - * @author Charles7c - * @since 2023/9/9 9:52 - */ -@Data -@Schema(description = "仪表盘-热门模块信息") -public class DashboardPopularModuleResp implements Serializable { - - @Serial - private static final long serialVersionUID = 1L; - - /** - * 模块 - */ - @Schema(description = "模块", example = "角色管理") - private String module; - - /** - * 浏览量(PV) - */ - @Schema(description = "浏览量(PV)", example = "1234") - private Long pvCount; - - /** - * 较昨日新增 PV(百分比) - */ - @Schema(description = "较昨日新增(百分比)", example = "23.4") - private BigDecimal newPvFromYesterday; - - /** - * 今日浏览量(PV) - */ - @JsonIgnore - private Long todayPvCount; - - /** - * 昨日浏览量(PV) - */ - @JsonIgnore - private Long yesterdayPvCount; -} diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/DashboardAccessTrendResp.java b/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/dashboard/DashboardAccessTrendResp.java similarity index 96% rename from continew-admin-system/src/main/java/top/continew/admin/system/model/resp/DashboardAccessTrendResp.java rename to continew-admin-system/src/main/java/top/continew/admin/system/model/resp/dashboard/DashboardAccessTrendResp.java index 911b7dea1..a567a608c 100644 --- a/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/DashboardAccessTrendResp.java +++ b/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/dashboard/DashboardAccessTrendResp.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package top.continew.admin.system.model.resp; +package top.continew.admin.system.model.resp.dashboard; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/DashboardGeoDistributionResp.java b/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/dashboard/DashboardChartCommonResp.java similarity index 55% rename from continew-admin-system/src/main/java/top/continew/admin/system/model/resp/DashboardGeoDistributionResp.java rename to continew-admin-system/src/main/java/top/continew/admin/system/model/resp/dashboard/DashboardChartCommonResp.java index 1961df57c..91ea72cac 100644 --- a/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/DashboardGeoDistributionResp.java +++ b/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/dashboard/DashboardChartCommonResp.java @@ -14,38 +14,40 @@ * limitations under the License. */ -package top.continew.admin.system.model.resp; +package top.continew.admin.system.model.resp.dashboard; import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; import java.io.Serial; import java.io.Serializable; -import java.util.List; -import java.util.Map; /** - * 仪表盘-访客地域分布信息 + * 仪表盘-通用图表信息 * * @author Charles7c - * @since 2023/9/9 12:07 + * @since 2024/10/17 21:37 */ @Data -@Schema(description = "仪表盘-访客地域分布信息") -public class DashboardGeoDistributionResp implements Serializable { +@NoArgsConstructor +@AllArgsConstructor +@Schema(description = "仪表盘-通用图表信息") +public class DashboardChartCommonResp implements Serializable { @Serial private static final long serialVersionUID = 1L; /** - * 地点列表 + * 名称 */ - @Schema(description = "地点列表", example = "[\"中国北京北京市\",\"中国广东省深圳市\"]") - private List locations; + @Schema(description = "名称", example = "Windows 10") + private String name; /** - * 地点 IP 统计信息 + * 数量 */ - @Schema(description = "地点 IP 统计信息", example = "[{\"name\":\"中国北京北京市\",\"value\":1000},{\"name\":\"中国广东省深圳市\",\"value\": 500}]") - private List> locationIpStatistics; + @Schema(description = "数量", example = "1234") + private Long value; } diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/DashboardNoticeResp.java b/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/dashboard/DashboardNoticeResp.java similarity index 96% rename from continew-admin-system/src/main/java/top/continew/admin/system/model/resp/DashboardNoticeResp.java rename to continew-admin-system/src/main/java/top/continew/admin/system/model/resp/dashboard/DashboardNoticeResp.java index 14f543624..43b5b8ace 100644 --- a/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/DashboardNoticeResp.java +++ b/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/dashboard/DashboardNoticeResp.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package top.continew.admin.system.model.resp; +package top.continew.admin.system.model.resp.dashboard; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/DashboardTotalResp.java b/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/dashboard/DashboardTotalResp.java similarity index 96% rename from continew-admin-system/src/main/java/top/continew/admin/system/model/resp/DashboardTotalResp.java rename to continew-admin-system/src/main/java/top/continew/admin/system/model/resp/dashboard/DashboardTotalResp.java index c033ac684..5c46ece01 100644 --- a/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/DashboardTotalResp.java +++ b/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/dashboard/DashboardTotalResp.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package top.continew.admin.system.model.resp; +package top.continew.admin.system.model.resp.dashboard; import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/service/DashboardService.java b/continew-admin-system/src/main/java/top/continew/admin/system/service/DashboardService.java index 5d347df0b..b0a1c6fb8 100644 --- a/continew-admin-system/src/main/java/top/continew/admin/system/service/DashboardService.java +++ b/continew-admin-system/src/main/java/top/continew/admin/system/service/DashboardService.java @@ -16,7 +16,7 @@ package top.continew.admin.system.service; -import top.continew.admin.system.model.resp.*; +import top.continew.admin.system.model.resp.dashboard.*; import java.util.List; @@ -44,23 +44,44 @@ public interface DashboardService { List listAccessTrend(Integer days); /** - * 查询热门模块列表 + * 查询公告列表 * - * @return 热门模块列表 + * @return 公告列表 */ - List listPopularModule(); + List listNotice(); /** - * 查询访客地域分布信息 + * 查询访问时段分析信息 * - * @return 访客地域分布信息 + * @return 访问时段分析信息 */ - DashboardGeoDistributionResp getGeoDistribution(); + List getAnalysisTimeslot(); /** - * 查询公告列表 + * 查询地域分析信息 * - * @return 公告列表 + * @return 地域分析信息 */ - List listNotice(); + List getAnalysisGeo(); + + /** + * 查询模块分析信息 + * + * @return 模块分析信息 + */ + List getAnalysisModule(); + + /** + * 查询终端分析信息 + * + * @return 终端分析信息 + */ + List getAnalysisOs(); + + /** + * 查询浏览器分析信息 + * + * @return 浏览器分析信息 + */ + List getAnalysisBrowser(); } diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/service/LogService.java b/continew-admin-system/src/main/java/top/continew/admin/system/service/LogService.java index 7539b1b08..fbbe37f3f 100644 --- a/continew-admin-system/src/main/java/top/continew/admin/system/service/LogService.java +++ b/continew-admin-system/src/main/java/top/continew/admin/system/service/LogService.java @@ -18,9 +18,9 @@ import jakarta.servlet.http.HttpServletResponse; import top.continew.admin.system.model.query.LogQuery; -import top.continew.admin.system.model.resp.DashboardAccessTrendResp; -import top.continew.admin.system.model.resp.DashboardPopularModuleResp; -import top.continew.admin.system.model.resp.DashboardTotalResp; +import top.continew.admin.system.model.resp.dashboard.DashboardAccessTrendResp; +import top.continew.admin.system.model.resp.dashboard.DashboardChartCommonResp; +import top.continew.admin.system.model.resp.dashboard.DashboardTotalResp; import top.continew.admin.system.model.resp.log.LogDetailResp; import top.continew.admin.system.model.resp.log.LogResp; import top.continew.starter.extension.crud.model.query.PageQuery; @@ -28,7 +28,6 @@ import top.continew.starter.extension.crud.model.resp.PageResp; import java.util.List; -import java.util.Map; /** * 系统日志业务接口 @@ -89,16 +88,41 @@ public interface LogService { List listDashboardAccessTrend(Integer days); /** - * 查询仪表盘热门模块列表 + * 查询仪表盘访问时段分析信息 * - * @return 仪表盘热门模块列表 + * @return 仪表盘访问时段分析信息 */ - List listDashboardPopularModule(); + List listDashboardAnalysisTimeslot(); /** - * 查询仪表盘访客地域分布信息 + * 查询仪表盘地域分析信息 + * + * @param top 显示数量 + * @return 仪表盘地域分析信息 + */ + List listDashboardAnalysisGeo(int top); + + /** + * 查询仪表盘模块分析信息 + * + * @param top 显示数量 + * @return 仪表盘模块分析信息 + */ + List listDashboardAnalysisModule(int top); + + /** + * 查询仪表盘终端分析信息 + * + * @param top 显示数量 + * @return 仪表盘终端分析信息 + */ + List listDashboardAnalysisOs(int top); + + /** + * 查询仪表盘浏览器分析信息 * - * @return 仪表盘访客地域分布信息 + * @param top 显示数量 + * @return 仪表盘浏览器分析信息 */ - List> listDashboardGeoDistribution(); + List listDashboardAnalysisBrowser(int top); } diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/service/NoticeService.java b/continew-admin-system/src/main/java/top/continew/admin/system/service/NoticeService.java index 88007ef3c..c7e2f9ea8 100644 --- a/continew-admin-system/src/main/java/top/continew/admin/system/service/NoticeService.java +++ b/continew-admin-system/src/main/java/top/continew/admin/system/service/NoticeService.java @@ -21,7 +21,7 @@ import top.continew.admin.system.model.req.NoticeReq; import top.continew.admin.system.model.resp.NoticeDetailResp; import top.continew.admin.system.model.resp.NoticeResp; -import top.continew.admin.system.model.resp.DashboardNoticeResp; +import top.continew.admin.system.model.resp.dashboard.DashboardNoticeResp; import top.continew.starter.extension.crud.service.BaseService; import top.continew.starter.data.mp.service.IService; diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/service/impl/DashboardServiceImpl.java b/continew-admin-system/src/main/java/top/continew/admin/system/service/impl/DashboardServiceImpl.java index bb1e34e8e..9fadbb929 100644 --- a/continew-admin-system/src/main/java/top/continew/admin/system/service/impl/DashboardServiceImpl.java +++ b/continew-admin-system/src/main/java/top/continew/admin/system/service/impl/DashboardServiceImpl.java @@ -16,18 +16,16 @@ package top.continew.admin.system.service.impl; -import cn.hutool.core.convert.Convert; import cn.hutool.core.util.NumberUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import top.continew.admin.system.service.NoticeService; +import top.continew.admin.system.model.resp.dashboard.*; import top.continew.admin.system.service.DashboardService; import top.continew.admin.system.service.LogService; -import top.continew.admin.system.model.resp.*; +import top.continew.admin.system.service.NoticeService; import java.math.BigDecimal; import java.util.List; -import java.util.Map; /** * 仪表盘业务实现 @@ -61,31 +59,32 @@ public List listAccessTrend(Integer days) { } @Override - public List listPopularModule() { - List popularModuleList = logService.listDashboardPopularModule(); - for (DashboardPopularModuleResp popularModule : popularModuleList) { - Long todayPvCount = popularModule.getTodayPvCount(); - Long yesterdayPvCount = popularModule.getYesterdayPvCount(); - BigDecimal newPvCountFromYesterday = NumberUtil.sub(todayPvCount, yesterdayPvCount); - BigDecimal newPvFromYesterday = (0 == yesterdayPvCount) - ? BigDecimal.valueOf(100) - : NumberUtil.round(NumberUtil.mul(NumberUtil.div(newPvCountFromYesterday, yesterdayPvCount), 100), 1); - popularModule.setNewPvFromYesterday(newPvFromYesterday); - } - return popularModuleList; + public List listNotice() { + return noticeService.listDashboard(); } @Override - public DashboardGeoDistributionResp getGeoDistribution() { - List> locationIpStatistics = logService.listDashboardGeoDistribution(); - DashboardGeoDistributionResp geoDistribution = new DashboardGeoDistributionResp(); - geoDistribution.setLocationIpStatistics(locationIpStatistics); - geoDistribution.setLocations(locationIpStatistics.stream().map(m -> Convert.toStr(m.get("name"))).toList()); - return geoDistribution; + public List getAnalysisTimeslot() { + return logService.listDashboardAnalysisTimeslot(); } @Override - public List listNotice() { - return noticeService.listDashboard(); + public List getAnalysisGeo() { + return logService.listDashboardAnalysisGeo(10); + } + + @Override + public List getAnalysisModule() { + return logService.listDashboardAnalysisModule(5); + } + + @Override + public List getAnalysisOs() { + return logService.listDashboardAnalysisOs(5); + } + + @Override + public List getAnalysisBrowser() { + return logService.listDashboardAnalysisBrowser(5); } } diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/service/impl/LogServiceImpl.java b/continew-admin-system/src/main/java/top/continew/admin/system/service/impl/LogServiceImpl.java index fafa98528..7b90f2753 100644 --- a/continew-admin-system/src/main/java/top/continew/admin/system/service/impl/LogServiceImpl.java +++ b/continew-admin-system/src/main/java/top/continew/admin/system/service/impl/LogServiceImpl.java @@ -33,9 +33,9 @@ import top.continew.admin.system.mapper.LogMapper; import top.continew.admin.system.model.entity.LogDO; import top.continew.admin.system.model.query.LogQuery; -import top.continew.admin.system.model.resp.DashboardAccessTrendResp; -import top.continew.admin.system.model.resp.DashboardPopularModuleResp; -import top.continew.admin.system.model.resp.DashboardTotalResp; +import top.continew.admin.system.model.resp.dashboard.DashboardAccessTrendResp; +import top.continew.admin.system.model.resp.dashboard.DashboardChartCommonResp; +import top.continew.admin.system.model.resp.dashboard.DashboardTotalResp; import top.continew.admin.system.model.resp.log.LogDetailResp; import top.continew.admin.system.model.resp.log.LogResp; import top.continew.admin.system.model.resp.log.LoginLogExportResp; @@ -47,9 +47,10 @@ import top.continew.starter.extension.crud.model.resp.PageResp; import top.continew.starter.file.excel.util.ExcelUtils; +import java.util.ArrayList; +import java.util.Comparator; import java.util.Date; import java.util.List; -import java.util.Map; /** * 系统日志业务实现 @@ -105,13 +106,62 @@ public List listDashboardAccessTrend(Integer days) { } @Override - public List listDashboardPopularModule() { - return baseMapper.selectListDashboardPopularModule(); + public List listDashboardAnalysisTimeslot() { + List list = baseMapper.selectListDashboardAnalysisTimeslot(); + if (list.size() < 12) { + // 获取所有时间段 + List allTimeSlots = new ArrayList<>(); + for (int hour = 0; hour < 24; hour += 2) { + String timeSlot = String.format("%02d:00", hour); + allTimeSlots.add(timeSlot); + } + // 补充缺失的时间段 + List missingTimeSlots = allTimeSlots.stream() + .filter(timeSlot -> list.stream().noneMatch(item -> item.getName().equals(timeSlot))) + .toList(); + list.addAll(missingTimeSlots.stream().map(timeSlot -> new DashboardChartCommonResp(timeSlot, 0L)).toList()); + list.sort(Comparator.comparing(DashboardChartCommonResp::getName)); + } + return list; + } + + @Override + public List listDashboardAnalysisGeo(int top) { + List list = baseMapper.selectListDashboardAnalysisGeo(top > 1 ? top - 1 : top); + return this.buildOtherPieChartData(list); + } + + @Override + public List listDashboardAnalysisModule(int top) { + List list = baseMapper.selectListDashboardAnalysisModule(top > 1 ? top - 1 : top); + return this.buildOtherPieChartData(list); + } + + @Override + public List listDashboardAnalysisOs(int top) { + List list = baseMapper.selectListDashboardAnalysisOs(top > 1 ? top - 1 : top); + return this.buildOtherPieChartData(list); } @Override - public List> listDashboardGeoDistribution() { - return baseMapper.selectListDashboardGeoDistribution(); + public List listDashboardAnalysisBrowser(int top) { + List list = baseMapper.selectListDashboardAnalysisBrowser(top > 1 ? top - 1 : top); + return this.buildOtherPieChartData(list); + } + + /** + * 构建其他饼图数据 + * + * @param list 饼图数据列表 + * @return 饼图数据列表 + */ + private List buildOtherPieChartData(List list) { + Long totalCount = baseMapper.lambdaQuery().count(); + long sumCount = list.stream().mapToLong(DashboardChartCommonResp::getValue).sum(); + if (sumCount < totalCount) { + list.add(new DashboardChartCommonResp("其他", totalCount - sumCount)); + } + return list; } /** diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/service/impl/NoticeServiceImpl.java b/continew-admin-system/src/main/java/top/continew/admin/system/service/impl/NoticeServiceImpl.java index c6e56a492..daab9cde6 100644 --- a/continew-admin-system/src/main/java/top/continew/admin/system/service/impl/NoticeServiceImpl.java +++ b/continew-admin-system/src/main/java/top/continew/admin/system/service/impl/NoticeServiceImpl.java @@ -22,7 +22,7 @@ import top.continew.admin.system.model.entity.NoticeDO; import top.continew.admin.system.model.query.NoticeQuery; import top.continew.admin.system.model.req.NoticeReq; -import top.continew.admin.system.model.resp.DashboardNoticeResp; +import top.continew.admin.system.model.resp.dashboard.DashboardNoticeResp; import top.continew.admin.system.model.resp.NoticeDetailResp; import top.continew.admin.system.model.resp.NoticeResp; import top.continew.admin.system.service.NoticeService; diff --git a/continew-admin-system/src/main/resources/mapper/LogMapper.xml b/continew-admin-system/src/main/resources/mapper/LogMapper.xml index 2f6d37942..7d20f9b45 100644 --- a/continew-admin-system/src/main/resources/mapper/LogMapper.xml +++ b/continew-admin-system/src/main/resources/mapper/LogMapper.xml @@ -41,7 +41,7 @@ ${ew.customSqlSegment} - SELECT (SELECT COUNT(*) FROM sys_log) AS pvCount, (SELECT COUNT(DISTINCT ip) FROM sys_log) AS ipCount, @@ -50,7 +50,7 @@ - SELECT - module, - COUNT(*) AS pvCount, - SUM(CASE WHEN DATE(create_time) = CURRENT_DATE THEN 1 ELSE 0 END) AS todayPvCount, - SUM(CASE WHEN DATE(create_time) = CURRENT_DATE - 1 THEN 1 ELSE 0 END) AS yesterdayPvCount + LPAD(CONCAT(FLOOR(HOUR(create_time) / 2) * 2, ':00'), 5, '0') AS name, + COUNT(*) AS value FROM sys_log - WHERE module != '验证码' AND module != '登录' - GROUP BY module - ORDER BY pvCount DESC - LIMIT 10 + GROUP BY name + ORDER BY name - SELECT CASE WHEN POSITION(' ' IN address) > 0 THEN SUBSTRING(address FROM 1 FOR POSITION(' ' IN address) - 1) @@ -86,6 +82,42 @@ FROM sys_log GROUP BY name ORDER BY value DESC - LIMIT 10 + LIMIT #{top} + + + + + + + diff --git a/continew-admin-system/src/main/resources/mapper/NoticeMapper.xml b/continew-admin-system/src/main/resources/mapper/NoticeMapper.xml index f5bc62243..3edd9bccc 100644 --- a/continew-admin-system/src/main/resources/mapper/NoticeMapper.xml +++ b/continew-admin-system/src/main/resources/mapper/NoticeMapper.xml @@ -3,7 +3,7 @@