|
|
|
@ -11,6 +11,7 @@ import org.apache.commons.lang.StringUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
@ -24,7 +25,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme |
|
|
|
|
@Override |
|
|
|
|
public BrowseReportVO getBrowseStatistics() { |
|
|
|
|
//存放访问的前一天至前七天的每天对应的日期
|
|
|
|
|
List<LocalDate> dateList = new ArrayList<>(); |
|
|
|
|
List<String> dateList = new ArrayList<>(); |
|
|
|
|
//存放这个月访问的前一天至前七天的每天对应的浏览量
|
|
|
|
|
List<String> ThisMonthBrowseList = new ArrayList<>(); |
|
|
|
|
//存放上个月访问的前一天至前七天的每天对应的浏览量
|
|
|
|
@ -36,7 +37,9 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme |
|
|
|
|
// 获取前七天的日期
|
|
|
|
|
for (int i = 1; i <= 7; i++) { |
|
|
|
|
LocalDate day = end.minusDays(i); |
|
|
|
|
dateList.add(day); |
|
|
|
|
// 定义一个仅包含月日的格式化器
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM-dd"); |
|
|
|
|
dateList.add(day.format(formatter)); |
|
|
|
|
|
|
|
|
|
//查询今天对应的浏览量
|
|
|
|
|
String browse = reportMapper.getBrowseByTime(day); |
|
|
|
@ -47,6 +50,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme |
|
|
|
|
LocalDate lastMonth = lastMonthToday.minusDays(i); |
|
|
|
|
//查询上个月的今天对应的浏览量
|
|
|
|
|
String lastMonthBrowse = reportMapper.getBrowseByTime(lastMonth); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LastMonthBrowseList.add(lastMonthBrowse); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|