| 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);
|
| 9428 |
amar.kumar |
33 |
for(InventoryItem inventoryItem:inventoryItems) {
|
|
|
34 |
if(inventoryItem.getId()<59078 ||
|
|
|
35 |
inventoryItem.getCurrentWarehouseId() == 1 ||
|
|
|
36 |
inventoryItem.getCurrentWarehouseId() == 9) {//removing doa_in entries before 2013 and all hotspot entries
|
|
|
37 |
inventoryItems.remove(inventoryItem);
|
|
|
38 |
}
|
|
|
39 |
}
|
| 5185 |
mandeep.dh |
40 |
} catch (Exception e) {
|
|
|
41 |
logger.error("Could not fetch inventory items", e);
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
return INDEX;
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
public String update() {
|
|
|
48 |
try {
|
|
|
49 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
50 |
InventoryItem inventoryItem = warehouseClient.getInventoryItemFromId(Long.valueOf(id));
|
| 5945 |
mandeep.dh |
51 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
|
|
52 |
Warehouse warehouse = inventoryClient.getWarehouse(inventoryItem.getCurrentWarehouseId());
|
| 8182 |
amar.kumar |
53 |
warehouseClient.scan(inventoryItem, ScanType.DOA_OUT, 1, warehouse.getBillingWarehouseId(), 0);
|
| 5185 |
mandeep.dh |
54 |
} catch (Exception e) {
|
|
|
55 |
logger.error("Could not fetch inventory items", e);
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
return index();
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
public String getWarehouseDisplayName(long warehouseId) {
|
|
|
62 |
try {
|
| 5945 |
mandeep.dh |
63 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
|
|
64 |
return inventoryClient.getWarehouse(warehouseId).getDisplayName();
|
| 5185 |
mandeep.dh |
65 |
} catch (Exception e) {
|
|
|
66 |
return "N/A";
|
|
|
67 |
}
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
public String getModelName(long itemId) {
|
|
|
71 |
try {
|
| 5945 |
mandeep.dh |
72 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = new CatalogClient()
|
| 5185 |
mandeep.dh |
73 |
.getClient();
|
|
|
74 |
return ModelUtils.extractProductNameFromItem(catalogClient
|
|
|
75 |
.getItem(itemId));
|
|
|
76 |
} catch (Exception e) {
|
|
|
77 |
return "N/A";
|
|
|
78 |
}
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
public Log getLogger() {
|
|
|
82 |
return logger;
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
public void setLogger(Log logger) {
|
|
|
86 |
this.logger = logger;
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
public List<InventoryItem> getInventoryItems() {
|
|
|
90 |
return inventoryItems;
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
public void setInventoryItems(List<InventoryItem> inventoryItems) {
|
|
|
94 |
this.inventoryItems = inventoryItems;
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
public String getId() {
|
|
|
98 |
return id;
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
public void setId(String id) {
|
|
|
102 |
this.id = id;
|
|
|
103 |
}
|
|
|
104 |
}
|