| Line 1... |
Line 1... |
| 1 |
package in.shop2020.warehouse.util;
|
1 |
package in.shop2020.warehouse.util;
|
| 2 |
|
2 |
|
| - |
|
3 |
import in.shop2020.model.v1.catalog.CatalogService;
|
| - |
|
4 |
import in.shop2020.model.v1.catalog.Item;
|
| 3 |
import in.shop2020.model.v1.inventory.BillingType;
|
5 |
import in.shop2020.model.v1.inventory.BillingType;
|
| 4 |
import in.shop2020.model.v1.inventory.InventoryService;
|
6 |
import in.shop2020.model.v1.inventory.InventoryService;
|
| 5 |
import in.shop2020.model.v1.inventory.InventoryServiceException;
|
7 |
import in.shop2020.model.v1.inventory.InventoryServiceException;
|
| 6 |
import in.shop2020.model.v1.inventory.InventoryType;
|
8 |
import in.shop2020.model.v1.inventory.InventoryType;
|
| 7 |
import in.shop2020.model.v1.inventory.ItemInventory;
|
9 |
import in.shop2020.model.v1.inventory.ItemInventory;
|
| 8 |
import in.shop2020.model.v1.inventory.Warehouse;
|
10 |
import in.shop2020.model.v1.inventory.Warehouse;
|
| 9 |
import in.shop2020.model.v1.inventory.WarehouseType;
|
11 |
import in.shop2020.model.v1.inventory.WarehouseType;
|
| - |
|
12 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 10 |
import in.shop2020.thrift.clients.InventoryClient;
|
13 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 11 |
import in.shop2020.utils.GmailUtils;
|
14 |
import in.shop2020.utils.GmailUtils;
|
| 12 |
import in.shop2020.warehouse.InventoryAvailability;
|
15 |
import in.shop2020.warehouse.InventoryAvailability;
|
| 13 |
import in.shop2020.warehouse.handler.ScanHandler;
|
16 |
import in.shop2020.warehouse.handler.ScanHandler;
|
| 14 |
|
17 |
|
| Line 56... |
Line 59... |
| 56 |
|
59 |
|
| 57 |
List<InventoryMismatchUnit> inventoryMismatches = new ArrayList<InventoryMismatchUnit>();
|
60 |
List<InventoryMismatchUnit> inventoryMismatches = new ArrayList<InventoryMismatchUnit>();
|
| 58 |
|
61 |
|
| 59 |
InventoryClient inventoryClient = new InventoryClient();
|
62 |
InventoryClient inventoryClient = new InventoryClient();
|
| 60 |
|
63 |
|
| - |
|
64 |
CatalogClient catalogClient = new CatalogClient();
|
| - |
|
65 |
|
| - |
|
66 |
CatalogService.Client catalogServiceClient = catalogClient.getClient();
|
| - |
|
67 |
|
| 61 |
InventoryService.Client invClient = inventoryClient.getClient();
|
68 |
InventoryService.Client invClient = inventoryClient.getClient();
|
| 62 |
|
69 |
|
| - |
|
70 |
List<Item> allAliveItems = catalogServiceClient.getAllAliveItems();
|
| - |
|
71 |
|
| - |
|
72 |
Map<Long, Item> allAliveItemsMap = new HashMap<Long, Item>();
|
| - |
|
73 |
|
| 63 |
Map<Long, ItemInventory> itemInventoryMap = invClient.getInventorySnapshot(0);
|
74 |
Map<Long, ItemInventory> itemInventoryMap = invClient.getInventorySnapshot(0);
|
| 64 |
List<Warehouse> allWarehouses = invClient.getAllWarehouses(false);
|
75 |
List<Warehouse> allWarehouses = invClient.getAllWarehouses(false);
|
| 65 |
|
76 |
|
| 66 |
List<Long> PHYSICAL_WAREHOUSE_IDS = Arrays.asList(7L,13L,1765L,3298L,3931L);
|
77 |
List<Long> PHYSICAL_WAREHOUSE_IDS = Arrays.asList(7L,13L,1765L,3298L,3931L);
|
| 67 |
Map<Long, Warehouse> allWarehousesMap = new HashMap<Long, Warehouse>();
|
78 |
Map<Long, Warehouse> allWarehousesMap = new HashMap<Long, Warehouse>();
|
| Line 70... |
Line 81... |
| 70 |
|
81 |
|
| 71 |
for(Warehouse wh : allWarehouses){
|
82 |
for(Warehouse wh : allWarehouses){
|
| 72 |
allWarehousesMap.put(wh.getId(), wh);
|
83 |
allWarehousesMap.put(wh.getId(), wh);
|
| 73 |
}
|
84 |
}
|
| 74 |
|
85 |
|
| - |
|
86 |
for(Item item: allAliveItems){
|
| - |
|
87 |
allAliveItemsMap.put(item.getId(), item);
|
| - |
|
88 |
}
|
| - |
|
89 |
|
| 75 |
for(Long physicalWarehouseId : PHYSICAL_WAREHOUSE_IDS){
|
90 |
for(Long physicalWarehouseId : PHYSICAL_WAREHOUSE_IDS){
|
| 76 |
totalInventoryList = new ArrayList<InventoryAvailability>();
|
91 |
totalInventoryList = new ArrayList<InventoryAvailability>();
|
| 77 |
|
92 |
|
| 78 |
List<InventoryAvailability> serializedInventoryList = scanHandler.getCurrentSerializedInventoryByScans(physicalWarehouseId);
|
93 |
List<InventoryAvailability> serializedInventoryList = scanHandler.getCurrentSerializedInventoryByScans(physicalWarehouseId);
|
| 79 |
List<InventoryAvailability> nonSerializedInventoryList = scanHandler.getCurrentNonSerializedInventoryByScans(physicalWarehouseId);
|
94 |
List<InventoryAvailability> nonSerializedInventoryList = scanHandler.getCurrentNonSerializedInventoryByScans(physicalWarehouseId);
|
| Line 82... |
Line 97... |
| 82 |
totalInventoryList.addAll(nonSerializedInventoryList);
|
97 |
totalInventoryList.addAll(nonSerializedInventoryList);
|
| 83 |
|
98 |
|
| 84 |
Map<Long, InventoryAvailability> totalInventoryMap = new HashMap<Long, InventoryAvailability>();
|
99 |
Map<Long, InventoryAvailability> totalInventoryMap = new HashMap<Long, InventoryAvailability>();
|
| 85 |
|
100 |
|
| 86 |
for(InventoryAvailability availability : totalInventoryList){
|
101 |
for(InventoryAvailability availability : totalInventoryList){
|
| 87 |
ItemInventory itemInvObj = itemInventoryMap.get(availability.getItemId());
|
102 |
totalInventoryMap.put(availability.getItemId(), availability);
|
| - |
|
103 |
}
|
| - |
|
104 |
|
| - |
|
105 |
for(InventoryAvailability availability : totalInventoryList){
|
| 88 |
long totalInventoryAsCatalog = 0;
|
106 |
long totalInventoryAsCatalog = 0;
|
| 89 |
if(itemInvObj!=null){
|
107 |
if(itemInventoryMap.containsKey(availability.getItemId())){
|
| - |
|
108 |
ItemInventory itemInvObj = itemInventoryMap.get(availability.getItemId());
|
| 90 |
Map<Long, Long> itemAvailibility = itemInvObj.getAvailability();
|
109 |
Map<Long, Long> itemAvailibility = itemInvObj.getAvailability();
|
| 91 |
|
- |
|
| 92 |
for(Long whId : itemAvailibility.keySet()){
|
110 |
for(Long whId : itemAvailibility.keySet()){
|
| 93 |
Warehouse warehouse = allWarehousesMap.get(whId);
|
111 |
Warehouse warehouse = allWarehousesMap.get(whId);
|
| 94 |
if(warehouse.getBillingType() == BillingType.OURS && warehouse.getBillingWarehouseId()==physicalWarehouseId &&
|
112 |
if(warehouse.getBillingType() == BillingType.OURS && warehouse.getBillingWarehouseId()==physicalWarehouseId &&
|
| 95 |
warehouse.getInventoryType()==InventoryType.GOOD && warehouse.getWarehouseType() == WarehouseType.OURS){
|
113 |
warehouse.getInventoryType()==InventoryType.GOOD && warehouse.getWarehouseType() == WarehouseType.OURS){
|
| 96 |
totalInventoryAsCatalog = totalInventoryAsCatalog + itemAvailibility.get(whId);
|
114 |
totalInventoryAsCatalog = totalInventoryAsCatalog + itemAvailibility.get(whId);
|
| Line 116... |
Line 134... |
| 116 |
invMismatchUnit.setQuantityAsPerCatalog(totalInventoryAsCatalog);
|
134 |
invMismatchUnit.setQuantityAsPerCatalog(totalInventoryAsCatalog);
|
| 117 |
inventoryMismatches.add(invMismatchUnit);
|
135 |
inventoryMismatches.add(invMismatchUnit);
|
| 118 |
}
|
136 |
}
|
| 119 |
}
|
137 |
}
|
| 120 |
|
138 |
|
| - |
|
139 |
for(Long itemId : itemInventoryMap.keySet()){
|
| - |
|
140 |
Item it = null;
|
| - |
|
141 |
if(!totalInventoryMap.containsKey(itemId)){
|
| - |
|
142 |
if(allAliveItemsMap.containsKey(itemId)){
|
| - |
|
143 |
it = allAliveItemsMap.get(itemId);
|
| - |
|
144 |
}else{
|
| - |
|
145 |
continue;
|
| - |
|
146 |
}
|
| - |
|
147 |
}else{
|
| - |
|
148 |
continue;
|
| - |
|
149 |
}
|
| - |
|
150 |
long totalInventoryAsCatalog = 0;
|
| - |
|
151 |
ItemInventory itemInvObj = itemInventoryMap.get(itemId);
|
| - |
|
152 |
Map<Long, Long> itemAvailibility = itemInvObj.getAvailability();
|
| - |
|
153 |
for(Long whId : itemAvailibility.keySet()){
|
| - |
|
154 |
Warehouse warehouse = allWarehousesMap.get(whId);
|
| - |
|
155 |
if(warehouse.getBillingType() == BillingType.OURS && warehouse.getBillingWarehouseId()==physicalWarehouseId &&
|
| - |
|
156 |
warehouse.getInventoryType()==InventoryType.GOOD && warehouse.getWarehouseType() == WarehouseType.OURS){
|
| - |
|
157 |
totalInventoryAsCatalog = totalInventoryAsCatalog + itemAvailibility.get(whId);
|
| - |
|
158 |
}
|
| - |
|
159 |
}
|
| - |
|
160 |
InventoryMismatchUnit invMismatchUnit = new InventoryMismatchUnit();
|
| - |
|
161 |
invMismatchUnit.setItemId(it.getId());
|
| - |
|
162 |
invMismatchUnit.setBrand(it.getBrand());
|
| - |
|
163 |
invMismatchUnit.setModelName(it.getModelName());
|
| - |
|
164 |
invMismatchUnit.setModelNumber(it.getModelNumber());
|
| - |
|
165 |
invMismatchUnit.setColor(it.getColor());
|
| - |
|
166 |
invMismatchUnit.setQuantityAsPerScans(0);
|
| - |
|
167 |
invMismatchUnit.setQuantityAsPerCatalog(totalInventoryAsCatalog);
|
| - |
|
168 |
inventoryMismatches.add(invMismatchUnit);
|
| - |
|
169 |
}
|
| - |
|
170 |
|
| 121 |
}
|
171 |
}
|
| 122 |
|
172 |
|
| 123 |
/*
|
173 |
/*
|
| 124 |
|
174 |
|
| 125 |
|
175 |
|