| 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 |
|
| 9429 |
amar.kumar |
15 |
import java.util.ArrayList;
|
| 5185 |
mandeep.dh |
16 |
import java.util.List;
|
|
|
17 |
|
|
|
18 |
import org.apache.commons.logging.Log;
|
|
|
19 |
import org.apache.commons.logging.LogFactory;
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
* @author mandeep
|
|
|
23 |
*
|
|
|
24 |
*/
|
|
|
25 |
public class DoaInController extends BaseController {
|
|
|
26 |
private Log logger = LogFactory.getLog(DoaInController.class);
|
|
|
27 |
private List<InventoryItem> inventoryItems;
|
|
|
28 |
private String id;
|
|
|
29 |
|
|
|
30 |
public String index() {
|
|
|
31 |
try {
|
| 9429 |
amar.kumar |
32 |
List<InventoryItem> tobeRemovedInventoryItems = new ArrayList<InventoryItem>();
|
| 5185 |
mandeep.dh |
33 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
34 |
inventoryItems = warehouseClient.getInventoryItemsFromLastScanType(ScanType.DOA_IN);
|
| 9428 |
amar.kumar |
35 |
for(InventoryItem inventoryItem:inventoryItems) {
|
| 10150 |
amar.kumar |
36 |
if(inventoryItem.getId()<=47129 ||
|
| 9428 |
amar.kumar |
37 |
inventoryItem.getCurrentWarehouseId() == 1 ||
|
| 9429 |
amar.kumar |
38 |
inventoryItem.getCurrentWarehouseId() == 9) {//removing doa_in entries before 2013 and all hotspot entries
|
|
|
39 |
tobeRemovedInventoryItems.add(inventoryItem);
|
| 9428 |
amar.kumar |
40 |
}
|
|
|
41 |
}
|
| 9429 |
amar.kumar |
42 |
for(InventoryItem inventoryItem:tobeRemovedInventoryItems) {
|
|
|
43 |
inventoryItems.remove(inventoryItem);
|
|
|
44 |
}
|
| 5185 |
mandeep.dh |
45 |
} catch (Exception e) {
|
|
|
46 |
logger.error("Could not fetch inventory items", e);
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
return INDEX;
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
public String update() {
|
|
|
53 |
try {
|
|
|
54 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
55 |
InventoryItem inventoryItem = warehouseClient.getInventoryItemFromId(Long.valueOf(id));
|
| 5945 |
mandeep.dh |
56 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
|
|
57 |
Warehouse warehouse = inventoryClient.getWarehouse(inventoryItem.getCurrentWarehouseId());
|
| 8182 |
amar.kumar |
58 |
warehouseClient.scan(inventoryItem, ScanType.DOA_OUT, 1, warehouse.getBillingWarehouseId(), 0);
|
| 5185 |
mandeep.dh |
59 |
} catch (Exception e) {
|
|
|
60 |
logger.error("Could not fetch inventory items", e);
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
return index();
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
public String getWarehouseDisplayName(long warehouseId) {
|
|
|
67 |
try {
|
| 5945 |
mandeep.dh |
68 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
|
|
69 |
return inventoryClient.getWarehouse(warehouseId).getDisplayName();
|
| 5185 |
mandeep.dh |
70 |
} catch (Exception e) {
|
|
|
71 |
return "N/A";
|
|
|
72 |
}
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
public String getModelName(long itemId) {
|
|
|
76 |
try {
|
| 5945 |
mandeep.dh |
77 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = new CatalogClient()
|
| 5185 |
mandeep.dh |
78 |
.getClient();
|
|
|
79 |
return ModelUtils.extractProductNameFromItem(catalogClient
|
|
|
80 |
.getItem(itemId));
|
|
|
81 |
} catch (Exception e) {
|
|
|
82 |
return "N/A";
|
|
|
83 |
}
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
public Log getLogger() {
|
|
|
87 |
return logger;
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
public void setLogger(Log logger) {
|
|
|
91 |
this.logger = logger;
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
public List<InventoryItem> getInventoryItems() {
|
|
|
95 |
return inventoryItems;
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
public void setInventoryItems(List<InventoryItem> inventoryItems) {
|
|
|
99 |
this.inventoryItems = inventoryItems;
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
public String getId() {
|
|
|
103 |
return id;
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
public void setId(String id) {
|
|
|
107 |
this.id = id;
|
|
|
108 |
}
|
|
|
109 |
}
|