QueryResult countResults = influxDBConfig.query(selectSql.toString()); QueryResult results = influxDBConfig.query(selectSql.toString()); List<KeyValue> keyValues = queryResultProcess(results); private List<KeyValue> queryResultProcess(QueryResult queryResult) { List<KeyValue> mapList = new ArrayList<>(); List<QueryResult.Result> resultList = queryResult.getResults(); for (QueryResult.Result query : resultList) { List<QueryResult.Series> seriesList = query.getSeries(); if (seriesList != null && seriesList.size() != 0) { for (QueryResult.Series series : seriesList) { List<List<Object>> values = series.getValues(); if (values != null && values.size() != 0) { for (List<Object> value : values) { KeyValue keyValue = new KeyValue(); keyValue.setTime(processTime(value.get(0))); keyValue.setId((String) value.get(1)); keyValue.setVal((Double) value.get(2)); mapList.add(keyValue); } } } } } return mapList; } private String processTime(Object time) { if (ObjectUtil.isNotNull(time)) { String str = (String) time; return str.substring(0, 19).replace('T', ' '); } return null; }
标签:QueryResult,读取,List,influxdb,keyValue,seriesList,mysql,query,String From: https://www.cnblogs.com/lcaiqin/p/17880409.html