| Line 126... |
Line 126... |
| 126 |
File fileToCreate = new File("/tmp/", "Amazon-shipping.xls");
|
126 |
File fileToCreate = new File("/tmp/", "Amazon-shipping.xls");
|
| 127 |
FileUtils.copyFile(this.file, fileToCreate);
|
127 |
FileUtils.copyFile(this.file, fileToCreate);
|
| 128 |
FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
|
128 |
FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
|
| 129 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
129 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
| 130 |
HSSFSheet sheet = workbook.getSheetAt(0);
|
130 |
HSSFSheet sheet = workbook.getSheetAt(0);
|
| 131 |
Map<Long,String> amazonOrderMap = new HashMap<Long,String>();
|
131 |
Map<Long,Map<String,String>> amazonOrderMap = new HashMap<Long,Map<String,String>>();
|
| 132 |
for (int iterator=sheet.getFirstRowNum();iterator<=sheet.getLastRowNum();iterator++){
|
132 |
for (int iterator=sheet.getFirstRowNum();iterator<=sheet.getLastRowNum();iterator++){
|
| 133 |
TransactionClient tcl = new TransactionClient();
|
133 |
TransactionClient tcl = new TransactionClient();
|
| 134 |
List<AmazonOrder> orders = tcl.getClient().getAmazonOrderByAmazonOrderId(sheet.getRow(iterator).getCell(0).getStringCellValue());
|
134 |
List<AmazonOrder> orders = tcl.getClient().getAmazonOrderByAmazonOrderId(sheet.getRow(iterator).getCell(0).getStringCellValue());
|
| 135 |
for (AmazonOrder order : orders){
|
135 |
for (AmazonOrder order : orders){
|
| 136 |
if (StringUtils.equals(order.getStatus(), "Order-Payment-Success")){
|
136 |
if (StringUtils.equals(order.getStatus(), "Order-Payment-Success")){
|
| - |
|
137 |
Map<String,String> dateMap = new HashMap<String,String>();
|
| 137 |
amazonOrderMap.put(order.getOrderId(), sheet.getRow(iterator).getCell(1).getStringCellValue());
|
138 |
dateMap.put(sheet.getRow(iterator).getCell(1).getStringCellValue(), sheet.getRow(iterator).getCell(2).getStringCellValue());
|
| - |
|
139 |
amazonOrderMap.put(order.getOrderId(), dateMap);
|
| 138 |
}
|
140 |
}
|
| 139 |
}
|
141 |
}
|
| 140 |
}
|
142 |
}
|
| 141 |
TransactionClient tcl = new TransactionClient();
|
143 |
TransactionClient tcl = new TransactionClient();
|
| 142 |
tcl.getClient().updateTimestampForAmazonOrder(amazonOrderMap);
|
144 |
tcl.getClient().updateTimestampForAmazonOrder(amazonOrderMap);
|
| Line 192... |
Line 194... |
| 192 |
LogisticsClient logisticsClient = new LogisticsClient();
|
194 |
LogisticsClient logisticsClient = new LogisticsClient();
|
| 193 |
return logisticsClient.getClient().getLogisticsInfo("110001", Long.valueOf(itemId), DeliveryType.COD, PickUpType.COURIER).getShippingTime();
|
195 |
return logisticsClient.getClient().getLogisticsInfo("110001", Long.valueOf(itemId), DeliveryType.COD, PickUpType.COURIER).getShippingTime();
|
| 194 |
|
196 |
|
| 195 |
}
|
197 |
}
|
| 196 |
|
198 |
|
| 197 |
public Map<Long, Item> getAliveItemMap() throws TTransportException{
|
199 |
public Map<Long, Item> getAliveItemMap() throws TTransportException, InterruptedException{
|
| 198 |
Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
- |
|
| 199 |
List<Item> itemList = null;
|
200 |
List<Item> itemList = null;
|
| 200 |
int retry=0;
|
201 |
int retry=0;
|
| 201 |
while(true){
|
202 |
while(true){
|
| 202 |
try {
|
203 |
try {
|
| 203 |
if (retry==3)
|
204 |
if (retry==3)
|
| - |
|
205 |
break;
|
| - |
|
206 |
Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| - |
|
207 |
itemList = CatalogClient.getAllAliveItems();
|
| 204 |
break;
|
208 |
break;
|
| 205 |
itemList = CatalogClient.getAllAliveItems();
|
209 |
} catch ( NullPointerException e) {
|
| 206 |
break;
|
210 |
retry++;
|
| - |
|
211 |
System.out.println("Unable to fetch alive items.Retrying");
|
| - |
|
212 |
Thread.sleep(3000);
|
| - |
|
213 |
e.printStackTrace();
|
| 207 |
} catch (TException e) {
|
214 |
} catch (TException e) {
|
| 208 |
retry++;
|
215 |
retry++;
|
| - |
|
216 |
System.out.println("Unable to fetch alive items.Retrying");
|
| - |
|
217 |
Thread.sleep(3000);
|
| 209 |
e.printStackTrace();
|
218 |
e.printStackTrace();
|
| 210 |
}
|
219 |
}
|
| 211 |
}
|
220 |
}
|
| 212 |
Map<Long, Item> itemMap = new HashMap<Long, Item>();
|
221 |
Map<Long, Item> itemMap = new HashMap<Long, Item>();
|
| 213 |
for (Item o : itemList) {
|
222 |
for (Item o : itemList) {
|
| 214 |
itemMap.put((Long) o.getId(), o);
|
223 |
itemMap.put((Long) o.getId(), o);
|
| 215 |
}
|
224 |
}
|