| 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.PurchaseClient;
|
9 |
import in.shop2020.thrift.clients.PurchaseClient;
|
| 9 |
import in.shop2020.thrift.clients.WarehouseClient;
|
10 |
import in.shop2020.thrift.clients.WarehouseClient;
|
| 10 |
import in.shop2020.utils.ModelUtils;
|
11 |
import in.shop2020.utils.ModelUtils;
|
| 11 |
import in.shop2020.warehouse.InventoryItem;
|
12 |
import in.shop2020.warehouse.InventoryItem;
|
| 12 |
import in.shop2020.warehouse.ScanType;
|
13 |
import in.shop2020.warehouse.ScanType;
|
| Line 14... |
Line 15... |
| 14 |
|
15 |
|
| 15 |
import java.util.List;
|
16 |
import java.util.List;
|
| 16 |
|
17 |
|
| 17 |
import org.apache.commons.logging.Log;
|
18 |
import org.apache.commons.logging.Log;
|
| 18 |
import org.apache.commons.logging.LogFactory;
|
19 |
import org.apache.commons.logging.LogFactory;
|
| 19 |
import org.apache.thrift.TException;
|
- |
|
| 20 |
import org.apache.thrift.transport.TTransportException;
|
- |
|
| 21 |
|
20 |
|
| 22 |
/**
|
21 |
/**
|
| 23 |
* @author mandeep
|
22 |
* @author mandeep
|
| 24 |
*
|
23 |
*
|
| 25 |
*/
|
24 |
*/
|
| Line 42... |
Line 41... |
| 42 |
|
41 |
|
| 43 |
public String update() {
|
42 |
public String update() {
|
| 44 |
try {
|
43 |
try {
|
| 45 |
Client warehouseClient = new WarehouseClient().getClient();
|
44 |
Client warehouseClient = new WarehouseClient().getClient();
|
| 46 |
InventoryItem inventoryItem = warehouseClient.getInventoryItemFromId(Long.valueOf(id));
|
45 |
InventoryItem inventoryItem = warehouseClient.getInventoryItemFromId(Long.valueOf(id));
|
| 47 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = new CatalogClient().getClient();
|
46 |
in.shop2020.model.v1.inventory.InventoryService.Client catalogClient = new InventoryClient().getClient();
|
| 48 |
Warehouse warehouse = catalogClient.getWarehouse(inventoryItem.getCurrentWarehouseId());
|
47 |
Warehouse warehouse = catalogClient.getWarehouse(inventoryItem.getCurrentWarehouseId());
|
| 49 |
warehouseClient.scan(inventoryItem, ScanType.DOA_REPLACED, inventoryItem.getInitialQuantity(), warehouse.getBillingWarehouseId());
|
48 |
warehouseClient.scan(inventoryItem, ScanType.DOA_REPLACED, inventoryItem.getInitialQuantity(), warehouse.getBillingWarehouseId());
|
| 50 |
in.shop2020.purchase.PurchaseService.Client purchaseClient = new PurchaseClient().getClient();
|
49 |
in.shop2020.purchase.PurchaseService.Client purchaseClient = new PurchaseClient().getClient();
|
| 51 |
purchaseClient.unFulfillPO(inventoryItem.getPurchaseId(), inventoryItem.getItemId(), 1);
|
50 |
purchaseClient.unFulfillPO(inventoryItem.getPurchaseId(), inventoryItem.getItemId(), 1);
|
| 52 |
} catch (Exception e) {
|
51 |
} catch (Exception e) {
|
| Line 65... |
Line 64... |
| 65 |
}
|
64 |
}
|
| 66 |
}
|
65 |
}
|
| 67 |
|
66 |
|
| 68 |
public String getWarehouseDisplayName(long warehouseId) {
|
67 |
public String getWarehouseDisplayName(long warehouseId) {
|
| 69 |
try {
|
68 |
try {
|
| 70 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = new CatalogClient().getClient();
|
69 |
in.shop2020.model.v1.inventory.InventoryService.Client catalogClient = new InventoryClient().getClient();
|
| 71 |
return catalogClient.getWarehouse(warehouseId).getDisplayName();
|
70 |
return catalogClient.getWarehouse(warehouseId).getDisplayName();
|
| 72 |
} catch (Exception e) {
|
71 |
} catch (Exception e) {
|
| 73 |
return "N/A";
|
72 |
return "N/A";
|
| 74 |
}
|
73 |
}
|
| 75 |
}
|
74 |
}
|
| 76 |
|
75 |
|
| 77 |
public String getModelName(long itemId) {
|
76 |
public String getModelName(long itemId) {
|
| 78 |
try {
|
77 |
try {
|
| 79 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = new CatalogClient()
|
78 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = new CatalogClient()
|
| 80 |
.getClient();
|
79 |
.getClient();
|
| 81 |
return ModelUtils.extractProductNameFromItem(catalogClient
|
80 |
return ModelUtils.extractProductNameFromItem(catalogClient
|
| 82 |
.getItem(itemId));
|
81 |
.getItem(itemId));
|
| 83 |
} catch (Exception e) {
|
82 |
} catch (Exception e) {
|
| 84 |
return "N/A";
|
83 |
return "N/A";
|