| Line 96... |
Line 96... |
| 96 |
* @param inventoryAge
|
96 |
* @param inventoryAge
|
| 97 |
* @return
|
97 |
* @return
|
| 98 |
*/
|
98 |
*/
|
| 99 |
private File createFile(List<InventoryAge> inventoryAge, List<InventoryAge> inventoryAgeAmazon) {
|
99 |
private File createFile(List<InventoryAge> inventoryAge, List<InventoryAge> inventoryAgeAmazon) {
|
| 100 |
Map<Long,InventoryAge> inventoryAgeMap = new HashMap<Long,InventoryAge>();
|
100 |
Map<Long,InventoryAge> inventoryAgeMap = new HashMap<Long,InventoryAge>();
|
| 101 |
|
101 |
|
| 102 |
for(InventoryAge invAge : inventoryAge){
|
102 |
for(InventoryAge invAge : inventoryAge){
|
| 103 |
inventoryAgeMap.put(invAge.getItemId(), invAge);
|
103 |
inventoryAgeMap.put(invAge.getItemId(), invAge);
|
| 104 |
}
|
104 |
}
|
| 105 |
|
105 |
|
| 106 |
for(InventoryAge invAge : inventoryAgeAmazon){
|
106 |
for(InventoryAge invAge : inventoryAgeAmazon){
|
| 107 |
if(inventoryAgeMap.containsKey(invAge.getItemId())){
|
107 |
if(inventoryAgeMap.containsKey(invAge.getItemId())){
|
| 108 |
InventoryAge invAgeObj = inventoryAgeMap.get(invAge.getItemId());
|
108 |
InventoryAge invAgeObj = inventoryAgeMap.get(invAge.getItemId());
|
| 109 |
invAgeObj.setFreshCount(invAgeObj.getFreshCount()+ invAge.getFreshCount());
|
109 |
invAgeObj.setFreshCount(invAgeObj.getFreshCount()+ invAge.getFreshCount());
|
| 110 |
invAgeObj.setOneToTwoCount(invAgeObj.getOneToTwoCount() + invAge.getOneToTwoCount());
|
110 |
invAgeObj.setOneToTwoCount(invAgeObj.getOneToTwoCount() + invAge.getOneToTwoCount());
|
| 111 |
invAgeObj.setTwoToThreeCount(invAgeObj.getTwoToThreeCount() + invAge.getTwoToThreeCount());
|
111 |
invAgeObj.setTwoToThreeCount(invAgeObj.getTwoToThreeCount() + invAge.getTwoToThreeCount());
|
| 112 |
|
112 |
|
| 113 |
invAgeObj.setThreeToFourCount(invAgeObj.getThreeToFourCount() + invAge.getThreeToFourCount());
|
113 |
invAgeObj.setThreeToFourCount(invAgeObj.getThreeToFourCount() + invAge.getThreeToFourCount());
|
| 114 |
invAgeObj.setFourPlusCount(invAgeObj.getFourPlusCount() + invAge.getFourPlusCount());
|
114 |
invAgeObj.setFourPlusCount(invAgeObj.getFourPlusCount() + invAge.getFourPlusCount());
|
| 115 |
invAgeObj.setThreeMonthPlusCount(invAgeObj.getThreeMonthPlusCount() + invAge.getThreeMonthPlusCount());
|
115 |
invAgeObj.setThreeMonthPlusCount(invAgeObj.getThreeMonthPlusCount() + invAge.getThreeMonthPlusCount());
|
| 116 |
invAgeObj.setSixMonthPlusCount(invAgeObj.getSixMonthPlusCount() + invAge.getSixMonthPlusCount());
|
116 |
invAgeObj.setSixMonthPlusCount(invAgeObj.getSixMonthPlusCount() + invAge.getSixMonthPlusCount());
|
| 117 |
invAgeObj.setZeroToThreeMonthCount(invAgeObj.getZeroToThreeMonthCount() + invAge.getZeroToThreeMonthCount());
|
117 |
invAgeObj.setZeroToThreeMonthCount(invAgeObj.getZeroToThreeMonthCount() + invAge.getZeroToThreeMonthCount());
|
| Line 120... |
Line 120... |
| 120 |
invAgeObj.setTwelveMonthsPlusCount(invAgeObj.getTwelveMonthsPlusCount() + invAge.getTwelveMonthsPlusCount());
|
120 |
invAgeObj.setTwelveMonthsPlusCount(invAgeObj.getTwelveMonthsPlusCount() + invAge.getTwelveMonthsPlusCount());
|
| 121 |
invAgeObj.setZeroPlusCount(invAgeObj.getZeroPlusCount() + invAge.getZeroPlusCount());
|
121 |
invAgeObj.setZeroPlusCount(invAgeObj.getZeroPlusCount() + invAge.getZeroPlusCount());
|
| 122 |
invAgeObj.setOnePlusCount(invAgeObj.getOnePlusCount() + invAge.getOnePlusCount());
|
122 |
invAgeObj.setOnePlusCount(invAgeObj.getOnePlusCount() + invAge.getOnePlusCount());
|
| 123 |
invAgeObj.setZeroPlusCost(invAgeObj.getZeroPlusCost() + invAge.getZeroPlusCost());
|
123 |
invAgeObj.setZeroPlusCost(invAgeObj.getZeroPlusCost() + invAge.getZeroPlusCost());
|
| 124 |
invAgeObj.setOnePlusCost(invAgeObj.getOnePlusCost() + invAge.getOnePlusCost());
|
124 |
invAgeObj.setOnePlusCost(invAgeObj.getOnePlusCost() + invAge.getOnePlusCost());
|
| 125 |
|
125 |
|
| 126 |
inventoryAgeMap.put(invAge.getItemId(), invAgeObj);
|
126 |
inventoryAgeMap.put(invAge.getItemId(), invAgeObj);
|
| 127 |
|
127 |
|
| 128 |
}
|
128 |
}
|
| 129 |
else{
|
129 |
else{
|
| 130 |
inventoryAgeMap.put(invAge.getItemId(), invAge);
|
130 |
inventoryAgeMap.put(invAge.getItemId(), invAge);
|
| 131 |
}
|
131 |
}
|
| 132 |
}
|
132 |
}
|
| Line 201... |
Line 201... |
| 201 |
|
201 |
|
| 202 |
List<InventoryAge> amazonInventoryAge = new ArrayList<InventoryAge>();
|
202 |
List<InventoryAge> amazonInventoryAge = new ArrayList<InventoryAge>();
|
| 203 |
try{
|
203 |
try{
|
| 204 |
InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
204 |
InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
| 205 |
List<AmazonFbaInventorySnapshot> amazonFbaInventorySnapshot = inventoryClient.getAllAmazonFbaItemInventory();
|
205 |
List<AmazonFbaInventorySnapshot> amazonFbaInventorySnapshot = inventoryClient.getAllAmazonFbaItemInventory();
|
| 206 |
|
206 |
|
| 207 |
List<Long> itemIds = new ArrayList<Long>();
|
207 |
List<Long> itemIds = new ArrayList<Long>();
|
| - |
|
208 |
|
| 208 |
for(AmazonFbaInventorySnapshot invSnapShot : amazonFbaInventorySnapshot)
|
209 |
for(AmazonFbaInventorySnapshot invSnapShot : amazonFbaInventorySnapshot){
|
| - |
|
210 |
logger.info("AmazonFbaInventorySnapshot entry " + invSnapShot.getItem_id());
|
| - |
|
211 |
if(!itemIds.contains(invSnapShot.getItem_id())){
|
| 209 |
itemIds.add(invSnapShot.getItem_id());
|
212 |
itemIds.add(invSnapShot.getItem_id());
|
| - |
|
213 |
}
|
| - |
|
214 |
else{
|
| - |
|
215 |
logger.info("AmazonFbaInventorySnapshot entry skipped" + invSnapShot.getItem_id());
|
| - |
|
216 |
}
|
| - |
|
217 |
}
|
| - |
|
218 |
|
| 210 |
Client client = new WarehouseClient().getClient();
|
219 |
Client client = new WarehouseClient().getClient();
|
| 211 |
|
220 |
|
| 212 |
List<AmazonTransferredSkuDetail> amazonTransferredSkuDetails = client.getAmazonTransferredSkuDetails(itemIds);
|
221 |
List<AmazonTransferredSkuDetail> amazonTransferredSkuDetails = client.getAmazonTransferredSkuDetails(itemIds);
|
| 213 |
Map<Long, AmazonFbaInventorySnapshot> amazonFbaSnapshotMap = new HashMap<Long, AmazonFbaInventorySnapshot> ();
|
222 |
Map<Long, AmazonFbaInventorySnapshot> amazonFbaSnapshotMap = new HashMap<Long, AmazonFbaInventorySnapshot> ();
|
| 214 |
|
223 |
|
| 215 |
Map<Long, List<AmazonTransferredSkuDetail>> skuDetailsMap = new HashMap<Long, List<AmazonTransferredSkuDetail>>();
|
224 |
Map<Long, List<AmazonTransferredSkuDetail>> skuDetailsMap = new HashMap<Long, List<AmazonTransferredSkuDetail>>();
|
| 216 |
|
225 |
|
| 217 |
for(AmazonFbaInventorySnapshot invSnapShot : amazonFbaInventorySnapshot){
|
226 |
for(AmazonFbaInventorySnapshot invSnapShot : amazonFbaInventorySnapshot){
|
| 218 |
Long itemId= invSnapShot.getItem_id();
|
227 |
Long itemId= invSnapShot.getItem_id();
|
| 219 |
if(!amazonFbaSnapshotMap.containsKey(itemId)){
|
228 |
if(!amazonFbaSnapshotMap.containsKey(itemId)){
|
| 220 |
amazonFbaSnapshotMap.put(itemId, invSnapShot);
|
229 |
amazonFbaSnapshotMap.put(itemId, invSnapShot);
|
| - |
|
230 |
logger.info("Adding Availabity " + invSnapShot.getItem_id() + " Availability " +invSnapShot.getAvailability());
|
| 221 |
} else {
|
231 |
} else {
|
| 222 |
AmazonFbaInventorySnapshot invSS = amazonFbaSnapshotMap.get(itemId);
|
232 |
AmazonFbaInventorySnapshot invSS = amazonFbaSnapshotMap.get(itemId);
|
| 223 |
invSnapShot.setAvailability(invSnapShot.getAvailability() + invSS.getAvailability());
|
233 |
invSnapShot.setAvailability(invSnapShot.getAvailability() + invSS.getAvailability());
|
| 224 |
amazonFbaSnapshotMap.put(itemId, invSnapShot);
|
234 |
amazonFbaSnapshotMap.put(itemId, invSnapShot);
|
| - |
|
235 |
logger.info("Updating Availabity " + invSnapShot.getItem_id() + " Availability " +invSnapShot.getAvailability());
|
| 225 |
}
|
236 |
}
|
| 226 |
|
237 |
|
| 227 |
List<AmazonTransferredSkuDetail> mappedList = new ArrayList<AmazonTransferredSkuDetail>();
|
238 |
List<AmazonTransferredSkuDetail> mappedList = new ArrayList<AmazonTransferredSkuDetail>();
|
| 228 |
for(AmazonTransferredSkuDetail detail: amazonTransferredSkuDetails){
|
239 |
for(AmazonTransferredSkuDetail detail: amazonTransferredSkuDetails){
|
| 229 |
if(itemId == detail.getItemId()){
|
240 |
if(itemId == detail.getItemId()){
|
| - |
|
241 |
logger.info("Amazon Transferred Sku Details Detail found for ITEM ID " + detail.getItemId());
|
| 230 |
mappedList.add(detail);
|
242 |
mappedList.add(detail);
|
| 231 |
}
|
243 |
}
|
| - |
|
244 |
else{
|
| - |
|
245 |
logger.info("Amazon Transferred Sku Details Detail not found for ITEM ID " + detail.getItemId());
|
| - |
|
246 |
}
|
| - |
|
247 |
}
|
| - |
|
248 |
if(mappedList.size()>0){
|
| - |
|
249 |
skuDetailsMap.put(itemId, mappedList);
|
| - |
|
250 |
logger.info("Amazon Sku Details transfer entries added Item ID " + itemId + " Total Entires " +mappedList.size());
|
| - |
|
251 |
}
|
| - |
|
252 |
else{
|
| - |
|
253 |
logger.info("Amazon Sku Details transfer entries not found added Item ID " + itemId + " Total Entires " +mappedList.size());
|
| 232 |
}
|
254 |
}
|
| 233 |
skuDetailsMap.put(itemId, mappedList);
|
- |
|
| 234 |
}
|
255 |
}
|
| 235 |
|
256 |
|
| 236 |
//CatalogService.Client catalogClient = new CatalogClient().getClient();
|
257 |
//CatalogService.Client catalogClient = new CatalogClient().getClient();
|
| 237 |
|
258 |
|
| 238 |
for(AmazonFbaInventorySnapshot invSnapShot : amazonFbaSnapshotMap.values()){
|
259 |
for(AmazonFbaInventorySnapshot invSnapShot : amazonFbaSnapshotMap.values()){
|
| 239 |
try{
|
260 |
try{
|
| 240 |
|
261 |
|
| 241 |
Long item_id = invSnapShot.getItem_id();
|
262 |
Long item_id = invSnapShot.getItem_id();
|
| 242 |
List<AmazonTransferredSkuDetail> amazonTranSkuDetails = skuDetailsMap.get(item_id);
|
263 |
List<AmazonTransferredSkuDetail> amazonTranSkuDetails = skuDetailsMap.get(item_id);
|
| Line 268... |
Line 289... |
| 268 |
brand = amazonTranSkuDetails.get(0).getBrand();
|
289 |
brand = amazonTranSkuDetails.get(0).getBrand();
|
| 269 |
modelName = amazonTranSkuDetails.get(0).getModelName();
|
290 |
modelName = amazonTranSkuDetails.get(0).getModelName();
|
| 270 |
modelNumber = amazonTranSkuDetails.get(0).getModelNumber();
|
291 |
modelNumber = amazonTranSkuDetails.get(0).getModelNumber();
|
| 271 |
color = amazonTranSkuDetails.get(0).getColor();
|
292 |
color = amazonTranSkuDetails.get(0).getColor();
|
| 272 |
category = amazonTranSkuDetails.get(0).getCategory();
|
293 |
category = amazonTranSkuDetails.get(0).getCategory();
|
| 273 |
}else{
|
294 |
}else{
|
| - |
|
295 |
logger.info("Amazon Sku Transfer details skipped " + item_id);
|
| 274 |
continue;
|
296 |
continue;
|
| 275 |
}
|
297 |
}
|
| 276 |
double invAge = 0;
|
298 |
double invAge = 0;
|
| 277 |
|
299 |
|
| 278 |
for(AmazonTransferredSkuDetail amazonSkuDetail : amazonTranSkuDetails){
|
300 |
for(AmazonTransferredSkuDetail amazonSkuDetail : amazonTranSkuDetails){
|
| Line 324... |
Line 346... |
| 324 |
threeMonthPlusCount = threeMonthPlusCount + amazonSkuInfo.getQuantity();
|
346 |
threeMonthPlusCount = threeMonthPlusCount + amazonSkuInfo.getQuantity();
|
| 325 |
}
|
347 |
}
|
| 326 |
if(invAge >= 26){
|
348 |
if(invAge >= 26){
|
| 327 |
sixMonthPlusCount = sixMonthPlusCount + amazonSkuInfo.getQuantity();
|
349 |
sixMonthPlusCount = sixMonthPlusCount + amazonSkuInfo.getQuantity();
|
| 328 |
}
|
350 |
}
|
| 329 |
|
351 |
|
| 330 |
if(invAge >0 && invAge <=13){
|
352 |
if(invAge >0 && invAge <=13){
|
| 331 |
zeroToThreeMonthCount = zeroToThreeMonthCount + amazonSkuInfo.getQuantity();
|
353 |
zeroToThreeMonthCount = zeroToThreeMonthCount + amazonSkuInfo.getQuantity();
|
| 332 |
}
|
354 |
}
|
| 333 |
|
355 |
|
| 334 |
if(invAge >13 && invAge <=26){
|
356 |
if(invAge >13 && invAge <=26){
|
| 335 |
threeToSixMonthsCount = threeToSixMonthsCount + amazonSkuInfo.getQuantity();
|
357 |
threeToSixMonthsCount = threeToSixMonthsCount + amazonSkuInfo.getQuantity();
|
| 336 |
}
|
358 |
}
|
| 337 |
|
359 |
|
| 338 |
if(invAge >26 && invAge <=52){
|
360 |
if(invAge >26 && invAge <=52){
|
| 339 |
sixToTwelveMonthsCount = sixToTwelveMonthsCount + amazonSkuInfo.getQuantity();
|
361 |
sixToTwelveMonthsCount = sixToTwelveMonthsCount + amazonSkuInfo.getQuantity();
|
| 340 |
}
|
362 |
}
|
| 341 |
|
363 |
|
| 342 |
if(invAge > 52){
|
364 |
if(invAge > 52){
|
| 343 |
twelveMonthsPlusCount = twelveMonthsPlusCount + amazonSkuInfo.getQuantity();
|
365 |
twelveMonthsPlusCount = twelveMonthsPlusCount + amazonSkuInfo.getQuantity();
|
| 344 |
}
|
366 |
}
|
| 345 |
|
367 |
|
| 346 |
zeroPlusCount = zeroPlusCount + amazonSkuInfo.getQuantity();
|
368 |
zeroPlusCount = zeroPlusCount + amazonSkuInfo.getQuantity();
|
| 347 |
|
369 |
|
| 348 |
zeroPlusCost = (long)(zeroPlusCost + ( amazonSkuInfo.getQuantity() * amazonSkuInfo.getUnitPrice() ));
|
370 |
zeroPlusCost = (long)(zeroPlusCost + ( amazonSkuInfo.getQuantity() * amazonSkuInfo.getUnitPrice() ));
|
| 349 |
}
|
371 |
}
|
| 350 |
|
372 |
|
| 351 |
|
373 |
|
| 352 |
InventoryAge inventAge = new InventoryAge();
|
374 |
InventoryAge inventAge = new InventoryAge();
|
| 353 |
inventAge.setItemId(item_id);
|
375 |
inventAge.setItemId(item_id);
|
| 354 |
inventAge.setBrand(brand);
|
376 |
inventAge.setBrand(brand);
|
| 355 |
inventAge.setModelName(modelName);
|
377 |
inventAge.setModelName(modelName);
|
| 356 |
inventAge.setModelNumber(modelNumber);
|
378 |
inventAge.setModelNumber(modelNumber);
|
| Line 383... |
Line 405... |
| 383 |
catch(Exception e){
|
405 |
catch(Exception e){
|
| 384 |
e.printStackTrace();
|
406 |
e.printStackTrace();
|
| 385 |
}
|
407 |
}
|
| 386 |
return amazonInventoryAge;
|
408 |
return amazonInventoryAge;
|
| 387 |
}
|
409 |
}
|
| 388 |
|
410 |
|
| 389 |
public File createFile(List<InventoryAge> inventoryAge, String name){
|
411 |
public File createFile(List<InventoryAge> inventoryAge, String name){
|
| 390 |
try {
|
412 |
try {
|
| 391 |
File file = new File(name);
|
413 |
File file = new File(name);
|
| 392 |
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file));
|
414 |
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file));
|
| 393 |
bufferedWriter.write(StringUtils.join(new String[] {
|
415 |
bufferedWriter.write(StringUtils.join(new String[] {
|
| Line 444... |
Line 466... |
| 444 |
bufferedWriter.close();
|
466 |
bufferedWriter.close();
|
| 445 |
return file;
|
467 |
return file;
|
| 446 |
} catch (Exception e) {
|
468 |
} catch (Exception e) {
|
| 447 |
return null;
|
469 |
return null;
|
| 448 |
}
|
470 |
}
|
| 449 |
|
471 |
|
| 450 |
}
|
472 |
}
|
| 451 |
|
473 |
|
| 452 |
public void downloadAmazonInventoryAge(){
|
474 |
public void downloadAmazonInventoryAge(){
|
| 453 |
try {
|
475 |
try {
|
| 454 |
List<InventoryAge> inventoryAgeAmazon = getAmazonInventoryAge();
|
476 |
List<InventoryAge> inventoryAgeAmazon = getAmazonInventoryAge();
|
| 455 |
byte[] buffer = null;
|
477 |
byte[] buffer = null;
|
| 456 |
File file = createFile(inventoryAgeAmazon,"/tmp/AmazonInventoryAge.xls");
|
478 |
File file = createFile(inventoryAgeAmazon,"/tmp/AmazonInventoryAge.xls");
|
| Line 492... |
Line 514... |
| 492 |
}
|
514 |
}
|
| 493 |
catch (Exception e) {
|
515 |
catch (Exception e) {
|
| 494 |
}
|
516 |
}
|
| 495 |
|
517 |
|
| 496 |
}
|
518 |
}
|
| 497 |
|
519 |
|
| 498 |
public void downloadSaholicInventoryAge(){
|
520 |
public void downloadSaholicInventoryAge(){
|
| 499 |
try {
|
521 |
try {
|
| 500 |
Client client = new WarehouseClient().getClient();
|
522 |
Client client = new WarehouseClient().getClient();
|
| 501 |
List<InventoryAge> inventoryAge = client.getInventoryAge();
|
523 |
List<InventoryAge> inventoryAge = client.getInventoryAge();
|
| 502 |
byte[] buffer = null;
|
524 |
byte[] buffer = null;
|
| Line 541... |
Line 563... |
| 541 |
}
|
563 |
}
|
| 542 |
|
564 |
|
| 543 |
}
|
565 |
}
|
| 544 |
|
566 |
|
| 545 |
/*public static void main(String[] args) throws Exception{
|
567 |
/*public static void main(String[] args) throws Exception{
|
| 546 |
|
568 |
|
| 547 |
}*/
|
569 |
}*/
|
| 548 |
}
|
570 |
}
|