折线图数据获取及处理

Controller层

 public SegmentChartVo getChartInfo(@PathVariable("id") Long id) {
        Tuple2 tuple2 = getDT(id);//获得开始熏蒸任务开始时间,若结束时间未到获取当前时间,否者则end获取结束时间
        LocalDateTime[] localDateTimes = (LocalDateTime[]) tuple2.second;
        Long segmentId = (Long) tuple2.first;
        SegmentChartVo chartVo = new SegmentChartVo();
        Tuple5 axisData = chartService.getTHMAxisDataById(segmentId, localDateTimes[0], localDateTimes[1], "hour", 1l, 1);//将室内温湿度,ppm浓度,水份按照每一小时为一个间隔返回
        Tuple3 axisData2 = chartService.getWeatherAxisData(localDateTimes[0], localDateTimes[1]);//将室外温湿度按照每五分钟为一个单位返回
        chartVo.setSegment(axisData);
        chartVo.setWeather(axisData2);
        return chartVo;
    }

室内坐标轴获取

因为室内传感器较多,获取数据时间不规律,所以按照整小时为x坐标,对其内数据进行相关处理。

 public Tuple5 getTHMAxisDataById(Long segmentId, LocalDateTime start, LocalDateTime end, String type, Long step,Integer typo) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DATE_FORMAT_FULL);
        List<LocalDateTime> xAxis = generatorXAxis(start, end, type, step);//获取x坐标
        List<String> xAxisFormatter =//获得日期的标准格式
                xAxis.stream().map(localDateTime -> {
                    return parseLocalDateTime(localDateTime, dateTimeFormatter);
                }).collect(Collectors.toList());
        Map<String, List<KmSensorInfoHis>> data =
                aggregateService.getDataBetweenDateBySegmentId(segmentId, DateUtils.convertDate(start), DateUtils.convertDate(end),null,typo);//将数据按照deviceid分类
        Tuple4 tuple4 = getY(data,xAxis,"max");//获取y坐标
        return Tuple5.with(xAxisFormatter,tuple4.first,tuple4.second,tuple4.third,tuple4.fourth);//将x,y坐标返回
    }

按照时间间隔取得Y轴坐标

public T
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值