| Line 1... |
Line 1... |
| 1 |
package in.shop2020.support.controllers;
|
1 |
package in.shop2020.support.controllers;
|
| 2 |
|
2 |
|
| 3 |
import in.shop2020.model.v1.catalog.InventoryService.Client;
|
3 |
import in.shop2020.model.v1.catalog.InventoryService.Client;
|
| 4 |
import in.shop2020.model.v1.catalog.InventoryServiceException;
|
4 |
import in.shop2020.model.v1.catalog.InventoryServiceException;
|
| 5 |
import in.shop2020.model.v1.catalog.Item;
|
5 |
import in.shop2020.model.v1.catalog.Item;
|
| - |
|
6 |
import in.shop2020.model.v1.catalog.ItemInventory;
|
| 6 |
import in.shop2020.model.v1.catalog.ItemType;
|
7 |
import in.shop2020.model.v1.catalog.ItemType;
|
| 7 |
import in.shop2020.model.v1.catalog.VendorItemMapping;
|
8 |
import in.shop2020.model.v1.catalog.VendorItemMapping;
|
| 8 |
import in.shop2020.model.v1.catalog.Warehouse;
|
9 |
import in.shop2020.model.v1.catalog.Warehouse;
|
| 9 |
import in.shop2020.support.models.BillingUpdate;
|
10 |
import in.shop2020.support.models.BillingUpdate;
|
| 10 |
import in.shop2020.support.models.InventoryUpdate;
|
11 |
import in.shop2020.support.models.InventoryUpdate;
|
| Line 60... |
Line 61... |
| 60 |
return this.inventoryUpdate;
|
61 |
return this.inventoryUpdate;
|
| 61 |
}
|
62 |
}
|
| 62 |
|
63 |
|
| 63 |
public HttpHeaders show(){
|
64 |
public HttpHeaders show(){
|
| 64 |
logger.info("Status requested for warehouse id: " + getId());
|
65 |
logger.info("Status requested for warehouse id: " + getId());
|
| 65 |
CatalogClient catalogServiceClient;
|
- |
|
| 66 |
Client client;
|
66 |
Client client;
|
| 67 |
|
67 |
|
| 68 |
try {
|
68 |
try {
|
| 69 |
client = new CatalogClient().getClient();
|
69 |
client = new CatalogClient().getClient();
|
| 70 |
long warehouseId = Long.parseLong(getId());
|
70 |
long warehouseId = Long.parseLong(getId());
|
| Line 111... |
Line 111... |
| 111 |
// return fetchItems();
|
111 |
// return fetchItems();
|
| 112 |
return new ArrayList<Item>();
|
112 |
return new ArrayList<Item>();
|
| 113 |
}
|
113 |
}
|
| 114 |
}
|
114 |
}
|
| 115 |
|
115 |
|
| - |
|
116 |
/**
|
| - |
|
117 |
* @return
|
| - |
|
118 |
*/
|
| - |
|
119 |
private ItemInventory fetchInventory(long itemId) {
|
| - |
|
120 |
try {
|
| - |
|
121 |
Client snapshotClient = new CatalogClient().getClient();
|
| - |
|
122 |
return snapshotClient.getItemInventoryByItemId(itemId);
|
| - |
|
123 |
} catch (Exception e) {
|
| - |
|
124 |
logger.error("Could not fetch all items. Retrying.", e);
|
| - |
|
125 |
return fetchInventory(itemId);
|
| - |
|
126 |
}
|
| - |
|
127 |
}
|
| - |
|
128 |
|
| 116 |
/**
|
129 |
/**
|
| 117 |
*
|
130 |
*
|
| 118 |
*/
|
131 |
*/
|
| 119 |
private void loadHotspotMappings() {
|
132 |
private void loadHotspotMappings() {
|
| 120 |
try {
|
133 |
try {
|
| Line 221... |
Line 234... |
| 221 |
}
|
234 |
}
|
| 222 |
|
235 |
|
| 223 |
if (hotspotMappings.containsKey(item.getId())) {
|
236 |
if (hotspotMappings.containsKey(item.getId())) {
|
| 224 |
PLBDetails plbDetails = currentInventory
|
237 |
PLBDetails plbDetails = currentInventory
|
| 225 |
.get(hotspotMappings.get(item.getId()));
|
238 |
.get(hotspotMappings.get(item.getId()));
|
| 226 |
Long currentSnapshotAvailibility = item.getItemInventory()
|
239 |
Long currentSnapshotAvailibility = fetchInventory(item.getId()).getAvailability().get(warehouseId);
|
| 227 |
.getAvailability().get(warehouseId);
|
- |
|
| 228 |
if ((currentSnapshotAvailibility == null || currentSnapshotAvailibility.equals(0)) &&
|
240 |
if ((currentSnapshotAvailibility == null || currentSnapshotAvailibility.equals(0)) &&
|
| 229 |
(plbDetails == null || plbDetails.getQuantity().longValue() == 0))
|
241 |
(plbDetails == null || plbDetails.getQuantity().longValue() == 0))
|
| 230 |
{
|
242 |
{
|
| 231 |
continue;
|
243 |
continue;
|
| 232 |
}
|
244 |
}
|
| Line 240... |
Line 252... |
| 240 |
}
|
252 |
}
|
| 241 |
|
253 |
|
| 242 |
String subject = mismatches.size() + " mismatches with PLB sync for warehouse id: " + warehouseId;
|
254 |
String subject = mismatches.size() + " mismatches with PLB sync for warehouse id: " + warehouseId;
|
| 243 |
StringBuilder body = new StringBuilder("Item Id\tBrand\tModel Name\tModel Number\tColor\tSpice Online Retail\tHotspot\n");
|
255 |
StringBuilder body = new StringBuilder("Item Id\tBrand\tModel Name\tModel Number\tColor\tSpice Online Retail\tHotspot\n");
|
| 244 |
for (Item item : mismatches.keySet()) {
|
256 |
for (Item item : mismatches.keySet()) {
|
| 245 |
Long currentSnapshotAvailability = item.getItemInventory().getAvailability().get(warehouseId);
|
257 |
Long currentSnapshotAvailability = fetchInventory(item.getId()).getAvailability().get(warehouseId);
|
| 246 |
String plbQuantity = mismatches.get(item) == null ? "0" : mismatches.get(item).getQuantity().toString();
|
258 |
String plbQuantity = mismatches.get(item) == null ? "0" : mismatches.get(item).getQuantity().toString();
|
| 247 |
String currentSnapshotQuantity = currentSnapshotAvailability == null ? "0" : currentSnapshotAvailability.toString();
|
259 |
String currentSnapshotQuantity = currentSnapshotAvailability == null ? "0" : currentSnapshotAvailability.toString();
|
| 248 |
body.append(item.getId() + "\t" + item.getBrand() + "\t" + item.getModelName() + "\t" + item.getModelNumber() + "\t" + item.getColor() + "\t" + currentSnapshotQuantity + "\t" + plbQuantity + "\n");
|
260 |
body.append(item.getId() + "\t" + item.getBrand() + "\t" + item.getModelName() + "\t" + item.getModelNumber() + "\t" + item.getColor() + "\t" + currentSnapshotQuantity + "\t" + plbQuantity + "\n");
|
| 249 |
}
|
261 |
}
|
| 250 |
|
262 |
|