| Line 695... |
Line 695... |
| 695 |
FileInputStream fis = new FileInputStream("/root/code/trunk/SnapDealFeeds/SellerInventory.xls");
|
695 |
FileInputStream fis = new FileInputStream("/root/code/trunk/SnapDealFeeds/SellerInventory.xls");
|
| 696 |
Workbook hwb = new HSSFWorkbook(fis);
|
696 |
Workbook hwb = new HSSFWorkbook(fis);
|
| 697 |
Sheet sheet = hwb.getSheetAt(0);
|
697 |
Sheet sheet = hwb.getSheetAt(0);
|
| 698 |
Row row;
|
698 |
Row row;
|
| 699 |
int iterator=1;
|
699 |
int iterator=1;
|
| 700 |
long available,reserve,defaultinventory,holdinventory,heldorders=0,sent_inventory,totalheld,heldforsource,allocable;
|
700 |
long available,reserve,defaultinventory,holdinventory,heldorders=0,sent_inventory = 0,totalheld,heldforsource,allocable;
|
| 701 |
SnapdealItemForInventory inventoryItem;
|
701 |
SnapdealItemForInventory inventoryItem;
|
| 702 |
StringBuffer outOfStockItems =new StringBuffer();
|
702 |
StringBuffer outOfStockItems =new StringBuffer();
|
| 703 |
StringBuffer backInStockItems =new StringBuffer();
|
703 |
StringBuffer backInStockItems =new StringBuffer();
|
| 704 |
long sku = 0;
|
704 |
long sku = 0;
|
| 705 |
SnapdealItemDetails snapdealitem;
|
705 |
SnapdealItemDetails snapdealitem;
|
| Line 712... |
Line 712... |
| 712 |
else{
|
712 |
else{
|
| 713 |
continue;
|
713 |
continue;
|
| 714 |
}
|
714 |
}
|
| 715 |
if(snapdealitem.getItem_id()!=0 && snapdealitem.isIsListedOnSnapdeal() && !snapdealitem.isSuppressInventoryFeed()){
|
715 |
if(snapdealitem.getItem_id()!=0 && snapdealitem.isIsListedOnSnapdeal() && !snapdealitem.isSuppressInventoryFeed()){
|
| 716 |
inventoryItem = allItemsInventoryMap.get(sku);
|
716 |
inventoryItem = allItemsInventoryMap.get(sku);
|
| 717 |
if(inventoryItem==null || inventoryItem.getStatus().equals(status.PAUSED)){
|
717 |
if(inventoryItem==null){
|
| 718 |
continue;
|
718 |
continue;
|
| 719 |
}
|
719 |
}
|
| 720 |
available = inventoryItem.getAvailability();
|
720 |
available = inventoryItem.getAvailability();
|
| 721 |
reserve = inventoryItem.getReserve();
|
721 |
reserve = inventoryItem.getReserve();
|
| 722 |
defaultinventory = inventoryItem.getDefaultInventory();
|
722 |
defaultinventory = inventoryItem.getDefaultInventory();
|
| 723 |
holdinventory = inventoryItem.getHoldInventory();
|
723 |
holdinventory = inventoryItem.getHoldInventory();
|
| 724 |
totalheld = inventoryItem.getTotalHeldInventory();
|
724 |
totalheld = inventoryItem.getTotalHeldInventory();
|
| 725 |
heldforsource = inventoryItem.getHeldForSource();
|
725 |
heldforsource = inventoryItem.getHeldForSource();
|
| 726 |
|
- |
|
| 727 |
if(itemIdpendingOrdersMap.containsKey(sku)){
|
726 |
if(itemIdpendingOrdersMap.containsKey(sku)){
|
| 728 |
heldorders = itemIdpendingOrdersMap.get(sku);
|
727 |
heldorders = itemIdpendingOrdersMap.get(sku);
|
| 729 |
if(heldorders < 0){
|
728 |
if(heldorders < 0){
|
| 730 |
heldorders = 0;
|
729 |
heldorders = 0;
|
| 731 |
}
|
730 |
}
|
| Line 733... |
Line 732... |
| 733 |
System.out.println("itemId: " + inventoryItem.getId() + "\trisky: " + inventoryItem.getRisky()+
|
732 |
System.out.println("itemId: " + inventoryItem.getId() + "\trisky: " + inventoryItem.getRisky()+
|
| 734 |
"\tavailable: " + available + "\treserve: " + reserve + "\theldForSource:" + heldforsource +
|
733 |
"\tavailable: " + available + "\treserve: " + reserve + "\theldForSource:" + heldforsource +
|
| 735 |
"\twebsite_hold: " + holdinventory + "\ttotal_held: " +totalheld +"\tdefault_inv: "
|
734 |
"\twebsite_hold: " + holdinventory + "\ttotal_held: " +totalheld +"\tdefault_inv: "
|
| 736 |
+ defaultinventory + "\theldorders " + heldorders);
|
735 |
+ defaultinventory + "\theldorders " + heldorders);
|
| 737 |
row = sheet.getRow((short) iterator);
|
736 |
row = sheet.getRow((short) iterator);
|
| 738 |
|
- |
|
| 739 |
if(inventoryItem.getRisky()){
|
- |
|
| 740 |
allocable = available - reserve - totalheld - holdinventory;
|
- |
|
| 741 |
if(allocable < 0){
|
- |
|
| 742 |
allocable = 0;
|
- |
|
| 743 |
}
|
- |
|
| 744 |
sent_inventory = Math.round(allocable*2/3) + heldforsource - heldorders ;
|
- |
|
| 745 |
//System.out.println("allocable" + allocable + "\t2/3allocable" + Math.round(allocable*2/3) + "\theld for source" + heldforsource + "\ttotal held" + totalheld +"\theldorders" + heldorders + "\tFinal Value is : " + (Math.round(allocable*2/3) + heldforsource - heldorders));
|
737 |
if(!inventoryItem.getStatus().equals(status.PAUSED)){
|
| 746 |
if(sent_inventory < 0){
|
738 |
if(inventoryItem.getRisky()){
|
| 747 |
sent_inventory = 0;
|
- |
|
| 748 |
}
|
- |
|
| 749 |
}
|
- |
|
| 750 |
else{
|
- |
|
| 751 |
allocable = available - reserve - totalheld;
|
739 |
allocable = available - reserve - totalheld - holdinventory;
|
| 752 |
if(allocable < 0){
|
740 |
if(allocable < 0){
|
| 753 |
allocable = 0;
|
741 |
allocable = 0;
|
| 754 |
}
|
742 |
}
|
| 755 |
if((allocable + heldforsource ) > defaultinventory){
|
- |
|
| 756 |
sent_inventory = Math.round(allocable*2/3) + heldforsource - heldorders;
|
743 |
sent_inventory = Math.round(allocable*2/3) + heldforsource - heldorders ;
|
| 757 |
//System.out.println("actual" + allocable + "\t2/3actual" + Math.round(allocable*2/3) + "\theld for source" + heldforsource + "\theldorders" + heldorders + "\tFinal Value is : " + (Math.round(allocable*2/3) + heldforsource - heldorders));
|
744 |
//System.out.println("allocable" + allocable + "\t2/3allocable" + Math.round(allocable*2/3) + "\theld for source" + heldforsource + "\ttotal held" + totalheld +"\theldorders" + heldorders + "\tFinal Value is : " + (Math.round(allocable*2/3) + heldforsource - heldorders));
|
| 758 |
if(sent_inventory < 0){
|
745 |
if(sent_inventory < 0){
|
| 759 |
sent_inventory = 0;
|
746 |
sent_inventory = 0;
|
| 760 |
}
|
747 |
}
|
| 761 |
}
|
748 |
}
|
| 762 |
else{
|
749 |
else{
|
| - |
|
750 |
allocable = available - reserve - totalheld;
|
| - |
|
751 |
if(allocable < 0){
|
| - |
|
752 |
allocable = 0;
|
| - |
|
753 |
}
|
| - |
|
754 |
if((allocable + heldforsource ) > defaultinventory){
|
| - |
|
755 |
sent_inventory = Math.round(allocable*2/3) + heldforsource - heldorders;
|
| - |
|
756 |
//System.out.println("actual" + allocable + "\t2/3actual" + Math.round(allocable*2/3) + "\theld for source" + heldforsource + "\theldorders" + heldorders + "\tFinal Value is : " + (Math.round(allocable*2/3) + heldforsource - heldorders));
|
| 763 |
if(defaultinventory > heldorders){
|
757 |
if(sent_inventory < 0){
|
| 764 |
sent_inventory = defaultinventory - heldorders;
|
758 |
sent_inventory = 0;
|
| - |
|
759 |
}
|
| 765 |
}
|
760 |
}
|
| 766 |
else{
|
761 |
else{
|
| - |
|
762 |
if(defaultinventory > heldorders){
|
| - |
|
763 |
sent_inventory = defaultinventory - heldorders;
|
| - |
|
764 |
}
|
| - |
|
765 |
else{
|
| 767 |
sent_inventory = 0;
|
766 |
sent_inventory = 0;
|
| - |
|
767 |
}
|
| 768 |
}
|
768 |
}
|
| 769 |
}
|
769 |
}
|
| 770 |
}
|
770 |
}
|
| 771 |
if(inventory.getAvailableInventory()!= sent_inventory){
|
771 |
if(inventory.getAvailableInventory()!= sent_inventory){
|
| 772 |
row.getCell((short) 0).setCellValue(inventory.getSupc());
|
772 |
row.getCell((short) 0).setCellValue(inventory.getSupc());
|