Subversion Repositories SmartDukaan

Rev

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

Rev 5504 Rev 5946
Line 1... Line 1...
1
package in.shop2020.catalog.util;
1
package in.shop2020.catalog.util;
2
 
2
 
3
import in.shop2020.catalog.dashboard.shared.Item;
3
import in.shop2020.catalog.dashboard.shared.Item;
4
import in.shop2020.catalog.dashboard.shared.VendorPricings;
4
import in.shop2020.catalog.dashboard.shared.VendorPricings;
5
import in.shop2020.config.ConfigException;
5
import in.shop2020.config.ConfigException;
6
import in.shop2020.model.v1.catalog.InventoryService;
6
import in.shop2020.model.v1.catalog.CatalogService;
7
import in.shop2020.model.v1.catalog.ItemType;
7
import in.shop2020.model.v1.catalog.ItemType;
8
import in.shop2020.model.v1.catalog.status;
8
import in.shop2020.model.v1.catalog.status;
-
 
9
import in.shop2020.model.v1.inventory.InventoryService.Client;
9
import in.shop2020.thrift.clients.CatalogClient;
10
import in.shop2020.thrift.clients.CatalogClient;
-
 
11
import in.shop2020.thrift.clients.InventoryClient;
10
import in.shop2020.thrift.clients.config.ConfigClient;
12
import in.shop2020.thrift.clients.config.ConfigClient;
11
import in.shop2020.utils.CategoryManager;
13
import in.shop2020.utils.CategoryManager;
12
import in.shop2020.utils.ConfigClientKeys;
14
import in.shop2020.utils.ConfigClientKeys;
13
 
15
 
14
import java.io.ByteArrayOutputStream;
16
import java.io.ByteArrayOutputStream;
Line 59... Line 61...
59
        List<in.shop2020.model.v1.catalog.Item> thriftItemList = new ArrayList<in.shop2020.model.v1.catalog.Item>();
61
        List<in.shop2020.model.v1.catalog.Item> thriftItemList = new ArrayList<in.shop2020.model.v1.catalog.Item>();
60
        List<in.shop2020.model.v1.catalog.Item> thriftItemListInactive = new ArrayList<in.shop2020.model.v1.catalog.Item>();
62
        List<in.shop2020.model.v1.catalog.Item> thriftItemListInactive = new ArrayList<in.shop2020.model.v1.catalog.Item>();
61
        try {
63
        try {
62
            CatalogClient catalogServiceClient = new CatalogClient(ConfigClientKeys.catalog_service_server_host_prod.toString(),
64
            CatalogClient catalogServiceClient = new CatalogClient(ConfigClientKeys.catalog_service_server_host_prod.toString(),
63
                    ConfigClientKeys.catalog_service_server_port.toString());
65
                    ConfigClientKeys.catalog_service_server_port.toString());
64
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
66
            CatalogService.Client catalogClient = catalogServiceClient.getClient();
-
 
67
            
-
 
68
            InventoryClient inventoryServiceClient = new InventoryClient();
-
 
69
            Client inventoryClient = inventoryServiceClient.getClient();
-
 
70
            
65
            thriftItemListInactive.addAll(catalogClient.getAllItemsByStatus(status.PAUSED));
71
            thriftItemListInactive.addAll(catalogClient.getAllItemsByStatus(status.PAUSED));
66
            if(TYPE_INACTIVE != type){
72
            if(TYPE_INACTIVE != type){
67
            	catalogServiceClient = new CatalogClient(ConfigClientKeys.catalog_service_server_host_prod.toString(),
73
            	catalogServiceClient = new CatalogClient(ConfigClientKeys.catalog_service_server_host_prod.toString(),
68
                        ConfigClientKeys.catalog_service_server_port.toString());
74
                        ConfigClientKeys.catalog_service_server_port.toString());
69
            	catalogClient = catalogServiceClient.getClient();
75
            	catalogClient = catalogServiceClient.getClient();
Line 95... Line 101...
95
	            headerRow.createCell(7).setCellValue("Current Status");
101
	            headerRow.createCell(7).setCellValue("Current Status");
96
	            headerRow.getCell(7).setCellStyle(styleBold);
102
	            headerRow.getCell(7).setCellStyle(styleBold);
97
	            headerRow.createCell(8).setCellValue("Reason");
103
	            headerRow.createCell(8).setCellValue("Reason");
98
	            headerRow.getCell(8).setCellStyle(styleBold);
104
	            headerRow.getCell(8).setCellStyle(styleBold);
99
	            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItemList) {
105
	            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItemList) {
100
	            	List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
106
	            	List<in.shop2020.model.v1.inventory.VendorItemPricing> vip = inventoryClient.getAllItemPricing(thriftItem.getId());
101
	            	Item item = getItemFromThriftItem(thriftItem, vip);
107
	            	Item item = getItemFromThriftItem(thriftItem, vip);
102
	            	List<Object> breakeven = isBreakeven(item);
108
	            	List<Object> breakeven = isBreakeven(item);
103
	            	if(!(Boolean)breakeven.get(0)){
109
	            	if(!(Boolean)breakeven.get(0)){
104
	            		try{
110
	            		try{
105
	            		Row itemRow = ngpSheet.createRow(++rowNo);
111
	            		Row itemRow = ngpSheet.createRow(++rowNo);
Line 159... Line 165...
159
	            anotherHeaderRow.getCell(5).setCellStyle(styleBold);
165
	            anotherHeaderRow.getCell(5).setCellStyle(styleBold);
160
	            anotherHeaderRow.createCell(6).setCellValue("Available Pieces");
166
	            anotherHeaderRow.createCell(6).setCellValue("Available Pieces");
161
	            anotherHeaderRow.getCell(6).setCellStyle(styleBold);
167
	            anotherHeaderRow.getCell(6).setCellStyle(styleBold);
162
				for (in.shop2020.model.v1.catalog.Item thriftItem : thriftItemListInactive) {
168
				for (in.shop2020.model.v1.catalog.Item thriftItem : thriftItemListInactive) {
163
					try {
169
					try {
164
						in.shop2020.model.v1.catalog.ItemInventory itemInventory = catalogClient.getItemInventoryByItemId(thriftItem.getId());
170
						in.shop2020.model.v1.inventory.ItemInventory itemInventory = inventoryClient.getItemInventoryByItemId(thriftItem.getId());
165
						long available = 0;
171
						long available = 0;
166
						for(long count : itemInventory.getAvailability().values()){
172
						for(long count : itemInventory.getAvailability().values()){
167
							available += count;
173
							available += count;
168
						}
174
						}
169
						for(long count : itemInventory.getReserved().values()){
175
						for(long count : itemInventory.getReserved().values()){
Line 321... Line 327...
321
	 * @param tSimilarItems
327
	 * @param tSimilarItems
322
	 * @return item object with attributes copied from thrift item object.
328
	 * @return item object with attributes copied from thrift item object.
323
	 */
329
	 */
324
	private Item getItemFromThriftItem(
330
	private Item getItemFromThriftItem(
325
			in.shop2020.model.v1.catalog.Item thriftItem,
331
			in.shop2020.model.v1.catalog.Item thriftItem,
326
			List<in.shop2020.model.v1.catalog.VendorItemPricing> tVendorPricings) {
332
			List<in.shop2020.model.v1.inventory.VendorItemPricing> tVendorPricings) {
327
 
333
 
328
		Map<Long, VendorPricings> vendorPricingMap = new HashMap<Long, VendorPricings>();
334
		Map<Long, VendorPricings> vendorPricingMap = new HashMap<Long, VendorPricings>();
329
		VendorPricings vPricings;
335
		VendorPricings vPricings;
330
		if (tVendorPricings != null) {
336
		if (tVendorPricings != null) {
331
			for (in.shop2020.model.v1.catalog.VendorItemPricing vip : tVendorPricings) {
337
			for (in.shop2020.model.v1.inventory.VendorItemPricing vip : tVendorPricings) {
332
				vPricings = new VendorPricings();
338
				vPricings = new VendorPricings();
333
				vPricings.setVendorId(vip.getVendorId());
339
				vPricings.setVendorId(vip.getVendorId());
334
				vPricings.setMop(vip.getMop());
340
				vPricings.setMop(vip.getMop());
335
				vPricings.setDealerPrice(vip.getDealerPrice());
341
				vPricings.setDealerPrice(vip.getDealerPrice());
336
				vPricings.setTransferPrice(vip.getTransferPrice());
342
				vPricings.setTransferPrice(vip.getTransferPrice());