| Line 1... |
Line 1... |
| 1 |
/**
|
1 |
/**
|
| 2 |
*
|
2 |
*
|
| 3 |
*/
|
3 |
*/
|
| 4 |
package in.shop2020.inventory.controllers;
|
4 |
package in.shop2020.inventory.controllers;
|
| 5 |
|
5 |
|
| 6 |
import in.shop2020.model.v1.catalog.Warehouse;
|
6 |
import in.shop2020.model.v1.inventory.Warehouse;
|
| 7 |
import in.shop2020.thrift.clients.CatalogClient;
|
7 |
import in.shop2020.thrift.clients.CatalogClient;
|
| - |
|
8 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 8 |
import in.shop2020.thrift.clients.WarehouseClient;
|
9 |
import in.shop2020.thrift.clients.WarehouseClient;
|
| 9 |
import in.shop2020.utils.ModelUtils;
|
10 |
import in.shop2020.utils.ModelUtils;
|
| 10 |
import in.shop2020.warehouse.InventoryItem;
|
11 |
import in.shop2020.warehouse.InventoryItem;
|
| 11 |
import in.shop2020.warehouse.ScanType;
|
12 |
import in.shop2020.warehouse.ScanType;
|
| 12 |
import in.shop2020.warehouse.WarehouseService.Client;
|
13 |
import in.shop2020.warehouse.WarehouseService.Client;
|
| Line 38... |
Line 39... |
| 38 |
|
39 |
|
| 39 |
public String update() {
|
40 |
public String update() {
|
| 40 |
try {
|
41 |
try {
|
| 41 |
Client warehouseClient = new WarehouseClient().getClient();
|
42 |
Client warehouseClient = new WarehouseClient().getClient();
|
| 42 |
InventoryItem inventoryItem = warehouseClient.getInventoryItemFromId(Long.valueOf(id));
|
43 |
InventoryItem inventoryItem = warehouseClient.getInventoryItemFromId(Long.valueOf(id));
|
| 43 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = new CatalogClient().getClient();
|
44 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
| 44 |
Warehouse warehouse = catalogClient.getWarehouse(inventoryItem.getCurrentWarehouseId());
|
45 |
Warehouse warehouse = inventoryClient.getWarehouse(inventoryItem.getCurrentWarehouseId());
|
| 45 |
warehouseClient.scan(inventoryItem, ScanType.DOA_OUT, inventoryItem.getInitialQuantity(), warehouse.getBillingWarehouseId());
|
46 |
warehouseClient.scan(inventoryItem, ScanType.DOA_OUT, inventoryItem.getInitialQuantity(), warehouse.getBillingWarehouseId());
|
| 46 |
} catch (Exception e) {
|
47 |
} catch (Exception e) {
|
| 47 |
logger.error("Could not fetch inventory items", e);
|
48 |
logger.error("Could not fetch inventory items", e);
|
| 48 |
}
|
49 |
}
|
| 49 |
|
50 |
|
| 50 |
return index();
|
51 |
return index();
|
| 51 |
}
|
52 |
}
|
| 52 |
|
53 |
|
| 53 |
public String getWarehouseDisplayName(long warehouseId) {
|
54 |
public String getWarehouseDisplayName(long warehouseId) {
|
| 54 |
try {
|
55 |
try {
|
| 55 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = new CatalogClient().getClient();
|
56 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
| 56 |
return catalogClient.getWarehouse(warehouseId).getDisplayName();
|
57 |
return inventoryClient.getWarehouse(warehouseId).getDisplayName();
|
| 57 |
} catch (Exception e) {
|
58 |
} catch (Exception e) {
|
| 58 |
return "N/A";
|
59 |
return "N/A";
|
| 59 |
}
|
60 |
}
|
| 60 |
}
|
61 |
}
|
| 61 |
|
62 |
|
| 62 |
public String getModelName(long itemId) {
|
63 |
public String getModelName(long itemId) {
|
| 63 |
try {
|
64 |
try {
|
| 64 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = new CatalogClient()
|
65 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = new CatalogClient()
|
| 65 |
.getClient();
|
66 |
.getClient();
|
| 66 |
return ModelUtils.extractProductNameFromItem(catalogClient
|
67 |
return ModelUtils.extractProductNameFromItem(catalogClient
|
| 67 |
.getItem(itemId));
|
68 |
.getItem(itemId));
|
| 68 |
} catch (Exception e) {
|
69 |
} catch (Exception e) {
|
| 69 |
return "N/A";
|
70 |
return "N/A";
|