Subversion Repositories SmartDukaan

Rev

Rev 31710 | Rev 33245 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 31710 Rev 31746
Line 497... Line 497...
497
				int color = (int) avColorEntry.getValue();
497
				int color = (int) avColorEntry.getValue();
498
				catalogSolrObj.setField("w" + whId + "_i", color);
498
				catalogSolrObj.setField("w" + whId + "_i", color);
499
			}
499
			}
500
			catalogSolrObj.setField("active_b", active);
500
			catalogSolrObj.setField("active_b", active);
501
			logger.info("catalogSolrObj {}", catalogSolrObj.get("rank_i"));
501
			logger.info("catalogSolrObj {}", catalogSolrObj.get("rank_i"));
502
 
-
 
503
			catalogSolrObjs.add(catalogSolrObj);
502
			catalogSolrObjs.add(catalogSolrObj);
504
 
503
 
505
		}
504
		}
506
 
505
 
507
		logger.info("catalogSolrObjs {}", catalogSolrObjs);
506
		logger.info("catalogSolrObjs {}", catalogSolrObjs);
Line 511... Line 510...
511
		org.apache.solr.client.solrj.response.UpdateResponse updateResponse = solr.commit();
510
		org.apache.solr.client.solrj.response.UpdateResponse updateResponse = solr.commit();
512
		logger.info("solr {}", updateResponse.getStatus());
511
		logger.info("solr {}", updateResponse.getStatus());
513
 
512
 
514
	}
513
	}
515
 
514
 
516
	/*
-
 
517
	 * public void populateTagItems() throws Exception { Map<String, Map<String,
-
 
518
	 * Map<String, Integer>>> availabilityItemMap = getItemMap(); List<TagRanking>
-
 
519
	 * tagRankingList = tagRankingRepository.getAllTagRanking();
-
 
520
	 * 
-
 
521
	 * List<Integer> rankingList = new ArrayList<>(); SolrInputDocument featureMap =
-
 
522
	 * new SolrInputDocument(); for (TagRanking tagRanking : tagRankingList) {
-
 
523
	 * rankingList.add(tagRanking.getCatalogItemId());
-
 
524
	 * featureMap.addField(String.valueOf(tagRanking.getCatalogItemId()),
-
 
525
	 * tagRanking.getFeature()); }
-
 
526
	 * 
-
 
527
	 * Map<Integer, SolrInputDocument> catalogMap = new HashMap<>(); List<status>
-
 
528
	 * statuses = new ArrayList<>(); statuses.add(status.ACTIVE);
-
 
529
	 * statuses.add(status.PAUSED_BY_RISK); statuses.add(status.PARTIALLY_ACTIVE);
-
 
530
	 * List<ItemTagModel> tuples =
-
 
531
	 * tagListingRepository.getAllItemTagByStatus(statuses); SolrInputDocument
-
 
532
	 * projection = new SolrInputDocument();
-
 
533
	 * 
-
 
534
	 * projection.addField("defaultImageUrl", 1); List<String> excludeBrands =
-
 
535
	 * Arrays.asList("Live Demo", "FOC", "Dummy", "FOC HANDSET");
-
 
536
	 * 
-
 
537
	 * for (ItemTagModel result : tuples) { TagListing tag = result.getTagListing();
-
 
538
	 * com.spice.profitmandi.dao.entity.catalog.Item item = result.getItem(); if
-
 
539
	 * (excludeBrands.contains(item.getBrand())) { continue; }
-
 
540
	 * 
-
 
541
	 * if (!catalogMap.containsKey(item.getCatalogItemId())) { SolrInputDocument
-
 
542
	 * catalogObj = new SolrInputDocument(); catalogObj.addField("feature", "");
-
 
543
	 * catalogObj.addField("title", String.join(" ", Arrays.asList(item.getBrand(),
-
 
544
	 * item.getModelName(), item.getModelNumber()) .stream().filter(s -> s != null
-
 
545
	 * && !s.isEmpty()).collect(Collectors.toList()))); catalogObj.addField("brand",
-
 
546
	 * item.getBrand()); if (item.getBrand().equals("Huawei") ||
-
 
547
	 * item.getBrand().equals("Honor")) { catalogObj.addField("brand", new String[]
-
 
548
	 * { "Huawei", "Honor" }); } if (item.getBrand().equals("Mi") ||
-
 
549
	 * item.getBrand().equals("Xiaomi") || item.getBrand().equals("Redmi")) {
-
 
550
	 * catalogObj.addField("brand", new String[] { "Mi", "Xiaomi", "Redmi" }); }
-
 
551
	 * catalogObj.addField("identifier", item.getCatalogItemId());
-
 
552
	 * catalogObj.addField("items", new SolrInputDocument()); SolrInputDocument
-
 
553
	 * filterMap = new SolrInputDocument(); filterMap.addField("_id",
-
 
554
	 * item.getCatalogItemId());
-
 
555
	 * 
-
 
556
	 * try {
-
 
557
	 * 
-
 
558
	 * BrandCatalog brandCatalog = brandsRepository.selectByBrand(item.getBrand());
-
 
559
	 * catalogObj.addField("imageUrl", brandCatalog.getLogoUrl());
-
 
560
	 * System.out.println(catalogObj.get("imageUrl")); } catch (Exception e) { try {
-
 
561
	 * catalogObj.addField("imageUrl",
-
 
562
	 * "https://images.smartdukaan.com/uploads/campaigns/" + item.getCatalogItemId()
-
 
563
	 * + ".jpg"); } catch (Exception e2) { e2.printStackTrace(); } } try {
-
 
564
	 * catalogObj.addField("rank", rankingList.indexOf(item.getCatalogItemId())); }
-
 
565
	 * catch (Exception e) { // A very big number e.printStackTrace();
-
 
566
	 * catalogObj.addField("rank", 50000000); } if
-
 
567
	 * (featureMap.containsKey(String.valueOf(item.getCatalogItemId())) &&
-
 
568
	 * featureMap.get(String.valueOf(item.getCatalogItemId())) != null) {
-
 
569
	 * catalogObj.addField("feature", featureMap.get(item.getCatalogItemId()));
-
 
570
	 * 
-
 
571
	 * catalogObj.addField("categoryId",
-
 
572
	 * CATEGORY_MASTER.contains(item.getCategoryId()) ? item.getCategoryId() : 6);
-
 
573
	 * 
-
 
574
	 * }
-
 
575
	 * 
-
 
576
	 * if (item.getCategoryId() == 10006) { catalogObj.addField("categoryId", 3); }
-
 
577
	 * catalogObj.addField("subCategoryId", item.getCategoryId());
-
 
578
	 * catalogObj.addField("create_timestamp", tag.getCreatedTimestamp());
-
 
579
	 * catalogMap.put(item.getCatalogItemId(), catalogObj);
-
 
580
	 * catalogObj.addField("avColor", new SolrInputDocument());
-
 
581
	 * 
-
 
582
	 * // Don't include if catalog not available
-
 
583
	 * 
-
 
584
	 * catalogObj = catalogMap.get(item.getCatalogItemId()); if
-
 
585
	 * (availabilityItemMap.containsKey(String.valueOf(item.getId()))) { for
-
 
586
	 * (Map.Entry<String, Map<String, Integer>> entry : availabilityItemMap
-
 
587
	 * .get(String.valueOf(item.getId())).entrySet()) { String warehouseId =
-
 
588
	 * entry.getKey(); Map<String, Integer> avMap = entry.getValue();
-
 
589
	 * 
-
 
590
	 * SolrInputDocument avColorDoc = (SolrInputDocument)
-
 
591
	 * catalogObj.getFieldValue("avColor"); //.catalogObj.get if
-
 
592
	 * (!avColorDoc.containsKey(warehouseId)) { avColorDoc.addField(warehouseId, 0);
-
 
593
	 * } int color = (int) avColorDoc.getFieldValue(warehouseId);
-
 
594
	 * 
-
 
595
	 * if (avMap.get("netAvailability") > 0) { color = 2; } else if
-
 
596
	 * (avMap.get("netAvailability") + avMap.get("netPo") > 0) { color =
-
 
597
	 * Math.max(color, 1); } else { color = Math.max(color, 0); }
-
 
598
	 * 
-
 
599
	 * avColorDoc.addField(warehouseId, 0);
-
 
600
	 * 
-
 
601
	 * }
-
 
602
	 * 
-
 
603
	 * }
-
 
604
	 * 
-
 
605
	 * SolrInputDocument itemColorDoc = (SolrInputDocument)
-
 
606
	 * catalogObj.getFieldValue("items");
-
 
607
	 * 
-
 
608
	 * if (!itemColorDoc.containsKey(item.getId())) {
-
 
609
	 * 
-
 
610
	 * itemColorDoc.addField(String.valueOf(item.getId()), new SolrInputDocument() {
-
 
611
	 * { addField("color", item.getColor().replace("f_", ""));
-
 
612
	 * addField("tagPricing", new ArrayList<TagListing>()); } }); }
-
 
613
	 * 
-
 
614
	 * SolrInputDocument itemMap = (SolrInputDocument) itemColorDoc
-
 
615
	 * .getFieldValue(String.valueOf(item.getId()));
-
 
616
	 * 
-
 
617
	 * List<TagListing> tagPricing = (List<TagListing>)
-
 
618
	 * itemMap.getFieldValue("tagPricing"); tagPricing.add(tag);
-
 
619
	 * 
-
 
620
	 * List<Map<String, Object>> catalogObjs = new ArrayList<>(); for
-
 
621
	 * (Entry<Integer, HashMap<String, Object>> entry : catalogMap.entrySet()) { int
-
 
622
	 * catalogId = entry.getKey(); Map<String, Object> catalogValMap =
-
 
623
	 * entry.getValue();
-
 
624
	 * 
-
 
625
	 * boolean active = false; Map<String, Object> itemsMap = (Map<String, Object>)
-
 
626
	 * catalogValMap.get("items"); List<Map<String, Object>> itemObjs = new
-
 
627
	 * ArrayList<>(); float mop = 0;
-
 
628
	 * 
-
 
629
	 * for (Entry<String, Object> itemEntry : itemsMap.entrySet()) { int itemId =
-
 
630
	 * Integer.parseInt(itemEntry.getKey()); Map<String, Object> itemValMap =
-
 
631
	 * (Map<String, Object>) itemEntry.getValue(); List<TagListing> tags =
-
 
632
	 * (List<TagListing>) catalogValMap.get("tagPricing");
-
 
633
	 * 
-
 
634
	 * for (TagListing taglist : tags) { active = active || (Boolean)
-
 
635
	 * taglist.isActive(); Map<String, Object> itemObj = new HashMap<>();
-
 
636
	 * itemObj.put("id", "itemtag-" + itemId + "-" + tag.getTagId());
-
 
637
	 * itemObj.put("color_s", itemMap.get("color")); itemObj.put("itemId_i",
-
 
638
	 * itemId); itemObj.put("tagId_i", tag.getTagId()); itemObj.put("mrp_f",
-
 
639
	 * tag.getMrp()); itemObj.put("mop_f", tag.getMop());
-
 
640
	 * itemObj.put("sellingPrice_f", tag.getSellingPrice()); itemObj.put("active_b",
-
 
641
	 * tag.isActive()); itemObj.put("hot_deal_b", tag.isHotDeals()); mop =
-
 
642
	 * tag.getMop(); itemObjs.add(itemObj); } } // Map<String, Object> catalogObj =
-
 
643
	 * new HashMap<String, Object>(); catalogObj.put("id", "catalog" + catalogId);
-
 
644
	 * catalogObj.put("rank_i", catalogMap.get("rank")); catalogObj.put("title_s",
-
 
645
	 * catalogMap.get("title")); catalogObj.put("_childDocuments_", itemObjs);
-
 
646
	 * catalogObj.put("child_b", itemObjs.size() > 0); catalogObj.put("catalogId_i",
-
 
647
	 * catalogId); catalogObj.put("imageUrl_s",
-
 
648
	 * catalogMap.get("imageUrl").toString().replace("saholic", "smartdukaan"));
-
 
649
	 * catalogObj.put("feature_s", catalogMap.get("feature"));
-
 
650
	 * catalogObj.put("brand_ss", catalogMap.get("brand"));
-
 
651
	 * catalogObj.put("create_s", catalogMap.get("create_timestamp"));
-
 
652
	 * catalogObj.put("categoryId_i", catalogMap.get("categoryId"));
-
 
653
	 * catalogObj.put("subCategoryId_i", catalogMap.get("subCategoryId"));
-
 
654
	 * catalogObj.put("w7573_i", 0); catalogObj.put("w7678_i", 0);
-
 
655
	 * catalogObj.put("w7720_i", 0); catalogObj.put("w8468_i", 0);
-
 
656
	 * catalogObj.put("w8889_i", 0); catalogObj.put("w8947_i", 0);
-
 
657
	 * catalogObj.put("w9213_i", 0); catalogObj.put("w9203_i", 0);
-
 
658
	 * catalogObj.put("mop_f", mop); for (Entry<Integer, Integer> avColorEntry :
-
 
659
	 * avColorMap.entrySet()) { int whId = avColorEntry.getKey(); int color = (int)
-
 
660
	 * avColorEntry.getValue(); catalogObj.put("w" + whId + "_i", color);
-
 
661
	 * 
-
 
662
	 * catalogObj.put("active_b", active); catalogObjs.add(catalogObj);
-
 
663
	 * solr.deleteByQuery("*:*"); // solr.add((catalogObjs); }
-
 
664
	 * 
-
 
665
	 * } } }
-
 
666
	 * 
-
 
667
	 * }
-
 
668
	 */
-
 
669
 
-
 
670
	public void pushData() throws Exception {
515
	public void pushData() throws Exception {
671
		this.populateTagItems();
516
		this.populateTagItems();
672
	}
517
	}
673
}
518
}