| Line 16... |
Line 16... |
| 16 |
import com.spice.profitmandi.common.web.client.RestClient;
|
16 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 17 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
17 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 18 |
import com.spice.profitmandi.dao.entity.catalog.*;
|
18 |
import com.spice.profitmandi.dao.entity.catalog.*;
|
| 19 |
import com.spice.profitmandi.dao.entity.dtr.WebListing;
|
19 |
import com.spice.profitmandi.dao.entity.dtr.WebListing;
|
| 20 |
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
|
20 |
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
|
| - |
|
21 |
import com.spice.profitmandi.dao.entity.dtr.WebProductListing;
|
| 21 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
22 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 22 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
23 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
| 23 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
24 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
| 24 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
|
25 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
|
| 25 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
26 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
| Line 575... |
Line 576... |
| 575 |
|
576 |
|
| 576 |
RestClient rc = new RestClient();
|
577 |
RestClient rc = new RestClient();
|
| 577 |
Map<String, String> params = new HashMap<>();
|
578 |
Map<String, String> params = new HashMap<>();
|
| 578 |
List<String> mandatoryQ = new ArrayList<>();
|
579 |
List<String> mandatoryQ = new ArrayList<>();
|
| 579 |
mandatoryQ.add("show_default_b:true");
|
580 |
mandatoryQ.add("show_default_b:true");
|
| - |
|
581 |
|
| - |
|
582 |
List<Integer> webProducts = null;
|
| 580 |
if (webListing.getType().equals(WebListingType.solr)) {
|
583 |
if (webListing.getType().equals(WebListingType.solr)) {
|
| 581 |
logger.info("solrtype {}", webListing.getSolrQuery());
|
584 |
logger.info("solrtype {}", webListing.getSolrQuery());
|
| 582 |
mandatoryQ.add(String.format("+{!parent which=\"" + webListing.getSolrQuery() + "\"} AND active_b:true"));
|
585 |
mandatoryQ.add(String.format("+{!parent which=\"" + webListing.getSolrQuery() + "\"} AND active_b:true"));
|
| 583 |
|
586 |
|
| 584 |
} else {
|
587 |
} else {
|
| 585 |
logger.info("solrtype2 {}", webListing.getSolrQuery());
|
588 |
logger.info("solrtype2 {}", webListing.getSolrQuery());
|
| 586 |
|
589 |
|
| 587 |
List<Integer> webProducts = webProductListingRepository
|
590 |
webProducts = webProductListingRepository
|
| 588 |
.selectAllByWebListingId(webListing.getId(), Integer.parseInt(offset), Integer.parseInt(limit))
|
591 |
.selectAllByWebListingId(webListing.getId(), Integer.parseInt(offset), Integer.parseInt(limit))
|
| 589 |
.stream().filter(x -> x.getRank() > 0).map(x -> x.getEntityId()).collect(Collectors.toList());
|
592 |
.stream().filter(x -> x.getRank() > 0).map(x -> x.getEntityId()).collect(Collectors.toList());
|
| 590 |
if (webProducts.size() == 0) {
|
593 |
if (webProducts.size() == 0) {
|
| 591 |
return new ArrayList<>();
|
594 |
return new ArrayList<>();
|
| 592 |
}
|
595 |
}
|
| Line 601... |
Line 604... |
| 601 |
params.put("start", String.valueOf(offset));
|
604 |
params.put("start", String.valueOf(offset));
|
| 602 |
params.put("rows", String.valueOf(limit));
|
605 |
params.put("rows", String.valueOf(limit));
|
| 603 |
params.put("wt", "json");
|
606 |
params.put("wt", "json");
|
| 604 |
String response = null;
|
607 |
String response = null;
|
| 605 |
try {
|
608 |
try {
|
| 606 |
response = rc.get(SchemeType.HTTP, "50.116.10.120", 8984, "solr/demo/select", params);
|
609 |
response = rc.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);
|
| 607 |
} catch (HttpHostConnectException e) {
|
610 |
} catch (HttpHostConnectException e) {
|
| 608 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
611 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
| 609 |
}
|
612 |
}
|
| 610 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
613 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
| 611 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
614 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
| 612 |
List<FofoCatalogResponse> dealResponse = getCatalogResponse(docs, false, userInfo.getRetailerId());
|
615 |
List<FofoCatalogResponse> dealResponse = getCatalogResponse(docs, false, userInfo.getRetailerId());
|
| - |
|
616 |
if (webProducts != null) {
|
| - |
|
617 |
List<Integer> webProductsFinal = webProducts;
|
| - |
|
618 |
dealResponse = dealResponse.stream()
|
| - |
|
619 |
.sorted(Comparator.comparing(x -> webProductsFinal.indexOf(x.getCatalogId())))
|
| - |
|
620 |
.collect(Collectors.toList());
|
| - |
|
621 |
}
|
| - |
|
622 |
|
| 613 |
return dealResponse;
|
623 |
return dealResponse;
|
| 614 |
}
|
624 |
}
|
| 615 |
|
625 |
|
| 616 |
@Autowired
|
626 |
@Autowired
|
| 617 |
private SaholicCISTableRepository saholicCISTableRepository;
|
627 |
private SaholicCISTableRepository saholicCISTableRepository;
|
| Line 670... |
Line 680... |
| 670 |
.get(fofoCatalogResponse.getCatalogId());
|
680 |
.get(fofoCatalogResponse.getCatalogId());
|
| 671 |
|
681 |
|
| 672 |
logger.info("webOffers {}", webOffers);
|
682 |
logger.info("webOffers {}", webOffers);
|
| 673 |
if (webOffers != null && webOffers.size() > 0) {
|
683 |
if (webOffers != null && webOffers.size() > 0) {
|
| 674 |
fofoCatalogResponse.setWebOffers(webOffers);
|
684 |
fofoCatalogResponse.setWebOffers(webOffers);
|
| - |
|
685 |
fofoCatalogResponse.setOffers(webOffers.stream().map(x -> x.getTitle()).collect(Collectors.toList()));
|
| - |
|
686 |
|
| 675 |
}
|
687 |
}
|
| 676 |
|
688 |
|
| 677 |
List<ComboModel> comboModels = comboModelRepository.selectByWarehouseId(warehouseId).stream()
|
689 |
List<ComboModel> comboModels = comboModelRepository.selectByWarehouseId(warehouseId).stream()
|
| 678 |
.filter(x -> x.getCatalogId() == fofoCatalogResponse.getCatalogId()).collect(Collectors.toList());
|
690 |
.filter(x -> x.getCatalogId() == fofoCatalogResponse.getCatalogId()).collect(Collectors.toList());
|
| 679 |
|
691 |
|
| Line 693... |
Line 705... |
| 693 |
fofoCatalogResponse.setFeature(doc.getString("feature_s"));
|
705 |
fofoCatalogResponse.setFeature(doc.getString("feature_s"));
|
| 694 |
} catch (Exception e) {
|
706 |
} catch (Exception e) {
|
| 695 |
fofoCatalogResponse.setFeature(null);
|
707 |
fofoCatalogResponse.setFeature(null);
|
| 696 |
logger.info("Could not find Feature_s for {}", fofoCatalogResponse.getCatalogId());
|
708 |
logger.info("Could not find Feature_s for {}", fofoCatalogResponse.getCatalogId());
|
| 697 |
}
|
709 |
}
|
| - |
|
710 |
|
| 698 |
fofoCatalogResponse.setBrand(doc.getJSONArray("brand_ss").getString(0));
|
711 |
fofoCatalogResponse.setBrand(doc.getJSONArray("brand_ss").getString(0));
|
| - |
|
712 |
logger.info("labelss {}", doc.has("label_ss"));
|
| - |
|
713 |
|
| - |
|
714 |
if (doc.has("label_ss")) {
|
| - |
|
715 |
logger.info("label {}", doc.getJSONArray("label_ss"));
|
| - |
|
716 |
|
| - |
|
717 |
JSONArray arr = doc.getJSONArray("label_ss");
|
| - |
|
718 |
List<String> labels = new ArrayList<String>();
|
| - |
|
719 |
for (int j = 0; j < arr.length(); j++) {
|
| - |
|
720 |
labels.add(arr.getString(j));
|
| - |
|
721 |
}
|
| - |
|
722 |
|
| - |
|
723 |
fofoCatalogResponse.setLabels(labels);
|
| - |
|
724 |
|
| - |
|
725 |
}
|
| - |
|
726 |
|
| 699 |
if (doc.has("_childDocuments_")) {
|
727 |
if (doc.has("_childDocuments_")) {
|
| 700 |
String modelColorClass = "grey";
|
728 |
String modelColorClass = "grey";
|
| 701 |
FofoAvailabilityInfo fdiAnyColour = null;
|
729 |
FofoAvailabilityInfo fdiAnyColour = null;
|
| 702 |
// Iterating itemIds
|
730 |
// Iterating itemIds
|
| 703 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
731 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|