| 20763 |
amit.gupta |
1 |
import in.shop2020.model.v1.order.Order;
|
| 20764 |
amit.gupta |
2 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 20763 |
amit.gupta |
3 |
import in.shop2020.model.v1.order.TransactionService.Client;
|
|
|
4 |
import in.shop2020.thrift.clients.TransactionClient;
|
|
|
5 |
|
|
|
6 |
import java.util.ArrayList;
|
|
|
7 |
import java.util.Arrays;
|
| 22599 |
amit.gupta |
8 |
import java.util.Date;
|
| 20763 |
amit.gupta |
9 |
import java.util.HashMap;
|
|
|
10 |
import java.util.List;
|
|
|
11 |
import java.util.Map;
|
|
|
12 |
|
|
|
13 |
import com.providers.logistics.Provider;
|
|
|
14 |
import com.providers.logistics.ProviderFactory;
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
public class Test {
|
| 22599 |
amit.gupta |
19 |
public static void main (String[] args) throws Throwable {
|
|
|
20 |
//generateAramex();
|
|
|
21 |
//System.out.println("/tmp/123".substring("/tmp/123".lastIndexOf('/') + 1));
|
|
|
22 |
/*String s = "ABCDEF";
|
|
|
23 |
System.out.println(s.substring(0,4));*/
|
|
|
24 |
assignAwbs();
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
/*public static void generateAramex() throws Throwable{
|
|
|
28 |
List<String> waybills=Arrays.asList("43272597933","43272597981","43272670453","43272670700","43272670615","43272702874","43272703375","43272702981","43272703471","43272703821","43272703600","43272702966","43272703084","43272703003","43272703423","43272703681","43272716701","43272716760");
|
|
|
29 |
|
|
|
30 |
TransactionClient transactionServiceClient = new TransactionClient();
|
|
|
31 |
Aramex aramex = new Aramex();
|
|
|
32 |
for (String wayBill : waybills){
|
|
|
33 |
TransactionService.Client tsc = transactionServiceClient.getClient();
|
|
|
34 |
List<Order> orders = tsc.getOrderForAwb(wayBill);
|
|
|
35 |
//List<Order> orders = tsc.getOrderForAwb("43272670700");
|
|
|
36 |
//System.out.println(orders);
|
|
|
37 |
String newWayBill = aramex.getAirwayBillNo(orders);
|
|
|
38 |
System.out.println("update `order` set airwaybill_no='" + newWayBill + "', tracking_id='" + newWayBill + "' where airwaybill_no = '" + wayBill+ "';");
|
| 20776 |
amit.gupta |
39 |
}
|
| 22599 |
amit.gupta |
40 |
}*/
|
|
|
41 |
|
|
|
42 |
public static void printInvoice() throws Exception {
|
|
|
43 |
/*GSTInvoiceGenerationService invoiceGenerationService = new GSTInvoiceGenerationService();
|
|
|
44 |
invoiceGenerationService.generateInvoice(748108, false, 7441);*/
|
| 20776 |
amit.gupta |
45 |
}
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
public static void assignAwbs() throws Exception{
|
| 20763 |
amit.gupta |
49 |
TransactionClient client = new TransactionClient("support_transaction_service_server_host", "transaction_service_server_port");
|
|
|
50 |
Client c = client.getClient();
|
| 22599 |
amit.gupta |
51 |
List<Order> allOrdersWithMissingAwb = c.getAllOrders(Arrays.asList(OrderStatus.BILLED), 0, new Date().getTime(), 7573);
|
| 20763 |
amit.gupta |
52 |
Map<String, List<Order>> logisticsTxnOrdersMap = new HashMap<String, List<Order>>();
|
|
|
53 |
for(Order o: allOrdersWithMissingAwb) {
|
|
|
54 |
if(!logisticsTxnOrdersMap.containsKey(o.getLogisticsTransactionId())) {
|
|
|
55 |
logisticsTxnOrdersMap.put(o.getLogisticsTransactionId(), new ArrayList<Order>());
|
|
|
56 |
}
|
|
|
57 |
List<Order> orderList = logisticsTxnOrdersMap.get(o.getLogisticsTransactionId());
|
|
|
58 |
orderList.add(o);
|
|
|
59 |
}
|
| 22599 |
amit.gupta |
60 |
System.out.println(logisticsTxnOrdersMap.keySet());
|
| 20763 |
amit.gupta |
61 |
//Iterate LogisticTransaction Id and
|
|
|
62 |
for (Map.Entry<String, List<Order>> entry : logisticsTxnOrdersMap.entrySet()) {
|
|
|
63 |
Order o = entry.getValue().get(0);
|
|
|
64 |
Provider logisticsProvider = ProviderFactory.getProvider(2);
|
| 20764 |
amit.gupta |
65 |
if(o.getLogistics_provider_id()==2 && o.getStatus().equals(OrderStatus.BILLED)) {
|
| 20763 |
amit.gupta |
66 |
String airwayBill = logisticsProvider.getAirwayBillNo(entry.getValue());
|
|
|
67 |
c.updateMasterOrderAWB(entry.getKey(), airwayBill);
|
| 20776 |
amit.gupta |
68 |
System.out.println("Updated logisticsTransactionId - " + entry.getKey() + " with airway bill - " + airwayBill + "count ");
|
| 20765 |
amit.gupta |
69 |
} else {
|
| 20766 |
amit.gupta |
70 |
System.out.println("Ignored logisticsTransactionId - " + entry.getKey() + "Prodider id - " + o.getLogistics_provider_id() + " Status - " + o.getStatusDescription());
|
| 20763 |
amit.gupta |
71 |
}
|
|
|
72 |
}
|
|
|
73 |
}
|
|
|
74 |
}
|