Rev 20776 | Blame | Compare with Previous | Last modification | View Log | RSS feed
import in.shop2020.model.v1.order.Order;import in.shop2020.model.v1.order.OrderStatus;import in.shop2020.model.v1.order.TransactionService.Client;import in.shop2020.thrift.clients.TransactionClient;import java.util.ArrayList;import java.util.Arrays;import java.util.Date;import java.util.HashMap;import java.util.List;import java.util.Map;import com.providers.logistics.Provider;import com.providers.logistics.ProviderFactory;public class Test {public static void main (String[] args) throws Throwable {//generateAramex();//System.out.println("/tmp/123".substring("/tmp/123".lastIndexOf('/') + 1));/*String s = "ABCDEF";System.out.println(s.substring(0,4));*/assignAwbs();}/*public static void generateAramex() throws Throwable{List<String> waybills=Arrays.asList("43272597933","43272597981","43272670453","43272670700","43272670615","43272702874","43272703375","43272702981","43272703471","43272703821","43272703600","43272702966","43272703084","43272703003","43272703423","43272703681","43272716701","43272716760");TransactionClient transactionServiceClient = new TransactionClient();Aramex aramex = new Aramex();for (String wayBill : waybills){TransactionService.Client tsc = transactionServiceClient.getClient();List<Order> orders = tsc.getOrderForAwb(wayBill);//List<Order> orders = tsc.getOrderForAwb("43272670700");//System.out.println(orders);String newWayBill = aramex.getAirwayBillNo(orders);System.out.println("update `order` set airwaybill_no='" + newWayBill + "', tracking_id='" + newWayBill + "' where airwaybill_no = '" + wayBill+ "';");}}*/public static void printInvoice() throws Exception {/*GSTInvoiceGenerationService invoiceGenerationService = new GSTInvoiceGenerationService();invoiceGenerationService.generateInvoice(748108, false, 7441);*/}public static void assignAwbs() throws Exception{TransactionClient client = new TransactionClient("support_transaction_service_server_host", "transaction_service_server_port");Client c = client.getClient();List<Order> allOrdersWithMissingAwb = c.getAllOrders(Arrays.asList(OrderStatus.BILLED), 0, new Date().getTime(), 7573);Map<String, List<Order>> logisticsTxnOrdersMap = new HashMap<String, List<Order>>();for(Order o: allOrdersWithMissingAwb) {if(!logisticsTxnOrdersMap.containsKey(o.getLogisticsTransactionId())) {logisticsTxnOrdersMap.put(o.getLogisticsTransactionId(), new ArrayList<Order>());}List<Order> orderList = logisticsTxnOrdersMap.get(o.getLogisticsTransactionId());orderList.add(o);}System.out.println(logisticsTxnOrdersMap.keySet());//Iterate LogisticTransaction Id andfor (Map.Entry<String, List<Order>> entry : logisticsTxnOrdersMap.entrySet()) {Order o = entry.getValue().get(0);Provider logisticsProvider = ProviderFactory.getProvider(2);if(o.getLogistics_provider_id()==2 && o.getStatus().equals(OrderStatus.BILLED)) {String airwayBill = logisticsProvider.getAirwayBillNo(entry.getValue());c.updateMasterOrderAWB(entry.getKey(), airwayBill);System.out.println("Updated logisticsTransactionId - " + entry.getKey() + " with airway bill - " + airwayBill + "count ");} else {System.out.println("Ignored logisticsTransactionId - " + entry.getKey() + "Prodider id - " + o.getLogistics_provider_id() + " Status - " + o.getStatusDescription());}}}}