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