public ListgetAllAbsData(RankParam rankParam) {
List dataList = new ArrayList();
MongoDatabase mongoDatabase= MongoDbConn.getDatabase("localhost", 27017, "area_new");
MongoCollection collection = mongoDatabase.getCollection("vaabs_monthly");
FindIterable findIterable = null;if ("vaabs".equals(rankParam.getIndexCode())) {if (rankParam.getAreaCode() == null || "".equals(rankParam.getAreaCode())) {//全国//db.vaabs_monthly.find({"$and":[{"indusId":300},{"areaCode":/.*0000$/}]})
Pattern queryPattern = Pattern.compile(".*0000$", Pattern.CASE_INSENSITIVE);
BasicDBObject queryObject= newBasicDBObject();
queryObject.put("areaCode", queryPattern);
queryObject.put("indusId", rankParam.getIndusId());
findIterable=collection.find(queryObject);
}else {//全省所有市的数据//db.vaabs_monthly.find({"$and":[{"indusId":300},{"date":"2007-01-31"},{"areaCode":/^13/},{"areaCode":/.*00$/},{"areaCode":{"$not":/.*0000$/}}]})//Pattern startPattern = Pattern.compile("^13", Pattern.CASE_INSENSITIVE);
Pattern startPattern = Pattern.compile("^"+rankParam.getAreaCode(), Pattern.CASE_INSENSITIVE);
Pattern endPattern= Pattern.compile(".*00$", Pattern.CASE_INSENSITIVE);
Pattern notPattern= Pattern.compile(".*0000$", Pattern.CASE_INSENSITIVE);
BasicDBObject queryObject= new BasicDBObject().append(QueryOperators.AND, new BasicDBObject[]{new BasicDBObject("indusId",rankParam.getIndusId()),new BasicDBObject("areaCode",startPattern),new BasicDBObject("areaCode",endPattern),new BasicDBObject("areaCode", new BasicDBObject("$not",notPattern))
});
findIterable=collection.find(queryObject);
}
MongoCursor mongoCursor =findIterable.iterator();while(mongoCursor.hasNext()) {
Document document=mongoCursor.next();
dataList.add(new Data(document.getString("name"), document.getDouble("value"), document.getString("date"), document.getString("areaCode"), document.getInteger("indusId")));
}
}else{
}returndataList;
}