| 6322 |
amar.kumar |
1 |
package in.shop2020.inventory.controllers;
|
|
|
2 |
|
| 6388 |
amar.kumar |
3 |
import java.text.DateFormat;
|
| 6322 |
amar.kumar |
4 |
import java.text.ParseException;
|
|
|
5 |
import java.text.SimpleDateFormat;
|
|
|
6 |
import java.util.Calendar;
|
|
|
7 |
import java.util.Date;
|
|
|
8 |
import java.util.List;
|
|
|
9 |
|
|
|
10 |
import org.apache.thrift.TException;
|
|
|
11 |
import org.apache.thrift.transport.TTransportException;
|
|
|
12 |
|
|
|
13 |
import in.shop2020.thrift.clients.WarehouseClient;
|
|
|
14 |
import in.shop2020.warehouse.InventoryItem;
|
|
|
15 |
import in.shop2020.warehouse.Scan;
|
|
|
16 |
import in.shop2020.warehouse.ScanType;
|
|
|
17 |
import in.shop2020.warehouse.WarehouseService;
|
|
|
18 |
import in.shop2020.warehouse.WarehouseService.Client;
|
|
|
19 |
|
|
|
20 |
public class ScanRecordController extends BaseController{
|
|
|
21 |
|
|
|
22 |
private String filterTypeSelector;
|
|
|
23 |
private String toDate;
|
|
|
24 |
private String fromDate;
|
|
|
25 |
private String searchNumber;
|
| 7711 |
amar.kumar |
26 |
private SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
| 6388 |
amar.kumar |
27 |
|
|
|
28 |
private List<Scan> scans;
|
| 6322 |
amar.kumar |
29 |
public String index() {
|
|
|
30 |
if(filterTypeSelector!=null ||filterTypeSelector!=null ||fromDate!=null){
|
|
|
31 |
try {
|
|
|
32 |
return search();
|
|
|
33 |
} catch(Exception e) {
|
|
|
34 |
addActionError("Error while fetching Scan Records");
|
|
|
35 |
return INDEX;
|
|
|
36 |
}
|
|
|
37 |
}else {
|
|
|
38 |
return INDEX;
|
|
|
39 |
}
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
public String search() throws ParseException, TException {
|
|
|
43 |
try {
|
|
|
44 |
|
|
|
45 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
46 |
if(filterTypeSelector.equals("itemId")) {
|
|
|
47 |
Date fromDate = formatter.parse(this.fromDate);
|
|
|
48 |
Date toDate = formatter.parse(this.toDate);
|
|
|
49 |
Long itemId = Long.parseLong(searchNumber);
|
|
|
50 |
scans = warehouseClient.getInventoryScansForItem(itemId,
|
|
|
51 |
fromDate.getTime(), toDate.getTime());
|
|
|
52 |
} else if(filterTypeSelector.equals("serialNumber")) {
|
| 7410 |
amar.kumar |
53 |
scans = warehouseClient.getScanRecordsForSerialNumber(searchNumber);
|
| 6322 |
amar.kumar |
54 |
}
|
|
|
55 |
else
|
|
|
56 |
return INDEX;
|
|
|
57 |
} catch (TTransportException e) {
|
| 7790 |
amar.kumar |
58 |
log.error("Error in getting Scan Records",e);
|
| 6322 |
amar.kumar |
59 |
}
|
|
|
60 |
return INDEX;
|
|
|
61 |
}
|
|
|
62 |
|
| 7711 |
amar.kumar |
63 |
public String getDateTime(long milliseconds) {
|
|
|
64 |
Calendar cal = Calendar.getInstance();
|
|
|
65 |
cal.setTimeInMillis(milliseconds);
|
|
|
66 |
return formatter.format(cal.getTime());
|
|
|
67 |
}
|
|
|
68 |
|
| 6322 |
amar.kumar |
69 |
public String getFilterTypeSelector() {
|
|
|
70 |
return filterTypeSelector;
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
public void setFilterTypeSelector(String filterTypeSelector) {
|
|
|
74 |
this.filterTypeSelector = filterTypeSelector;
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
public String getToDate() {
|
|
|
78 |
return toDate;
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
public void setToDate(String toDate) {
|
|
|
82 |
this.toDate = toDate;
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
public String getFromDate() {
|
|
|
86 |
return fromDate;
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
public void setFromDate(String fromDate) {
|
|
|
90 |
this.fromDate = fromDate;
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
public String getSearchNumber() {
|
|
|
94 |
return searchNumber;
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
public void setSearchNumber(String searchNumber) {
|
|
|
98 |
this.searchNumber = searchNumber;
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
public List<Scan> getScans() {
|
|
|
102 |
return scans;
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
public void setScans(List<Scan> scans) {
|
|
|
106 |
this.scans = scans;
|
|
|
107 |
}
|
|
|
108 |
}
|