主页图表监控日志接口

    @RequestMapping(value = "/indexhits", method = RequestMethod.POST)
    public Map<String,Object> Indexhits() {
        System.out.println("进入8006...");
        Map<String,Object> map = new HashMap<>();
        Integer totalvisitsCount = operationhitsRepository.getNum();//总访问数 求和 //    总访问量
        map.put("totalvisitsCount",totalvisitsCount);
        Integer visitsthismonthCount = logInfoRepository.findNumberMONTH();    本月访问量
        Integer visitsinonedayCount = logInfoRepository.findNumberDATE();    一天内访问量
//        总访问ip量
        Integer totalipCount = operationhitsRepository.countNum(null);
        map.put("visitsthismonthCount",visitsthismonthCount);
        map.put("visitsinonedayCount",visitsinonedayCount);
        map.put("totalipCount",totalipCount);

//        查询近一个月每天的数据总数
        List<IAedWarnSum> mothDayHitsActionValuemap = logInfoRepository.mothDayHitsActionValue();

        //获取当前时间跟一个月前的时间,使用当前时间得到一个月前的时间
        LocalDateTime beforeTime = LocalDateTime.now().minusMonths(1);
        System.out.println("beforeTime"+beforeTime);

//        DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("MM-dd");
//
//        String strDate2 = dtf2.format(beforeTime);
//        System.out.println(strDate2);

        List<String> mothDayText = new ArrayList<>();
        List<String> mothDayHitsActionValue = new ArrayList<>();

        //创建有序的map容器
        Map<String, Integer> aedWarnSumMap = new LinkedHashMap<>();
        //使用一个月前的时间作为循环条件
        while (beforeTime.isBefore(LocalDateTime.now())) {
            LocalDateTime finalMonthAgoDate = beforeTime;
            //创建一个Optional对象为map的加入条件
            Optional<IAedWarnSum> optional = mothDayHitsActionValuemap.stream().filter(file -> finalMonthAgoDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")).toString().equals(file.getCreateTime())).findFirst();

            //有如果当天没有数据进行补零操作
//            aedWarnSumMap.put(finalMonthAgoDate.toString(), optional.isPresent() ? optional.get().getTotal() : 0);
            aedWarnSumMap.put(DateTimeFormatter.ofPattern("MM-dd").format(finalMonthAgoDate).toString(), optional.isPresent() ? optional.get().getTotal() : 0);

            mothDayText.add(DateTimeFormatter.ofPattern("MM-dd").format(finalMonthAgoDate).toString());
            mothDayHitsActionValue.add(""+(optional.isPresent() ? optional.get().getTotal() : 0));

            //每次循环将循环条件时间加一天
            beforeTime = beforeTime.plusDays(1);
        }
        System.out.println("aedWarnSumMap"+aedWarnSumMap);


        map.put("mothDayHitsActionValue",mothDayHitsActionValue);
        map.put("mothDayText",mothDayText);

        System.out.println("map:>>>" + map);
        return map;
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

萤火的微亮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值