Subversion Repositories SmartDukaan

Rev

Rev 23376 | Rev 23526 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23376 Rev 23509
Line 6... Line 6...
6
import java.net.URISyntaxException;
6
import java.net.URISyntaxException;
7
import java.net.URL;
7
import java.net.URL;
8
import java.util.ArrayList;
8
import java.util.ArrayList;
9
import java.util.Collections;
9
import java.util.Collections;
10
import java.util.HashMap;
10
import java.util.HashMap;
-
 
11
import java.util.HashSet;
11
import java.util.List;
12
import java.util.List;
12
import java.util.Map;
13
import java.util.Map;
13
import java.util.Set;
14
import java.util.Set;
14
import java.util.TreeSet;
15
import java.util.TreeSet;
15
 
16
 
Line 31... Line 32...
31
import com.spice.profitmandi.common.web.client.RestClient;
32
import com.spice.profitmandi.common.web.client.RestClient;
32
import com.spice.profitmandi.thrift.clients.CatalogClient;
33
import com.spice.profitmandi.thrift.clients.CatalogClient;
33
import com.spice.profitmandi.thrift.clients.InventoryClient;
34
import com.spice.profitmandi.thrift.clients.InventoryClient;
34
import com.spice.profitmandi.thrift.clients.TransactionClient;
35
import com.spice.profitmandi.thrift.clients.TransactionClient;
35
import com.spice.profitmandi.thrift.clients.UserClient;
36
import com.spice.profitmandi.thrift.clients.UserClient;
-
 
37
import com.spice.profitmandi.thrift.clients.WarehouseClient;
36
import com.spice.profitmandi.thrift.clients.config.ConfigClient;
38
import com.spice.profitmandi.thrift.clients.config.ConfigClient;
37
 
39
 
38
import in.shop2020.model.v1.catalog.CatalogService;
40
import in.shop2020.model.v1.catalog.CatalogService;
39
import in.shop2020.model.v1.inventory.InventoryService;
41
import in.shop2020.model.v1.inventory.InventoryService;
40
import in.shop2020.model.v1.inventory.StateInfo;
42
import in.shop2020.model.v1.inventory.StateInfo;
-
 
43
import in.shop2020.model.v1.inventory.Warehouse;
41
import in.shop2020.model.v1.order.RechargeOrderStatus;
44
import in.shop2020.model.v1.order.RechargeOrderStatus;
42
import in.shop2020.model.v1.order.RechargePlan;
45
import in.shop2020.model.v1.order.RechargePlan;
43
import in.shop2020.model.v1.order.RechargeType;
46
import in.shop2020.model.v1.order.RechargeType;
-
 
47
import in.shop2020.model.v1.order.SellerInfo;
-
 
48
import in.shop2020.model.v1.order.WarehouseAddress;
44
import in.shop2020.model.v1.user.Sex;
49
import in.shop2020.model.v1.user.Sex;
45
import in.shop2020.model.v1.user.User;
50
import in.shop2020.model.v1.user.User;
46
import in.shop2020.model.v1.user.UserContextException;
51
import in.shop2020.model.v1.user.UserContextException;
-
 
52
import in.shop2020.warehouse.InventoryItem;
-
 
53
import in.shop2020.warehouse.WarehouseService;
47
 
54
 
48
 
55
 
49
 
56
 
50
public class Utils {
57
public class Utils {
51
 
58
 
Line 113... Line 120...
113
			logger.error("Could not get providers", e);
120
			logger.error("Could not get providers", e);
114
		}
121
		}
115
	}
122
	}
116
 
123
 
117
 
124
 
-
 
125
	public static SellerInfo getSellerInfoBySellerId(int sellerId) throws Exception {
-
 
126
		TransactionClient tcl = new TransactionClient();
-
 
127
		return tcl.getClient().getSellerInfo((long)sellerId);
-
 
128
	}
118
 
129
	
119
	@SuppressWarnings("serial")
130
	@SuppressWarnings("serial")
120
	public static final Map<String,String> MIME_TYPE = Collections.unmodifiableMap(
131
	public static final Map<String,String> MIME_TYPE = Collections.unmodifiableMap(
121
			new HashMap<String, String>(){
132
			new HashMap<String, String>(){
122
				{
133
				{
123
					put("image/png", "png");
134
					put("image/png", "png");
Line 315... Line 326...
315
			return catalogClient;
326
			return catalogClient;
316
		}catch (Exception e) {
327
		}catch (Exception e) {
317
			throw e;
328
			throw e;
318
		}
329
		}
319
	}
330
	}
-
 
331
 
-
 
332
	private static WarehouseService.Client getWarehouseClient() throws Exception{
-
 
333
		try{
-
 
334
			WarehouseClient client = new WarehouseClient();
-
 
335
			WarehouseService.Client warehouseClient = client.getClient();
-
 
336
			return warehouseClient;
-
 
337
		}catch (Exception e) {
-
 
338
			throw e;
-
 
339
		}
-
 
340
	}
-
 
341
	
-
 
342
	
-
 
343
	public static Map<String, Warehouse> getWarehouseByImeis(List<String> imeis) throws Exception{
-
 
344
		List<InventoryItem> inventoryItems = getWarehouseClient().getInventoryItemsBySerailNumbers(imeis);
-
 
345
		Map<String, InventoryItem> imeiInventoryItemMap = new HashMap<>();
-
 
346
		for(InventoryItem inventoryItem : inventoryItems) {
-
 
347
			imeiInventoryItemMap.put(inventoryItem.getSerialNumber(), inventoryItem);
-
 
348
		}
-
 
349
		Map<Integer, Warehouse> warehouseMap = new HashMap<>(); 
-
 
350
		Map<String, Warehouse> serialNumberWarehouseMap = new HashMap<>();
-
 
351
		InventoryClient client = new InventoryClient();
-
 
352
		InventoryService.Client inventoryClient = client.getClient();
-
 
353
		logger.info("[imeiInventoryItemMap] {}", imeiInventoryItemMap);
-
 
354
		for(InventoryItem inventory : new HashSet<>(imeiInventoryItemMap.values())) {
-
 
355
			Warehouse phWarehouse = null;
-
 
356
			if(warehouseMap.containsKey(inventory.getPhysicalWarehouseId())) {
-
 
357
				phWarehouse = warehouseMap.get((int)inventory.getPhysicalWarehouseId());
-
 
358
			} else {
-
 
359
				phWarehouse = inventoryClient.getWarehouse(inventory.getPhysicalWarehouseId());
-
 
360
				warehouseMap.put((int)inventory.getPhysicalWarehouseId(), phWarehouse);
-
 
361
			}
-
 
362
			serialNumberWarehouseMap.put(inventory.getSerialNumber(), phWarehouse);
-
 
363
			
-
 
364
		}
-
 
365
		return serialNumberWarehouseMap;
-
 
366
	}
320
	
367
	
321
	
368
	
322
	public static String getStateCode(String stateName) throws Exception{
369
	public static String getStateCode(String stateName) throws Exception{
323
		return getStateInfo(stateName).getStateCode();
370
		return getStateInfo(stateName).getStateCode();
324
	}
371
	}
325
	
372
	
326
	public static long getStateId(String stateName) throws Exception{
373
	public static long getStateId(String stateName) throws Exception{
327
		return getStateInfo(stateName).getId();
374
		return getStateInfo(stateName).getId();
328
	}
375
	}
329
	
376
	
-
 
377
	public static StateInfo getStateByStateId(long stateId) throws Exception{
-
 
378
		InventoryClient client = new InventoryClient();
-
 
379
		InventoryService.Client inventoryClient = client.getClient();
-
 
380
		Map<Long, StateInfo> map = inventoryClient.getStateMaster();
-
 
381
		return map.get(stateId);
-
 
382
	}
-
 
383
	
330
	public static StateInfo getStateInfo(String stateName) throws Exception{
384
	public static StateInfo getStateInfo(String stateName) throws Exception{
331
		try{
385
		try{
332
			InventoryClient client = new InventoryClient();
386
			InventoryClient client = new InventoryClient();
333
			InventoryService.Client inventoryClient = client.getClient();
387
			InventoryService.Client inventoryClient = client.getClient();
334
			Map<Long, StateInfo> map = inventoryClient.getStateMaster();
388
			Map<Long, StateInfo> map = inventoryClient.getStateMaster();
Line 364... Line 418...
364
		}catch (Exception e) {
418
		}catch (Exception e) {
365
			e.printStackTrace();
419
			e.printStackTrace();
366
			return sortedStateNames;
420
			return sortedStateNames;
367
		}
421
		}
368
	}
422
	}
-
 
423
 
-
 
424
	public static Map<Long, StateInfo> getAllStatesMap() throws Exception{
-
 
425
		InventoryClient client = new InventoryClient();
-
 
426
		InventoryService.Client inventoryClient = client.getClient();
-
 
427
		return  inventoryClient.getStateMaster();
-
 
428
 
-
 
429
	}
369
	
430
	
370
	public static User createSaholicUser(String emailId) throws ProfitMandiBusinessException{
431
	public static User createSaholicUser(String emailId) throws ProfitMandiBusinessException{
371
		in.shop2020.model.v1.user.User user = new in.shop2020.model.v1.user.User();
432
		in.shop2020.model.v1.user.User user = new in.shop2020.model.v1.user.User();
372
		user.setEmail(emailId);
433
		user.setEmail(emailId);
373
		user.setPassword("");
434
		user.setPassword("");
Line 392... Line 453...
392
	}
453
	}
393
	
454
	
394
	public static void main (String[] args) throws Exception{
455
	public static void main (String[] args) throws Exception{
395
		Utils.sendSms("Hello", "9990381569");
456
		Utils.sendSms("Hello", "9990381569");
396
	}
457
	}
-
 
458
 
-
 
459
	public static WarehouseAddress getWarehouseByWarehouseId(int warehouseAddressId) throws Exception{
-
 
460
		TransactionClient tcl = new TransactionClient();
-
 
461
		return tcl.getClient().getWarehouseAddress((long)warehouseAddressId);
-
 
462
	}
397
	
463
	
398
	
464
	
399
}
465
}