| Line 1... |
Line 1... |
| 1 |
package in.shop2020.support.controllers;
|
1 |
package in.shop2020.support.controllers;
|
| 2 |
|
2 |
|
| - |
|
3 |
import in.shop2020.logistics.DeliveryType;
|
| - |
|
4 |
import in.shop2020.logistics.LogisticsService.Client;
|
| - |
|
5 |
import in.shop2020.logistics.LogisticsServiceException;
|
| - |
|
6 |
import in.shop2020.model.v1.catalog.CatalogServiceException;
|
| - |
|
7 |
import in.shop2020.model.v1.catalog.Item;
|
| - |
|
8 |
import in.shop2020.model.v1.catalog.status;
|
| - |
|
9 |
import in.shop2020.model.v1.inventory.InventoryServiceException;
|
| - |
|
10 |
import in.shop2020.model.v1.inventory.ItemInventory;
|
| - |
|
11 |
import in.shop2020.support.utils.FileUtils;
|
| - |
|
12 |
import in.shop2020.support.utils.ReportsUtils;
|
| - |
|
13 |
import in.shop2020.thrift.clients.CatalogClient;
|
| - |
|
14 |
import in.shop2020.thrift.clients.InventoryClient;
|
| - |
|
15 |
import in.shop2020.thrift.clients.LogisticsClient;
|
| - |
|
16 |
import in.shop2020.utils.CategoryManager;
|
| - |
|
17 |
|
| 3 |
import java.io.ByteArrayOutputStream;
|
18 |
import java.io.ByteArrayOutputStream;
|
| 4 |
import java.io.File;
|
19 |
import java.io.File;
|
| 5 |
import java.io.FileNotFoundException;
|
20 |
import java.io.FileNotFoundException;
|
| 6 |
import java.io.FileOutputStream;
|
21 |
import java.io.FileOutputStream;
|
| 7 |
import java.io.IOException;
|
22 |
import java.io.IOException;
|
| Line 11... |
Line 26... |
| 11 |
import java.util.HashMap;
|
26 |
import java.util.HashMap;
|
| 12 |
import java.util.LinkedHashMap;
|
27 |
import java.util.LinkedHashMap;
|
| 13 |
import java.util.List;
|
28 |
import java.util.List;
|
| 14 |
import java.util.Map;
|
29 |
import java.util.Map;
|
| 15 |
|
30 |
|
| 16 |
import in.shop2020.logistics.DeliveryType;
|
- |
|
| 17 |
import in.shop2020.logistics.LogisticsService.Client;
|
- |
|
| 18 |
import in.shop2020.logistics.LogisticsServiceException;
|
- |
|
| 19 |
import in.shop2020.model.v1.catalog.InventoryServiceException;
|
- |
|
| 20 |
import in.shop2020.model.v1.catalog.Item;
|
- |
|
| 21 |
import in.shop2020.model.v1.catalog.ItemInventory;
|
- |
|
| 22 |
import in.shop2020.model.v1.catalog.status;
|
- |
|
| 23 |
import in.shop2020.support.utils.FileUtils;
|
- |
|
| 24 |
import in.shop2020.support.utils.ReportsUtils;
|
- |
|
| 25 |
import in.shop2020.thrift.clients.CatalogClient;
|
- |
|
| 26 |
import in.shop2020.thrift.clients.LogisticsClient;
|
- |
|
| 27 |
import in.shop2020.utils.CategoryManager;
|
- |
|
| 28 |
|
- |
|
| 29 |
import javax.servlet.ServletContext;
|
31 |
import javax.servlet.ServletContext;
|
| 30 |
import javax.servlet.ServletOutputStream;
|
32 |
import javax.servlet.ServletOutputStream;
|
| 31 |
import javax.servlet.http.HttpServletRequest;
|
33 |
import javax.servlet.http.HttpServletRequest;
|
| 32 |
import javax.servlet.http.HttpServletResponse;
|
34 |
import javax.servlet.http.HttpServletResponse;
|
| 33 |
import javax.servlet.http.HttpSession;
|
35 |
import javax.servlet.http.HttpSession;
|
| Line 149... |
Line 151... |
| 149 |
String notAvailable = "Out of Stock";
|
151 |
String notAvailable = "Out of Stock";
|
| 150 |
LogisticsClient logisticsServiceClient;
|
152 |
LogisticsClient logisticsServiceClient;
|
| 151 |
CatalogClient catalogClientService;
|
153 |
CatalogClient catalogClientService;
|
| 152 |
try {
|
154 |
try {
|
| 153 |
catalogClientService = new CatalogClient();
|
155 |
catalogClientService = new CatalogClient();
|
| - |
|
156 |
InventoryClient inventoryClientService = new InventoryClient();
|
| 154 |
logisticsServiceClient = new LogisticsClient();
|
157 |
logisticsServiceClient = new LogisticsClient();
|
| 155 |
in.shop2020.model.v1.catalog.InventoryService.Client client = catalogClientService.getClient();
|
158 |
in.shop2020.model.v1.catalog.CatalogService.Client client = catalogClientService.getClient();
|
| - |
|
159 |
in.shop2020.model.v1.inventory.InventoryService.Client iclient = inventoryClientService.getClient();
|
| 156 |
List<Item> items = client.getAllItems(false);
|
160 |
List<Item> items = client.getAllItems(false);
|
| 157 |
Client logisticsClient = logisticsServiceClient.getClient();
|
161 |
Client logisticsClient = logisticsServiceClient.getClient();
|
| 158 |
|
162 |
|
| 159 |
CategoryManager catm = CategoryManager.getCategoryManager();
|
163 |
CategoryManager catm = CategoryManager.getCategoryManager();
|
| 160 |
for(Item item : items){
|
164 |
for(Item item : items){
|
| Line 188... |
Line 192... |
| 188 |
|
192 |
|
| 189 |
deliveryDays = logisticsClient.getLogisticsEstimation(item.getId(), DEFAULT_PINCODE, DeliveryType.PREPAID).getDeliveryTime();
|
193 |
deliveryDays = logisticsClient.getLogisticsEstimation(item.getId(), DEFAULT_PINCODE, DeliveryType.PREPAID).getDeliveryTime();
|
| 190 |
}catch (LogisticsServiceException e) {
|
194 |
}catch (LogisticsServiceException e) {
|
| 191 |
logger.error("Error while getting estimate of the inventory for item " + item.getId(), e);
|
195 |
logger.error("Error while getting estimate of the inventory for item " + item.getId(), e);
|
| 192 |
}
|
196 |
}
|
| 193 |
ItemInventory inventory = client.getItemInventoryByItemId(item.getId());
|
197 |
ItemInventory inventory = iclient.getItemInventoryByItemId(item.getId());
|
| 194 |
RowItem rowItem = new RowItem(item, deliveryDays, inventory);
|
198 |
RowItem rowItem = new RowItem(item, deliveryDays, inventory);
|
| 195 |
if(state == status.ACTIVE){
|
199 |
if(state == status.ACTIVE){
|
| 196 |
if(deliveryDays == NEXT_DAY_DELAY)
|
200 |
if(deliveryDays == NEXT_DAY_DELAY)
|
| 197 |
sheetsMap.get(nextDay).add(rowItem);
|
201 |
sheetsMap.get(nextDay).add(rowItem);
|
| 198 |
else
|
202 |
else
|
| Line 215... |
Line 219... |
| 215 |
}
|
219 |
}
|
| 216 |
}
|
220 |
}
|
| 217 |
} catch (TTransportException e) {
|
221 |
} catch (TTransportException e) {
|
| 218 |
logger.error("Unable to get the items from the inventory", e);
|
222 |
logger.error("Unable to get the items from the inventory", e);
|
| 219 |
return null;
|
223 |
return null;
|
| 220 |
} catch (InventoryServiceException e) {
|
224 |
} catch (CatalogServiceException e) {
|
| 221 |
logger.error("Error while getting the items from the inventory", e);
|
225 |
logger.error("Error while getting the items from the inventory", e);
|
| 222 |
return null;
|
226 |
return null;
|
| 223 |
} catch (TException e) {
|
227 |
} catch (TException e) {
|
| 224 |
logger.error("Error while getting the items from the inventory", e);
|
228 |
logger.error("Error while getting the items from the inventory", e);
|
| 225 |
return null;
|
229 |
return null;
|
| - |
|
230 |
} catch (InventoryServiceException e) {
|
| - |
|
231 |
logger.error("Error while getting the items from the inventory", e);
|
| - |
|
232 |
return null;
|
| 226 |
}
|
233 |
}
|
| 227 |
|
234 |
|
| 228 |
ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
|
235 |
ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
|
| 229 |
|
236 |
|
| 230 |
Workbook wb = new HSSFWorkbook();
|
237 |
Workbook wb = new HSSFWorkbook();
|
| 231 |
|
238 |
|