mongoDB查询语句:
db.df_order_signed_monthly.aggregate([{$match:{"df_signed_time":{$gte:"2017-11-01"},"df_signed_time":{$lte:"2017-11-30"}}},{$group:{"_id":{"tiny_village_code":"$tiny_village_code"},"count":{$sum:1}}}])
java调用查询:
public List<JSONObject> selecTinyOrderLastMonthCountByVillage() {
List<JSONObject> result = new ArrayList<JSONObject>();
MongoDbUtil mDbUtil = (MongoDbUtil)SpringHelper.getBean("mongodb");
MongoDatabase database = mDbUtil.getDatabase();
MongoCollection<Document> collection = database.getCollection("df_order_signed_monthly");
List<Document> pipeline = new ArrayList<Document>();
Document filter = new Document();
Calendar cale = null;
cale = Calendar.getInstance();
int year = cale.get(Calendar.YEAR);