Commit b3efd9917e66cdf32375db29b21e1bd9a60c8f55
1 parent
ad3dcbf808
Exists in
master
and in
6 other branches
update
Showing 1 changed file with 17 additions and 5 deletions
platform-dal/src/main/java/com/lyms/platform/query/AntExChuQuery.java
View file @
b3efd99
| ... | ... | @@ -5,6 +5,7 @@ |
| 5 | 5 | import com.lyms.platform.common.dao.operator.MongoCondition; |
| 6 | 6 | import com.lyms.platform.common.dao.operator.MongoOper; |
| 7 | 7 | import com.lyms.platform.common.dao.operator.MongoQuery; |
| 8 | +import com.lyms.platform.common.utils.StringUtils; | |
| 8 | 9 | import org.apache.commons.collections.CollectionUtils; |
| 9 | 10 | import org.springframework.data.mongodb.core.query.Criteria; |
| 10 | 11 | |
| ... | ... | @@ -325,9 +326,6 @@ |
| 325 | 326 | if (null != xhdb) { |
| 326 | 327 | condition = condition.and("xhdb", xhdb, MongoOper.NE); |
| 327 | 328 | } |
| 328 | - if (null != xhdbXiao) { | |
| 329 | - condition = condition.and("xhdb", xhdbXiao, MongoOper.LT); | |
| 330 | - } | |
| 331 | 329 | |
| 332 | 330 | if (null != hivkt) { |
| 333 | 331 | condition = condition.and("hivkt", hivkt, MongoOper.IS); |
| 334 | 332 | |
| 335 | 333 | |
| ... | ... | @@ -424,10 +422,24 @@ |
| 424 | 422 | condition = condition.orCondition(new MongoCondition[]{mongoCondition, condition2}); |
| 425 | 423 | } |
| 426 | 424 | if (null != lpXhdbStart&&null!=lpXhdbEnd) { |
| 425 | + //字符串判断大小 | |
| 426 | + String formatXhdb = String.format("function() {\n" + | |
| 427 | + " return this.xhdb >= %s &&this.xhdb <= %s \n" + | |
| 428 | + " }",lpXhdbStart,lpXhdbEnd); | |
| 427 | 429 | if (null != c) { |
| 428 | - c = c.and("xhdb").gte(lpXhdbStart).lte(lpXhdbEnd); | |
| 430 | + c.and("$where").is(formatXhdb).and("xhdb").ne("");//加ne:该字段在mongo中是”“ ,如果表达式有>=0也可查出。可以避免空数据 | |
| 429 | 431 | } else { |
| 430 | - c = Criteria.where("xhdb").gte(lpXhdbStart).lte(lpXhdbEnd); | |
| 432 | + c = Criteria.where("$where").is(formatXhdb).and("xhdb").ne(""); | |
| 433 | + } | |
| 434 | + } | |
| 435 | + if(StringUtils.isNotEmpty(xhdbXiao)){ | |
| 436 | + String formatXhdb = String.format("function() {\n" + | |
| 437 | + " return this.xhdb < %s \n" + | |
| 438 | + " }",xhdbXiao); | |
| 439 | + if(null != c){ | |
| 440 | + c = c.and("$where").is(formatXhdb).and("xhdb").ne("");//加ne:该字段在mongo中是”“ ,如果表达式有>=0也可查出。可以避免空数据 | |
| 441 | + }else{ | |
| 442 | + c = Criteria.where("$where").is(formatXhdb).and("xhdb").ne(""); | |
| 431 | 443 | } |
| 432 | 444 | } |
| 433 | 445 |