mongodb spring data Projection项目仅日期部分删除了现有时间部分。
我还需要对数据进行分组。
Aggregation aggregation = Aggregation.newAggregation(NucleusFunctionSpaceGuestRoomPace.class,
Aggregation.match(Criteria.where("propertyId").is(propertyId).
andOperator(
Criteria.where("lastModifiedDate").lt(endDate),
Criteria.where("lastModifiedDate").gte(startDate)
)),
sort(Sort.Direction.ASC, "propertyId")
.and(Sort.Direction.ASC, "bookingId")
.and(Sort.Direction.ASC, "roomType")
.and(Sort.Direction.ASC, "stayDate")
.and(Sort.Direction.DESC, "lastModifiedDate")
,
Aggregation.project().and("propertyId").as("propertyId")
.and("bookingId").as("bookingId")
.and("roomType").as("roomType")
.and("stayDate").as("stayDate")
.and("bookingPaceId").as("bookingPaceId")
.and("roomNights").as("roomNights")
.and("guestRoomStatus").as("guestRoomStatus")
.and("lastModifiedDate").as("lastModifiedDate")
.andExpression("year(lastModifiedDate)").as("year")
.andExpression("month(lastModifiedDate)").as("month")
.andExpression("dayOfMonth(lastModifiedDate)").as("month")
);