| Line 59... |
Line 59... |
| 59 |
|
59 |
|
| 60 |
public class CreateSnapDealInventoryFeed {
|
60 |
public class CreateSnapDealInventoryFeed {
|
| 61 |
private static long time = System.currentTimeMillis();
|
61 |
private static long time = System.currentTimeMillis();
|
| 62 |
private static String SNAPDEAL_INVENTORY_SHEET;
|
62 |
private static String SNAPDEAL_INVENTORY_SHEET;
|
| 63 |
private static Map<Long, SnapdealItemForInventory> allItemsInventoryMap = new HashMap<Long, SnapdealItemForInventory>();
|
63 |
private static Map<Long, SnapdealItemForInventory> allItemsInventoryMap = new HashMap<Long, SnapdealItemForInventory>();
|
| 64 |
private static ArrayList<Inventory> inventoryItemList;
|
64 |
private static ArrayList<Inventory> currentInventoryItemList;
|
| 65 |
static Map<Long,Long> itemIdpendingOrdersMap = new HashMap<Long,Long>();
|
65 |
static Map<Long,Long> itemIdpendingOrdersMap = new HashMap<Long,Long>();
|
| 66 |
private static Map<String,InventoryHistory> inventoryhistoryItemMap;
|
66 |
private static Map<String,InventoryHistory> inventoryhistoryItemMap;
|
| 67 |
private static DefaultHttpClient client = new DefaultHttpClient();
|
67 |
private static DefaultHttpClient client = new DefaultHttpClient();
|
| 68 |
static Map<String,SnapdealItemDetails> snapdealItemMap = new HashMap<String,SnapdealItemDetails>();
|
68 |
static Map<String,SnapdealItemDetails> snapdealItemMap = new HashMap<String,SnapdealItemDetails>();
|
| 69 |
static Map<Long,SnapdealItemDetails> itemSnapdealMap = new HashMap<Long,SnapdealItemDetails>();
|
69 |
static Map<Long,SnapdealItemDetails> itemSnapdealMap = new HashMap<Long,SnapdealItemDetails>();
|
| Line 153... |
Line 153... |
| 153 |
long heldForSource=0;
|
153 |
long heldForSource=0;
|
| 154 |
double nlc=0;
|
154 |
double nlc=0;
|
| 155 |
double maxnlc=0;
|
155 |
double maxnlc=0;
|
| 156 |
Item thriftItem;
|
156 |
Item thriftItem;
|
| 157 |
long sku = 0;
|
157 |
long sku = 0;
|
| 158 |
for(Inventory inventoryItem:inventoryItemList){
|
158 |
for(Inventory inventoryItem:currentInventoryItemList){
|
| 159 |
if(inventoryItem.getSellerSku() == "10462" || inventoryItem.getSellerSku() == "10492"){
|
- |
|
| 160 |
System.out.println(inventoryItem.getSellerSku());
|
- |
|
| 161 |
}
|
- |
|
| 162 |
else{
|
- |
|
| 163 |
continue;
|
- |
|
| 164 |
}
|
- |
|
| 165 |
if(snapdealItemMap.containsKey(inventoryItem.getSellerSku())){
|
159 |
if(snapdealItemMap.containsKey(inventoryItem.getSellerSku())){
|
| 166 |
sku = snapdealItemMap.get(inventoryItem.getSellerSku()).getItem_id();
|
160 |
sku = snapdealItemMap.get(inventoryItem.getSellerSku()).getItem_id();
|
| 167 |
}
|
161 |
}
|
| 168 |
else{
|
162 |
else{
|
| 169 |
continue;
|
163 |
continue;
|
| Line 483... |
Line 477... |
| 483 |
}*/
|
477 |
}*/
|
| 484 |
int i = 1;
|
478 |
int i = 1;
|
| 485 |
int items=0;
|
479 |
int items=0;
|
| 486 |
Gson gson = new Gson();
|
480 |
Gson gson = new Gson();
|
| 487 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = null;
|
481 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = null;
|
| 488 |
inventoryItemList = new ArrayList<Inventory>();
|
482 |
currentInventoryItemList = new ArrayList<Inventory>();
|
| 489 |
HttpGet get;
|
483 |
HttpGet get;
|
| 490 |
HttpResponse response = null;
|
484 |
HttpResponse response = null;
|
| 491 |
BufferedReader rd= null;
|
485 |
BufferedReader rd= null;
|
| 492 |
while(true){
|
486 |
while(true){
|
| 493 |
System.out.println("Fetching current inventory page " +i);
|
487 |
System.out.println("Fetching current inventory page " +i);
|
| Line 511... |
Line 505... |
| 511 |
e.printStackTrace();
|
505 |
e.printStackTrace();
|
| 512 |
}
|
506 |
}
|
| 513 |
InventoryItems inventoryitems = (InventoryItems) gson.fromJson(rd, InventoryItems.class);
|
507 |
InventoryItems inventoryitems = (InventoryItems) gson.fromJson(rd, InventoryItems.class);
|
| 514 |
if(inventoryitems.getRows().size()!=0){
|
508 |
if(inventoryitems.getRows().size()!=0){
|
| 515 |
for(Inventory inventory : inventoryitems.getRows()){
|
509 |
for(Inventory inventory : inventoryitems.getRows()){
|
| 516 |
inventoryItemList.add(inventory);
|
510 |
currentInventoryItemList.add(inventory);
|
| 517 |
items++;
|
511 |
items++;
|
| 518 |
}
|
512 |
}
|
| 519 |
}
|
513 |
}
|
| 520 |
else{
|
514 |
else{
|
| 521 |
System.out.println("Fetched " + items);
|
515 |
System.out.println("Fetched " + items);
|
| Line 539... |
Line 533... |
| 539 |
} catch (TTransportException e1) {
|
533 |
} catch (TTransportException e1) {
|
| 540 |
// TODO Auto-generated catch block
|
534 |
// TODO Auto-generated catch block
|
| 541 |
e1.printStackTrace();
|
535 |
e1.printStackTrace();
|
| 542 |
}
|
536 |
}
|
| 543 |
List<String> notMappedItems = new ArrayList<String>();
|
537 |
List<String> notMappedItems = new ArrayList<String>();
|
| 544 |
for(Inventory inventory:inventoryItemList){
|
538 |
for(Inventory inventory:currentInventoryItemList){
|
| - |
|
539 |
if(inventory.getSellerSku() == "10462" || inventory.getSellerSku() == "10492"){
|
| - |
|
540 |
System.out.println(inventory.getSellerSku());
|
| - |
|
541 |
}
|
| - |
|
542 |
else{
|
| - |
|
543 |
continue;
|
| - |
|
544 |
}
|
| 545 |
created_orders = 0;
|
545 |
created_orders = 0;
|
| 546 |
pending_orders = 0;
|
546 |
pending_orders = 0;
|
| 547 |
try {
|
547 |
try {
|
| 548 |
snapdealitem = snapdealItemMap.get(inventory.getSellerSku());
|
548 |
snapdealitem = snapdealItemMap.get(inventory.getSellerSku());
|
| 549 |
if(snapdealitem==null){
|
549 |
if(snapdealitem==null){
|
| 550 |
continue;
|
- |
|
| 551 |
}
|
- |
|
| 552 |
if(snapdealitem.getItem_id()!=0){
|
- |
|
| 553 |
sku = snapdealitem.getItem_id();
|
- |
|
| 554 |
}
|
- |
|
| 555 |
else{
|
- |
|
| 556 |
notMappedItems.add("inventory.getSellerSku() "+inventory.getProductName());
|
550 |
notMappedItems.add("inventory.getSellerSku() "+inventory.getProductName());
|
| 557 |
System.out.println();
|
551 |
continue;
|
| 558 |
}
|
552 |
}
|
| 559 |
if(sku!=0){
|
553 |
if(sku!=0){
|
| 560 |
try{
|
554 |
try{
|
| 561 |
if(lastUpdatedInventoryTime > 0){
|
555 |
if(lastUpdatedInventoryTime > 0){
|
| 562 |
System.out.println("Fetching created orders for " + sku);
|
556 |
System.out.println("Fetching created orders for " + sku);
|
| 563 |
System.out.println("Last Updated on Time is " + lastUpdatedInventoryTime);
|
557 |
System.out.println("Last Updated on Time is " + lastUpdatedInventoryTime);
|
| 564 |
created_orders = transactionClient.getOrdersCreatedAfterTimestampForSource(lastUpdatedInventoryTime, 7, sku);
|
558 |
created_orders = transactionClient.getOrdersCreatedAfterTimestampForSource(lastUpdatedInventoryTime, 7, sku);
|
| 565 |
}
|
559 |
}
|
| 566 |
}
|
560 |
}
|
| 567 |
catch(TTransportException e){
|
561 |
catch(TTransportException e){
|
| - |
|
562 |
if(lastUpdatedInventoryTime > 0){
|
| 568 |
transactionClient = new TransactionClient("support_transaction_service_server_host","transaction_service_server_port").getClient();
|
563 |
transactionClient = new TransactionClient("support_transaction_service_server_host","transaction_service_server_port").getClient();
|
| 569 |
created_orders = transactionClient.getOrdersCreatedAfterTimestampForSource(lastUpdatedInventoryTime, 7, sku);
|
564 |
created_orders = transactionClient.getOrdersCreatedAfterTimestampForSource(lastUpdatedInventoryTime, 7, sku);
|
| - |
|
565 |
}
|
| 570 |
}
|
566 |
}
|
| 571 |
}
|
567 |
}
|
| 572 |
else{
|
568 |
else{
|
| 573 |
continue;
|
569 |
continue;
|
| 574 |
}
|
570 |
}
|
| 575 |
} catch (NumberFormatException e) {
|
- |
|
| 576 |
// TODO Auto-generated catch block
|
- |
|
| 577 |
e.printStackTrace();
|
- |
|
| 578 |
} catch (TException e) {
|
571 |
} catch (TException e) {
|
| 579 |
// TODO Auto-generated catch block
|
572 |
// TODO Auto-generated catch block
|
| 580 |
e.printStackTrace();
|
573 |
e.printStackTrace();
|
| 581 |
}
|
574 |
}
|
| 582 |
pending_orders = PendingOrdersInventoryHistoryMap.get(inventory.getSellerSku()).getPendingOrders()+(inventory.getAvailableInventory() - PendingOrdersInventoryHistoryMap.get(inventory.getSellerSku()).getInventoryHistory() - created_orders);
|
575 |
pending_orders = PendingOrdersInventoryHistoryMap.get(inventory.getSellerSku()).getPendingOrders()+(inventory.getAvailableInventory() - PendingOrdersInventoryHistoryMap.get(inventory.getSellerSku()).getInventoryHistory() - created_orders);
|
| Line 630... |
Line 623... |
| 630 |
long availability,reserve,defaultinventory,holdinventory,actualavailability,heldorders=0,sent_inventory;
|
623 |
long availability,reserve,defaultinventory,holdinventory,actualavailability,heldorders=0,sent_inventory;
|
| 631 |
SnapdealItemForInventory inventoryItem;
|
624 |
SnapdealItemForInventory inventoryItem;
|
| 632 |
StringBuffer outOfStockItems =new StringBuffer();
|
625 |
StringBuffer outOfStockItems =new StringBuffer();
|
| 633 |
StringBuffer backInStockItems =new StringBuffer();
|
626 |
StringBuffer backInStockItems =new StringBuffer();
|
| 634 |
long sku = 0;
|
627 |
long sku = 0;
|
| 635 |
for(Inventory inventory:inventoryItemList){
|
628 |
for(Inventory inventory:currentInventoryItemList){
|
| 636 |
//System.out.println(inventory.getSupc()+" "+inventory.getSellerSku()+ " " +inventory.getProductName()+" "+inventory.getAvailableInventory()+" "+inventory.isLive()+" "+itemIdpendingOrdersMap.get(Long.parseLong(inventory.getSellerSku())));
|
629 |
//System.out.println(inventory.getSupc()+" "+inventory.getSellerSku()+ " " +inventory.getProductName()+" "+inventory.getAvailableInventory()+" "+inventory.isLive()+" "+itemIdpendingOrdersMap.get(Long.parseLong(inventory.getSellerSku())));
|
| 637 |
try{
|
630 |
try{
|
| 638 |
if(snapdealItemMap.containsKey(inventory.getSellerSku())){
|
631 |
if(snapdealItemMap.containsKey(inventory.getSellerSku())){
|
| 639 |
sku = snapdealItemMap.get(inventory.getSellerSku()).getItem_id();
|
632 |
sku = snapdealItemMap.get(inventory.getSellerSku()).getItem_id();
|
| 640 |
}
|
633 |
}
|