| 7931 |
manish.sha |
1 |
package in.shop2020.serving.controllers;
|
|
|
2 |
|
| 9338 |
manish.sha |
3 |
import in.shop2020.model.v1.inventory.Warehouse;
|
|
|
4 |
import in.shop2020.model.v1.order.Order;
|
|
|
5 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 7931 |
manish.sha |
6 |
import in.shop2020.serving.model.ShipmentUpdate;
|
|
|
7 |
import in.shop2020.serving.services.FedExTrackingService;
|
| 9338 |
manish.sha |
8 |
import in.shop2020.thrift.clients.InventoryClient;
|
|
|
9 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 7931 |
manish.sha |
10 |
|
|
|
11 |
import java.util.List;
|
|
|
12 |
|
|
|
13 |
import org.apache.log4j.Logger;
|
| 9338 |
manish.sha |
14 |
import org.apache.thrift.TException;
|
|
|
15 |
import org.apache.thrift.transport.TTransportException;
|
| 7931 |
manish.sha |
16 |
|
|
|
17 |
public class FedExUpdatesController extends BaseController {
|
|
|
18 |
/**
|
|
|
19 |
*
|
|
|
20 |
*/
|
|
|
21 |
private static final long serialVersionUID = 2544586714453252214L;
|
|
|
22 |
private static Logger log = Logger.getLogger(Class.class);
|
|
|
23 |
private String id;
|
|
|
24 |
private List<ShipmentUpdate> updates;
|
|
|
25 |
|
|
|
26 |
public FedExUpdatesController(){
|
|
|
27 |
super();
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
public String show() {
|
|
|
31 |
log.info("FedEx Updates Controller " + id);
|
| 9338 |
manish.sha |
32 |
TransactionClient transactionServiceClient = null;
|
|
|
33 |
try {
|
|
|
34 |
transactionServiceClient = new TransactionClient();
|
|
|
35 |
} catch (TTransportException e) {
|
|
|
36 |
log.error("Exception : Getting Transaction Client",e);
|
|
|
37 |
}
|
|
|
38 |
Order order = null;
|
|
|
39 |
if(transactionServiceClient!=null){
|
|
|
40 |
try {
|
|
|
41 |
order = transactionServiceClient.getClient().getOrderForAirwayBillNo(id);
|
|
|
42 |
} catch (TransactionServiceException e) {
|
|
|
43 |
log.error("Exception : Getting Transaction Service Exception",e);
|
|
|
44 |
} catch (TException e) {
|
|
|
45 |
log.error("Exception : Getting Transaction Service TException",e);
|
|
|
46 |
}
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
Warehouse warehouse = null;
|
|
|
50 |
if(order!=null){
|
|
|
51 |
try{
|
|
|
52 |
InventoryClient isc = new InventoryClient();
|
|
|
53 |
warehouse = isc.getClient().getWarehouse(order.getWarehouse_id());
|
|
|
54 |
} catch(Exception e) {
|
|
|
55 |
log.error("Unable to get warehouse for id : " + order.getWarehouse_id(),e);
|
|
|
56 |
}
|
|
|
57 |
}
|
|
|
58 |
if(warehouse!=null){
|
|
|
59 |
FedExTrackingService trackingService = new FedExTrackingService(warehouse.getLogisticsLocation());
|
|
|
60 |
updates = trackingService.getUpdates(id);
|
|
|
61 |
}
|
| 7931 |
manish.sha |
62 |
return "show";
|
|
|
63 |
}
|
|
|
64 |
public String getId(){
|
|
|
65 |
return id;
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
public void setId(String id){
|
|
|
69 |
this.id = id;
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
public List<ShipmentUpdate> getUpdates(){
|
|
|
73 |
return updates;
|
|
|
74 |
}
|
|
|
75 |
}
|