.is(month).and("createTime")
.gte(startDate).lt(endDate)
.and("result").is(1),
Aggregation.group("month").count()
.as("NUmCount"));// 分組條件:月份
List<MyObject> listist = mongoTemplate.aggregate(aggregation, collectionName, MyObject.class).getMappedResults();
mongoTemplate.insert(listist, newCollectionName);
2、Aggregation aggregation = Aggregation.newAggregation(Aggregation.match(Criteria.where("id").is(id).and("createTime").gte(startDate).lt(endDate)),
Aggregation.group("money").count().as("totalOrder").sum("age").as("totalage")
.addToSet("agePercent").as("agePercent").addToSet("ageLimited").as("ageLimited"));
List<MyObject> listist = mongoTemplate.aggregate(aggregation, collectionName, MyObject.class).getMappedResults();
mongoTemplate.insert(listist, newCollectionName);