Commit 1d08efbbdf6cabd2633d9293be25b531b543e8d1
1 parent
3ae51116d1
Exists in
master
and in
8 other branches
增加社区查询
Showing 5 changed files with 42 additions and 4 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/param/CommunityQuery.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CommunityConfigService.java
- platform-common/src/main/java/com/lyms/platform/common/dao/operator/MongoCondition.java
- platform-common/src/main/java/com/lyms/platform/common/dao/operator/MongoOper.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CommunityConfigController.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/param/CommunityQuery.java
View file @
1d08efb
| ... | ... | @@ -8,8 +8,15 @@ |
| 8 | 8 | public class CommunityQuery extends BaseQuery { |
| 9 | 9 | private String keyword; |
| 10 | 10 | private String id; |
| 11 | + private String orgAreaId; | |
| 11 | 12 | |
| 13 | + public String getOrgAreaId() { | |
| 14 | + return orgAreaId; | |
| 15 | + } | |
| 12 | 16 | |
| 17 | + public void setOrgAreaId(String orgAreaId) { | |
| 18 | + this.orgAreaId = orgAreaId; | |
| 19 | + } | |
| 13 | 20 | |
| 14 | 21 | public String getId() { |
| 15 | 22 | return id; |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CommunityConfigService.java
View file @
1d08efb
| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | import org.springframework.stereotype.Service; |
| 13 | 13 | |
| 14 | 14 | import javax.swing.plaf.synth.Region; |
| 15 | +import java.util.ArrayList; | |
| 15 | 16 | import java.util.List; |
| 16 | 17 | |
| 17 | 18 | /** |
| ... | ... | @@ -49,8 +50,15 @@ |
| 49 | 50 | mongoCondition = mongoCondition.orCondition(new MongoCondition[]{new MongoCondition("name", communityQuery.getKeyword(), MongoOper.LIKE), new MongoCondition("gxxq", communityQuery.getKeyword(), MongoOper.LIKE)}); |
| 50 | 51 | } |
| 51 | 52 | mongoCondition.and("yn", YnEnums.YES.getId(), MongoOper.IS); |
| 52 | - if(null != communityQuery.getId() ) { | |
| 53 | - mongoCondition = mongoCondition.andCondition(new MongoCondition("areas", communityQuery.getId(), MongoOper.IS)); | |
| 53 | + if(null != communityQuery.getId() ||null!=communityQuery.getOrgAreaId()) { | |
| 54 | + List<String> list = new ArrayList<>(); | |
| 55 | + if(null!=communityQuery.getOrgAreaId()){ | |
| 56 | + list.add(communityQuery.getOrgAreaId()); | |
| 57 | + } | |
| 58 | + if(null!=communityQuery.getId()){ | |
| 59 | + list.add(communityQuery.getId()); | |
| 60 | + } | |
| 61 | + mongoCondition = mongoCondition.andCondition(new MongoCondition("areas", list, MongoOper.ALL)); | |
| 54 | 62 | } |
| 55 | 63 | MongoQuery mongoQuery = mongoCondition.toMongoQuery(); |
| 56 | 64 |
platform-common/src/main/java/com/lyms/platform/common/dao/operator/MongoCondition.java
View file @
1d08efb
| ... | ... | @@ -2,6 +2,8 @@ |
| 2 | 2 | |
| 3 | 3 | import org.springframework.data.mongodb.core.query.Criteria; |
| 4 | 4 | |
| 5 | +import java.util.Collection; | |
| 6 | + | |
| 5 | 7 | /** |
| 6 | 8 | * 封装mongo 条件属性的操作 对于模糊查询的时候 obj为一个正则表达式 如: <code> |
| 7 | 9 | * <ui> |
| ... | ... | @@ -79,6 +81,20 @@ |
| 79 | 81 | return this; |
| 80 | 82 | } |
| 81 | 83 | |
| 84 | + public MongoCondition all(Collection<?> o,String key) { | |
| 85 | + if (criteria == null) { | |
| 86 | + criteria = Criteria.where(key); | |
| 87 | + set(MongoOper.ALL, o, criteria); | |
| 88 | + } else { | |
| 89 | + Criteria criteria1 = criteria.and(key); | |
| 90 | + set(MongoOper.ALL, o, criteria1); | |
| 91 | + criteria = criteria1; | |
| 92 | + } | |
| 93 | + | |
| 94 | + return this; | |
| 95 | + } | |
| 96 | + | |
| 97 | + | |
| 82 | 98 | /** |
| 83 | 99 | * Query query = new Query(Criteria.where("b").elemMatch( Criteria.where("startDate").gte(date) .and("endDate").lte(date) ); |
| 84 | 100 | * |
| ... | ... | @@ -171,6 +187,12 @@ |
| 171 | 187 | criteria.lt(obj); |
| 172 | 188 | } else if (MongoOper.NE == oper) { |
| 173 | 189 | criteria.ne(obj); |
| 190 | + }else if(MongoOper.ALL==oper){ | |
| 191 | + if(obj instanceof Collection){ | |
| 192 | + criteria.all((Collection)obj); | |
| 193 | + }else{ | |
| 194 | + criteria.all(obj); | |
| 195 | + } | |
| 174 | 196 | } |
| 175 | 197 | } |
| 176 | 198 |
platform-common/src/main/java/com/lyms/platform/common/dao/operator/MongoOper.java
View file @
1d08efb
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CommunityConfigController.java
View file @
1d08efb
| ... | ... | @@ -103,7 +103,7 @@ |
| 103 | 103 | String areaId = autoMatchFacade.match(loginState.getId()); |
| 104 | 104 | List<CommunityConfig> communityConfigList; |
| 105 | 105 | if (null != areaId) { |
| 106 | - communityQuery.setId(areaId); | |
| 106 | + communityQuery.setOrgAreaId(areaId); | |
| 107 | 107 | } |
| 108 | 108 | communityConfigList = communityConfigService.queryCommunity(communityQuery); |
| 109 | 109 | List<BasicConfig> basicConfigs = null; |