| Line 168... |
Line 168... |
| 168 |
}
|
168 |
}
|
| 169 |
}
|
169 |
}
|
| 170 |
else{
|
170 |
else{
|
| 171 |
System.out.println("No inventory in FBA");
|
171 |
System.out.println("No inventory in FBA");
|
| 172 |
}
|
172 |
}
|
| 173 |
Map<Long,Double> itemIdOurPriceMap = new HashMap<Long,Double>();
|
173 |
Map<Long,PriceAtDate> itemIdOurPriceMap = new HashMap<Long,PriceAtDate>();
|
| 174 |
Map<Long,Double> itemIdSalePriceMap = new HashMap<Long,Double>();
|
174 |
Map<Long,PriceAtDate> itemIdSalePriceMap = new HashMap<Long,PriceAtDate>();
|
| 175 |
Map<Long,Double> itemIdminFBAPriceMap = new HashMap<Long,Double>();
|
175 |
Map<Long,PriceAtDate> itemIdminFBAPriceMap = new HashMap<Long,PriceAtDate>();
|
| 176 |
Map<Long,Double> itemIdminMFNPriceMap = new HashMap<Long,Double>();
|
176 |
Map<Long,PriceAtDate> itemIdminMFNPriceMap = new HashMap<Long,PriceAtDate>();
|
| 177 |
count=1;
|
177 |
count=1;
|
| 178 |
while ((nextLine = inventoryhealthreportreader.readNext()) != null ) {
|
178 |
while ((nextLine = inventoryhealthreportreader.readNext()) != null ) {
|
| 179 |
if(count!=1){
|
179 |
if(count!=1){
|
| 180 |
//System.out.println(nextLine[1] +" "+ nextLine[31] +" " + nextLine[32] + " " + nextLine[34]);
|
180 |
//System.out.println(nextLine[1] +" "+ nextLine[31] +" " + nextLine[32] + " " + nextLine[34]);
|
| - |
|
181 |
SimpleDateFormat istFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
| - |
|
182 |
istFormatter .setLenient(false);
|
| - |
|
183 |
TimeZone zone= TimeZone.getTimeZone("GMT");
|
| - |
|
184 |
istFormatter.setTimeZone(zone);
|
| - |
|
185 |
Date date = istFormatter.parse(nextLine[0]);
|
| 181 |
Long item_id = Long.parseLong(nextLine[1].replaceAll("FBA",""));
|
186 |
Long item_id = Long.parseLong(nextLine[1].replaceAll("FBA",""));
|
| 182 |
Double ourPrice = null;
|
187 |
Double ourPrice = null;
|
| 183 |
Double minFBAPrice= null;
|
188 |
Double minFBAPrice= null;
|
| 184 |
Double minMFNPrice= null;
|
189 |
Double minMFNPrice= null;
|
| 185 |
Double salePrice= null;
|
190 |
Double salePrice= null;
|
| 186 |
|
- |
|
| 187 |
if(nextLine[30].length() >0){
|
191 |
if(nextLine[30].length() >0){
|
| 188 |
ourPrice = Double.parseDouble(nextLine[30]);
|
192 |
ourPrice = Double.parseDouble(nextLine[30]);
|
| - |
|
193 |
if(itemIdOurPriceMap.containsKey(item_id) && itemIdOurPriceMap.get(item_id).getDate().before(date)){
|
| - |
|
194 |
itemIdOurPriceMap.get(item_id).setDate(date);
|
| - |
|
195 |
itemIdOurPriceMap.get(item_id).setPrice(ourPrice);
|
| - |
|
196 |
}
|
| - |
|
197 |
else{
|
| - |
|
198 |
PriceAtDate priceAtDate= new PriceAtDate();
|
| - |
|
199 |
priceAtDate.setDate(date);
|
| - |
|
200 |
priceAtDate.setPrice(ourPrice);
|
| 189 |
itemIdOurPriceMap.put(item_id,ourPrice);
|
201 |
itemIdOurPriceMap.put(item_id,priceAtDate);
|
| - |
|
202 |
}
|
| 190 |
}
|
203 |
}
|
| 191 |
if(nextLine[31].length() >0){
|
204 |
if(nextLine[31].length() >0){
|
| 192 |
salePrice = Double.parseDouble(nextLine[31]);
|
205 |
salePrice = Double.parseDouble(nextLine[31]);
|
| - |
|
206 |
if(itemIdSalePriceMap.containsKey(item_id) && itemIdSalePriceMap.get(item_id).getDate().before(date)){
|
| - |
|
207 |
itemIdSalePriceMap.get(item_id).setDate(date);
|
| - |
|
208 |
itemIdSalePriceMap.get(item_id).setPrice(ourPrice);
|
| - |
|
209 |
}
|
| - |
|
210 |
else{
|
| - |
|
211 |
PriceAtDate priceAtDate= new PriceAtDate();
|
| - |
|
212 |
priceAtDate.setDate(date);
|
| - |
|
213 |
priceAtDate.setPrice(ourPrice);
|
| 193 |
itemIdSalePriceMap.put(item_id,salePrice);
|
214 |
itemIdSalePriceMap.put(item_id,priceAtDate);
|
| - |
|
215 |
}
|
| 194 |
}
|
216 |
}
|
| 195 |
if(nextLine[32].length() >0){
|
217 |
if(nextLine[32].length() >0){
|
| 196 |
minFBAPrice = Double.parseDouble(nextLine[32]);
|
218 |
minFBAPrice = Double.parseDouble(nextLine[32]);
|
| - |
|
219 |
if(itemIdminFBAPriceMap.containsKey(item_id) && itemIdminFBAPriceMap.get(item_id).getDate().before(date)){
|
| - |
|
220 |
itemIdminFBAPriceMap.get(item_id).setDate(date);
|
| - |
|
221 |
itemIdminFBAPriceMap.get(item_id).setPrice(ourPrice);
|
| - |
|
222 |
}
|
| - |
|
223 |
else{
|
| - |
|
224 |
PriceAtDate priceAtDate= new PriceAtDate();
|
| - |
|
225 |
priceAtDate.setDate(date);
|
| - |
|
226 |
priceAtDate.setPrice(ourPrice);
|
| 197 |
itemIdminFBAPriceMap.put(item_id,minFBAPrice);
|
227 |
itemIdminFBAPriceMap.put(item_id,priceAtDate);
|
| - |
|
228 |
}
|
| 198 |
}
|
229 |
}
|
| 199 |
if(nextLine[34].length() >0){
|
230 |
if(nextLine[34].length() >0){
|
| 200 |
minMFNPrice = Double.parseDouble(nextLine[34]);
|
231 |
minMFNPrice = Double.parseDouble(nextLine[34]);
|
| - |
|
232 |
if(itemIdminMFNPriceMap.containsKey(item_id) && itemIdminMFNPriceMap.get(item_id).getDate().before(date)){
|
| - |
|
233 |
itemIdminMFNPriceMap.get(item_id).setDate(date);
|
| - |
|
234 |
itemIdminMFNPriceMap.get(item_id).setPrice(ourPrice);
|
| - |
|
235 |
}
|
| - |
|
236 |
else{
|
| - |
|
237 |
PriceAtDate priceAtDate= new PriceAtDate();
|
| - |
|
238 |
priceAtDate.setDate(date);
|
| - |
|
239 |
priceAtDate.setPrice(ourPrice);
|
| 201 |
itemIdminMFNPriceMap.put(item_id,minMFNPrice);
|
240 |
itemIdminMFNPriceMap.put(item_id,priceAtDate);
|
| - |
|
241 |
}
|
| 202 |
}
|
242 |
}
|
| 203 |
}
|
243 |
}
|
| 204 |
count++;
|
244 |
count++;
|
| 205 |
}
|
245 |
}
|
| 206 |
boolean oos;
|
246 |
boolean oos;
|
| Line 231... |
Line 271... |
| 231 |
amazon_item = catalogClient.getAmazonItemDetails(item_id);
|
271 |
amazon_item = catalogClient.getAmazonItemDetails(item_id);
|
| 232 |
}
|
272 |
}
|
| 233 |
else{
|
273 |
else{
|
| 234 |
continue;
|
274 |
continue;
|
| 235 |
}
|
275 |
}
|
| 236 |
if(itemIdSalePriceMap.containsKey(item_id) && itemIdSalePriceMap.get(item_id)!=0){
|
276 |
if(itemIdSalePriceMap.containsKey(item_id) && itemIdSalePriceMap.get(item_id).getPrice()!=0){
|
| 237 |
amazonfbasalessnapshot.setSalePrice(itemIdSalePriceMap.get(item_id));
|
277 |
amazonfbasalessnapshot.setSalePrice(itemIdSalePriceMap.get(item_id).getPrice());
|
| 238 |
}
|
278 |
}
|
| 239 |
else{
|
279 |
else{
|
| 240 |
amazonfbasalessnapshot.setSalePrice(0.0);
|
280 |
amazonfbasalessnapshot.setSalePrice(0.0);
|
| 241 |
}
|
281 |
}
|
| 242 |
if(itemIdminMFNPriceMap.containsKey(item_id) && itemIdminMFNPriceMap.get(item_id)!=0){
|
282 |
if(itemIdminMFNPriceMap.containsKey(item_id) && itemIdminMFNPriceMap.get(item_id).getPrice()!=0){
|
| 243 |
amazonfbasalessnapshot.setMinMfnPrice(itemIdminMFNPriceMap.get(item_id));
|
283 |
amazonfbasalessnapshot.setMinMfnPrice(itemIdminMFNPriceMap.get(item_id).getPrice());
|
| 244 |
}
|
284 |
}
|
| 245 |
else{
|
285 |
else{
|
| 246 |
amazonfbasalessnapshot.setMinMfnPrice(0.0);
|
286 |
amazonfbasalessnapshot.setMinMfnPrice(0.0);
|
| 247 |
}
|
287 |
}
|
| 248 |
if(itemIdminFBAPriceMap.containsKey(item_id) && itemIdminFBAPriceMap.get(item_id)!=0){
|
288 |
if(itemIdminFBAPriceMap.containsKey(item_id) && itemIdminFBAPriceMap.get(item_id).getPrice()!=0){
|
| 249 |
amazonfbasalessnapshot.setMinFbaPrice(itemIdminFBAPriceMap.get(item_id));
|
289 |
amazonfbasalessnapshot.setMinFbaPrice(itemIdminFBAPriceMap.get(item_id).getPrice());
|
| 250 |
}
|
290 |
}
|
| 251 |
else{
|
291 |
else{
|
| 252 |
amazonfbasalessnapshot.setMinFbaPrice(0.0);
|
292 |
amazonfbasalessnapshot.setMinFbaPrice(0.0);
|
| 253 |
}
|
293 |
}
|
| 254 |
if(itemIdOurPriceMap.containsKey(item_id) && itemIdOurPriceMap.get(item_id)!=0){
|
294 |
if(itemIdOurPriceMap.containsKey(item_id) && itemIdOurPriceMap.get(item_id).getPrice()!=0){
|
| 255 |
amazonfbasalessnapshot.setOurPrice(itemIdOurPriceMap.get(item_id));
|
295 |
amazonfbasalessnapshot.setOurPrice(itemIdOurPriceMap.get(item_id).getPrice());
|
| 256 |
}
|
296 |
}
|
| 257 |
else{
|
297 |
else{
|
| 258 |
amazonfbasalessnapshot.setOurPrice(amazon_item.getFbaPrice());
|
298 |
amazonfbasalessnapshot.setOurPrice(amazon_item.getFbaPrice());
|
| 259 |
}
|
299 |
}
|
| 260 |
amazonfbasalessnapshot.setAmazonFbaInventory(inventory);
|
300 |
amazonfbasalessnapshot.setAmazonFbaInventory(inventory);
|
| Line 269... |
Line 309... |
| 269 |
e.printStackTrace();
|
309 |
e.printStackTrace();
|
| 270 |
} catch (TException e) {
|
310 |
} catch (TException e) {
|
| 271 |
// TODO Auto-generated catch block
|
311 |
// TODO Auto-generated catch block
|
| 272 |
e.printStackTrace();
|
312 |
e.printStackTrace();
|
| 273 |
}
|
313 |
}
|
| - |
|
314 |
|
| 274 |
}
|
315 |
}
|
| 275 |
|
316 |
|
| 276 |
|
317 |
|
| 277 |
public static Double getPercentageDifferenceFromMinimumPrice(AmazonFbaSalesSnapshot snapshot){
|
318 |
public static Double getPercentageDifferenceFromMinimumPrice(AmazonFbaSalesSnapshot snapshot){
|
| 278 |
Double minPrice = getMinimumSalePriceOnAmazonFBA(snapshot);
|
319 |
Double minPrice = getMinimumSalePriceOnAmazonFBA(snapshot);
|