|
@@ -1,5 +1,8 @@
|
|
|
package com.fjhx.xmhjc.controller.browsing;
|
|
|
|
|
|
+import cn.hutool.core.date.DatePattern;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.fjhx.xmhjc.entity.browsing.vo.StatisticVo;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fjhx.xmhjc.entity.browsing.vo.BrowsingHistoryVo;
|
|
@@ -9,6 +12,7 @@ import com.ruoyi.common.core.domain.BaseSelectDto;
|
|
|
import com.fjhx.xmhjc.service.browsing.BrowsingHistoryService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
+import java.text.DateFormat;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -74,4 +78,27 @@ public class BrowsingHistoryController {
|
|
|
browsingHistoryService.delete(dto.getId());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 统计今日,本周,本月,总浏览量
|
|
|
+ */
|
|
|
+ @PostMapping("/getStatistic")
|
|
|
+ public StatisticVo getStatistic(@RequestBody BrowsingHistorySelectDto dto) {
|
|
|
+ StatisticVo statisticVo = new StatisticVo();
|
|
|
+
|
|
|
+
|
|
|
+ dto.setBeginTime(DateUtil.beginOfMonth(DateUtil.date()).toString(DatePattern.NORM_DATETIME_MS_FORMAT));
|
|
|
+ dto.setEndTime(DateUtil.endOfMonth(DateUtil.date()).toString(DatePattern.NORM_DATETIME_MS_FORMAT));
|
|
|
+ List<BrowsingHistoryVo> list = browsingHistoryService.getList(dto);
|
|
|
+ // 今日浏览量
|
|
|
+ long count = list.stream().filter(browsingHistoryVo -> DateUtil.isSameDay(browsingHistoryVo.getCreateTime(), DateUtil.date())).count();
|
|
|
+ statisticVo.setToday(count);
|
|
|
+ // 本周浏览量
|
|
|
+ long weekCount = list.stream().filter(browsingHistoryVo -> DateUtil.weekOfYear(DateUtil.date()) == browsingHistoryVo.getWeek()).count();
|
|
|
+ statisticVo.setWeek(weekCount);
|
|
|
+ // 本月浏览量
|
|
|
+ long monthCount = list.stream().filter(browsingHistoryVo -> DateUtil.month(DateUtil.date()) == browsingHistoryVo.getMonth()).count();
|
|
|
+ statisticVo.setMonth(monthCount);
|
|
|
+
|
|
|
+ return statisticVo;
|
|
|
+ }
|
|
|
}
|