| Line 54... |
Line 54... |
| 54 |
import org.apache.thrift.TException;
|
54 |
import org.apache.thrift.TException;
|
| 55 |
import org.apache.thrift.transport.TTransportException;
|
55 |
import org.apache.thrift.transport.TTransportException;
|
| 56 |
import com.google.gson.Gson;
|
56 |
import com.google.gson.Gson;
|
| 57 |
|
57 |
|
| 58 |
public class CreateSnapDealInventoryFeed {
|
58 |
public class CreateSnapDealInventoryFeed {
|
| 59 |
private static long time = System.currentTimeMillis();
|
59 |
private static long time;
|
| 60 |
private static final String SNAPDEAL_INVENTORY_SHEET = "/home/snapdeal/snapdeal-inventory-"+time+".xls";
|
60 |
private static String SNAPDEAL_INVENTORY_SHEET;
|
| 61 |
private static Map<Long, SnapdealItemForInventory> allItemsInventoryMap = new HashMap<Long, SnapdealItemForInventory>();
|
61 |
private static Map<Long, SnapdealItemForInventory> allItemsInventoryMap = new HashMap<Long, SnapdealItemForInventory>();
|
| 62 |
private static ArrayList<Inventory> inventoryItemList;
|
62 |
private static ArrayList<Inventory> inventoryItemList;
|
| 63 |
static Map<Long,Long> itemIdpendingOrdersMap = new HashMap<Long,Long>();
|
63 |
static Map<Long,Long> itemIdpendingOrdersMap = new HashMap<Long,Long>();
|
| 64 |
private static void calculateinventory(){
|
64 |
private static void calculateinventory(){
|
| 65 |
|
65 |
|
| Line 85... |
Line 85... |
| 85 |
} catch (TTransportException e) {
|
85 |
} catch (TTransportException e) {
|
| 86 |
e.printStackTrace();
|
86 |
e.printStackTrace();
|
| 87 |
}
|
87 |
}
|
| 88 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
88 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 89 |
List<in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems> ignoreItems = inventoryClient.getIgnoredWarehouseidsAndItemids();
|
89 |
List<in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems> ignoreItems = inventoryClient.getIgnoredWarehouseidsAndItemids();
|
| - |
|
90 |
time = System.currentTimeMillis();
|
| - |
|
91 |
SNAPDEAL_INVENTORY_SHEET = "/home/snapdeal/snapdeal-inventory-"+time+".xls";
|
| 90 |
availability = inventoryClient.getInventorySnapshot(0);
|
92 |
availability = inventoryClient.getInventorySnapshot(0);
|
| 91 |
List<Warehouse> warehouses = inventoryClient.getWarehouses(WarehouseType.OURS_THIRDPARTY,null,0,0,0);
|
93 |
List<Warehouse> warehouses = inventoryClient.getWarehouses(WarehouseType.OURS_THIRDPARTY,null,0,0,0);
|
| 92 |
List<Warehouse> ours_warehouses = inventoryClient.getWarehouses(WarehouseType.OURS, InventoryType.GOOD, 0, 0, 0);
|
94 |
List<Warehouse> ours_warehouses = inventoryClient.getWarehouses(WarehouseType.OURS, InventoryType.GOOD, 0, 0, 0);
|
| 93 |
List<Long> thirdpartywarehouseids = new ArrayList<Long>();
|
95 |
List<Long> thirdpartywarehouseids = new ArrayList<Long>();
|
| 94 |
List<Long> oursGoodWarehouse = new ArrayList<Long>();
|
96 |
List<Long> oursGoodWarehouse = new ArrayList<Long>();
|
| Line 418... |
Line 420... |
| 418 |
FileInputStream fis = new FileInputStream("/home/vikram/Desktop/SellerInventory.xls");
|
420 |
FileInputStream fis = new FileInputStream("/home/vikram/Desktop/SellerInventory.xls");
|
| 419 |
Workbook hwb = new HSSFWorkbook(fis);
|
421 |
Workbook hwb = new HSSFWorkbook(fis);
|
| 420 |
Sheet sheet = hwb.getSheetAt(0);
|
422 |
Sheet sheet = hwb.getSheetAt(0);
|
| 421 |
Row row;
|
423 |
Row row;
|
| 422 |
int iterator=1;
|
424 |
int iterator=1;
|
| 423 |
long availability,reserve,defaultinventory,holdinventory,actualavailability,heldorders;
|
425 |
long availability,reserve,defaultinventory,holdinventory,actualavailability,heldorders,sent_inventory;
|
| 424 |
SnapdealItemForInventory inventoryItem;
|
426 |
SnapdealItemForInventory inventoryItem;
|
| 425 |
for(Inventory inventory:inventoryItemList){
|
427 |
for(Inventory inventory:inventoryItemList){
|
| 426 |
System.out.println(inventory.getSupc()+" "+inventory.getSellerSku()+ " " +inventory.getProductName()+" "+inventory.getAvailableInventory()+" "+inventory.isLive()+" "+itemIdpendingOrdersMap.get(Long.parseLong(inventory.getSellerSku())));
|
428 |
System.out.println(inventory.getSupc()+" "+inventory.getSellerSku()+ " " +inventory.getProductName()+" "+inventory.getAvailableInventory()+" "+inventory.isLive()+" "+itemIdpendingOrdersMap.get(Long.parseLong(inventory.getSellerSku())));
|
| 427 |
try{
|
429 |
try{
|
| 428 |
snapdealitem = catalogServiceClient.getSnapdealItem(Long.parseLong(inventory.getSellerSku()));
|
430 |
snapdealitem = catalogServiceClient.getSnapdealItem(Long.parseLong(inventory.getSellerSku()));
|
| Line 451... |
Line 453... |
| 451 |
long inventoryForRiskyItem = actualavailability - holdinventory;
|
453 |
long inventoryForRiskyItem = actualavailability - holdinventory;
|
| 452 |
if(inventoryItem.getRisky()){
|
454 |
if(inventoryItem.getRisky()){
|
| 453 |
if(inventoryForRiskyItem > 0){
|
455 |
if(inventoryForRiskyItem > 0){
|
| 454 |
if((Math.round(inventoryForRiskyItem*2/3) - heldorders + inventoryItem.getHeldForSource()) > 0){
|
456 |
if((Math.round(inventoryForRiskyItem*2/3) - heldorders + inventoryItem.getHeldForSource()) > 0){
|
| 455 |
row.getCell((short) 4).setCellValue(Math.round(inventoryForRiskyItem*2/3) - heldorders + inventoryItem.getHeldForSource());
|
457 |
row.getCell((short) 4).setCellValue(Math.round(inventoryForRiskyItem*2/3) - heldorders + inventoryItem.getHeldForSource());
|
| - |
|
458 |
sent_inventory = Math.round(inventoryForRiskyItem*2/3) - heldorders + inventoryItem.getHeldForSource();
|
| 456 |
}
|
459 |
}
|
| 457 |
else{
|
460 |
else{
|
| 458 |
row.getCell((short) 4).setCellValue(0);
|
461 |
row.getCell((short) 4).setCellValue(0);
|
| - |
|
462 |
sent_inventory = 0;
|
| 459 |
}
|
463 |
}
|
| 460 |
}
|
464 |
}
|
| 461 |
else{
|
465 |
else{
|
| 462 |
row.getCell((short) 4).setCellValue(0);
|
466 |
row.getCell((short) 4).setCellValue(0);
|
| - |
|
467 |
sent_inventory = 0;
|
| 463 |
}
|
468 |
}
|
| 464 |
}
|
469 |
}
|
| 465 |
else{
|
470 |
else{
|
| 466 |
if(actualavailability > defaultinventory){
|
471 |
if(actualavailability > defaultinventory){
|
| 467 |
if((Math.round(actualavailability*2/3) + inventoryItem.getHeldForSource()) > heldorders){
|
472 |
if((Math.round(actualavailability*2/3) + inventoryItem.getHeldForSource()) > heldorders){
|
| 468 |
System.out.println("actual" + actualavailability + "\t2/3actual" + Math.round(actualavailability*2/3) + "\theld for source" + inventoryItem.getHeldForSource() + "\theldorders" + heldorders + "\tFinal Value is : " + (Math.round(actualavailability*2/3) + inventoryItem.getHeldForSource() - heldorders));
|
473 |
System.out.println("actual" + actualavailability + "\t2/3actual" + Math.round(actualavailability*2/3) + "\theld for source" + inventoryItem.getHeldForSource() + "\theldorders" + heldorders + "\tFinal Value is : " + (Math.round(actualavailability*2/3) + inventoryItem.getHeldForSource() - heldorders));
|
| 469 |
row.getCell((short) 4).setCellValue(Math.round(actualavailability*2/3) + inventoryItem.getHeldForSource() - heldorders);
|
474 |
row.getCell((short) 4).setCellValue(Math.round(actualavailability*2/3) + inventoryItem.getHeldForSource() - heldorders);
|
| - |
|
475 |
sent_inventory = Math.round(actualavailability*2/3) + inventoryItem.getHeldForSource() - heldorders;
|
| 470 |
}
|
476 |
}
|
| 471 |
else{
|
477 |
else{
|
| 472 |
row.getCell((short) 4).setCellValue(0);
|
478 |
row.getCell((short) 4).setCellValue(0);
|
| - |
|
479 |
sent_inventory = 0;
|
| 473 |
}
|
480 |
}
|
| 474 |
}
|
481 |
}
|
| 475 |
else{
|
482 |
else{
|
| 476 |
if(defaultinventory > heldorders){
|
483 |
if(defaultinventory > heldorders){
|
| 477 |
row.getCell((short) 4).setCellValue(defaultinventory - heldorders);
|
484 |
row.getCell((short) 4).setCellValue(defaultinventory - heldorders);
|
| - |
|
485 |
sent_inventory = defaultinventory - heldorders;
|
| 478 |
}
|
486 |
}
|
| 479 |
else{
|
487 |
else{
|
| 480 |
row.getCell((short) 4).setCellValue(0);
|
488 |
row.getCell((short) 4).setCellValue(0);
|
| - |
|
489 |
sent_inventory = 0;
|
| 481 |
}
|
490 |
}
|
| 482 |
}
|
491 |
}
|
| 483 |
}
|
492 |
}
|
| 484 |
if(inventory.isLive()){
|
493 |
if(inventory.isLive()){
|
| 485 |
row.getCell((short) 5).setCellValue("Yes");
|
494 |
row.getCell((short) 5).setCellValue("Yes");
|
| 486 |
}
|
495 |
}
|
| 487 |
else{
|
496 |
else{
|
| 488 |
row.getCell((short) 5).setCellValue("No");
|
497 |
row.getCell((short) 5).setCellValue("No");
|
| 489 |
}
|
498 |
}
|
| - |
|
499 |
SnapdealInventoryItem snapdealinventoryitem = new SnapdealInventoryItem();
|
| - |
|
500 |
snapdealinventoryitem.setAvailability(sent_inventory);
|
| - |
|
501 |
snapdealinventoryitem.setItem_id(Long.parseLong(inventory.getSellerSku()));
|
| - |
|
502 |
snapdealinventoryitem.setLastUpdatedOnSnapdeal(time);
|
| - |
|
503 |
inventoryClient.addOrUpdateSnapdealInventoryForItem(snapdealinventoryitem);
|
| 490 |
iterator++;
|
504 |
iterator++;
|
| 491 |
}
|
505 |
}
|
| 492 |
else{
|
506 |
else{
|
| 493 |
continue;
|
507 |
continue;
|
| 494 |
}
|
508 |
}
|