| Line 50... |
Line 50... |
| 50 |
cal.add(Calendar.DATE, -1);cal.set(Calendar.HOUR_OF_DAY, 00);cal.set(Calendar.MINUTE,00);cal.set(Calendar.SECOND,00);cal.set(Calendar.MILLISECOND,00);
|
50 |
cal.add(Calendar.DATE, -1);cal.set(Calendar.HOUR_OF_DAY, 00);cal.set(Calendar.MINUTE,00);cal.set(Calendar.SECOND,00);cal.set(Calendar.MILLISECOND,00);
|
| 51 |
obj.add(new BasicDBObject("dateOfSale", cal.getTimeInMillis()));
|
51 |
obj.add(new BasicDBObject("dateOfSale", cal.getTimeInMillis()));
|
| 52 |
andQuery.put("$and", obj);
|
52 |
andQuery.put("$and", obj);
|
| 53 |
BasicDBObject orderBy = new BasicDBObject();
|
53 |
BasicDBObject orderBy = new BasicDBObject();
|
| 54 |
orderBy.put("dateOfSale", -1);
|
54 |
orderBy.put("dateOfSale", -1);
|
| 55 |
System.out.println(andQuery);
|
- |
|
| 56 |
System.out.println(orderBy);
|
- |
|
| 57 |
DBCursor cursor = collection.find(andQuery).sort(orderBy).limit(1);
|
55 |
DBCursor cursor = collection.find(andQuery).sort(orderBy).limit(1);
|
| 58 |
Gson gson = new Gson();
|
56 |
Gson gson = new Gson();
|
| 59 |
while (cursor.hasNext()) {
|
57 |
while (cursor.hasNext()) {
|
| 60 |
salesObj = gson.fromJson(cursor.next().toString(), AmazonFbaSalesSnapshot.class);
|
58 |
salesObj = gson.fromJson(cursor.next().toString(), AmazonFbaSalesSnapshot.class);
|
| 61 |
}
|
59 |
}
|
| Line 63... |
Line 61... |
| 63 |
|
61 |
|
| 64 |
}
|
62 |
}
|
| 65 |
|
63 |
|
| 66 |
public static AmazonFbaSalesSnapshot getAmazonFbaSalesLatestSnapshotForItem(long item_id){
|
64 |
public static AmazonFbaSalesSnapshot getAmazonFbaSalesLatestSnapshotForItem(long item_id){
|
| 67 |
AmazonFbaSalesSnapshot salesObj = new AmazonFbaSalesSnapshot();
|
65 |
AmazonFbaSalesSnapshot salesObj = new AmazonFbaSalesSnapshot();
|
| 68 |
System.out.println(salesObj);
|
- |
|
| 69 |
DB db = mongo.getDB(AMAZON_SALES_SNAPSHOT);
|
66 |
DB db = mongo.getDB(AMAZON_SALES_SNAPSHOT);
|
| 70 |
DBCollection collection = db.getCollection(AMAZON_DAILY_SALE_SNAPSHOT);
|
67 |
DBCollection collection = db.getCollection(AMAZON_DAILY_SALE_SNAPSHOT);
|
| 71 |
BasicDBObject andQuery = new BasicDBObject();
|
68 |
BasicDBObject andQuery = new BasicDBObject();
|
| 72 |
List<BasicDBObject> obj = new ArrayList<BasicDBObject>();
|
69 |
List<BasicDBObject> obj = new ArrayList<BasicDBObject>();
|
| 73 |
obj.add(new BasicDBObject("item_id", item_id));
|
70 |
obj.add(new BasicDBObject("item_id", item_id));
|
| Line 75... |
Line 72... |
| 75 |
cal.add(Calendar.DATE, -1);cal.set(Calendar.HOUR_OF_DAY, 00);cal.set(Calendar.MINUTE,00);cal.set(Calendar.SECOND,00);cal.set(Calendar.MILLISECOND,00);
|
72 |
cal.add(Calendar.DATE, -1);cal.set(Calendar.HOUR_OF_DAY, 00);cal.set(Calendar.MINUTE,00);cal.set(Calendar.SECOND,00);cal.set(Calendar.MILLISECOND,00);
|
| 76 |
obj.add(new BasicDBObject("dateOfSale", cal.getTimeInMillis()));
|
73 |
obj.add(new BasicDBObject("dateOfSale", cal.getTimeInMillis()));
|
| 77 |
andQuery.put("$and", obj);
|
74 |
andQuery.put("$and", obj);
|
| 78 |
BasicDBObject orderBy = new BasicDBObject();
|
75 |
BasicDBObject orderBy = new BasicDBObject();
|
| 79 |
orderBy.put("dateOfSale", -1);
|
76 |
orderBy.put("dateOfSale", -1);
|
| 80 |
System.out.println(andQuery);
|
- |
|
| 81 |
DBCursor cursor = collection.find(andQuery).sort(orderBy).limit(1);
|
77 |
DBCursor cursor = collection.find(andQuery).sort(orderBy).limit(1);
|
| 82 |
Gson gson = new Gson();
|
78 |
Gson gson = new Gson();
|
| 83 |
while (cursor.hasNext()) {
|
79 |
while (cursor.hasNext()) {
|
| 84 |
salesObj = gson.fromJson(cursor.next().toString(), AmazonFbaSalesSnapshot.class);
|
80 |
salesObj = gson.fromJson(cursor.next().toString(), AmazonFbaSalesSnapshot.class);
|
| 85 |
}
|
81 |
}
|
| Line 101... |
Line 97... |
| 101 |
obj.put("$lte", toDate);
|
97 |
obj.put("$lte", toDate);
|
| 102 |
query.put("dateOfSale",obj);
|
98 |
query.put("dateOfSale",obj);
|
| 103 |
BasicDBObject orderBy = new BasicDBObject();
|
99 |
BasicDBObject orderBy = new BasicDBObject();
|
| 104 |
orderBy.put("dateOfSale", 1);
|
100 |
orderBy.put("dateOfSale", 1);
|
| 105 |
Gson gson = new Gson();
|
101 |
Gson gson = new Gson();
|
| 106 |
System.out.println(query);
|
- |
|
| 107 |
List<AmazonFbaSalesSnapshot> salesSnapshot = new ArrayList<AmazonFbaSalesSnapshot>();
|
102 |
List<AmazonFbaSalesSnapshot> salesSnapshot = new ArrayList<AmazonFbaSalesSnapshot>();
|
| 108 |
DBCursor cursor = collection.find(query).sort(orderBy);
|
103 |
DBCursor cursor = collection.find(query).sort(orderBy);
|
| 109 |
while (cursor.hasNext()) {
|
104 |
while (cursor.hasNext()) {
|
| 110 |
AmazonFbaSalesSnapshot salesObj = gson.fromJson(cursor.next().toString(), AmazonFbaSalesSnapshot.class);
|
105 |
AmazonFbaSalesSnapshot salesObj = gson.fromJson(cursor.next().toString(), AmazonFbaSalesSnapshot.class);
|
| 111 |
salesSnapshot.add(salesObj);
|
106 |
salesSnapshot.add(salesObj);
|