Commit cdd48b59d125273928cb5d3661f202be9bb29653
1 parent
439b70bb0f
Exists in
master
and in
6 other branches
update
Showing 1 changed file with 32 additions and 14 deletions
platform-dal/src/main/java/com/lyms/platform/query/BabyModelQuery.java
View file @
cdd48b5
... | ... | @@ -1389,19 +1389,20 @@ |
1389 | 1389 | if (null != riskCodeExist) { |
1390 | 1390 | condition = condition.and("riskCode", riskCodeExist, MongoOper.EXISTS); |
1391 | 1391 | } |
1392 | - if (StringUtils.isNotEmpty(openDisease)) { | |
1393 | - if ("2".equals(openDisease)) | |
1394 | - { | |
1395 | - condition = condition.and("openDisease", openDisease, MongoOper.IS); | |
1396 | - } | |
1397 | - else | |
1398 | - { | |
1399 | - MongoCondition con1 = MongoCondition.newInstance("openDisease", "1", MongoOper.IS); | |
1400 | - MongoCondition con = MongoCondition.newInstance("openDisease", false, MongoOper.EXISTS); | |
1401 | - condition = condition.orCondition(new MongoCondition[]{con1, con}); | |
1402 | - } | |
1403 | 1392 | |
1404 | - } | |
1393 | + //条件查询有冲突 | |
1394 | +// if (StringUtils.isNotEmpty(openDisease)) { | |
1395 | +// if ("2".equals(openDisease)) | |
1396 | +// { | |
1397 | +// condition = condition.and("openDisease", openDisease, MongoOper.IS); | |
1398 | +// } | |
1399 | +// else | |
1400 | +// { | |
1401 | +// MongoCondition con1 = MongoCondition.newInstance("openDisease", "1", MongoOper.IS); | |
1402 | +// MongoCondition con = MongoCondition.newInstance("openDisease", false, MongoOper.EXISTS); | |
1403 | +// condition = condition.orCondition(new MongoCondition[]{con1, con}); | |
1404 | +// } | |
1405 | +// } | |
1405 | 1406 | |
1406 | 1407 | if (null != endCase) { |
1407 | 1408 | condition = condition.and("endCase", endCase, MongoOper.IS); |
1408 | 1409 | |
1409 | 1410 | |
... | ... | @@ -1971,16 +1972,33 @@ |
1971 | 1972 | MongoCondition con2 = MongoCondition.newInstance("weakSon", 1, MongoOper.IS); |
1972 | 1973 | cor=c1.orCondition(new MongoCondition[]{con1, con2}).getCriteria(); |
1973 | 1974 | } |
1975 | + //条件查询:儿童疾病是否开通字段 查询冲突问题解决 | |
1976 | + Criteria cor2=null; | |
1977 | + if (StringUtils.isNotEmpty(openDisease)) { | |
1978 | + if ("2".equals(openDisease)) | |
1979 | + { | |
1980 | + condition = condition.and("openDisease", openDisease, MongoOper.IS); | |
1981 | + } | |
1982 | + else | |
1983 | + { | |
1984 | + MongoCondition con =MongoCondition.newInstance(); | |
1985 | + MongoCondition con1 = MongoCondition.newInstance("openDisease", "1", MongoOper.IS); | |
1986 | + MongoCondition con2 = MongoCondition.newInstance("openDisease", false, MongoOper.EXISTS); | |
1987 | + cor2 = con.orCondition(new MongoCondition[]{con1, con2}).getCriteria(); | |
1988 | + } | |
1989 | + } | |
1974 | 1990 | |
1975 | 1991 | /** |
1976 | 1992 | * 多个orCondition 需要添加Criteria来控制json同级两个and或者or来解决mongodb执行查询问题 |
1977 | 1993 | */ |
1978 | - if(c!=null&&cor!=null){ | |
1979 | - return new MongoCondition(c.andOperator(condition.getCriteria(), cor)).toMongoQuery(); | |
1994 | + if(c!=null&&cor!=null&&cor2!=null){ | |
1995 | + return new MongoCondition(c.andOperator(condition.getCriteria(), cor,cor2)).toMongoQuery(); | |
1980 | 1996 | }else if(c!=null){ |
1981 | 1997 | return new MongoCondition(c.andOperator(condition.getCriteria())).toMongoQuery(); |
1982 | 1998 | }else if(cor!=null){ |
1983 | 1999 | return new MongoCondition(cor.andOperator(condition.getCriteria())).toMongoQuery(); |
2000 | + }else if(cor2!=null){ | |
2001 | + return new MongoCondition(cor2.andOperator(condition.getCriteria())).toMongoQuery(); | |
1984 | 2002 | }else { |
1985 | 2003 | return condition.toMongoQuery(); |
1986 | 2004 | } |