| 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;
|
| 10886 |
manish.sha |
12 |
import in.shop2020.warehouse.Scan;
|
| 5185 |
mandeep.dh |
13 |
import in.shop2020.warehouse.ScanType;
|
|
|
14 |
import in.shop2020.warehouse.WarehouseService.Client;
|
|
|
15 |
|
| 10886 |
manish.sha |
16 |
import java.text.SimpleDateFormat;
|
| 9429 |
amar.kumar |
17 |
import java.util.ArrayList;
|
| 10886 |
manish.sha |
18 |
import java.util.Date;
|
| 5185 |
mandeep.dh |
19 |
import java.util.List;
|
|
|
20 |
|
|
|
21 |
import org.apache.commons.logging.Log;
|
|
|
22 |
import org.apache.commons.logging.LogFactory;
|
|
|
23 |
|
|
|
24 |
/**
|
|
|
25 |
* @author mandeep
|
|
|
26 |
*
|
|
|
27 |
*/
|
|
|
28 |
public class DoaInController extends BaseController {
|
|
|
29 |
private Log logger = LogFactory.getLog(DoaInController.class);
|
|
|
30 |
private List<InventoryItem> inventoryItems;
|
|
|
31 |
private String id;
|
| 10886 |
manish.sha |
32 |
private String output;
|
| 5185 |
mandeep.dh |
33 |
|
|
|
34 |
public String index() {
|
|
|
35 |
try {
|
| 9429 |
amar.kumar |
36 |
List<InventoryItem> tobeRemovedInventoryItems = new ArrayList<InventoryItem>();
|
| 5185 |
mandeep.dh |
37 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
38 |
inventoryItems = warehouseClient.getInventoryItemsFromLastScanType(ScanType.DOA_IN);
|
| 9428 |
amar.kumar |
39 |
for(InventoryItem inventoryItem:inventoryItems) {
|
| 10177 |
amar.kumar |
40 |
if(inventoryItem.getId()<47129 ||
|
| 9428 |
amar.kumar |
41 |
inventoryItem.getCurrentWarehouseId() == 1 ||
|
| 9429 |
amar.kumar |
42 |
inventoryItem.getCurrentWarehouseId() == 9) {//removing doa_in entries before 2013 and all hotspot entries
|
|
|
43 |
tobeRemovedInventoryItems.add(inventoryItem);
|
| 9428 |
amar.kumar |
44 |
}
|
|
|
45 |
}
|
| 9429 |
amar.kumar |
46 |
for(InventoryItem inventoryItem:tobeRemovedInventoryItems) {
|
|
|
47 |
inventoryItems.remove(inventoryItem);
|
|
|
48 |
}
|
| 5185 |
mandeep.dh |
49 |
} catch (Exception e) {
|
|
|
50 |
logger.error("Could not fetch inventory items", e);
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
return INDEX;
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
public String update() {
|
|
|
57 |
try {
|
|
|
58 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
59 |
InventoryItem inventoryItem = warehouseClient.getInventoryItemFromId(Long.valueOf(id));
|
| 5945 |
mandeep.dh |
60 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
|
|
61 |
Warehouse warehouse = inventoryClient.getWarehouse(inventoryItem.getCurrentWarehouseId());
|
| 8182 |
amar.kumar |
62 |
warehouseClient.scan(inventoryItem, ScanType.DOA_OUT, 1, warehouse.getBillingWarehouseId(), 0);
|
| 5185 |
mandeep.dh |
63 |
} catch (Exception e) {
|
|
|
64 |
logger.error("Could not fetch inventory items", e);
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
return index();
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
public String getWarehouseDisplayName(long warehouseId) {
|
|
|
71 |
try {
|
| 5945 |
mandeep.dh |
72 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
|
|
73 |
return inventoryClient.getWarehouse(warehouseId).getDisplayName();
|
| 5185 |
mandeep.dh |
74 |
} catch (Exception e) {
|
|
|
75 |
return "N/A";
|
|
|
76 |
}
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
public String getModelName(long itemId) {
|
|
|
80 |
try {
|
| 5945 |
mandeep.dh |
81 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = new CatalogClient()
|
| 5185 |
mandeep.dh |
82 |
.getClient();
|
|
|
83 |
return ModelUtils.extractProductNameFromItem(catalogClient
|
|
|
84 |
.getItem(itemId));
|
|
|
85 |
} catch (Exception e) {
|
|
|
86 |
return "N/A";
|
|
|
87 |
}
|
|
|
88 |
}
|
| 10886 |
manish.sha |
89 |
|
|
|
90 |
public String getOrderIdDOAInItem(){
|
|
|
91 |
try{
|
|
|
92 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
93 |
List<Scan> scanList = warehouseClient.getScansForInventoryItem(Long.valueOf(id), ScanType.DOA_IN);
|
|
|
94 |
Scan lastScan = scanList.get(scanList.size()-1);
|
|
|
95 |
SimpleDateFormat df= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
96 |
String doaInOrderIdDiv = "<div id = 'doa-in-order-id-div' align='center'><table id = 'doa-in-order-id-table'><tr><th>OrderId</th><th>DOA-In Time</th></tr>";
|
|
|
97 |
doaInOrderIdDiv = doaInOrderIdDiv + "<tr><td>" + lastScan.getOrderId()+ "</td><td>" + df.format(new Date(lastScan.getScannedAt())) +"</td></tr></table></div>";
|
|
|
98 |
setOutput(doaInOrderIdDiv);
|
|
|
99 |
} catch(Exception e){
|
|
|
100 |
logger.error("Error while getting order Id for DOA In item", e);
|
|
|
101 |
}
|
|
|
102 |
return OUTPUT;
|
|
|
103 |
}
|
| 5185 |
mandeep.dh |
104 |
|
|
|
105 |
public Log getLogger() {
|
|
|
106 |
return logger;
|
|
|
107 |
}
|
|
|
108 |
|
|
|
109 |
public void setLogger(Log logger) {
|
|
|
110 |
this.logger = logger;
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
public List<InventoryItem> getInventoryItems() {
|
|
|
114 |
return inventoryItems;
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
public void setInventoryItems(List<InventoryItem> inventoryItems) {
|
|
|
118 |
this.inventoryItems = inventoryItems;
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
public String getId() {
|
|
|
122 |
return id;
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
public void setId(String id) {
|
|
|
126 |
this.id = id;
|
|
|
127 |
}
|
| 10886 |
manish.sha |
128 |
|
|
|
129 |
public String getOutput() {
|
|
|
130 |
return output;
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
public void setOutput(String output) {
|
|
|
134 |
this.output = output;
|
|
|
135 |
}
|
| 5185 |
mandeep.dh |
136 |
}
|