private List getChildModuleChartData(Integer serviceId, String parentModule, String orgId) {
List orgIds = getSonOrgIdsByOrgId(orgId);
Aggregation aggregationTmp = Aggregation.newAggregation(
match(Criteria.where("serviceId").is(serviceId)
.and("moduleInfo.parentModule").is(parentModule)
.and("organization._id").in(orgIds)),
group("moduleInfo.childModule").count().as("value")
.first("moduleInfo.childModule").as("name"),
project("name", "value").andExclude("_id")
);
AggregationResults results = mongoTemplate.aggregate(aggregationTmp, "app_data", ChartDataVo.class);
。。。
参考mybatisplus或者tk-mybatis的方法
Example example = new Example(AdminUser.class);
example.createCriteria().
andEqual("serviceId", serviceId).andEqual("moduleInfo.parentModule", parentModule).andEqual("organization._id", orgIds);
AggregateCondition aggregateCondition = AggregateCondition.builder().groupby("moduleInfo.childModule").aggregateBy("moduleInfo.childModule").aggregateType(AggregateType.COUNT)