Subversion Repositories SmartDukaan

Rev

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

Rev 11940 Rev 11944
Line 19... Line 19...
19
//import inventory.SnapdealItemForInventory;
19
//import inventory.SnapdealItemForInventory;
20
 
20
 
21
import java.io.BufferedReader;
21
import java.io.BufferedReader;
22
import java.io.BufferedWriter;
22
import java.io.BufferedWriter;
23
import java.io.File;
23
import java.io.File;
-
 
24
import java.io.FileReader;
24
import java.io.FileWriter;
25
import java.io.FileWriter;
25
import java.io.IOException;
26
import java.io.IOException;
26
import java.io.InputStreamReader;
27
import java.io.InputStreamReader;
27
import java.util.ArrayList;
28
import java.util.ArrayList;
28
import java.util.Collections;
29
import java.util.Collections;
Line 75... Line 76...
75
	static {
76
	static {
76
		emailFromAddress = "build-staging@shop2020.in";
77
		emailFromAddress = "build-staging@shop2020.in";
77
		password = "shop2020";
78
		password = "shop2020";
78
		mailer = new GmailUtils();
79
		mailer = new GmailUtils();
79
		sendTo = new String[] { "vikram.raghav@shop2020.in",
80
		sendTo = new String[] { "vikram.raghav@shop2020.in",
80
				"manish.sharma@shop2020.in" };
81
		"manish.sharma@shop2020.in" };
81
		/*
82
		/*
82
		 * sendTo = new String[]{ "sandeep.sachdeva@shop2020.in",
83
		 * sendTo = new String[]{ "sandeep.sachdeva@shop2020.in",
83
		 * "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
84
		 * "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
84
		 * "khushal.bhatia@shop2020.in"
85
		 * "khushal.bhatia@shop2020.in"
85
		 * ,"manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
86
		 * ,"manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
Line 93... Line 94...
93
		} catch (TTransportException e1) {
94
		} catch (TTransportException e1) {
94
			// TODO Auto-generated catch block
95
			// TODO Auto-generated catch block
95
			e1.printStackTrace();
96
			e1.printStackTrace();
96
		}
97
		}
97
		in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = catalogServiceClient
98
		in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = catalogServiceClient
98
				.getClient();
99
		.getClient();
99
 
100
 
100
		try {
101
		try {
101
			snapdealItems = catalogClient.getAllSnapdealItems();
102
			snapdealItems = catalogClient.getAllSnapdealItems();
102
			flipkartItems = catalogClient.getAllFlipkartItems();
103
			flipkartItems = catalogClient.getAllFlipkartItems();
103
		} catch (TException e) {
104
		} catch (TException e) {
Line 153... Line 154...
153
			catalogServiceClient = new CatalogClient();
154
			catalogServiceClient = new CatalogClient();
154
		} catch (TTransportException e) {
155
		} catch (TTransportException e) {
155
			e.printStackTrace();
156
			e.printStackTrace();
156
		}
157
		}
157
		in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = catalogServiceClient
158
		in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = catalogServiceClient
158
				.getClient();
159
		.getClient();
159
		try {
160
		try {
160
			List<Item> aliveItems = catalogClient.getAllAliveItems();
161
			List<Item> aliveItems = catalogClient.getAllAliveItems();
161
			Map<Long, Item> aliveItemsMap = new HashMap<Long, Item>();
162
			Map<Long, Item> aliveItemsMap = new HashMap<Long, Item>();
162
			for (in.shop2020.model.v1.catalog.Item thriftItem : aliveItems) {
163
			for (in.shop2020.model.v1.catalog.Item thriftItem : aliveItems) {
163
				aliveItemsMap.put(thriftItem.getId(), thriftItem);
164
				aliveItemsMap.put(thriftItem.getId(), thriftItem);
Line 168... Line 169...
168
				inventoryServiceClient = new InventoryClient();
169
				inventoryServiceClient = new InventoryClient();
169
			} catch (TTransportException e) {
170
			} catch (TTransportException e) {
170
				e.printStackTrace();
171
				e.printStackTrace();
171
			}
172
			}
172
			in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient
173
			in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient
173
					.getClient();
174
			.getClient();
174
			List<Vendor> allVendors = inventoryClient.getAllVendors();
175
			List<Vendor> allVendors = inventoryClient.getAllVendors();
175
			for (Vendor v : allVendors) {
176
			for (Vendor v : allVendors) {
176
				vendorDataMap.put(v.getId(), v.getName());
177
				vendorDataMap.put(v.getId(), v.getName());
177
			}
178
			}
178
			List<in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems> ignoreItems = inventoryClient
179
			List<in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems> ignoreItems = inventoryClient
179
					.getIgnoredWarehouseidsAndItemids();
180
			.getIgnoredWarehouseidsAndItemids();
180
 
181
 
181
			availability = inventoryClient.getInventorySnapshot(0);
182
			availability = inventoryClient.getInventorySnapshot(0);
182
			List<Warehouse> allwarehouses = inventoryClient.getWarehouses(null,
183
			List<Warehouse> allwarehouses = inventoryClient.getWarehouses(null,
183
					null, 0, 0, 0);
184
					null, 0, 0, 0);
184
			Map<Long, Warehouse> allWarehousesMap = new HashMap<Long, Warehouse>();
185
			Map<Long, Warehouse> allWarehousesMap = new HashMap<Long, Warehouse>();
Line 245... Line 246...
245
							if (warehouse.getBillingWarehouseId() != 7) {
246
							if (warehouse.getBillingWarehouseId() != 7) {
246
								if (warehouse.getLogisticsLocation().equals(
247
								if (warehouse.getLogisticsLocation().equals(
247
										WarehouseLocation.Delhi)
248
										WarehouseLocation.Delhi)
248
										&& warehouse.getWarehouseType().equals(
249
										&& warehouse.getWarehouseType().equals(
249
												WarehouseType.THIRD_PARTY)
250
												WarehouseType.THIRD_PARTY)
250
										&& warehouse.getVendor().getId() != 1) {
251
												&& warehouse.getVendor().getId() != 1) {
251
 
252
 
252
								} else {
253
								} else {
253
									continue;
254
									continue;
254
								}
255
								}
255
							}
256
							}
256
							in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems ignoredItem = new in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems();
257
							in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems ignoredItem = new in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems();
257
							ignoredItem.setItemId(thriftItem.getId());
258
							ignoredItem.setItemId(thriftItem.getId());
258
							ignoredItem.setWarehouseId(warehouse.getId());
259
							ignoredItem.setWarehouseId(warehouse.getId());
259
							if (itemavailability.get(warehouse.getId()) != null
260
							if (itemavailability.get(warehouse.getId()) != null
260
									&& !thirdpartywarehouseids
261
									&& !thirdpartywarehouseids
261
											.contains(warehouse.getId())
262
									.contains(warehouse.getId())
262
									&& !ignoreItems.contains(ignoredItem)) {
263
									&& !ignoreItems.contains(ignoredItem)) {
263
								try {
264
								try {
264
									nlc = inventoryClient.getNlcForWarehouse(
265
									nlc = inventoryClient.getNlcForWarehouse(
265
											warehouse.getId(),
266
											warehouse.getId(),
266
											thriftItem.getId());
267
											thriftItem.getId());
267
 
268
 
268
								} catch (TTransportException e) {
269
								} catch (TTransportException e) {
269
									inventoryClient = inventoryServiceClient
270
									inventoryClient = inventoryServiceClient
270
											.getClient();
271
									.getClient();
271
									nlc = inventoryClient.getNlcForWarehouse(
272
									nlc = inventoryClient.getNlcForWarehouse(
272
											warehouse.getId(),
273
											warehouse.getId(),
273
											thriftItem.getId());
274
											thriftItem.getId());
274
								}
275
								}
275
 
276
 
Line 325... Line 326...
325
										// + total_held + "\theldForSource:" +
326
										// + total_held + "\theldForSource:" +
326
										// heldForSource + "\tavailable:" +
327
										// heldForSource + "\tavailable:" +
327
										// available);
328
										// available);
328
									} else {
329
									} else {
329
										long available = itemavailability
330
										long available = itemavailability
330
												.get(warehouse.getId());
331
										.get(warehouse.getId());
331
										if (available > 0) {
332
										if (available > 0) {
332
											nlcLOISD = new NlcLeftOutInventory();
333
											nlcLOISD = new NlcLeftOutInventory();
333
											nlcLOISD.setItemId(snapdealItem
334
											nlcLOISD.setItemId(snapdealItem
334
													.getItem_id());
335
													.getItem_id());
335
											nlcLOISD.setProductName(snapdealItem
336
											nlcLOISD.setProductName(snapdealItem
336
													.getBrand()
337
													.getBrand()
337
													+ " "
338
													+ " "
338
													+ snapdealItem
339
													+ snapdealItem
339
															.getModel_name()
340
													.getModel_name()
340
													+ " "
341
													+ " "
341
													+ snapdealItem
342
													+ snapdealItem
342
															.getModel_number()
343
													.getModel_number()
343
													+ " "
344
													+ " "
344
													+ snapdealItem.getColor());
345
													+ snapdealItem.getColor());
345
											nlcLOISD.setOurNlc(maxnlcSD);
346
											nlcLOISD.setOurNlc(maxnlcSD);
346
											nlcLOISD.setSkuAtSource(snapdealItem
347
											nlcLOISD.setSkuAtSource(snapdealItem
347
													.getSkuAtSnapdeal());
348
													.getSkuAtSnapdeal());
Line 414... Line 415...
414
										// + total_held + "\theldForSource:" +
415
										// + total_held + "\theldForSource:" +
415
										// heldForSource + "\tavailable:" +
416
										// heldForSource + "\tavailable:" +
416
										// available);
417
										// available);
417
									} else {
418
									} else {
418
										long available = itemavailability
419
										long available = itemavailability
419
												.get(warehouse.getId());
420
										.get(warehouse.getId());
420
										if (available > 0) {
421
										if (available > 0) {
421
											nlcLOIFK = new NlcLeftOutInventory();
422
											nlcLOIFK = new NlcLeftOutInventory();
422
											nlcLOIFK.setItemId(flipkartItem
423
											nlcLOIFK.setItemId(flipkartItem
423
													.getItem_id());
424
													.getItem_id());
424
											nlcLOIFK.setProductName(thriftItem
425
											nlcLOIFK.setProductName(thriftItem
425
													.getBrand()
426
													.getBrand()
426
													+ " "
427
													+ " "
427
													+ thriftItem.getModelName()
428
													+ thriftItem.getModelName()
428
													+ " "
429
													+ " "
429
													+ thriftItem
430
													+ thriftItem
430
															.getModelNumber()
431
													.getModelNumber()
431
													+ " "
432
													+ " "
432
													+ thriftItem.getColor());
433
													+ thriftItem.getColor());
433
											nlcLOIFK.setOurNlc(maxnlcFK);
434
											nlcLOIFK.setOurNlc(maxnlcFK);
434
											nlcLOIFK.setSkuAtSource(flipkartItem
435
											nlcLOIFK.setSkuAtSource(flipkartItem
435
													.getSkuAtFlipkart());
436
													.getSkuAtFlipkart());
Line 475... Line 476...
475
									.getBillingWarehouseId() != 7) {
476
									.getBillingWarehouseId() != 7) {
476
								if (allWarehousesMap.get(entry.getKey())
477
								if (allWarehousesMap.get(entry.getKey())
477
										.getLogisticsLocation()
478
										.getLogisticsLocation()
478
										.equals(WarehouseLocation.Delhi)
479
										.equals(WarehouseLocation.Delhi)
479
										&& allWarehousesMap
480
										&& allWarehousesMap
480
												.get(entry.getKey())
481
										.get(entry.getKey())
481
												.getWarehouseType()
482
										.getWarehouseType()
482
												.equals(WarehouseType.THIRD_PARTY)
483
										.equals(WarehouseType.THIRD_PARTY)
483
										&& allWarehousesMap.get(entry.getKey())
484
										&& allWarehousesMap.get(entry.getKey())
484
												.getVendor().getId() != 1) {
485
										.getVendor().getId() != 1) {
485
 
486
 
486
								} else {
487
								} else {
487
									continue;
488
									continue;
488
								}
489
								}
489
							}
490
							}
Line 545... Line 546...
545
										// + total_held + "\theldForSource:" +
546
										// + total_held + "\theldForSource:" +
546
										// heldForSource + "\tavailable:" +
547
										// heldForSource + "\tavailable:" +
547
										// available);
548
										// available);
548
									} else {
549
									} else {
549
										long available = itemavailability
550
										long available = itemavailability
550
												.get(entry.getKey());
551
										.get(entry.getKey());
551
										if (available > 0) {
552
										if (available > 0) {
552
											nlcLOISD = new NlcLeftOutInventory();
553
											nlcLOISD = new NlcLeftOutInventory();
553
											nlcLOISD.setItemId(snapdealItem
554
											nlcLOISD.setItemId(snapdealItem
554
													.getItem_id());
555
													.getItem_id());
555
											nlcLOISD.setProductName(snapdealItem
556
											nlcLOISD.setProductName(snapdealItem
556
													.getBrand()
557
													.getBrand()
557
													+ " "
558
													+ " "
558
													+ snapdealItem
559
													+ snapdealItem
559
															.getModel_name()
560
													.getModel_name()
560
													+ " "
561
													+ " "
561
													+ snapdealItem
562
													+ snapdealItem
562
															.getModel_number()
563
													.getModel_number()
563
													+ " "
564
													+ " "
564
													+ snapdealItem.getColor());
565
													+ snapdealItem.getColor());
565
											nlcLOISD.setOurNlc(maxnlcSD);
566
											nlcLOISD.setOurNlc(maxnlcSD);
566
											nlcLOISD.setSkuAtSource(snapdealItem
567
											nlcLOISD.setSkuAtSource(snapdealItem
567
													.getSkuAtSnapdeal());
568
													.getSkuAtSnapdeal());
Line 630... Line 631...
630
										// + total_held + "\theldForSource:" +
631
										// + total_held + "\theldForSource:" +
631
										// heldForSource + "\tavailable:" +
632
										// heldForSource + "\tavailable:" +
632
										// available);
633
										// available);
633
									} else {
634
									} else {
634
										long available = itemavailability
635
										long available = itemavailability
635
												.get(entry.getKey());
636
										.get(entry.getKey());
636
										if (available > 0) {
637
										if (available > 0) {
637
											nlcLOIFK = new NlcLeftOutInventory();
638
											nlcLOIFK = new NlcLeftOutInventory();
638
											nlcLOIFK.setItemId(flipkartItem
639
											nlcLOIFK.setItemId(flipkartItem
639
													.getItem_id());
640
													.getItem_id());
640
											nlcLOIFK.setProductName(thriftItem
641
											nlcLOIFK.setProductName(thriftItem
641
													.getBrand()
642
													.getBrand()
642
													+ " "
643
													+ " "
643
													+ thriftItem.getModelName()
644
													+ thriftItem.getModelName()
644
													+ " "
645
													+ " "
645
													+ thriftItem
646
													+ thriftItem
646
															.getModelNumber()
647
													.getModelNumber()
647
													+ " "
648
													+ " "
648
													+ thriftItem.getColor());
649
													+ thriftItem.getColor());
649
											nlcLOIFK.setOurNlc(maxnlcFK);
650
											nlcLOIFK.setOurNlc(maxnlcFK);
650
											nlcLOIFK.setSkuAtSource(flipkartItem
651
											nlcLOIFK.setSkuAtSource(flipkartItem
651
													.getSkuAtFlipkart());
652
													.getSkuAtFlipkart());
Line 693... Line 694...
693
							if (warehouse.getBillingWarehouseId() != 7) {
694
							if (warehouse.getBillingWarehouseId() != 7) {
694
								if (warehouse.getLogisticsLocation().equals(
695
								if (warehouse.getLogisticsLocation().equals(
695
										WarehouseLocation.Delhi)
696
										WarehouseLocation.Delhi)
696
										&& warehouse.getWarehouseType().equals(
697
										&& warehouse.getWarehouseType().equals(
697
												WarehouseType.THIRD_PARTY)
698
												WarehouseType.THIRD_PARTY)
698
										&& warehouse.getVendor().getId() != 1) {
699
												&& warehouse.getVendor().getId() != 1) {
699
 
700
 
700
								} else {
701
								} else {
701
									continue;
702
									continue;
702
								}
703
								}
703
							}
704
							}
704
							in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems ignoredItem = new in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems();
705
							in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems ignoredItem = new in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems();
705
							ignoredItem.setItemId(thriftItem.getId());
706
							ignoredItem.setItemId(thriftItem.getId());
706
							ignoredItem.setWarehouseId(warehouse.getId());
707
							ignoredItem.setWarehouseId(warehouse.getId());
707
							if (itemreserve.get(warehouse.getId()) != null
708
							if (itemreserve.get(warehouse.getId()) != null
708
									&& !thirdpartywarehouseids
709
									&& !thirdpartywarehouseids
709
											.contains(warehouse.getId())
710
									.contains(warehouse.getId())
710
									&& !ignoreItems.contains(warehouse.getId())) {
711
									&& !ignoreItems.contains(warehouse.getId())) {
711
								nlc = inventoryClient.getNlcForWarehouse(
712
								nlc = inventoryClient.getNlcForWarehouse(
712
										warehouse.getId(), thriftItem.getId());
713
										warehouse.getId(), thriftItem.getId());
713
								// maxnlc =
714
								// maxnlc =
714
								// catalogClient.getSnapdealItem(thriftItem.getId()).getMaxNlc();
715
								// catalogClient.getSnapdealItem(thriftItem.getId()).getMaxNlc();
Line 738... Line 739...
738
									} else {
739
									} else {
739
										if (snapdealLeftInvDataMap
740
										if (snapdealLeftInvDataMap
740
												.containsKey(snapdealItem
741
												.containsKey(snapdealItem
741
														.getSkuAtSnapdeal())) {
742
														.getSkuAtSnapdeal())) {
742
											Map<Long, NlcLeftOutInventory> newNlcObjMap = snapdealLeftInvDataMap
743
											Map<Long, NlcLeftOutInventory> newNlcObjMap = snapdealLeftInvDataMap
743
													.get(snapdealItem
744
											.get(snapdealItem
744
															.getSkuAtSnapdeal());
745
													.getSkuAtSnapdeal());
745
											if (newNlcObjMap
746
											if (newNlcObjMap
746
													.containsKey(warehouse
747
													.containsKey(warehouse
747
															.getId())) {
748
															.getId())) {
748
												NlcLeftOutInventory newObj = newNlcObjMap
749
												NlcLeftOutInventory newObj = newNlcObjMap
749
														.get(warehouse.getId());
750
												.get(warehouse.getId());
750
												newObj.setReserved(itemreserve
751
												newObj.setReserved(itemreserve
751
														.get(warehouse.getId()));
752
														.get(warehouse.getId()));
752
												newObj.setTotalAvailability(newObj
753
												newObj.setTotalAvailability(newObj
753
														.getVendorAvailability()
754
														.getVendorAvailability()
754
														- itemreserve.get(warehouse
755
														- itemreserve.get(warehouse
Line 787... Line 788...
787
									} else {
788
									} else {
788
										if (flipkartLeftInvDataMap
789
										if (flipkartLeftInvDataMap
789
												.containsKey(flipkartItem
790
												.containsKey(flipkartItem
790
														.getSkuAtFlipkart())) {
791
														.getSkuAtFlipkart())) {
791
											Map<Long, NlcLeftOutInventory> newNlcObjMap = flipkartLeftInvDataMap
792
											Map<Long, NlcLeftOutInventory> newNlcObjMap = flipkartLeftInvDataMap
792
													.get(flipkartItem
793
											.get(flipkartItem
793
															.getSkuAtFlipkart());
794
													.getSkuAtFlipkart());
794
											if (newNlcObjMap
795
											if (newNlcObjMap
795
													.containsKey(warehouse
796
													.containsKey(warehouse
796
															.getId())) {
797
															.getId())) {
797
												NlcLeftOutInventory newObj = newNlcObjMap
798
												NlcLeftOutInventory newObj = newNlcObjMap
798
														.get(warehouse.getId());
799
												.get(warehouse.getId());
799
												newObj.setReserved(itemreserve
800
												newObj.setReserved(itemreserve
800
														.get(warehouse.getId()));
801
														.get(warehouse.getId()));
801
												newObj.setTotalAvailability(newObj
802
												newObj.setTotalAvailability(newObj
802
														.getVendorAvailability()
803
														.getVendorAvailability()
803
														- itemreserve.get(warehouse
804
														- itemreserve.get(warehouse
Line 835... Line 836...
835
									.getBillingWarehouseId() != 7) {
836
									.getBillingWarehouseId() != 7) {
836
								if (allWarehousesMap.get(entry.getKey())
837
								if (allWarehousesMap.get(entry.getKey())
837
										.getLogisticsLocation()
838
										.getLogisticsLocation()
838
										.equals(WarehouseLocation.Delhi)
839
										.equals(WarehouseLocation.Delhi)
839
										&& allWarehousesMap
840
										&& allWarehousesMap
840
												.get(entry.getKey())
841
										.get(entry.getKey())
841
												.getWarehouseType()
842
										.getWarehouseType()
842
												.equals(WarehouseType.THIRD_PARTY)
843
										.equals(WarehouseType.THIRD_PARTY)
843
										&& allWarehousesMap.get(entry.getKey())
844
										&& allWarehousesMap.get(entry.getKey())
844
												.getVendor().getId() != 1) {
845
										.getVendor().getId() != 1) {
845
 
846
 
846
								} else {
847
								} else {
847
									continue;
848
									continue;
848
								}
849
								}
849
							}
850
							}
Line 878... Line 879...
878
									} else {
879
									} else {
879
										if (snapdealLeftInvDataMap
880
										if (snapdealLeftInvDataMap
880
												.containsKey(snapdealItem
881
												.containsKey(snapdealItem
881
														.getSkuAtSnapdeal())) {
882
														.getSkuAtSnapdeal())) {
882
											Map<Long, NlcLeftOutInventory> newNlcObjMap = snapdealLeftInvDataMap
883
											Map<Long, NlcLeftOutInventory> newNlcObjMap = snapdealLeftInvDataMap
883
													.get(snapdealItem
884
											.get(snapdealItem
884
															.getSkuAtSnapdeal());
885
													.getSkuAtSnapdeal());
885
											if (newNlcObjMap.containsKey(entry
886
											if (newNlcObjMap.containsKey(entry
886
													.getKey())) {
887
													.getKey())) {
887
												NlcLeftOutInventory newObj = newNlcObjMap
888
												NlcLeftOutInventory newObj = newNlcObjMap
888
														.get(entry.getKey());
889
												.get(entry.getKey());
889
												newObj.setReserved(itemreserve
890
												newObj.setReserved(itemreserve
890
														.get(entry.getKey()));
891
														.get(entry.getKey()));
891
												newObj.setTotalAvailability(newObj
892
												newObj.setTotalAvailability(newObj
892
														.getVendorAvailability()
893
														.getVendorAvailability()
893
														- itemreserve.get(entry
894
														- itemreserve.get(entry
Line 922... Line 923...
922
									} else {
923
									} else {
923
										if (flipkartLeftInvDataMap
924
										if (flipkartLeftInvDataMap
924
												.containsKey(flipkartItem
925
												.containsKey(flipkartItem
925
														.getSkuAtFlipkart())) {
926
														.getSkuAtFlipkart())) {
926
											Map<Long, NlcLeftOutInventory> newNlcObjMap = flipkartLeftInvDataMap
927
											Map<Long, NlcLeftOutInventory> newNlcObjMap = flipkartLeftInvDataMap
927
													.get(flipkartItem
928
											.get(flipkartItem
928
															.getSkuAtFlipkart());
929
													.getSkuAtFlipkart());
929
											if (newNlcObjMap.containsKey(entry
930
											if (newNlcObjMap.containsKey(entry
930
													.getKey())) {
931
													.getKey())) {
931
												NlcLeftOutInventory newObj = newNlcObjMap
932
												NlcLeftOutInventory newObj = newNlcObjMap
932
														.get(entry.getKey());
933
												.get(entry.getKey());
933
												newObj.setReserved(itemreserve
934
												newObj.setReserved(itemreserve
934
														.get(entry.getKey()));
935
														.get(entry.getKey()));
935
												newObj.setTotalAvailability(newObj
936
												newObj.setTotalAvailability(newObj
936
														.getVendorAvailability()
937
														.getVendorAvailability()
937
														- itemreserve.get(entry
938
														- itemreserve.get(entry
Line 970... Line 971...
970
				}
971
				}
971
 
972
 
972
				nlcLoiItemsMapSD = snapdealLeftInvDataMap;
973
				nlcLoiItemsMapSD = snapdealLeftInvDataMap;
973
				nlcLoiItemsMapFK = flipkartLeftInvDataMap;
974
				nlcLoiItemsMapFK = flipkartLeftInvDataMap;
974
 
975
 
975
				List<NlcLeftOutInventory> subNlcLoiItemsListSD1 = new ArrayList<NlcLeftOutInventory>();
-
 
976
				List<NlcLeftOutInventory> subNlcLoiItemsListSD2 = new ArrayList<NlcLeftOutInventory>();
-
 
977
				List<NlcLeftOutInventory> subNlcLoiItemsListFK1 = new ArrayList<NlcLeftOutInventory>();
-
 
978
				List<NlcLeftOutInventory> subNlcLoiItemsListFK2 = new ArrayList<NlcLeftOutInventory>();
-
 
979
				for (Map<Long, NlcLeftOutInventory> nlcLOImap : nlcLoiItemsMapSD
-
 
980
						.values()) {
-
 
981
					// System.out.println("Inner Map Size "+nlcLOImap.size());
-
 
982
					for (NlcLeftOutInventory nlcLOI : nlcLOImap.values()) {
-
 
983
						if (nlcLOI.getWarehouseType().equalsIgnoreCase("OURS")) {
-
 
984
							subNlcLoiItemsListSD1.add(nlcLOI);
-
 
985
						}
-
 
986
						if (nlcLOI.getWarehouseType().equalsIgnoreCase(
-
 
987
								"THIRD_PARTY")) {
-
 
988
							subNlcLoiItemsListSD2.add(nlcLOI);
-
 
989
						}
-
 
990
					}
-
 
991
				}
-
 
992
 
-
 
993
				if (subNlcLoiItemsListSD1 != null
-
 
994
						&& subNlcLoiItemsListSD1.size() >= 2) {
-
 
995
					Collections.sort(subNlcLoiItemsListSD1,
-
 
996
							new NlcLeftOutInventoryComparator());
-
 
997
				}
-
 
998
				if (subNlcLoiItemsListSD2 != null
-
 
999
						&& subNlcLoiItemsListSD2.size() >= 2) {
-
 
1000
					Collections.sort(subNlcLoiItemsListSD2,
-
 
1001
							new NlcLeftOutInventoryComparator());
-
 
1002
				}
-
 
1003
				mainNlcLoiItemsListSD.addAll(subNlcLoiItemsListSD1);
-
 
1004
				mainNlcLoiItemsListSD.addAll(subNlcLoiItemsListSD2);
-
 
1005
 
-
 
1006
				for (Map<Long, NlcLeftOutInventory> nlcLOImap : nlcLoiItemsMapFK
-
 
1007
						.values()) {
-
 
1008
					// System.out.println("Inner Map Size "+nlcLOImap.size());
-
 
1009
					for (NlcLeftOutInventory nlcLOI : nlcLOImap.values()) {
-
 
1010
						if (nlcLOI.getWarehouseType().equalsIgnoreCase("OURS")) {
-
 
1011
							subNlcLoiItemsListFK1.add(nlcLOI);
-
 
1012
						}
-
 
1013
						if (nlcLOI.getWarehouseType().equalsIgnoreCase("THIRD_PARTY")) {
-
 
1014
							subNlcLoiItemsListFK2.add(nlcLOI);
-
 
1015
						}
-
 
1016
					}
-
 
1017
				}
-
 
1018
 
-
 
1019
				if (subNlcLoiItemsListFK1 != null
-
 
1020
						&& subNlcLoiItemsListFK1.size() >= 2) {
-
 
1021
					Collections.sort(subNlcLoiItemsListFK1,
-
 
1022
							new NlcLeftOutInventoryComparator());
-
 
1023
				}
-
 
1024
				if (subNlcLoiItemsListFK2 != null
-
 
1025
						&& subNlcLoiItemsListFK2.size() >= 2) {
-
 
1026
					Collections.sort(subNlcLoiItemsListFK2,
-
 
1027
							new NlcLeftOutInventoryComparator());
-
 
1028
				}
-
 
1029
				
-
 
1030
				mainNlcLoiItemsListFK.addAll(subNlcLoiItemsListFK1);
-
 
1031
				mainNlcLoiItemsListFK.addAll(subNlcLoiItemsListFK2);
-
 
1032
				
-
 
1033
 
-
 
1034
			}
976
			}
1035
		} catch (TException e) {
977
		} catch (TException e) {
1036
			// TODO Auto-generated catch block
978
			// TODO Auto-generated catch block
1037
			e.printStackTrace();
979
			e.printStackTrace();
1038
		}
980
		}
Line 1042... Line 984...
1042
	private static void createAndSendLeftOutInventoryFile(
984
	private static void createAndSendLeftOutInventoryFile(
1043
			Map<String, Map<Long, NlcLeftOutInventory>> nlcLeftoutInventoryItems,
985
			Map<String, Map<Long, NlcLeftOutInventory>> nlcLeftoutInventoryItems,
1044
			String fileName) {
986
			String fileName) {
1045
		try {
987
		try {
1046
 
988
 
-
 
989
			File file = new File("/tmp/" + fileName + "-leftOutInv.xls");
-
 
990
			BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(
-
 
991
					file));
-
 
992
			bufferedWriter.write(StringUtils.join(new String[] { "ItemId",
-
 
993
					"Product Name", "SkuAtSource", "Vendor Name",
-
 
994
					"Vendor Warehouse Id", "Warehouse Type", "Max Our NLC",
-
 
995
					"Vendor NLC", "Availability Count", "Reserved Count",
-
 
996
			"Net Availabilty" }, '\t'));
-
 
997
             //id -0, name -1, sku - 2, vname 3, wh 4, wt 5, mnlc 6, vnlc 7, av8, r9, na 10
-
 
998
			// System.out.println(fileName+
-
 
999
			// " Main Map Size "+nlcLeftoutInventoryItems.size());
-
 
1000
 
-
 
1001
			for (Map<Long, NlcLeftOutInventory> nlcLOImap : nlcLeftoutInventoryItems
-
 
1002
					.values()) {
-
 
1003
				// System.out.println("Inner Map Size "+nlcLOImap.size());
-
 
1004
				for (NlcLeftOutInventory nlcLOI : nlcLOImap.values()) {
-
 
1005
					bufferedWriter.newLine();
-
 
1006
 
-
 
1007
					bufferedWriter.write(StringUtils.join(
-
 
1008
							new String[] {
-
 
1009
									String.valueOf(nlcLOI.getItemId()),
-
 
1010
									nlcLOI.getProductName(),
-
 
1011
									nlcLOI.getSkuAtSource(),
-
 
1012
									nlcLOI.getVendorName(),
-
 
1013
									String.valueOf(nlcLOI
-
 
1014
											.getVendorWarehouseId()),
-
 
1015
											nlcLOI.getWarehouseType(),
-
 
1016
											String.valueOf(nlcLOI.getOurNlc()),
-
 
1017
											String.valueOf(nlcLOI.getVendorNlc()),
-
 
1018
											String.valueOf(nlcLOI
-
 
1019
													.getVendorAvailability()),
-
 
1020
													String.valueOf(nlcLOI.getReserved()),
-
 
1021
													String.valueOf(nlcLOI
-
 
1022
															.getTotalAvailability()) }, '\t'));
-
 
1023
 
-
 
1024
				}
-
 
1025
			}
-
 
1026
			bufferedWriter.close();
-
 
1027
 
-
 
1028
			List<NlcLeftOutInventory> subNlcLoiItemsListSD1 = new ArrayList<NlcLeftOutInventory>();
-
 
1029
			List<NlcLeftOutInventory> subNlcLoiItemsListSD2 = new ArrayList<NlcLeftOutInventory>();
-
 
1030
			List<NlcLeftOutInventory> subNlcLoiItemsListFK1 = new ArrayList<NlcLeftOutInventory>();
-
 
1031
			List<NlcLeftOutInventory> subNlcLoiItemsListFK2 = new ArrayList<NlcLeftOutInventory>();
-
 
1032
			
-
 
1033
			
-
 
1034
			BufferedReader reader = null;
-
 
1035
			File readfile = new File("/tmp/" + fileName + "-leftOutInv.xls");
-
 
1036
		    reader = new BufferedReader(new FileReader(readfile));
-
 
1037
		    String line;
-
 
1038
		    String values[];
-
 
1039
		  //id -0, name -1, sku - 2, vname 3, wh 4, wt 5, mnlc 6, vnlc 7, av8, r9, na 10
-
 
1040
		    while ((line = reader.readLine()) != null) {
-
 
1041
		        values = line.split("\t");
-
 
1042
		        NlcLeftOutInventory nlcLoI = new NlcLeftOutInventory();
-
 
1043
		        nlcLoI.setItemId(Long.parseLong(values[0]));
-
 
1044
		        nlcLoI.setProductName(values[1]);
-
 
1045
		        nlcLoI.setOurNlc(Double.parseDouble(values[6]));
-
 
1046
		        nlcLoI.setSkuAtSource(values[2]);
-
 
1047
		        nlcLoI.setVendorName(values[3]);
-
 
1048
		        nlcLoI.setVendorAvailability(Long.parseLong(values[8]));
-
 
1049
		        nlcLoI.setVendorNlc(Double.parseDouble(values[7]));
-
 
1050
		        nlcLoI.setVendorWarehouseId(Long.parseLong(values[4]));
-
 
1051
		        nlcLoI.setWarehouseType(values[5]);
-
 
1052
		        nlcLoI.setReserved(Long.parseLong(values[9]));
-
 
1053
		        nlcLoI.setTotalAvailability(Long.parseLong(values[10]));
-
 
1054
		        
-
 
1055
		        if(fileName.equalsIgnoreCase("SNAPDEAL")){
-
 
1056
		        	if (nlcLoI.getWarehouseType().equalsIgnoreCase("OURS")) {
-
 
1057
						subNlcLoiItemsListSD1.add(nlcLoI);
-
 
1058
					}
-
 
1059
					if (nlcLoI.getWarehouseType().equalsIgnoreCase("THIRD_PARTY")) {
-
 
1060
						subNlcLoiItemsListSD2.add(nlcLoI);
-
 
1061
					}
-
 
1062
		        }
-
 
1063
		        if(fileName.equalsIgnoreCase("FLIPKART")){
-
 
1064
		        	if (nlcLoI.getWarehouseType().equalsIgnoreCase("OURS")) {
-
 
1065
						subNlcLoiItemsListFK1.add(nlcLoI);
-
 
1066
					}
-
 
1067
					if (nlcLoI.getWarehouseType().equalsIgnoreCase("THIRD_PARTY")) {
-
 
1068
						subNlcLoiItemsListFK2.add(nlcLoI);
-
 
1069
					}
-
 
1070
		        }
-
 
1071
		    }
1047
			StringBuffer sb = new StringBuffer();
1072
		    StringBuffer sb = new StringBuffer();
1048
			sb.append("<html><table border=\"1\" align=\"center\">"
1073
			sb.append("<html><table border=\"1\" align=\"center\">"
1049
					+ "<caption><b>" + "LEFT OUT INVENTORY DETAIL" + "</b></caption>"
1074
					+ "<caption><b>" + "LEFT OUT INVENTORY DETAIL" + "</b></caption>"
1050
					+ "<tr>" + "<td><b>" + "ITEM-ID" + "</b></td>" + "<td><b>"
1075
					+ "<tr>" + "<td><b>" + "ITEM-ID" + "</b></td>" + "<td><b>"
1051
					+ "PRODUCT-NAME" + "</b></td>" + "<td><b>" + "SKU-AT-SOURCE"
1076
					+ "PRODUCT-NAME" + "</b></td>" + "<td><b>" + "SKU-AT-SOURCE"
1052
					+ "</b></td>" + "<td><b>" + "VENDOR-NAME" + "</b></td>"
1077
					+ "</b></td>" + "<td><b>" + "VENDOR-NAME" + "</b></td>"
Line 1055... Line 1080...
1055
					+ "</b></td>" + "</b></td>" + "<td><b>" + "VENDOR-NLC"
1080
					+ "</b></td>" + "</b></td>" + "<td><b>" + "VENDOR-NLC"
1056
					+ "</b></td>" + "<td><b>" + "AVAILABILITY-COUNT" + "</b></td>"
1081
					+ "</b></td>" + "<td><b>" + "AVAILABILITY-COUNT" + "</b></td>"
1057
					+ "<td><b>" + "RESERVED-COUNT" + "</b></td>"
1082
					+ "<td><b>" + "RESERVED-COUNT" + "</b></td>"
1058
					+ "<td><b>" + "NET-AVAILABILITY" + "</b></td>"
1083
					+ "<td><b>" + "NET-AVAILABILITY" + "</b></td>"
1059
					+ "</tr>");
1084
					+ "</tr>");
1060
			
1085
		    
1061
			if(fileName.equalsIgnoreCase("SNAPDEAL")){
1086
		    if(fileName.equalsIgnoreCase("SNAPDEAL")){
-
 
1087
			    if (subNlcLoiItemsListSD1 != null
-
 
1088
						&& subNlcLoiItemsListSD1.size() >= 2) {
-
 
1089
					Collections.sort(subNlcLoiItemsListSD1,
-
 
1090
							new NlcLeftOutInventoryComparator());
-
 
1091
				}
-
 
1092
				if (subNlcLoiItemsListSD2 != null
-
 
1093
						&& subNlcLoiItemsListSD2.size() >= 2) {
-
 
1094
					Collections.sort(subNlcLoiItemsListSD2,
-
 
1095
							new NlcLeftOutInventoryComparator());
-
 
1096
				}
-
 
1097
				mainNlcLoiItemsListSD.addAll(subNlcLoiItemsListSD1);
-
 
1098
				mainNlcLoiItemsListSD.addAll(subNlcLoiItemsListSD2);
-
 
1099
				
1062
				for(NlcLeftOutInventory obj: mainNlcLoiItemsListSD){
1100
				for(NlcLeftOutInventory obj: mainNlcLoiItemsListSD){
1063
					sb.append("<tr>"+"<td>"+obj.getItemId()+"</td>"
1101
					sb.append("<tr>"+"<td>"+obj.getItemId()+"</td>"
1064
							+"<td>"+obj.getProductName()+"</td>"
1102
							+"<td>"+obj.getProductName()+"</td>"
1065
							+"<td>"+obj.getSkuAtSource()+"</td>"
1103
							+"<td>"+obj.getSkuAtSource()+"</td>"
1066
							+"<td>"+obj.getVendorName()+"</td>"
1104
							+"<td>"+obj.getVendorName()+"</td>"
Line 1069... Line 1107...
1069
							+"<td>"+obj.getOurNlc()+"</td>"
1107
							+"<td>"+obj.getOurNlc()+"</td>"
1070
							+"<td>"+obj.getVendorNlc()+"</td>"
1108
							+"<td>"+obj.getVendorNlc()+"</td>"
1071
							+"<td>"+obj.getVendorAvailability()+"</td>"
1109
							+"<td>"+obj.getVendorAvailability()+"</td>"
1072
							+"<td>"+obj.getReserved()+"</td>"
1110
							+"<td>"+obj.getReserved()+"</td>"
1073
							+"<td>"+obj.getTotalAvailability()+"</td>"+"</tr>"
1111
							+"<td>"+obj.getTotalAvailability()+"</td>"+"</tr>"
1074
							);
1112
					);
1075
				}
1113
				}
1076
			}
1114
		    }
1077
			
1115
			
1078
			if(fileName.equalsIgnoreCase("FLIPKART")){
1116
		    if(fileName.equalsIgnoreCase("FLIPKART")){
-
 
1117
				if (subNlcLoiItemsListFK1 != null
-
 
1118
						&& subNlcLoiItemsListFK1.size() >= 2) {
-
 
1119
					Collections.sort(subNlcLoiItemsListFK1,
-
 
1120
							new NlcLeftOutInventoryComparator());
-
 
1121
				}
-
 
1122
				if (subNlcLoiItemsListFK2 != null
-
 
1123
						&& subNlcLoiItemsListFK2.size() >= 2) {
-
 
1124
					Collections.sort(subNlcLoiItemsListFK2,
-
 
1125
							new NlcLeftOutInventoryComparator());
-
 
1126
				}
-
 
1127
				mainNlcLoiItemsListFK.addAll(subNlcLoiItemsListFK1);
-
 
1128
				mainNlcLoiItemsListFK.addAll(subNlcLoiItemsListFK2);
-
 
1129
				
1079
				for(NlcLeftOutInventory obj: mainNlcLoiItemsListFK){
1130
				for(NlcLeftOutInventory obj: mainNlcLoiItemsListFK){
1080
					sb.append("<tr>"+"<td>"+obj.getItemId()+"</td>"
1131
					sb.append("<tr>"+"<td>"+obj.getItemId()+"</td>"
1081
							+"<td>"+obj.getProductName()+"</td>"
1132
							+"<td>"+obj.getProductName()+"</td>"
1082
							+"<td>"+obj.getSkuAtSource()+"</td>"
1133
							+"<td>"+obj.getSkuAtSource()+"</td>"
1083
							+"<td>"+obj.getVendorName()+"</td>"
1134
							+"<td>"+obj.getVendorName()+"</td>"
Line 1086... Line 1137...
1086
							+"<td>"+obj.getOurNlc()+"</td>"
1137
							+"<td>"+obj.getOurNlc()+"</td>"
1087
							+"<td>"+obj.getVendorNlc()+"</td>"
1138
							+"<td>"+obj.getVendorNlc()+"</td>"
1088
							+"<td>"+obj.getVendorAvailability()+"</td>"
1139
							+"<td>"+obj.getVendorAvailability()+"</td>"
1089
							+"<td>"+obj.getReserved()+"</td>"
1140
							+"<td>"+obj.getReserved()+"</td>"
1090
							+"<td>"+obj.getTotalAvailability()+"</td>"+"</tr>"
1141
							+"<td>"+obj.getTotalAvailability()+"</td>"+"</tr>"
1091
							);
1142
					);
1092
				}
1143
				}
1093
			}
1144
		    }
1094
			
1145
 
1095
			sb.append("</table></html>");
1146
			sb.append("</table></html>");
1096
			
1147
 
1097
			BufferedWriter out = new BufferedWriter(new FileWriter("/tmp/"+fileName+"-leftOutInv-file.htm"));
1148
			BufferedWriter out = new BufferedWriter(new FileWriter("/tmp/"+fileName+"-leftOutInv-file.htm"));
1098
			out.write(sb.toString());
1149
			out.write(sb.toString());
1099
			out.flush();
1150
			out.flush();
1100
			out.close();
1151
			out.close();
1101
			
1152
			
1102
			File file = new File("/tmp/" + fileName + "-leftOutInv.xls");
-
 
1103
			BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(
-
 
1104
					file));
-
 
1105
			bufferedWriter.write(StringUtils.join(new String[] { "ItemId",
-
 
1106
					"Product Name", "SkuAtSource", "Vendor Name",
-
 
1107
					"Vendor Warehouse Id", "Warehouse Type", "Max Our NLC",
-
 
1108
					"Vendor NLC", "Availability Count", "Reserved Count",
-
 
1109
					"Net Availabilty" }, '\t'));
-
 
1110
 
-
 
1111
			// System.out.println(fileName+
-
 
1112
			// " Main Map Size "+nlcLeftoutInventoryItems.size());
-
 
1113
 
-
 
1114
			for (Map<Long, NlcLeftOutInventory> nlcLOImap : nlcLeftoutInventoryItems
-
 
1115
					.values()) {
-
 
1116
				// System.out.println("Inner Map Size "+nlcLOImap.size());
-
 
1117
				for (NlcLeftOutInventory nlcLOI : nlcLOImap.values()) {
-
 
1118
					bufferedWriter.newLine();
-
 
1119
 
-
 
1120
					bufferedWriter.write(StringUtils.join(
-
 
1121
							new String[] {
-
 
1122
									String.valueOf(nlcLOI.getItemId()),
-
 
1123
									nlcLOI.getProductName(),
-
 
1124
									nlcLOI.getSkuAtSource(),
-
 
1125
									nlcLOI.getVendorName(),
-
 
1126
									String.valueOf(nlcLOI
-
 
1127
											.getVendorWarehouseId()),
-
 
1128
									nlcLOI.getWarehouseType(),
-
 
1129
									String.valueOf(nlcLOI.getOurNlc()),
-
 
1130
									String.valueOf(nlcLOI.getVendorNlc()),
-
 
1131
									String.valueOf(nlcLOI
-
 
1132
											.getVendorAvailability()),
-
 
1133
									String.valueOf(nlcLOI.getReserved()),
-
 
1134
									String.valueOf(nlcLOI
-
 
1135
											.getTotalAvailability()) }, '\t'));
-
 
1136
 
-
 
1137
				}
-
 
1138
			}
1153
			
1139
			bufferedWriter.close();
-
 
1140
 
-
 
1141
			List<File> files = new ArrayList<File>();
1154
			List<File> files = new ArrayList<File>();
1142
			files.add(file);
1155
			files.add(file);
1143
 
1156
 
1144
			mailer.sendSSLMessage(sendTo,
1157
			mailer.sendSSLMessage(sendTo,
1145
					"Inventory not Sent due to NLC Limitaion in case of - "
1158
					"Inventory not Sent due to NLC Limitaion in case of - "
1146
							+ fileName, "Please find attached file.",
1159
					+ fileName, "Please find attached file.",
1147
					emailFromAddress, password, "/tmp/" + fileName + "-leftOutInv.xls", "/tmp/"+fileName+"-leftOutInv-file.htm");
1160
					emailFromAddress, password, "/tmp/" + fileName + "-leftOutInv.xls", "/tmp/"+fileName+"-leftOutInv-file.htm");
1148
			/*mailer.sendSSLMessage(sendTo,
1161
			/*mailer.sendSSLMessage(sendTo,
1149
					"Inventory not Sent due to NLC Limitaion in case of - "
1162
					"Inventory not Sent due to NLC Limitaion in case of - "
1150
							+ fileName, "Please find attached file.",
1163
							+ fileName, "Please find attached file.",
1151
					emailFromAddress, password, files);*/
1164
					emailFromAddress, password, files);*/