| 20763 |
amit.gupta |
1 |
import in.shop2020.model.v1.order.Order;
|
| 20764 |
amit.gupta |
2 |
import in.shop2020.model.v1.order.OrderSource;
|
|
|
3 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 20763 |
amit.gupta |
4 |
import in.shop2020.model.v1.order.TransactionService.Client;
|
|
|
5 |
import in.shop2020.thrift.clients.TransactionClient;
|
|
|
6 |
|
|
|
7 |
import java.util.ArrayList;
|
|
|
8 |
import java.util.Arrays;
|
|
|
9 |
import java.util.HashMap;
|
|
|
10 |
import java.util.List;
|
|
|
11 |
import java.util.Map;
|
|
|
12 |
|
|
|
13 |
import com.aramex.impl.Aramex;
|
|
|
14 |
import com.providers.logistics.Provider;
|
|
|
15 |
import com.providers.logistics.ProviderFactory;
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
public class Test {
|
|
|
20 |
public static void main (String[] args) throws Exception {
|
| 20776 |
amit.gupta |
21 |
String a = null;
|
|
|
22 |
try {
|
|
|
23 |
a.charAt(0);
|
|
|
24 |
} catch(Exception e){
|
|
|
25 |
System.out.println(" e.getMessage() - " + e.getMessage());
|
|
|
26 |
System.out.println("e.toString() - " + e.toString());
|
|
|
27 |
System.out.println("e.getLocalizedMessage() - " + e.getLocalizedMessage());
|
|
|
28 |
}
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
public static void assignAwbs() throws Exception{
|
| 20763 |
amit.gupta |
33 |
TransactionClient client = new TransactionClient("support_transaction_service_server_host", "transaction_service_server_port");
|
|
|
34 |
Client c = client.getClient();
|
|
|
35 |
List<Order> allOrdersWithMissingAwb = c.getOrderForAirwayBillNo(null);
|
|
|
36 |
Map<String, List<Order>> logisticsTxnOrdersMap = new HashMap<String, List<Order>>();
|
|
|
37 |
for(Order o: allOrdersWithMissingAwb) {
|
|
|
38 |
if(!logisticsTxnOrdersMap.containsKey(o.getLogisticsTransactionId())) {
|
|
|
39 |
logisticsTxnOrdersMap.put(o.getLogisticsTransactionId(), new ArrayList<Order>());
|
|
|
40 |
}
|
|
|
41 |
List<Order> orderList = logisticsTxnOrdersMap.get(o.getLogisticsTransactionId());
|
|
|
42 |
orderList.add(o);
|
|
|
43 |
}
|
|
|
44 |
//Iterate LogisticTransaction Id and
|
|
|
45 |
for (Map.Entry<String, List<Order>> entry : logisticsTxnOrdersMap.entrySet()) {
|
|
|
46 |
Order o = entry.getValue().get(0);
|
|
|
47 |
Provider logisticsProvider = ProviderFactory.getProvider(2);
|
| 20764 |
amit.gupta |
48 |
if(o.getLogistics_provider_id()==2 && o.getStatus().equals(OrderStatus.BILLED)) {
|
| 20763 |
amit.gupta |
49 |
String airwayBill = logisticsProvider.getAirwayBillNo(entry.getValue());
|
|
|
50 |
c.updateMasterOrderAWB(entry.getKey(), airwayBill);
|
| 20776 |
amit.gupta |
51 |
System.out.println("Updated logisticsTransactionId - " + entry.getKey() + " with airway bill - " + airwayBill + "count ");
|
| 20765 |
amit.gupta |
52 |
} else {
|
| 20766 |
amit.gupta |
53 |
System.out.println("Ignored logisticsTransactionId - " + entry.getKey() + "Prodider id - " + o.getLogistics_provider_id() + " Status - " + o.getStatusDescription());
|
| 20763 |
amit.gupta |
54 |
}
|
|
|
55 |
}
|
|
|
56 |
}
|
|
|
57 |
}
|