| 5185 |
mandeep.dh |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.inventory.controllers;
|
|
|
5 |
|
|
|
6 |
import in.shop2020.model.v1.catalog.Warehouse;
|
|
|
7 |
import in.shop2020.thrift.clients.CatalogClient;
|
|
|
8 |
import in.shop2020.thrift.clients.WarehouseClient;
|
|
|
9 |
import in.shop2020.utils.ModelUtils;
|
|
|
10 |
import in.shop2020.warehouse.InventoryItem;
|
|
|
11 |
import in.shop2020.warehouse.ScanType;
|
|
|
12 |
import in.shop2020.warehouse.WarehouseService.Client;
|
|
|
13 |
|
|
|
14 |
import java.util.List;
|
|
|
15 |
|
|
|
16 |
import org.apache.commons.logging.Log;
|
|
|
17 |
import org.apache.commons.logging.LogFactory;
|
|
|
18 |
|
|
|
19 |
/**
|
|
|
20 |
* @author mandeep
|
|
|
21 |
*
|
|
|
22 |
*/
|
|
|
23 |
public class DoaInController extends BaseController {
|
|
|
24 |
private Log logger = LogFactory.getLog(DoaInController.class);
|
|
|
25 |
private List<InventoryItem> inventoryItems;
|
|
|
26 |
private String id;
|
|
|
27 |
|
|
|
28 |
public String index() {
|
|
|
29 |
try {
|
|
|
30 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
31 |
inventoryItems = warehouseClient.getInventoryItemsFromLastScanType(ScanType.DOA_IN);
|
|
|
32 |
} catch (Exception e) {
|
|
|
33 |
logger.error("Could not fetch inventory items", e);
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
return INDEX;
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
public String update() {
|
|
|
40 |
try {
|
|
|
41 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
42 |
InventoryItem inventoryItem = warehouseClient.getInventoryItemFromId(Long.valueOf(id));
|
|
|
43 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = new CatalogClient().getClient();
|
|
|
44 |
Warehouse warehouse = catalogClient.getWarehouse(inventoryItem.getCurrentWarehouseId());
|
|
|
45 |
warehouseClient.scanSerializedItem(inventoryItem, ScanType.DOA_OUT, warehouse.getBillingWarehouseId());
|
|
|
46 |
} catch (Exception e) {
|
|
|
47 |
logger.error("Could not fetch inventory items", e);
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
return index();
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
public String getWarehouseDisplayName(long warehouseId) {
|
|
|
54 |
try {
|
|
|
55 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = new CatalogClient().getClient();
|
|
|
56 |
return catalogClient.getWarehouse(warehouseId).getDisplayName();
|
|
|
57 |
} catch (Exception e) {
|
|
|
58 |
return "N/A";
|
|
|
59 |
}
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
public String getModelName(long itemId) {
|
|
|
63 |
try {
|
|
|
64 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = new CatalogClient()
|
|
|
65 |
.getClient();
|
|
|
66 |
return ModelUtils.extractProductNameFromItem(catalogClient
|
|
|
67 |
.getItem(itemId));
|
|
|
68 |
} catch (Exception e) {
|
|
|
69 |
return "N/A";
|
|
|
70 |
}
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
public Log getLogger() {
|
|
|
74 |
return logger;
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
public void setLogger(Log logger) {
|
|
|
78 |
this.logger = logger;
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
public List<InventoryItem> getInventoryItems() {
|
|
|
82 |
return inventoryItems;
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
public void setInventoryItems(List<InventoryItem> inventoryItems) {
|
|
|
86 |
this.inventoryItems = inventoryItems;
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
public String getId() {
|
|
|
90 |
return id;
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
public void setId(String id) {
|
|
|
94 |
this.id = id;
|
|
|
95 |
}
|
|
|
96 |
}
|