Hej,
Przy użyciu tej pętli:
for (Long user : users) {
List usersMap = new ArrayList();
final Statement stmt = new Statement();
stmt.setNamespace(xxx);
stmt.setSetName(xxxx);
stmt.setFilters(Filter.equal("u", user));
final RecordSet records = aerospikeClient.query(null, stmt);
StreamSupport.stream(records.spliterator(), true)
.flatMap(l -> {
final ArrayList<HashMap> auctionsFromRecord = (ArrayList<HashMap>) l.record.getValue("v");
return Optional.ofNullable(auctionsFromRecord).isPresent() ? auctionsFromRecord.stream() : Stream.<HashMap>empty();
})
.map(r -> parseAuction(r))
.collect(Collectors.toList())
.forEach(row -> {
if (row.getT().size() > 0) {
for (Transaction trans : row.getT()) {
if (trans.getTs() >= tsFrom && trans.getTs() <= tsTo) {
Map record = new HashMap();
Timestamp ts = new Timestamp(trans.getTs() * 1000);
Calendar cal = Calendar.getInstance(Locale.getDefault());
cal.setTime(new Date(ts.getTime()));
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) + 1;
int day = cal.get(Calendar.DATE);
System.out.println(trans);
for (int iYear = yearFrom; iYear <= yearTo; iYear++) {
for (int iMonth = 1; iMonth <= 12; iMonth++) {
if ((int) year == (int) iYear && (int) month == (int) iMonth) {
}
}
}
}
}
}
});
}
Potrzebuę pogrupować dane tak aby uzyskać tablicę:
[
2009 : [
1 : {
"user1" : {
"sum_qty" : "suma ilości",
"sum_value_of_sale" : "suma sprzedaży suma ilości * cena"
},
"user2" : {
"sum_qty" : "suma ilości",
"sum_value_of_sale" : "suma sprzedaży suma ilości * cena"
}
},
.
.
.
12 : {
"user1" : {
"sum_qty" : "suma ilości",
"sum_value_of_sale" : "suma sprzedaży suma ilości * cena"
},
"user2" : {
"sum_qty" : "suma ilości",
"sum_value_of_sale" : "suma sprzedaży suma ilości * cena"
}
],
2010 : [
1 : {
"user1" : {
"sum_qty" : "suma ilości",
"sum_value_of_sale" : "suma sprzedaży suma ilości * cena"
},
"user2" : {
"sum_qty" : "suma ilości",
"sum_value_of_sale" : "suma sprzedaży suma ilości * cena"
}
},
.
.
.
12 : {
"user1" : {
"sum_qty" : "suma ilości",
"sum_value_of_sale" : "suma sprzedaży suma ilości * cena"
},
"user2" : {
"sum_qty" : "suma ilości",
"sum_value_of_sale" : "suma sprzedaży suma ilości * cena"
}
],
];
System.out.println zwraca taki rekord:
Transaction(ts=1308238200, qty=1, price=4990, c=null, buyer=2250859356)
Jest to dla mnie ciężkie do ogarnięcia próbowałem już różnych sposobów , gdyby to było w PHPie to bym sobie poradził ale muszę to ogarnąć w Javie. Pomoże ktoś?