Subversion Repositories SmartDukaan

Rev

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

Rev 6277 Rev 6530
Line 1... Line 1...
1
package in.shop2020.catalog.dashboard.server;
1
package in.shop2020.catalog.dashboard.server;
2
 
2
 
3
import in.shop2020.catalog.dashboard.client.CatalogService;
3
import in.shop2020.catalog.dashboard.client.CatalogService;
-
 
4
 
4
import in.shop2020.catalog.dashboard.shared.Item;
5
import in.shop2020.catalog.dashboard.shared.Item;
5
import in.shop2020.catalog.dashboard.shared.ItemInventory;
6
import in.shop2020.catalog.dashboard.shared.ItemInventory;
6
import in.shop2020.catalog.dashboard.shared.ItemStatus;
7
import in.shop2020.catalog.dashboard.shared.ItemStatus;
7
import in.shop2020.catalog.dashboard.shared.ItemsComparator;
8
import in.shop2020.catalog.dashboard.shared.ItemsComparator;
8
import in.shop2020.catalog.dashboard.shared.SourcePricings;
9
import in.shop2020.catalog.dashboard.shared.SourcePricings;
Line 21... Line 22...
21
import in.shop2020.thrift.clients.ContentClient;
22
import in.shop2020.thrift.clients.ContentClient;
22
import in.shop2020.thrift.clients.InventoryClient;
23
import in.shop2020.thrift.clients.InventoryClient;
23
import in.shop2020.thrift.clients.config.ConfigClient;
24
import in.shop2020.thrift.clients.config.ConfigClient;
24
import in.shop2020.utils.CategoryManager;
25
import in.shop2020.utils.CategoryManager;
25
import in.shop2020.utils.ConfigClientKeys;
26
import in.shop2020.utils.ConfigClientKeys;
26
 
-
 
-
 
27
import in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems;
-
 
28
import in.shop2020.catalog.dashboard.shared.ItemWarehouse;
27
import java.io.BufferedReader;
29
import java.io.BufferedReader;
28
import java.io.FileReader;
30
import java.io.FileReader;
29
import java.io.IOException;
31
import java.io.IOException;
30
import java.text.DateFormat;
32
import java.text.DateFormat;
31
import java.text.SimpleDateFormat;
33
import java.text.SimpleDateFormat;
Line 86... Line 88...
86
        }
88
        }
87
        return count;
89
        return count;
88
    }
90
    }
89
    
91
    
90
    @Override
92
    @Override
-
 
93
	public List<Item> getInventoryOutofSyncItems(int offset, int limit){
-
 
94
        List<Item> itemList = new ArrayList<Item>();
-
 
95
 
-
 
96
        try {
-
 
97
            CatalogClient catalogServiceClient = new CatalogClient();
-
 
98
            Client catalogClient = catalogServiceClient.getClient();
-
 
99
 
-
 
100
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllIgnoredInventoryUpdateItemsList(offset, limit);
-
 
101
 
-
 
102
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
-
 
103
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null));
-
 
104
            }
-
 
105
        } catch (Exception e) {
-
 
106
            logger.error("Error while getting all items from the catalog service", e);
-
 
107
        }
-
 
108
        return itemList;
-
 
109
    }
-
 
110
    
-
 
111
    @Override
-
 
112
    public int getInventoryOutofSyncItemsCount(){
-
 
113
	int count=0;
-
 
114
    	try {
-
 
115
            InventoryClient inventoryServiceClient = new InventoryClient();
-
 
116
            in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
-
 
117
 
-
 
118
            count = inventoryClient.getAllIgnoredInventoryupdateItemsCount();
-
 
119
 
-
 
120
            } catch (Exception e) {
-
 
121
            logger.error("Error while getting all items from the catalog service", e);
-
 
122
        }
-
 
123
    	return count;	
-
 
124
    }    
-
 
125
    
-
 
126
    @Override
91
    public List<Item> getAllItems(int start, int limit) {
127
    public List<Item> getAllItems(int start, int limit) {
92
        List<Item> itemList = new ArrayList<Item>();
128
        List<Item> itemList = new ArrayList<Item>();
93
 
129
 
94
        try {
130
        try {
95
            CatalogClient catalogServiceClient = new CatalogClient();
131
            CatalogClient catalogServiceClient = new CatalogClient();
Line 179... Line 215...
179
        } catch(Exception e){
215
        } catch(Exception e){
180
            logger.error("Error while getting the best sellers from the catalog service", e);
216
            logger.error("Error while getting the best sellers from the catalog service", e);
181
        }
217
        }
182
        return itemList;        
218
        return itemList;        
183
    }
219
    }
-
 
220
    
-
 
221
    @Override
-
 
222
    public boolean addtoIgnoredInventoryUpdateItemsIdsWarehouseIds(long itemId,long warehouseId){
-
 
223
    	try {
-
 
224
				InventoryClient inventoryServiceClient = new InventoryClient();
-
 
225
				in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
-
 
226
				return inventoryClient.insertItemtoIgnoreInventoryUpdatelist(itemId, warehouseId);
-
 
227
			} catch (Exception e) {
-
 
228
            logger.error("Error while inserting item to ignore inventory update list", e);
-
 
229
            }
-
 
230
			return false;
-
 
231
    }
-
 
232
    
-
 
233
    @Override
-
 
234
    public boolean deleteFromIgnoredInventoryUpdateItemsIdsWarehouseIds(long itemId,long warehouseId){
-
 
235
    	try {
-
 
236
    			InventoryClient inventoryServiceClient = new InventoryClient();
-
 
237
    			in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
-
 
238
    			return inventoryClient.deleteItemFromIgnoredInventoryUpdateList(itemId,warehouseId);
-
 
239
    			
-
 
240
		} catch (Exception e) {
-
 
241
        logger.error("Error while inserting item to ignore inventory update list", e);
-
 
242
        }
-
 
243
		return false;
-
 
244
}
-
 
245
 
-
 
246
 
184
 
247
 
185
    @Override
248
    @Override
186
    public List<Item> getLatestArrivals(){
249
    public List<Item> getLatestArrivals(){
187
        List<Item> itemList = new ArrayList<Item>();
250
        List<Item> itemList = new ArrayList<Item>();
188
 
251
 
Line 335... Line 398...
335
            return false;
398
            return false;
336
        }
399
        }
337
        return true;
400
        return true;
338
    }
401
    }
339
 
402
 
-
 
403
    @Override
-
 
404
    public List<Long> getMonitoredWarehouseIdsForVendors(List<Long> vendorIds){
-
 
405
    	List<Long> monitoredWarehouseids=null;
-
 
406
    	 try {
-
 
407
			InventoryClient inventoryServiceClient = new InventoryClient();
-
 
408
			 in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
-
 
409
			 monitoredWarehouseids = inventoryClient.getMonitoredWarehouseForVendors(vendorIds);
-
 
410
		} catch (Exception e) {
-
 
411
			logger.error("Error while getting Monitored warehouse for vendor: ", e);
-
 
412
		}
-
 
413
		return monitoredWarehouseids;
-
 
414
        
-
 
415
    }
-
 
416
    
-
 
417
    @Override
-
 
418
    public List<ItemWarehouse> getignoredInventoryUpdateItemsIdsWarehouseIds(){
-
 
419
		List<ItemWarehouse> ignoredItemIdwarehouseIdList = new ArrayList<ItemWarehouse>();
-
 
420
    	try {
340
 
421
 
-
 
422
			InventoryClient inventoryServiceClient = new InventoryClient();
-
 
423
			in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
-
 
424
			List<IgnoredInventoryUpdateItems> ignoredInventoryUpdateItems = inventoryClient.getIgnoredWarehouseidsAndItemids();
-
 
425
			for(IgnoredInventoryUpdateItems ignoredInventoryUpdateItem:ignoredInventoryUpdateItems){
-
 
426
				ignoredItemIdwarehouseIdList.add(new ItemWarehouse(ignoredInventoryUpdateItem.getItemId(),ignoredInventoryUpdateItem.getWarehouseId()));
-
 
427
			}
-
 
428
			
-
 
429
			
-
 
430
		} catch (Exception e) {
-
 
431
			logger.error("Error while getting Monitored warehouseid and itemid : ", e);
-
 
432
		}
-
 
433
		return ignoredItemIdwarehouseIdList;
-
 
434
    	
-
 
435
    }
341
    @Override
436
    @Override
342
    public Map<Long, String> getAllVendors() {
437
    public Map<Long, String> getAllVendors() {
343
        Map<Long, String> vendorMap = new HashMap<Long, String>();
438
        Map<Long, String> vendorMap = new HashMap<Long, String>();
344
        try {
439
        try {
345
            InventoryClient inventoryServiceClient = new InventoryClient();
440
            InventoryClient inventoryServiceClient = new InventoryClient();
Line 1158... Line 1253...
1158
        }catch(Exception e){
1253
        }catch(Exception e){
1159
            logger.error("Error while adding the Voucher for: " + catalogItemId, e);
1254
            logger.error("Error while adding the Voucher for: " + catalogItemId, e);
1160
        }
1255
        }
1161
		return false;
1256
		return false;
1162
	}
1257
	}
1163
 
-
 
1164
	@Override
1258
	@Override
1165
	public Map<Long, String> getvoucherTypes() {
1259
	public Map<Long, String> getvoucherTypes() {
1166
		Map<Long, String> voucherType = new HashMap<Long, String>();
1260
		Map<Long, String> voucherType = new HashMap<Long, String>();
1167
		for(VoucherType voucher : VoucherType.values())
1261
		for(VoucherType voucher : VoucherType.values())
1168
		{
1262
		{
Line 1231... Line 1325...
1231
 
1325
 
1232
 
1326
 
1233
	
1327
	
1234
		
1328
		
1235
 
1329
 
1236
}
-
 
1237
1330
}
-
 
1331