| Line 23... |
Line 23... |
| 23 |
import au.com.bytecode.opencsv.CSVReader;
|
23 |
import au.com.bytecode.opencsv.CSVReader;
|
| 24 |
|
24 |
|
| 25 |
import com.amazonaws.mws.MarketplaceWebService;
|
25 |
import com.amazonaws.mws.MarketplaceWebService;
|
| 26 |
import com.amazonaws.mws.MarketplaceWebServiceClient;
|
26 |
import com.amazonaws.mws.MarketplaceWebServiceClient;
|
| 27 |
import com.amazonaws.mws.MarketplaceWebServiceConfig;
|
27 |
import com.amazonaws.mws.MarketplaceWebServiceConfig;
|
| - |
|
28 |
import com.amazonaws.mws.MarketplaceWebServiceException;
|
| 28 |
import com.amazonaws.mws.model.GetReportListRequest;
|
29 |
import com.amazonaws.mws.model.GetReportListRequest;
|
| 29 |
import com.amazonaws.mws.model.GetReportRequest;
|
30 |
import com.amazonaws.mws.model.GetReportRequest;
|
| 30 |
import com.amazonaws.mws.model.IdList;
|
31 |
import com.amazonaws.mws.model.IdList;
|
| 31 |
import com.amazonaws.mws.model.RequestReportRequest;
|
32 |
import com.amazonaws.mws.model.RequestReportRequest;
|
| 32 |
|
33 |
|
| Line 129... |
Line 130... |
| 129 |
//request.setEndDate(endDate);
|
130 |
//request.setEndDate(endDate);
|
| 130 |
// @TODO: set additional request parameters here
|
131 |
// @TODO: set additional request parameters here
|
| 131 |
Map<String,String> requestIdreportIdmap;
|
132 |
Map<String,String> requestIdreportIdmap;
|
| 132 |
///Request report
|
133 |
///Request report
|
| 133 |
while(true){
|
134 |
while(true){
|
| - |
|
135 |
String requestId = null;
|
| - |
|
136 |
try {
|
| 134 |
String requestId = RequestReportSample.invokeRequestReport(service, request);
|
137 |
requestId = RequestReportSample.invokeRequestReport(service, request);
|
| - |
|
138 |
} catch (MarketplaceWebServiceException e1) {
|
| - |
|
139 |
// TODO Auto-generated catch block
|
| - |
|
140 |
e1.printStackTrace();
|
| - |
|
141 |
}
|
| 135 |
while(true){
|
142 |
while(true){
|
| 136 |
GetReportListRequest requestreportlist = new GetReportListRequest();
|
143 |
GetReportListRequest requestreportlist = new GetReportListRequest();
|
| 137 |
requestreportlist.setMerchant( merchantId );
|
144 |
requestreportlist.setMerchant( merchantId );
|
| 138 |
final IdList requestIdList = new IdList(Arrays.asList(requestId));
|
145 |
final IdList requestIdList = new IdList(Arrays.asList(requestId));
|
| 139 |
requestreportlist.setReportRequestIdList(requestIdList);
|
146 |
requestreportlist.setReportRequestIdList(requestIdList);
|
| Line 146... |
Line 153... |
| 146 |
///Fetch report only if it is ready
|
153 |
///Fetch report only if it is ready
|
| 147 |
if(requestIdreportIdmap.get(requestId)!=null){
|
154 |
if(requestIdreportIdmap.get(requestId)!=null){
|
| 148 |
requestreport.setReportId( requestIdreportIdmap.get(requestId) );
|
155 |
requestreport.setReportId( requestIdreportIdmap.get(requestId) );
|
| 149 |
OutputStream report=null;
|
156 |
OutputStream report=null;
|
| 150 |
try {
|
157 |
try {
|
| 151 |
report = new FileOutputStream( "/home/vikram/Desktop/amazoninventoryreport.txt" );
|
158 |
report = new FileOutputStream( "/home/amazoninventoryreport.csv" );
|
| 152 |
} catch (FileNotFoundException e) {
|
159 |
} catch (FileNotFoundException e) {
|
| 153 |
// TODO Auto-generated catch block
|
160 |
// TODO Auto-generated catch block
|
| 154 |
e.printStackTrace();
|
161 |
e.printStackTrace();
|
| 155 |
}
|
162 |
}
|
| 156 |
requestreport.setReportOutputStream( report );
|
163 |
requestreport.setReportOutputStream( report );
|
| 157 |
GetReportSample.invokeGetReport(service, requestreport);
|
164 |
GetReportSample.invokeGetReport(service, requestreport);
|
| 158 |
System.out.println("Report ready please check");
|
165 |
//System.out.println("Report ready please check");
|
| 159 |
CSVReader reader = null;
|
166 |
CSVReader reader = null;
|
| 160 |
try {
|
167 |
try {
|
| 161 |
reader = new CSVReader(new FileReader("/home/vikram/Desktop/amazoninventoryreport.txt"),'\t');
|
168 |
//reader = new CSVReader(new FileReader("/home/vikram/Desktop/amazoninventoryreport.txt"),'\t');
|
| - |
|
169 |
reader = new CSVReader(new FileReader("/home/amazoninventoryreport.csv"),'\t');
|
| 162 |
} catch (FileNotFoundException e) {
|
170 |
} catch (FileNotFoundException e) {
|
| 163 |
// TODO Auto-generated catch block
|
171 |
// TODO Auto-generated catch block
|
| 164 |
e.printStackTrace();
|
172 |
e.printStackTrace();
|
| 165 |
}
|
173 |
}
|
| 166 |
String [] nextLine;
|
174 |
String [] nextLine;
|
| Line 172... |
Line 180... |
| 172 |
e.printStackTrace();
|
180 |
e.printStackTrace();
|
| 173 |
}in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
181 |
}in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 174 |
try {
|
182 |
try {
|
| 175 |
while ((nextLine = reader.readNext()) != null) {
|
183 |
while ((nextLine = reader.readNext()) != null) {
|
| 176 |
// nextLine[] is an array of values from the line
|
184 |
// nextLine[] is an array of values from the line
|
| 177 |
System.out.println(nextLine[0] +" "+ nextLine[1]+" " + nextLine[2]+" " + nextLine[3] +" "+ nextLine[4] +" " + nextLine[5]);
|
185 |
//System.out.println(nextLine[0] +" "+ nextLine[1]+" " + nextLine[2]+" " + nextLine[3] +" "+ nextLine[4] +" " + nextLine[5]);
|
| 178 |
if(nextLine[0].startsWith("FBA") && nextLine[4].equalsIgnoreCase("SELLABLE") ){
|
186 |
if(nextLine[0].startsWith("FBA") && nextLine[4].equalsIgnoreCase("SELLABLE") ){
|
| 179 |
//System.out.println("Item ID" + nextLine[0].replaceAll("FBA","") + "---"+"Inventory" + nextLine[5]);
|
187 |
//System.out.println("Item ID" + nextLine[0].replaceAll("FBA","") + "---"+"Inventory" + nextLine[5]);
|
| 180 |
AmazonFbaInventorySnapshot amazonfbainventorysnapshot = new AmazonFbaInventorySnapshot() ;
|
188 |
AmazonFbaInventorySnapshot amazonfbainventorysnapshot = new AmazonFbaInventorySnapshot() ;
|
| 181 |
amazonfbainventorysnapshot.setAvailability(Long.parseLong(nextLine[5]));
|
189 |
amazonfbainventorysnapshot.setAvailability(Long.parseLong(nextLine[5]));
|
| 182 |
amazonfbainventorysnapshot.setItem_id(Long.parseLong(nextLine[0].replaceAll("FBA","")));
|
190 |
amazonfbainventorysnapshot.setItem_id(Long.parseLong(nextLine[0].replaceAll("FBA","")));
|
| Line 192... |
Line 200... |
| 192 |
e.printStackTrace();
|
200 |
e.printStackTrace();
|
| 193 |
}
|
201 |
}
|
| 194 |
break;
|
202 |
break;
|
| 195 |
}
|
203 |
}
|
| 196 |
else{
|
204 |
else{
|
| 197 |
System.out.println("Report not ready");
|
205 |
//System.out.println("Report not ready");
|
| 198 |
try {
|
206 |
try {
|
| 199 |
Thread.sleep(5*60*1000);
|
207 |
Thread.sleep(5*60*1000);
|
| 200 |
} catch (InterruptedException e) {
|
208 |
} catch (InterruptedException e) {
|
| 201 |
// TODO Auto-generated catch block
|
209 |
// TODO Auto-generated catch block
|
| 202 |
e.printStackTrace();
|
210 |
e.printStackTrace();
|