Query criteria
Query query = new query ();
Query criteria
criteria = new criteria ();
SimpleDateFormat format = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");
if (Stringutils.isnotempty (type) &&!type.equals ("-1")) {
Criteria.and ("type"). is (type);
}
String Contacter=entrustinfovo.getcontacter ();
if (Stringutils.isnotempty (contacter)) {
Criteria.and ("Jsonobj.contacter"). is (contacter);
}
String Provinceid=entrustinfovo.getprovinceid ();
String Provincename=entrustinfovo.getprovincename ();
list<criteria> list = new arraylist<criteria> ();
if (Stringutils.isnotempty (Provinceid) | | Stringutils.isnotempty (Provincename)) {
Criteria.and ("Signuprecordhandlevo.provinceid"). is (Provinceid);
List.add (Criteria.where ("Signuprecordhandlevo.provincename"). is (Provincename));
}
Sale of the consignment and rental of the data is not displayed (1: Sale of housing Commission 2: rental Commission)
List.add (Criteria.where ("type"). In ("3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"));
Processing status
String Handleflag=entrustinfovo.gethandleflag ();
if (Stringutils.isnotempty (Handleflag)) {
Criteria.and ("Signuprecordhandlevo.handleflag"). Is (Integer.parseint (Handleflag));
}
if (list.size () > 0) {
Criterial.oroperator (List.toarray (New Criteria[list.size ()));
Criteria.andoperator (criterial);
}
Query.addcriteria (criteria);
Total number of bars
Long Count = Mongotemplate.count (query, Entrustjsonobj.class, tableconstants.steward_entrust_info);
System.out.print (Query.tostring ());
Page out
Query.skip ((pageNo-1) * pageSize);//Skip is the equivalent of which record starts
Query.limit (pageSize);//How many records are taken from the start of skip
Sort
Sort sort = new sort (Sort.Direction.DESC, "createtime");
Query.with (sort);
Pagebean.settotalcount (count);
MongoDB Query Condition setting