| 7930 |
manish.sha |
1 |
package in.shop2020.serving.services;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.config.ConfigException;
|
| 9338 |
manish.sha |
4 |
import in.shop2020.model.v1.inventory.WarehouseLocation;
|
| 8368 |
manish.sha |
5 |
import in.shop2020.model.v1.order.Order;
|
| 7930 |
manish.sha |
6 |
import in.shop2020.serving.model.ShipmentUpdate;
|
|
|
7 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
|
|
8 |
|
|
|
9 |
import java.text.SimpleDateFormat;
|
|
|
10 |
import java.util.ArrayList;
|
| 8368 |
manish.sha |
11 |
import java.util.HashMap;
|
| 7930 |
manish.sha |
12 |
import java.util.List;
|
| 8368 |
manish.sha |
13 |
import java.util.Map;
|
| 8353 |
manish.sha |
14 |
|
|
|
15 |
import org.apache.commons.logging.Log;
|
|
|
16 |
import org.apache.commons.logging.LogFactory;
|
|
|
17 |
|
| 7930 |
manish.sha |
18 |
import com.TrackWebServiceClient;
|
|
|
19 |
import com.fedex.track.stub.ClientDetail;
|
|
|
20 |
import com.fedex.track.stub.TrackDetail;
|
|
|
21 |
import com.fedex.track.stub.TrackEvent;
|
|
|
22 |
import com.fedex.track.stub.TrackReply;
|
|
|
23 |
import com.fedex.track.stub.WebAuthenticationCredential;
|
|
|
24 |
import com.fedex.track.stub.WebAuthenticationDetail;
|
|
|
25 |
|
|
|
26 |
public class FedExTrackingService {
|
| 8353 |
manish.sha |
27 |
|
|
|
28 |
private static final Log log = LogFactory.getLog(FedExTrackingService.class);
|
| 8368 |
manish.sha |
29 |
private ClientDetail clientDetails;
|
|
|
30 |
private WebAuthenticationDetail waDetails;
|
|
|
31 |
private String endPointAddress;
|
| 7930 |
manish.sha |
32 |
/**
|
|
|
33 |
* @param args
|
|
|
34 |
*/
|
|
|
35 |
|
| 9338 |
manish.sha |
36 |
public FedExTrackingService(WarehouseLocation location){
|
|
|
37 |
clientDetails = getFedExClientDetails(location);
|
| 9784 |
manish.sha |
38 |
waDetails = getFedExWebAuthenticationDetails(location);
|
| 8368 |
manish.sha |
39 |
endPointAddress = getFedExEndpointAddress();
|
|
|
40 |
}
|
|
|
41 |
|
| 9338 |
manish.sha |
42 |
public ClientDetail getFedExClientDetails(WarehouseLocation whlocation){
|
| 8368 |
manish.sha |
43 |
ClientDetail clientDetail = new ClientDetail();
|
|
|
44 |
String accountNumber ="";
|
|
|
45 |
String meterNumber ="";
|
|
|
46 |
try {
|
| 9338 |
manish.sha |
47 |
if(WarehouseLocation.Mumbai==whlocation){
|
|
|
48 |
accountNumber = ConfigClient.getClient().get("fedex_account_number_mumbai");
|
| 9784 |
manish.sha |
49 |
meterNumber = ConfigClient.getClient().get("fedex_meter_number_mumbai");
|
| 9338 |
manish.sha |
50 |
}
|
|
|
51 |
else{
|
|
|
52 |
accountNumber = ConfigClient.getClient().get("fedex_account_number");
|
| 9784 |
manish.sha |
53 |
meterNumber = ConfigClient.getClient().get("fedex_meter_number");
|
| 9338 |
manish.sha |
54 |
}
|
| 8368 |
manish.sha |
55 |
} catch (ConfigException e) {
|
|
|
56 |
log.error("Could not fetch Client Detail", e);
|
| 8387 |
manish.sha |
57 |
}
|
|
|
58 |
log.info("fedex_account_number in Tracking Service"+accountNumber);
|
|
|
59 |
log.info("fedex_meter_number in Tracking Service"+meterNumber);
|
| 8368 |
manish.sha |
60 |
clientDetail.setAccountNumber(accountNumber);
|
|
|
61 |
clientDetail.setMeterNumber(meterNumber);
|
|
|
62 |
return clientDetail;
|
|
|
63 |
}
|
|
|
64 |
|
| 9784 |
manish.sha |
65 |
public WebAuthenticationDetail getFedExWebAuthenticationDetails(WarehouseLocation whlocation){
|
| 8368 |
manish.sha |
66 |
WebAuthenticationCredential wac = new WebAuthenticationCredential();
|
|
|
67 |
String key="";
|
|
|
68 |
String password="";
|
|
|
69 |
try {
|
| 9784 |
manish.sha |
70 |
if(WarehouseLocation.Mumbai==whlocation){
|
|
|
71 |
key = ConfigClient.getClient().get("fedex_authenication_key_mumbai");
|
|
|
72 |
password = ConfigClient.getClient().get("fedex_authenication_password_mumbai");
|
|
|
73 |
}
|
|
|
74 |
else{
|
|
|
75 |
key = ConfigClient.getClient().get("fedex_authenication_key");
|
|
|
76 |
password = ConfigClient.getClient().get("fedex_authenication_password");
|
|
|
77 |
}
|
| 8368 |
manish.sha |
78 |
} catch (ConfigException e) {
|
|
|
79 |
log.error("Could not fetch Web Authenication Detail", e);
|
|
|
80 |
}
|
| 8387 |
manish.sha |
81 |
log.info("fedex_authenication_key in Tracking Service"+key);
|
|
|
82 |
log.info("fedex_authenication_password in Tracking Service"+password);
|
| 8368 |
manish.sha |
83 |
wac.setKey(key);
|
|
|
84 |
wac.setPassword(password);
|
|
|
85 |
return new WebAuthenticationDetail(wac);
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
public String getFedExEndpointAddress(){
|
|
|
89 |
String endPoint="";
|
|
|
90 |
try {
|
|
|
91 |
endPoint = ConfigClient.getClient().get("fedex_endpoint_address_track");
|
|
|
92 |
} catch (ConfigException e) {
|
|
|
93 |
log.error("Could not fetch enpoint Address", e);
|
|
|
94 |
}
|
| 8387 |
manish.sha |
95 |
log.info("fedex_endpoint_address_track in Tracking Service"+endPoint);
|
| 8368 |
manish.sha |
96 |
return endPoint;
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
public Map<String,String> readFedExPickupOrdersMap(List<Order> ordersList){
|
| 8388 |
manish.sha |
100 |
log.info("Into Method to Read Fedex Pickup Orders.... "+ ordersList.size());
|
| 8368 |
manish.sha |
101 |
Map<String,String> fedexPickupOrdersMap= new HashMap<String,String>();
|
|
|
102 |
for(Order ord: ordersList){
|
|
|
103 |
String awbNumber= ord.getAirwaybill_no();
|
| 8832 |
manish.sha |
104 |
System.out.println("Order Id.... "+ord.getId()+".....Airwaybill No..... "+awbNumber);
|
| 8391 |
manish.sha |
105 |
TrackReply trackreply = TrackWebServiceClient.getTrackingUpdates(awbNumber, clientDetails, waDetails, endPointAddress);
|
| 8368 |
manish.sha |
106 |
if(trackreply!=null){
|
| 8385 |
manish.sha |
107 |
log.info("Successfully get Fedex Pickup Orders Reply");
|
| 8368 |
manish.sha |
108 |
TrackDetail[] trackDetails=trackreply.getTrackDetails();
|
| 8402 |
manish.sha |
109 |
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
|
| 8368 |
manish.sha |
110 |
SimpleDateFormat timeformat = new SimpleDateFormat("HH:mm:ss");
|
| 8568 |
manish.sha |
111 |
trackDetailsLoop:for (int i=0; i< trackDetails.length; i++) {
|
| 8368 |
manish.sha |
112 |
TrackEvent trackEvents[]= trackDetails[i].getEvents();
|
| 8832 |
manish.sha |
113 |
if(trackEvents!=null && trackEvents.length > 0){
|
|
|
114 |
for(TrackEvent te : trackEvents){
|
| 12964 |
manish.sha |
115 |
if("PU".equalsIgnoreCase(te.getEventType()) || "OC".equalsIgnoreCase(te.getEventType())){
|
| 8832 |
manish.sha |
116 |
fedexPickupOrdersMap.put(awbNumber, dateformat.format(te.getTimestamp().getTime())+" "+timeformat.format(te.getTimestamp().getTime()));
|
|
|
117 |
break trackDetailsLoop;
|
|
|
118 |
}
|
|
|
119 |
}
|
| 8377 |
manish.sha |
120 |
}
|
| 8368 |
manish.sha |
121 |
}
|
|
|
122 |
}
|
|
|
123 |
}
|
| 8385 |
manish.sha |
124 |
log.info("Read Fedex Pickup Orders");
|
| 8368 |
manish.sha |
125 |
return fedexPickupOrdersMap;
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
public Map<String,String> readFedExReachedDestinationOrdersMap(List<Order> ordersList){
|
| 8388 |
manish.sha |
129 |
log.info("Into Method to Read Fedex Reached Destination Orders.... "+ ordersList.size());
|
| 8368 |
manish.sha |
130 |
Map<String,String> fedexReachedDestinationOrdersMap= new HashMap<String,String>();
|
|
|
131 |
for(Order ord: ordersList){
|
|
|
132 |
String awbNumber= ord.getAirwaybill_no();
|
| 8832 |
manish.sha |
133 |
System.out.println("Order Id.... "+ord.getId()+".....Airwaybill No..... "+awbNumber);
|
| 8391 |
manish.sha |
134 |
TrackReply trackreply = TrackWebServiceClient.getTrackingUpdates(awbNumber, clientDetails, waDetails, endPointAddress);
|
| 8368 |
manish.sha |
135 |
if(trackreply!=null){
|
| 8385 |
manish.sha |
136 |
log.info("Successfully get Fedex Reached Destination Orders");
|
| 8368 |
manish.sha |
137 |
TrackDetail[] trackDetails=trackreply.getTrackDetails();
|
| 8402 |
manish.sha |
138 |
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
|
| 8368 |
manish.sha |
139 |
SimpleDateFormat timeformat = new SimpleDateFormat("HH:mm:ss");
|
| 8568 |
manish.sha |
140 |
trackDetailsLoop:for (int i=0; i< trackDetails.length; i++) {
|
| 8368 |
manish.sha |
141 |
TrackEvent trackEvents[]= trackDetails[i].getEvents();
|
| 8832 |
manish.sha |
142 |
if(trackEvents!=null && trackEvents.length > 0){
|
|
|
143 |
for(TrackEvent te : trackEvents){
|
| 20020 |
kshitij.so |
144 |
if("AF".equalsIgnoreCase(te.getEventType())){
|
| 8832 |
manish.sha |
145 |
fedexReachedDestinationOrdersMap.put(awbNumber, dateformat.format(te.getTimestamp().getTime())+" "+timeformat.format(te.getTimestamp().getTime()));
|
|
|
146 |
break trackDetailsLoop;
|
|
|
147 |
}
|
|
|
148 |
}
|
| 8377 |
manish.sha |
149 |
}
|
| 8368 |
manish.sha |
150 |
}
|
|
|
151 |
}
|
|
|
152 |
}
|
| 8385 |
manish.sha |
153 |
log.info("Read Fedex Reached Destination Orders");
|
| 8368 |
manish.sha |
154 |
return fedexReachedDestinationOrdersMap;
|
|
|
155 |
}
|
|
|
156 |
|
|
|
157 |
public Map<String,String> readFedExDeliveredOrdersMap(List<Order> ordersList){
|
| 8388 |
manish.sha |
158 |
log.info("Into Method to Read Fedex Delivered Orders.... "+ ordersList.size());
|
| 8368 |
manish.sha |
159 |
Map<String,String> fedexDeliveredOrdersMap= new HashMap<String,String>();
|
|
|
160 |
for(Order ord: ordersList){
|
|
|
161 |
String awbNumber= ord.getAirwaybill_no();
|
| 8832 |
manish.sha |
162 |
System.out.println("Order Id.... "+ord.getId()+".....Airwaybill No..... "+awbNumber);
|
| 8391 |
manish.sha |
163 |
TrackReply trackreply = TrackWebServiceClient.getTrackingUpdates(awbNumber, clientDetails, waDetails, endPointAddress);
|
| 8368 |
manish.sha |
164 |
if(trackreply!=null){
|
| 8385 |
manish.sha |
165 |
log.info("Successfully get Fedex Delivered Orders");
|
| 8368 |
manish.sha |
166 |
TrackDetail[] trackDetails=trackreply.getTrackDetails();
|
| 8380 |
manish.sha |
167 |
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
|
| 8368 |
manish.sha |
168 |
SimpleDateFormat timeformat = new SimpleDateFormat("HH:mm:ss");
|
| 8568 |
manish.sha |
169 |
trackDetailsLoop:for (int i=0; i< trackDetails.length; i++) {
|
| 8368 |
manish.sha |
170 |
TrackEvent trackEvents[]= trackDetails[i].getEvents();
|
| 8832 |
manish.sha |
171 |
if(trackEvents!=null && trackEvents.length > 0){
|
|
|
172 |
for(TrackEvent te : trackEvents){
|
|
|
173 |
if("DL".equalsIgnoreCase(te.getEventType())){
|
|
|
174 |
if(trackDetails[i].getDeliverySignatureName()!=null && !trackDetails[i].getDeliverySignatureName().isEmpty()){
|
|
|
175 |
fedexDeliveredOrdersMap.put(awbNumber, dateformat.format(te.getTimestamp().getTime())+" "+timeformat.format(te.getTimestamp().getTime())+"|"+trackDetails[i].getDeliverySignatureName());
|
|
|
176 |
}
|
|
|
177 |
else{
|
|
|
178 |
fedexDeliveredOrdersMap.put(awbNumber, dateformat.format(te.getTimestamp().getTime())+" "+timeformat.format(te.getTimestamp().getTime())+"|"+ord.getCustomer_name());
|
|
|
179 |
}
|
|
|
180 |
break trackDetailsLoop;
|
|
|
181 |
}
|
|
|
182 |
}
|
| 8377 |
manish.sha |
183 |
}
|
| 8368 |
manish.sha |
184 |
}
|
|
|
185 |
}
|
|
|
186 |
}
|
| 8385 |
manish.sha |
187 |
log.info("Read Fedex Delivered Orders");
|
| 8368 |
manish.sha |
188 |
return fedexDeliveredOrdersMap;
|
|
|
189 |
}
|
|
|
190 |
|
|
|
191 |
public Map<String,String> readFedExReturnedOrdersMap(List<Order> ordersList){
|
| 8388 |
manish.sha |
192 |
log.info("Into Method to Read Fedex Returned Orders.... "+ ordersList.size());
|
| 8368 |
manish.sha |
193 |
Map<String,String> fedexReturnedOrdersMap= new HashMap<String,String>();
|
|
|
194 |
for(Order ord: ordersList){
|
|
|
195 |
String awbNumber= ord.getAirwaybill_no();
|
| 8832 |
manish.sha |
196 |
System.out.println("Order Id.... "+ord.getId()+".....Airwaybill No..... "+awbNumber);
|
| 8391 |
manish.sha |
197 |
TrackReply trackreply = TrackWebServiceClient.getTrackingUpdates(awbNumber, clientDetails, waDetails, endPointAddress);
|
| 8368 |
manish.sha |
198 |
if(trackreply!=null){
|
| 8385 |
manish.sha |
199 |
log.info("Successfully get Fedex Returned Orders");
|
| 8368 |
manish.sha |
200 |
TrackDetail[] trackDetails=trackreply.getTrackDetails();
|
| 8402 |
manish.sha |
201 |
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
|
| 8368 |
manish.sha |
202 |
SimpleDateFormat timeformat = new SimpleDateFormat("HH:mm:ss");
|
| 8568 |
manish.sha |
203 |
trackDetailsLoop:for (int i=0; i< trackDetails.length; i++) {
|
| 8368 |
manish.sha |
204 |
TrackEvent trackEvents[]= trackDetails[i].getEvents();
|
| 8832 |
manish.sha |
205 |
if(trackEvents!=null && trackEvents.length > 0){
|
|
|
206 |
for(TrackEvent te : trackEvents){
|
|
|
207 |
if("RS".equalsIgnoreCase(te.getEventType())){
|
|
|
208 |
fedexReturnedOrdersMap.put(awbNumber, dateformat.format(te.getTimestamp().getTime())+" "+timeformat.format(te.getTimestamp().getTime())+"|"+te.getEventDescription());
|
|
|
209 |
break trackDetailsLoop;
|
|
|
210 |
}
|
| 8377 |
manish.sha |
211 |
}
|
|
|
212 |
}
|
| 8368 |
manish.sha |
213 |
}
|
|
|
214 |
}
|
|
|
215 |
}
|
| 8385 |
manish.sha |
216 |
log.info("Read Fedex Returned Orders");
|
| 8368 |
manish.sha |
217 |
return fedexReturnedOrdersMap;
|
|
|
218 |
}
|
|
|
219 |
|
|
|
220 |
public Map<String,String> readFedExUnDeliveredOrdersMap(List<Order> ordersList){
|
| 8388 |
manish.sha |
221 |
log.info("Into Method to Read Fedex Undelivered Orders.... "+ ordersList.size());
|
| 8368 |
manish.sha |
222 |
Map<String,String> fedexUnDeliveredOrdersMap= new HashMap<String,String>();
|
| 8504 |
manish.sha |
223 |
orderLoop:for(Order ord: ordersList){
|
| 8368 |
manish.sha |
224 |
String awbNumber= ord.getAirwaybill_no();
|
| 8832 |
manish.sha |
225 |
System.out.println("Order Id.... "+ord.getId()+".....Airwaybill No..... "+awbNumber);
|
| 8391 |
manish.sha |
226 |
TrackReply trackreply = TrackWebServiceClient.getTrackingUpdates(awbNumber, clientDetails, waDetails, endPointAddress);
|
| 8368 |
manish.sha |
227 |
if(trackreply!=null){
|
| 8385 |
manish.sha |
228 |
log.info("Successfully Get Fedex Undelivered Orders");
|
| 8368 |
manish.sha |
229 |
TrackDetail[] trackDetails=trackreply.getTrackDetails();
|
| 8568 |
manish.sha |
230 |
trackDetailsLoop:for (int i=0; i< trackDetails.length; i++) {
|
| 8368 |
manish.sha |
231 |
TrackEvent trackEvents[]= trackDetails[i].getEvents();
|
| 8832 |
manish.sha |
232 |
if(trackEvents!=null && trackEvents.length > 0){
|
|
|
233 |
for(TrackEvent tevent : trackEvents){
|
|
|
234 |
if("DL".equalsIgnoreCase(tevent.getEventType())){
|
|
|
235 |
continue orderLoop;
|
|
|
236 |
}
|
| 8504 |
manish.sha |
237 |
}
|
| 8832 |
manish.sha |
238 |
for(TrackEvent te : trackEvents){
|
|
|
239 |
if("DE".equalsIgnoreCase(te.getEventType())){
|
|
|
240 |
fedexUnDeliveredOrdersMap.put(awbNumber, te.getEventDescription());
|
|
|
241 |
break trackDetailsLoop;
|
|
|
242 |
}
|
| 8377 |
manish.sha |
243 |
}
|
|
|
244 |
}
|
| 8368 |
manish.sha |
245 |
}
|
|
|
246 |
}
|
|
|
247 |
}
|
| 8385 |
manish.sha |
248 |
log.info("Read Fedex Undelivered Orders");
|
| 8368 |
manish.sha |
249 |
return fedexUnDeliveredOrdersMap;
|
|
|
250 |
}
|
|
|
251 |
|
|
|
252 |
public Map<String,String> readFedExFirstDeliveryAttemptedOrdersMap(List<Order> ordersList){
|
| 8388 |
manish.sha |
253 |
log.info("Into Method to Read Fedex First Delivery Attempted Orders.... "+ ordersList.size());
|
| 8368 |
manish.sha |
254 |
Map<String,String> fedexFirstDeliveryAttemptedOrdersMap= new HashMap<String,String>();
|
|
|
255 |
for(Order ord: ordersList){
|
|
|
256 |
String awbNumber= ord.getAirwaybill_no();
|
| 8832 |
manish.sha |
257 |
System.out.println("Order Id.... "+ord.getId()+".....Airwaybill No..... "+awbNumber);
|
| 8391 |
manish.sha |
258 |
TrackReply trackreply = TrackWebServiceClient.getTrackingUpdates(awbNumber, clientDetails, waDetails, endPointAddress);
|
| 8368 |
manish.sha |
259 |
if(trackreply!=null){
|
| 8385 |
manish.sha |
260 |
log.info("Successfully get Fedex First Delivery Attempted Orders");
|
| 8368 |
manish.sha |
261 |
TrackDetail[] trackDetails=trackreply.getTrackDetails();
|
| 8402 |
manish.sha |
262 |
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
|
| 8368 |
manish.sha |
263 |
SimpleDateFormat timeformat = new SimpleDateFormat("HH:mm:ss");
|
| 8568 |
manish.sha |
264 |
trackDeatilsLoop:for (int i=0; i< trackDetails.length; i++) {
|
| 8368 |
manish.sha |
265 |
TrackEvent trackEvents[]= trackDetails[i].getEvents();
|
| 8832 |
manish.sha |
266 |
if(trackEvents!=null && trackEvents.length > 0){
|
|
|
267 |
for(TrackEvent te : trackEvents){
|
|
|
268 |
if("OD".equalsIgnoreCase(te.getEventType())){
|
|
|
269 |
if(te.getStatusExceptionCode()!=null){
|
|
|
270 |
fedexFirstDeliveryAttemptedOrdersMap.put(awbNumber, dateformat.format(te.getTimestamp().getTime())+" "+timeformat.format(te.getTimestamp().getTime())+"|"+te.getStatusExceptionDescription());
|
|
|
271 |
}
|
|
|
272 |
else{
|
|
|
273 |
fedexFirstDeliveryAttemptedOrdersMap.put(awbNumber, dateformat.format(te.getTimestamp().getTime())+" "+timeformat.format(te.getTimestamp().getTime())+"|"+te.getEventDescription());
|
|
|
274 |
}
|
|
|
275 |
break trackDeatilsLoop;
|
| 8380 |
manish.sha |
276 |
}
|
| 8832 |
manish.sha |
277 |
else if("DE".equalsIgnoreCase(te.getEventType())){
|
| 8380 |
manish.sha |
278 |
fedexFirstDeliveryAttemptedOrdersMap.put(awbNumber, dateformat.format(te.getTimestamp().getTime())+" "+timeformat.format(te.getTimestamp().getTime())+"|"+te.getEventDescription());
|
| 8832 |
manish.sha |
279 |
break trackDeatilsLoop;
|
| 8380 |
manish.sha |
280 |
}
|
| 8377 |
manish.sha |
281 |
}
|
|
|
282 |
}
|
| 8368 |
manish.sha |
283 |
}
|
|
|
284 |
}
|
|
|
285 |
}
|
| 8385 |
manish.sha |
286 |
log.info("Read Fedex First Delivery Attempted Orders");
|
| 8368 |
manish.sha |
287 |
return fedexFirstDeliveryAttemptedOrdersMap;
|
|
|
288 |
}
|
|
|
289 |
|
| 7930 |
manish.sha |
290 |
public List<ShipmentUpdate> getUpdates(String awbNumber){
|
|
|
291 |
List<ShipmentUpdate> updates = new ArrayList<ShipmentUpdate>();
|
| 8391 |
manish.sha |
292 |
TrackReply trackreply = TrackWebServiceClient.getTrackingUpdates(awbNumber, clientDetails, waDetails, endPointAddress);
|
| 7930 |
manish.sha |
293 |
if(trackreply!=null){
|
|
|
294 |
TrackDetail[] trackDetails=trackreply.getTrackDetails();
|
|
|
295 |
SimpleDateFormat dateformat = new SimpleDateFormat("dd-MMM-yyyy");
|
|
|
296 |
SimpleDateFormat timeformat = new SimpleDateFormat("HH:mm:ss");
|
|
|
297 |
for (int i=0; i< trackDetails.length; i++) {
|
|
|
298 |
TrackEvent trackEvents[]= trackDetails[i].getEvents();
|
| 8832 |
manish.sha |
299 |
if(trackEvents!=null && trackEvents.length > 0){
|
|
|
300 |
for(TrackEvent te : trackEvents){
|
|
|
301 |
ShipmentUpdate shipUpdate = new ShipmentUpdate();
|
|
|
302 |
if(te.getAddress()!=null){
|
|
|
303 |
if(te.getAddress().getCity()!=null){
|
|
|
304 |
shipUpdate.city= te.getAddress().getCity();
|
|
|
305 |
}
|
|
|
306 |
else{
|
|
|
307 |
shipUpdate.city="Unknown";
|
|
|
308 |
}
|
| 8353 |
manish.sha |
309 |
}
|
|
|
310 |
else{
|
|
|
311 |
shipUpdate.city="Unknown";
|
|
|
312 |
}
|
| 8832 |
manish.sha |
313 |
shipUpdate.date= dateformat.format(te.getTimestamp().getTime());
|
|
|
314 |
shipUpdate.time= timeformat.format(te.getTimestamp().getTime());
|
|
|
315 |
shipUpdate.description= te.getEventDescription();
|
|
|
316 |
updates.add(shipUpdate);
|
| 8353 |
manish.sha |
317 |
}
|
| 8832 |
manish.sha |
318 |
}
|
| 7930 |
manish.sha |
319 |
}
|
|
|
320 |
return updates;
|
|
|
321 |
}
|
|
|
322 |
else{
|
|
|
323 |
return null;
|
|
|
324 |
}
|
|
|
325 |
}
|
|
|
326 |
|
|
|
327 |
public static void main(String[] args) {
|
| 9338 |
manish.sha |
328 |
FedExTrackingService trackClient = new FedExTrackingService(WarehouseLocation.Delhi);
|
| 20020 |
kshitij.so |
329 |
List<ShipmentUpdate> updates = trackClient.getUpdates("783305300460");
|
| 7930 |
manish.sha |
330 |
for(ShipmentUpdate update: updates){
|
|
|
331 |
System.out.println(update.toString());
|
|
|
332 |
}
|
|
|
333 |
}
|
|
|
334 |
|
|
|
335 |
}
|