Subversion Repositories SmartDukaan

Rev

Rev 8540 | Rev 8826 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8540 Rev 8825
Line 13... Line 13...
13
import java.io.FileReader;
13
import java.io.FileReader;
14
import java.io.IOException;
14
import java.io.IOException;
15
import java.io.OutputStream;
15
import java.io.OutputStream;
16
import java.text.ParseException;
16
import java.text.ParseException;
17
import java.text.SimpleDateFormat;
17
import java.text.SimpleDateFormat;
-
 
18
import java.util.ArrayList;
18
import java.util.Arrays;
19
import java.util.Arrays;
19
import java.util.Calendar;
20
import java.util.Calendar;
20
import java.util.Date;
21
import java.util.Date;
21
import java.util.GregorianCalendar;
22
import java.util.GregorianCalendar;
22
import java.util.HashMap;
23
import java.util.HashMap;
Line 167... Line 168...
167
		while(retry && retryCount!=5){
168
		while(retry && retryCount!=5){
168
			if(retryCount==4){
169
			if(retryCount==4){
169
				String emailFromAddress = "build@shop2020.in";
170
				String emailFromAddress = "build@shop2020.in";
170
				String password = "cafe@nes";
171
				String password = "cafe@nes";
171
				String[] sendTo = new String[]{ "vikram.raghav@shop2020.in"};
172
				String[] sendTo = new String[]{ "vikram.raghav@shop2020.in"};
172
				String emailSubjectTxt = "FBA Stock Estimation Sheet Failure";
173
				String emailSubjectTxt = "Fetch FBA Sale failure";
173
 
-
 
174
				try {
174
				try {
175
					GmailUtils mailer = new GmailUtils();
175
					GmailUtils mailer = new GmailUtils();
176
					mailer.sendSSLMessage(sendTo, emailSubjectTxt, "", emailFromAddress, password,"");
176
					mailer.sendSSLMessage(sendTo, emailSubjectTxt, "", emailFromAddress, password,"");
177
				}
177
				}
178
				catch (Exception ex) {
178
				catch (Exception ex) {
Line 320... Line 320...
320
					TransactionClient transactionServiceClient = null;
320
					TransactionClient transactionServiceClient = null;
321
					CatalogClient catalogServiceClient = null;
321
					CatalogClient catalogServiceClient = null;
322
					try {
322
					try {
323
						inventoryServiceClient = new InventoryClient();
323
						inventoryServiceClient = new InventoryClient();
324
						transactionServiceClient = new TransactionClient();
324
						transactionServiceClient = new TransactionClient();
325
						//catalogServiceClient = new CatalogClient();
325
						catalogServiceClient = new CatalogClient();
326
						catalogServiceClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port");
326
						//catalogServiceClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port");
327
					} catch (Exception e) {
327
					} catch (Exception e) {
328
						// TODO Auto-generated catch block
328
						// TODO Auto-generated catch block
329
						e.printStackTrace();
329
						e.printStackTrace();
330
					}	
330
					}	
331
					in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
331
					in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
332
					in.shop2020.model.v1.order.TransactionService.Client transactionClient   = transactionServiceClient.getClient();
332
					in.shop2020.model.v1.order.TransactionService.Client transactionClient   = transactionServiceClient.getClient();
333
					in.shop2020.model.v1.catalog.CatalogService.Client catalogClient   = catalogServiceClient.getClient();
333
					in.shop2020.model.v1.catalog.CatalogService.Client catalogClient   = catalogServiceClient.getClient();
334
					SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
334
					SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
335
					Date date_today = dateFormat.parse(dateFormat.format(new Date()));
335
					//Date date_today = dateFormat.parse(dateFormat.format(new Date()));
-
 
336
					List<Date> dates = new ArrayList<Date>();
-
 
337
					Calendar cal = Calendar.getInstance();
-
 
338
					cal.add(Calendar.DATE, -1);
-
 
339
					Date date_end = dateFormat.parse(dateFormat.format(cal.getTime()));
-
 
340
					cal.add(Calendar.DATE, -5);
-
 
341
					Date date_start = dateFormat.parse(dateFormat.format(cal.getTime()));
-
 
342
					System.out.println("Start Date = " + date_start);
-
 
343
					System.out.println("End Date = " + date_end);
-
 
344
					Date d = date_start;
-
 
345
					while(!d.equals(date_end)){
-
 
346
				        cal.setTime(d);
-
 
347
				        cal.add(Calendar.DATE,1);
-
 
348
						d = cal.getTime();
-
 
349
						dates.add(d);
-
 
350
					}
336
					List<AmazonFbaInventorySnapshot> nonzeroFbaInventorySnapshotlist =  inventoryClient.getAllAmazonFbaItemInventory();
351
					List<AmazonFbaInventorySnapshot> nonzeroFbaInventorySnapshotlist =  inventoryClient.getAllAmazonFbaItemInventory();
-
 
352
					for(Date date:dates){
337
					if(nonzeroFbaInventorySnapshotlist!=null){
353
						if(nonzeroFbaInventorySnapshotlist!=null){
338
						for(AmazonFbaInventorySnapshot amazonFbaInventory:nonzeroFbaInventorySnapshotlist){
354
							for(AmazonFbaInventorySnapshot amazonFbaInventory:nonzeroFbaInventorySnapshotlist){
339
							if(orderDateItemIdFbaSaleSnapshotMap.containsKey(date_today) ){ 
355
								if(orderDateItemIdFbaSaleSnapshotMap.containsKey(date) ){ 
340
								if(!orderDateItemIdFbaSaleSnapshotMap.get(date_today).containsKey(amazonFbaInventory.getItem_id())){
356
									if(!orderDateItemIdFbaSaleSnapshotMap.get(date).containsKey(amazonFbaInventory.getItem_id())){
-
 
357
										Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<Long,FbaSalesSnapshot>();
-
 
358
										FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
-
 
359
										fbaSalesSnapshot.setTotalOrderCount(0);
-
 
360
										fbaSalesSnapshot.setPromotionOrderCount(0);
-
 
361
										fbaSalesSnapshot.setTotalPromotionSale((float) 0);
-
 
362
										fbaSalesSnapshot.setTotalSale((float) 0);
-
 
363
										ItemIdFbaSaleSnapshotMap.put(amazonFbaInventory.getItem_id(),fbaSalesSnapshot);
-
 
364
										orderDateItemIdFbaSaleSnapshotMap.get(date).put(amazonFbaInventory.getItem_id(),fbaSalesSnapshot);
-
 
365
									}
-
 
366
 
-
 
367
								}
-
 
368
								else{
341
									Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<Long,FbaSalesSnapshot>();
369
									Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<Long,FbaSalesSnapshot>();
342
									FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
370
									FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
343
									fbaSalesSnapshot.setTotalOrderCount(0);
371
									fbaSalesSnapshot.setTotalOrderCount(0);
344
									fbaSalesSnapshot.setPromotionOrderCount(0);
372
									fbaSalesSnapshot.setPromotionOrderCount(0);
345
									fbaSalesSnapshot.setTotalPromotionSale((float) 0);
373
									fbaSalesSnapshot.setTotalPromotionSale((float) 0);
346
									fbaSalesSnapshot.setTotalSale((float) 0);
374
									fbaSalesSnapshot.setTotalSale((float) 0);
347
									ItemIdFbaSaleSnapshotMap.put(amazonFbaInventory.getItem_id(),fbaSalesSnapshot);
375
									ItemIdFbaSaleSnapshotMap.put(amazonFbaInventory.getItem_id(),fbaSalesSnapshot);
348
									orderDateItemIdFbaSaleSnapshotMap.get(date_today).put(amazonFbaInventory.getItem_id(),fbaSalesSnapshot);
376
									orderDateItemIdFbaSaleSnapshotMap.put(date,ItemIdFbaSaleSnapshotMap);
349
								}
377
								}
350
 
-
 
351
							}
-
 
352
							else{
-
 
353
								Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<Long,FbaSalesSnapshot>();
-
 
354
								FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
-
 
355
								fbaSalesSnapshot.setTotalOrderCount(0);
-
 
356
								fbaSalesSnapshot.setPromotionOrderCount(0);
-
 
357
								fbaSalesSnapshot.setTotalPromotionSale((float) 0);
-
 
358
								fbaSalesSnapshot.setTotalSale((float) 0);
-
 
359
								ItemIdFbaSaleSnapshotMap.put(amazonFbaInventory.getItem_id(),fbaSalesSnapshot);
-
 
360
								orderDateItemIdFbaSaleSnapshotMap.put(date_today,ItemIdFbaSaleSnapshotMap);
-
 
361
							}
378
							}
362
						}
379
						}
363
					}
-
 
364
					else{
380
						else{
365
						System.out.println("No inventory in FBA");
381
							System.out.println("No inventory in FBA");
-
 
382
						}
366
					}
383
					}
367
					Map<Long,PriceAtDate> itemIdOurPriceMap = new HashMap<Long,PriceAtDate>();
384
					Map<Long,PriceAtDate> itemIdOurPriceMap = new HashMap<Long,PriceAtDate>();
368
					Map<Long,PriceAtDate> itemIdSalePriceMap = new HashMap<Long,PriceAtDate>();
385
					Map<Long,PriceAtDate> itemIdSalePriceMap = new HashMap<Long,PriceAtDate>();
369
					Map<Long,PriceAtDate> itemIdminFBAPriceMap = new HashMap<Long,PriceAtDate>();
386
					Map<Long,PriceAtDate> itemIdminFBAPriceMap = new HashMap<Long,PriceAtDate>();
370
					Map<Long,PriceAtDate> itemIdminMFNPriceMap = new HashMap<Long,PriceAtDate>();
387
					Map<Long,PriceAtDate> itemIdminMFNPriceMap = new HashMap<Long,PriceAtDate>();