| Line 1... |
Line 1... |
| 1 |
package in.shop2020.support.controllers;
|
1 |
package in.shop2020.support.controllers;
|
| 2 |
|
2 |
|
| 3 |
import java.io.File;
|
3 |
import java.io.File;
|
| - |
|
4 |
import java.io.FileInputStream;
|
| 4 |
import java.io.IOException;
|
5 |
import java.io.IOException;
|
| 5 |
import java.util.HashMap;
|
6 |
import java.util.HashMap;
|
| 6 |
import java.util.List;
|
7 |
import java.util.List;
|
| 7 |
import java.util.Map;
|
8 |
import java.util.Map;
|
| 8 |
|
9 |
|
| Line 15... |
Line 16... |
| 15 |
import in.shop2020.model.v1.catalog.CatalogServiceException;
|
16 |
import in.shop2020.model.v1.catalog.CatalogServiceException;
|
| 16 |
import in.shop2020.model.v1.catalog.Item;
|
17 |
import in.shop2020.model.v1.catalog.Item;
|
| 17 |
import in.shop2020.model.v1.inventory.AmazonInventorySnapshot;
|
18 |
import in.shop2020.model.v1.inventory.AmazonInventorySnapshot;
|
| 18 |
import in.shop2020.model.v1.catalog.CatalogService.Client;
|
19 |
import in.shop2020.model.v1.catalog.CatalogService.Client;
|
| 19 |
import in.shop2020.model.v1.inventory.InventoryServiceException;
|
20 |
import in.shop2020.model.v1.inventory.InventoryServiceException;
|
| - |
|
21 |
import in.shop2020.model.v1.order.AmazonOrder;
|
| 20 |
import in.shop2020.support.utils.ReportsUtils;
|
22 |
import in.shop2020.support.utils.ReportsUtils;
|
| 21 |
import in.shop2020.thrift.clients.CatalogClient;
|
23 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 22 |
import in.shop2020.thrift.clients.InventoryClient;
|
24 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 23 |
import in.shop2020.thrift.clients.LogisticsClient;
|
25 |
import in.shop2020.thrift.clients.LogisticsClient;
|
| - |
|
26 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 24 |
import in.shop2020.logistics.DeliveryType;
|
27 |
import in.shop2020.logistics.DeliveryType;
|
| 25 |
import in.shop2020.logistics.LogisticsInfo;
|
28 |
import in.shop2020.logistics.LogisticsInfo;
|
| 26 |
import in.shop2020.logistics.LogisticsServiceException;
|
29 |
import in.shop2020.logistics.LogisticsServiceException;
|
| 27 |
import in.shop2020.logistics.PickUpType;
|
30 |
import in.shop2020.logistics.PickUpType;
|
| 28 |
|
31 |
|
| 29 |
import org.apache.commons.io.FileUtils;
|
32 |
import org.apache.commons.io.FileUtils;
|
| 30 |
import org.apache.commons.lang.xwork.StringUtils;
|
33 |
import org.apache.commons.lang.xwork.StringUtils;
|
| - |
|
34 |
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
| - |
|
35 |
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
| 31 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
36 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
| 32 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
37 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
| 33 |
import org.apache.struts2.convention.annotation.Result;
|
38 |
import org.apache.struts2.convention.annotation.Result;
|
| 34 |
import org.apache.struts2.convention.annotation.Results;
|
39 |
import org.apache.struts2.convention.annotation.Results;
|
| 35 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
40 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
| 36 |
import org.apache.thrift.TException;
|
41 |
import org.apache.thrift.TException;
|
| - |
|
42 |
import org.apache.thrift.transport.TTransportException;
|
| 37 |
import org.slf4j.Logger;
|
43 |
import org.slf4j.Logger;
|
| 38 |
import org.slf4j.LoggerFactory;
|
44 |
import org.slf4j.LoggerFactory;
|
| 39 |
|
45 |
|
| 40 |
import com.opensymphony.xwork2.ValidationAwareSupport;
|
46 |
import com.opensymphony.xwork2.ValidationAwareSupport;
|
| 41 |
|
47 |
|
| Line 114... |
Line 120... |
| 114 |
//setUrl("/amazon-list/");
|
120 |
//setUrl("/amazon-list/");
|
| 115 |
return "index";
|
121 |
return "index";
|
| 116 |
|
122 |
|
| 117 |
}
|
123 |
}
|
| 118 |
|
124 |
|
| 119 |
public String upload() throws IOException {
|
125 |
public String upload() throws IOException, TException {
|
| 120 |
File fileToCreate = new File("/tmp/", "Amazon-shipping.xls");
|
126 |
File fileToCreate = new File("/tmp/", "Amazon-shipping.xls");
|
| 121 |
FileUtils.copyFile(this.file, fileToCreate);
|
127 |
FileUtils.copyFile(this.file, fileToCreate);
|
| - |
|
128 |
FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
|
| - |
|
129 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
| - |
|
130 |
HSSFSheet sheet = workbook.getSheetAt(0);
|
| - |
|
131 |
Map<Long,String> amazonOrderMap = new HashMap<Long,String>();
|
| - |
|
132 |
for (int iterator=sheet.getFirstRowNum();iterator<=sheet.getLastRowNum();iterator++){
|
| - |
|
133 |
TransactionClient tcl = new TransactionClient();
|
| - |
|
134 |
List<AmazonOrder> orders = tcl.getClient().getAmazonOrderByAmazonOrderId(sheet.getRow(iterator).getCell(0).getStringCellValue());
|
| - |
|
135 |
for (AmazonOrder order : orders){
|
| - |
|
136 |
if (StringUtils.equals(order.getStatus(), "Acknowledgement-Sent")){
|
| - |
|
137 |
amazonOrderMap.put(order.getOrderId(), sheet.getRow(iterator).getCell(1).getStringCellValue());
|
| - |
|
138 |
}
|
| - |
|
139 |
}
|
| - |
|
140 |
}
|
| - |
|
141 |
TransactionClient tcl = new TransactionClient();
|
| - |
|
142 |
tcl.getClient().updateTimestampForAmazonOrder(amazonOrderMap);
|
| 122 |
return "authsuccess";
|
143 |
return "authsuccess";
|
| 123 |
}
|
144 |
}
|
| 124 |
|
145 |
|
| 125 |
private void changeItemInventory() throws NumberFormatException, TException {
|
146 |
private void changeItemInventory() throws NumberFormatException, TException {
|
| 126 |
Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
147 |
Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|