Commit a726ad01b02a8c96c5f0047e4437845d84ff349e
1 parent
a86a8856de
Exists in
master
and in
6 other branches
孕产-社区医生统计分组查询
Showing 2 changed files with 16 additions and 5 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java
View file @
a726ad0
... | ... | @@ -42,6 +42,9 @@ |
42 | 42 | import org.springframework.beans.factory.annotation.Qualifier; |
43 | 43 | import org.springframework.data.domain.Sort; |
44 | 44 | import org.springframework.data.mongodb.core.MongoTemplate; |
45 | +import org.springframework.data.mongodb.core.aggregation.Aggregation; | |
46 | +import org.springframework.data.mongodb.core.aggregation.AggregationOperation; | |
47 | +import org.springframework.data.mongodb.core.aggregation.AggregationResults; | |
45 | 48 | import org.springframework.data.mongodb.core.query.Criteria; |
46 | 49 | import org.springframework.data.mongodb.core.query.Query; |
47 | 50 | import org.springframework.data.mongodb.core.query.Update; |
... | ... | @@ -65,6 +68,8 @@ |
65 | 68 | import java.util.concurrent.ThreadPoolExecutor; |
66 | 69 | import java.util.concurrent.TimeUnit; |
67 | 70 | |
71 | +import static org.springframework.data.mongodb.core.aggregation.Aggregation.project; | |
72 | + | |
68 | 73 | /** |
69 | 74 | * |
70 | 75 | */ |
71 | 76 | |
... | ... | @@ -3402,10 +3407,16 @@ |
3402 | 3407 | |
3403 | 3408 | public BaseObjectResponse queryRecommend(RecommendQuery recommendQuery) { |
3404 | 3409 | MongoQuery query = recommendQuery.convertToQuery().addOrder(Sort.Direction.DESC, "bookbuildingDate"); |
3405 | - System.out.println(query.convertToMongoQuery().toString()); | |
3406 | - List<Patients> patientses = mongoTemplate.find(query.convertToMongoQuery(), Patients.class); | |
3410 | + AggregationOperation queryParam = Aggregation.match(query.getCriteria()); | |
3411 | + AggregationOperation group = Aggregation.group("townOrgId","recommend"); | |
3412 | + AggregationOperation month = project(). | |
3413 | + andExpression("townOrgId").as("townOrgId"). | |
3414 | + andExpression("recommend").as("recommend"); | |
3415 | + Aggregation aggregation= Aggregation.newAggregation(queryParam,month, group); | |
3416 | + | |
3417 | + final AggregationResults<Patients> lyms_patient = mongoTemplate.aggregate(aggregation, "lyms_patient", Patients.class); | |
3407 | 3418 | List<Map> result=new ArrayList<>(); |
3408 | - for (Patients patients : patientses) { | |
3419 | + for (Patients patients : lyms_patient) { | |
3409 | 3420 | recommendQuery.setRecommend(patients.getRecommend()); |
3410 | 3421 | recommendQuery.setTownOrgId(patients.getTownOrgId()); |
3411 | 3422 | final long count = mongoTemplate.count(recommendQuery.convertToQuery().convertToMongoQuery(), Patients.class); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/RecommendQuery.java
View file @
a726ad0
... | ... | @@ -74,10 +74,10 @@ |
74 | 74 | public MongoQuery convertToQuery() { |
75 | 75 | MongoCondition condition = MongoCondition.newInstance(); |
76 | 76 | if (StringUtils.isNotEmpty(recommend)) { |
77 | - condition = condition.and("recommend", recommend, MongoOper.IS); | |
77 | + condition = condition.and("recommend", recommend, MongoOper.LIKE); | |
78 | 78 | } |
79 | 79 | if (StringUtils.isNotEmpty(townOrgId)) { |
80 | - condition = condition.and("townOrgId", townOrgId, MongoOper.NE); | |
80 | + condition = condition.and("townOrgId", townOrgId, MongoOper.IS); | |
81 | 81 | } |
82 | 82 | Criteria c = null; |
83 | 83 |