| Line 426... |
Line 426... |
| 426 |
List<SuperCatalogModel> superCatalogMappingList = superCatalogMappingRepository.selectJoinedData();
|
426 |
List<SuperCatalogModel> superCatalogMappingList = superCatalogMappingRepository.selectJoinedData();
|
| 427 |
List<SuperCatalogMapping> superCatalogs = superCatalogMappingRepository.selectAll();
|
427 |
List<SuperCatalogMapping> superCatalogs = superCatalogMappingRepository.selectAll();
|
| 428 |
List<SolrInputDocument> catalogSolrObjs = new ArrayList<>();
|
428 |
List<SolrInputDocument> catalogSolrObjs = new ArrayList<>();
|
| 429 |
for (Entry<Integer, Map<String, Object>> entry : catalogMap.entrySet()) {
|
429 |
for (Entry<Integer, Map<String, Object>> entry : catalogMap.entrySet()) {
|
| 430 |
int catalogId = entry.getKey();
|
430 |
int catalogId = entry.getKey();
|
| 431 |
Optional<SuperCatalogModel> superCatalogMapping = findMappingByCatalogId(superCatalogMappingList, catalogId);
|
431 |
Optional<SuperCatalogModel> superCatalogMapping = findMappingByCatalogId(superCatalogMappingList, catalogId, itemTagModels);
|
| 432 |
Map<String, Object> catalogValMap = entry.getValue();
|
432 |
Map<String, Object> catalogValMap = entry.getValue();
|
| 433 |
Map<Integer, Object> itemsMap = (Map<Integer, Object>) catalogValMap.get("items");
|
433 |
Map<Integer, Object> itemsMap = (Map<Integer, Object>) catalogValMap.get("items");
|
| 434 |
|
434 |
|
| 435 |
boolean active = false;
|
435 |
boolean active = false;
|
| 436 |
// Map<Integer, Object> itemsMap = (Map<String, Object>)
|
436 |
// Map<Integer, Object> itemsMap = (Map<String, Object>)
|
| Line 469... |
Line 469... |
| 469 |
catalogSolrObj.addChildDocuments(itemObjs);
|
469 |
catalogSolrObj.addChildDocuments(itemObjs);
|
| 470 |
catalogSolrObj.setField("child_b", itemObjs.size() > 0);
|
470 |
catalogSolrObj.setField("child_b", itemObjs.size() > 0);
|
| 471 |
catalogSolrObj.setField("catalogId_i", catalogId);
|
471 |
catalogSolrObj.setField("catalogId_i", catalogId);
|
| 472 |
logger.info("superCatalogMapping1- {}", superCatalogMapping);
|
472 |
logger.info("superCatalogMapping1- {}", superCatalogMapping);
|
| 473 |
if (superCatalogMapping.isPresent()) {
|
473 |
if (superCatalogMapping.isPresent()) {
|
| 474 |
logger.info("superCatalogMapping2- {}", superCatalogMapping);
|
- |
|
| 475 |
int superCatalogId = superCatalogMapping.get().getSuperCatalogId();
|
474 |
int superCatalogId = superCatalogMapping.get().getSuperCatalogId();
|
| 476 |
String superCatalogMappingVariants = findMappingVariantsByCatalogId(superCatalogs, superCatalogId);
|
475 |
String superCatalogMappingVariants = findMappingVariantsByCatalogId(superCatalogs, superCatalogId, itemTagModels);
|
| 477 |
catalogSolrObj.setField("superCatalog_i", superCatalogId);
|
476 |
catalogSolrObj.setField("superCatalog_i", superCatalogId);
|
| 478 |
catalogSolrObj.setField("superCatalog_s", superCatalogMapping.get().getSuperCatalogName());
|
477 |
catalogSolrObj.setField("superCatalog_s", superCatalogMapping.get().getSuperCatalogName());
|
| 479 |
catalogSolrObj.setField("superCatalogVariants_s", superCatalogMappingVariants);
|
478 |
catalogSolrObj.setField("superCatalogVariants_s", superCatalogMappingVariants);
|
| 480 |
} else {
|
479 |
} else {
|
| 481 |
logger.info("superCatalogMapping3- {}", superCatalogMapping);
|
- |
|
| 482 |
catalogSolrObj.setField("superCatalog_i", 0);
|
480 |
catalogSolrObj.setField("superCatalog_i", 0);
|
| 483 |
catalogSolrObj.setField("superCatalog_s", catalogValMap.get("title"));
|
481 |
catalogSolrObj.setField("superCatalog_s", catalogValMap.get("title"));
|
| 484 |
catalogSolrObj.setField("superCatalogVariants_s", "[]");
|
482 |
catalogSolrObj.setField("superCatalogVariants_s", "[]");
|
| 485 |
}
|
483 |
}
|
| 486 |
catalogSolrObj.setField("imageUrl_s",
|
484 |
catalogSolrObj.setField("imageUrl_s",
|
| Line 524... |
Line 522... |
| 524 |
similalarModels = new ArrayList<>();
|
522 |
similalarModels = new ArrayList<>();
|
| 525 |
for (Entry<Float, List<Integer>> floatListEntry : priceModelMap.entrySet()) {
|
523 |
for (Entry<Float, List<Integer>> floatListEntry : priceModelMap.entrySet()) {
|
| 526 |
float modelPrice = floatListEntry.getKey();
|
524 |
float modelPrice = floatListEntry.getKey();
|
| 527 |
if (modelPrice >= starPrice && modelPrice <= endPrice) {
|
525 |
if (modelPrice >= starPrice && modelPrice <= endPrice) {
|
| 528 |
List<Integer> instock = floatListEntry.getValue().stream().filter(x->catalogMap.get(x).get("stockColor") != null && (Integer) (catalogMap.get(x).get("stockColor"))>0).collect(Collectors.toList());
|
526 |
List<Integer> instock = floatListEntry.getValue().stream().filter(x->catalogMap.get(x).get("stockColor") != null && (Integer) (catalogMap.get(x).get("stockColor"))>0).collect(Collectors.toList());
|
| 529 |
logger.info("Entry before - {}, after - {}", floatListEntry.getValue().size(), instock.size());
|
527 |
//logger.info("Entry before - {}, after - {}", floatListEntry.getValue().size(), instock.size());
|
| 530 |
similalarModels.addAll(instock);
|
528 |
similalarModels.addAll(instock);
|
| 531 |
}
|
529 |
}
|
| 532 |
if (modelPrice > endPrice) break;
|
530 |
if (modelPrice > endPrice) break;
|
| 533 |
}
|
531 |
}
|
| 534 |
similalarModels.remove(Integer.valueOf(catalogId));
|
532 |
similalarModels.remove(Integer.valueOf(catalogId));
|
| Line 553... |
Line 551... |
| 553 |
|
551 |
|
| 554 |
public void pushData() throws Exception {
|
552 |
public void pushData() throws Exception {
|
| 555 |
this.populateTagItems();
|
553 |
this.populateTagItems();
|
| 556 |
}
|
554 |
}
|
| 557 |
|
555 |
|
| 558 |
public Optional<SuperCatalogModel> findMappingByCatalogId(List<SuperCatalogModel> superCatalogMappingList, int id) {
|
556 |
public Optional<SuperCatalogModel> findMappingByCatalogId(List<SuperCatalogModel> superCatalogMappingList, int id, List<ItemTagModel> itemTagModels) {
|
| 559 |
|
- |
|
| 560 |
return superCatalogMappingList.parallelStream()
|
557 |
if (itemTagModels.stream().anyMatch(tag -> tag.getItem().getCatalogItemId() == id && tag.getTagListing().isActive())) {
|
| 561 |
.filter(mapping -> mapping.getCatalogId() == id)
|
558 |
return superCatalogMappingList.stream().filter(mapping -> mapping.getCatalogId() == id).findFirst();
|
| - |
|
559 |
}
|
| 562 |
.findFirst();
|
560 |
return Optional.empty();
|
| 563 |
}
|
561 |
}
|
| 564 |
|
562 |
|
| 565 |
public String findMappingVariantsByCatalogId(List<SuperCatalogMapping> superCatalogMappingList, int id) throws JsonProcessingException {
|
563 |
public String findMappingVariantsByCatalogId(List<SuperCatalogMapping> superCatalogMappingList, int id, List<ItemTagModel> itemTagModels) throws JsonProcessingException {
|
| 566 |
List<Map<String, Object>> variantList = new ArrayList<>();
|
564 |
List<Map<String, Object>> variantList = new ArrayList<>();
|
| 567 |
List<SuperCatalogMapping> matchingVariantNames = superCatalogMappingList.parallelStream()
|
565 |
List<SuperCatalogMapping> matchingVariantNames = superCatalogMappingList.parallelStream()
|
| 568 |
.filter(mapping -> mapping.getSuperCatalogId() == id)
|
566 |
.filter(mapping -> mapping.getSuperCatalogId() == id)
|
| 569 |
.collect(Collectors.toList());
|
567 |
.collect(Collectors.toList());
|
| 570 |
|
568 |
|
| 571 |
if (!matchingVariantNames.isEmpty()) {
|
569 |
if (!matchingVariantNames.isEmpty()) {
|
| 572 |
for (SuperCatalogMapping matchingVariantName : matchingVariantNames) {
|
570 |
for (SuperCatalogMapping matchingVariant : matchingVariantNames) {
|
| 573 |
logger.info("matchingVariantName: "+matchingVariantName);
|
571 |
logger.info("matchingVariantName: "+matchingVariant);
|
| 574 |
if (matchingVariantName != null && matchingVariantName.getVariantName() != null) {
|
572 |
if (matchingVariant != null && matchingVariant.getVariantName() != null && itemTagModels.stream().anyMatch(tag -> tag.getItem().getCatalogItemId() == matchingVariant.getCatalogId() && tag.getTagListing().isActive())) {
|
| 575 |
Map<String, Object> variantObj = new HashMap<>();
|
573 |
Map<String, Object> variantObj = new HashMap<>();
|
| 576 |
variantObj.put("catalogId", matchingVariantName.getCatalogId());
|
574 |
variantObj.put("catalogId", matchingVariant.getCatalogId());
|
| 577 |
variantObj.put("variantName", matchingVariantName.getVariantName());
|
575 |
variantObj.put("variantName", matchingVariant.getVariantName());
|
| 578 |
variantList.add(variantObj);
|
576 |
variantList.add(variantObj);
|
| 579 |
}
|
577 |
}
|
| 580 |
}
|
578 |
}
|
| 581 |
}
|
579 |
}
|
| 582 |
|
580 |
|