增删改查
Query query = new Query(Criteria.where("timestamp").gte(startTime.getTime()).lte(endTime.getTime()));
mongoTemplate.remove(query, collectionName);
mongoTemplate.insert(measureValue, collectionName);
List<MeasureValueDto> valueList = mongoTemplate.find(query, MeasureValueDto.class, collectionName);
group by
List<AggregationOperation> operationList = new ArrayList<>();
operationList.add(Aggregation.group("attribute", "station").avg("value").as("value"));
operationList.add(Aggregation.match(Criteria.where("timestamp").gte(startTime).lte(endTime)));//where
Aggregation aggregate = Aggregation.newAggregation(operationList);
AggregationResults<MeasureValueDto> groupResult = mongoTemplate.aggregate(aggregate, collectionName, MeasureValueDto.class);
for (MeasureValueDto result : groupResult) {
log.info(result.toString());
}