| Line 177... |
Line 177... |
| 177 |
int retryCount =0;
|
177 |
int retryCount =0;
|
| 178 |
while(retry && retryCount!=5){
|
178 |
while(retry && retryCount!=5){
|
| 179 |
if(retryCount==4){
|
179 |
if(retryCount==4){
|
| 180 |
String emailFromAddress = "build@shop2020.in";
|
180 |
String emailFromAddress = "build@shop2020.in";
|
| 181 |
String password = "cafe@nes";
|
181 |
String password = "cafe@nes";
|
| 182 |
String[] sendTo = new String[]{ "vikram.raghav@shop2020.in"};
|
182 |
String[] sendTo = new String[]{ "kshitij.sood@saholic.com","anikendra.das@shop2020.in"};
|
| 183 |
String emailSubjectTxt = "Fetch FBA Sale failure";
|
183 |
String emailSubjectTxt = "Fetch FBA Sale failure";
|
| 184 |
try {
|
184 |
try {
|
| 185 |
GmailUtils mailer = new GmailUtils();
|
185 |
GmailUtils mailer = new GmailUtils();
|
| 186 |
mailer.sendSSLMessage(sendTo, emailSubjectTxt, "", emailFromAddress, password,"");
|
186 |
mailer.sendSSLMessage(sendTo, emailSubjectTxt, "", emailFromAddress, password,"");
|
| 187 |
}
|
187 |
}
|
| Line 221... |
Line 221... |
| 221 |
requestorderreport.setReportId( requestIdreportIdmap.get(orderreportrequestId));
|
221 |
requestorderreport.setReportId( requestIdreportIdmap.get(orderreportrequestId));
|
| 222 |
requestinventoryhealthreport.setReportId(requestIdreportIdmap.get(inventoryhealthreportrequestId));
|
222 |
requestinventoryhealthreport.setReportId(requestIdreportIdmap.get(inventoryhealthreportrequestId));
|
| 223 |
OutputStream orderreport=null;
|
223 |
OutputStream orderreport=null;
|
| 224 |
OutputStream inventoryhealthreport=null;
|
224 |
OutputStream inventoryhealthreport=null;
|
| 225 |
try {
|
225 |
try {
|
| 226 |
orderreport = new FileOutputStream( "/home/amazonorderreport.xml" );
|
226 |
orderreport = new FileOutputStream( "/tmp/amazonorderreport.xml" );
|
| 227 |
inventoryhealthreport = new FileOutputStream( "/home/inventoryhealthreport.csv" );
|
227 |
inventoryhealthreport = new FileOutputStream( "/tmp/inventoryhealthreport.csv" );
|
| 228 |
} catch (FileNotFoundException e) {
|
228 |
} catch (FileNotFoundException e) {
|
| 229 |
// TODO Auto-generated catch block
|
229 |
// TODO Auto-generated catch block
|
| 230 |
e.printStackTrace();
|
230 |
e.printStackTrace();
|
| 231 |
}
|
231 |
}
|
| 232 |
requestorderreport.setReportOutputStream(orderreport);
|
232 |
requestorderreport.setReportOutputStream(orderreport);
|
| Line 235... |
Line 235... |
| 235 |
GetReportSample.invokeGetReport(service, requestinventoryhealthreport);
|
235 |
GetReportSample.invokeGetReport(service, requestinventoryhealthreport);
|
| 236 |
System.out.println("Order and Inventory Reports are ready please check");
|
236 |
System.out.println("Order and Inventory Reports are ready please check");
|
| 237 |
|
237 |
|
| 238 |
String toFind = "<AmazonEnvelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"amzn-envelope.xsd\">";
|
238 |
String toFind = "<AmazonEnvelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"amzn-envelope.xsd\">";
|
| 239 |
String toReplace = "<AmazonEnvelope xmlns=\"http://mws.amazonaws.com/doc/2009-01-01/\">";
|
239 |
String toReplace = "<AmazonEnvelope xmlns=\"http://mws.amazonaws.com/doc/2009-01-01/\">";
|
| 240 |
File orderReportFile = new File("/home/amazonorderreport.xml");
|
240 |
File orderReportFile = new File("/tmp/amazonorderreport.xml");
|
| 241 |
String content = "";
|
241 |
String content = "";
|
| 242 |
try {
|
242 |
try {
|
| 243 |
content = IOUtils.toString(new FileInputStream(orderReportFile));
|
243 |
content = IOUtils.toString(new FileInputStream(orderReportFile));
|
| 244 |
} catch (FileNotFoundException e1) {
|
244 |
} catch (FileNotFoundException e1) {
|
| 245 |
// TODO Auto-generated catch block
|
245 |
// TODO Auto-generated catch block
|
| Line 269... |
Line 269... |
| 269 |
}
|
269 |
}
|
| 270 |
|
270 |
|
| 271 |
/*CSVReader orderreportreader = null;*/
|
271 |
/*CSVReader orderreportreader = null;*/
|
| 272 |
CSVReader inventoryhealthreportreader = null;
|
272 |
CSVReader inventoryhealthreportreader = null;
|
| 273 |
try {
|
273 |
try {
|
| 274 |
/*orderreportreader = new CSVReader(new FileReader("/home/amazonorderreport.csv"),'\t');*/
|
274 |
/*orderreportreader = new CSVReader(new FileReader("/tmp/amazonorderreport.csv"),'\t');*/
|
| 275 |
inventoryhealthreportreader = new CSVReader(new FileReader("/home/inventoryhealthreport.csv"),'\t');
|
275 |
inventoryhealthreportreader = new CSVReader(new FileReader("/tmp/inventoryhealthreport.csv"),'\t');
|
| 276 |
} catch (FileNotFoundException e) {
|
276 |
} catch (FileNotFoundException e) {
|
| 277 |
// TODO Auto-generated catch block
|
277 |
// TODO Auto-generated catch block
|
| 278 |
e.printStackTrace();
|
278 |
e.printStackTrace();
|
| 279 |
}
|
279 |
}
|
| 280 |
String [] nextLine;
|
280 |
String [] nextLine;
|
| Line 318... |
Line 318... |
| 318 |
}
|
318 |
}
|
| 319 |
else{
|
319 |
else{
|
| 320 |
//System.out.println("Skipping Order not FBB or FBA" + amazonOrder.getAmazonOrderID()+" "+date_key+" "+ amazonOrder.getOrderItem().get(0).getSKU() +" " + amazonOrder.getOrderItem().get(0).getItemStatus() + " " + amazonOrder.getOrderItem().get(0).getQuantity());
|
320 |
//System.out.println("Skipping Order not FBB or FBA" + amazonOrder.getAmazonOrderID()+" "+date_key+" "+ amazonOrder.getOrderItem().get(0).getSKU() +" " + amazonOrder.getOrderItem().get(0).getItemStatus() + " " + amazonOrder.getOrderItem().get(0).getQuantity());
|
| 321 |
continue;
|
321 |
continue;
|
| 322 |
}
|
322 |
}
|
| - |
|
323 |
String asin = amazonOrder.getOrderItem().get(0).getASIN();
|
| 323 |
Integer qty=0;
|
324 |
Integer qty=0;
|
| 324 |
if(amazonOrder.getOrderItem().get(0).getQuantity()!=0){
|
325 |
if(amazonOrder.getOrderItem().get(0).getQuantity()!=0){
|
| 325 |
qty = new Integer(amazonOrder.getOrderItem().get(0).getQuantity());
|
326 |
qty = new Integer(amazonOrder.getOrderItem().get(0).getQuantity());
|
| 326 |
}
|
327 |
}
|
| 327 |
Float itemSale = null;
|
328 |
Float itemSale = null;
|
| Line 366... |
Line 367... |
| 366 |
fbaSalesSnapshot.setTotalPromotionSale(fbaSalesSnapshot.getTotalPromotionSale() + (itemSale - itemDiscount));
|
367 |
fbaSalesSnapshot.setTotalPromotionSale(fbaSalesSnapshot.getTotalPromotionSale() + (itemSale - itemDiscount));
|
| 367 |
}
|
368 |
}
|
| 368 |
fbaSalesSnapshot.setFcLocation(fcLocation);
|
369 |
fbaSalesSnapshot.setFcLocation(fcLocation);
|
| 369 |
fbaSalesSnapshot.setTotalOrderCount(fbaSalesSnapshot.getTotalOrderCount() + qty);
|
370 |
fbaSalesSnapshot.setTotalOrderCount(fbaSalesSnapshot.getTotalOrderCount() + qty);
|
| 370 |
fbaSalesSnapshot.setTotalSale(fbaSalesSnapshot.getTotalSale() + itemSale - itemDiscount);
|
371 |
fbaSalesSnapshot.setTotalSale(fbaSalesSnapshot.getTotalSale() + itemSale - itemDiscount);
|
| - |
|
372 |
fbaSalesSnapshot.setAsin(asin);
|
| 371 |
Map<String,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = orderDateItemIdFbaSaleSnapshotMap.get(date_key);
|
373 |
Map<String,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = orderDateItemIdFbaSaleSnapshotMap.get(date_key);
|
| 372 |
ItemIdFbaSaleSnapshotMap.put(amazonOrder.getOrderItem().get(0).getSKU(), fbaSalesSnapshot);
|
374 |
ItemIdFbaSaleSnapshotMap.put(amazonOrder.getOrderItem().get(0).getSKU(), fbaSalesSnapshot);
|
| 373 |
//System.out.println("Adding Order to list entry exists " + amazonOrder.getAmazonOrderID()+" "+date_key+" "+ amazonOrder.getOrderItem().get(0).getSKU() +" " + amazonOrder.getOrderItem().get(0).getItemStatus() + " " + amazonOrder.getOrderItem().get(0).getQuantity());
|
375 |
//System.out.println("Adding Order to list entry exists " + amazonOrder.getAmazonOrderID()+" "+date_key+" "+ amazonOrder.getOrderItem().get(0).getSKU() +" " + amazonOrder.getOrderItem().get(0).getItemStatus() + " " + amazonOrder.getOrderItem().get(0).getQuantity());
|
| 374 |
orderDateItemIdFbaSaleSnapshotMap.put(date_key,ItemIdFbaSaleSnapshotMap);
|
376 |
orderDateItemIdFbaSaleSnapshotMap.put(date_key,ItemIdFbaSaleSnapshotMap);
|
| 375 |
}
|
377 |
}
|
| 376 |
else{
|
378 |
else{
|
| 377 |
fbaSalesSnapshot = new FbaSalesSnapshot();
|
379 |
fbaSalesSnapshot = new FbaSalesSnapshot();
|
| 378 |
fbaSalesSnapshot.setFcLocation(fcLocation);
|
380 |
fbaSalesSnapshot.setFcLocation(fcLocation);
|
| 379 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
381 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
| 380 |
fbaSalesSnapshot.setTotalSale(itemSale - itemDiscount);
|
382 |
fbaSalesSnapshot.setTotalSale(itemSale - itemDiscount);
|
| - |
|
383 |
fbaSalesSnapshot.setAsin(asin);
|
| 381 |
if(itemDiscount!=0){
|
384 |
if(itemDiscount!=0){
|
| 382 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
385 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
| 383 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
386 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
| 384 |
}
|
387 |
}
|
| 385 |
else{
|
388 |
else{
|
| Line 396... |
Line 399... |
| 396 |
Map<String,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<String,FbaSalesSnapshot>();
|
399 |
Map<String,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<String,FbaSalesSnapshot>();
|
| 397 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
400 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
| 398 |
fbaSalesSnapshot.setFcLocation(fcLocation);
|
401 |
fbaSalesSnapshot.setFcLocation(fcLocation);
|
| 399 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
402 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
| 400 |
fbaSalesSnapshot.setTotalSale(itemSale);
|
403 |
fbaSalesSnapshot.setTotalSale(itemSale);
|
| - |
|
404 |
fbaSalesSnapshot.setAsin(asin);
|
| 401 |
if(itemDiscount!=0){
|
405 |
if(itemDiscount!=0){
|
| 402 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
406 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
| 403 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
407 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
| 404 |
}
|
408 |
}
|
| 405 |
else{
|
409 |
else{
|
| Line 656... |
Line 660... |
| 656 |
amazonfbasalessnapshot.setTotalOrderCount(entry1.getValue().getPromotionOrderCount());
|
660 |
amazonfbasalessnapshot.setTotalOrderCount(entry1.getValue().getPromotionOrderCount());
|
| 657 |
amazonfbasalessnapshot.setTotalOrderCount(entry1.getValue().getTotalOrderCount());
|
661 |
amazonfbasalessnapshot.setTotalOrderCount(entry1.getValue().getTotalOrderCount());
|
| 658 |
amazonfbasalessnapshot.setTotalSale(entry1.getValue().getTotalSale());
|
662 |
amazonfbasalessnapshot.setTotalSale(entry1.getValue().getTotalSale());
|
| 659 |
amazonfbasalessnapshot.setPromotionSale(entry1.getValue().getTotalPromotionSale());
|
663 |
amazonfbasalessnapshot.setPromotionSale(entry1.getValue().getTotalPromotionSale());
|
| 660 |
amazonfbasalessnapshot.setIsOutOfStock(oos);
|
664 |
amazonfbasalessnapshot.setIsOutOfStock(oos);
|
| - |
|
665 |
amazonfbasalessnapshot.setAsin(entry1.getValue().getAsin());
|
| 661 |
if(itemIdSalePriceMap.containsKey(item_id) && itemIdSalePriceMap.get(item_id).getPrice()!=0){
|
666 |
if(itemIdSalePriceMap.containsKey(item_id) && itemIdSalePriceMap.get(item_id).getPrice()!=0){
|
| 662 |
amazonfbasalessnapshot.setSalePrice(itemIdSalePriceMap.get(item_id).getPrice());
|
667 |
amazonfbasalessnapshot.setSalePrice(itemIdSalePriceMap.get(item_id).getPrice());
|
| 663 |
amazonfbasalessnapshot.setSalePriceSnapshotDate(itemIdSalePriceMap.get(item_id).getDate().getTime());
|
668 |
amazonfbasalessnapshot.setSalePriceSnapshotDate(itemIdSalePriceMap.get(item_id).getDate().getTime());
|
| 664 |
}
|
669 |
}
|
| 665 |
else{
|
670 |
else{
|