/** * Query Financial statements * @author Liupeng * @param timestart * @param timeend * @return *///public list<keyrequest> FINDBYTIMEF Orfinal (String Timestart, String timeend) {public list<dbobject> findbytimeforfinal (string Timestart, String Timeend) {basicdbobject key = new Basicdbobject (); Key.put ("Kq_timer_start", true); GroupBy conditions Basicdbobject cond = new Basicdbobject ("Kq_timer_start", New Basicdbobject ("$gte", Timestart). Append ("$lt Timeend);//query Where condition basicdbobject initial = new Basicdbobject (); Initial.put ("Cou", 0); Need to query out the content initial.put ("Kq_autosum", "" "); Need to query out the content initial.put ("Kq_accountsum", "" "); The content that needs to be queried is string reduce = "function (obj,out) {" + "out.cou++;" + "Out.kq_autosum = out.kq_autosum+obj.kq_autosum+ ' _ ';" + "Out.kq_accountsum = out.kq_accountsum+obj.kq_accountsum+ ' _ ';}"; Basicdblist returnlist = (basicdblist) keyrequest.group (key, cond, initial, reduce); System.out.println (returnlist); list<dbobject> list = new arraylist<dbobject> (); object[] o = Returnlist.toarray (); for (int i = 0; i < o.length; i++) {DBObject dbobject = (dbobject) o[i];list.add (dbobject);} Return list;//can print out any value in Basicdblist in the form of/*system.out.println (returnlist); object[] o = Returnlist.toarray (); for ( int i = 0; i < o.length; i++) {DBObject dbobject = (dbobject) o[i]; System.out.println (Dbobject.get ("kq_id"));} */}