Subversion Repositories SmartDukaan

Rev

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

Rev 37114 Rev 37276
Line 83... Line 83...
83
    private static final List<Integer> CATEGORY_MASTER = Arrays.asList(10006, 10007, 10010, 14202, 14203);
83
    private static final List<Integer> CATEGORY_MASTER = Arrays.asList(10006, 10007, 10010, 14202, 14203);
84
 
84
 
85
    @Autowired
85
    @Autowired
86
    ModelFlagshipRepository modelFlagshipRepository;
86
    ModelFlagshipRepository modelFlagshipRepository;
87
 
87
 
-
 
88
    @Autowired
-
 
89
    ModelHotDealRepository modelHotDealRepository;
-
 
90
 
88
    private static String getUrlContent(String urlString) {
91
    private static String getUrlContent(String urlString) {
89
        BufferedReader reader = null;
92
        BufferedReader reader = null;
90
        try {
93
        try {
91
            URL url = new URL(urlString);
94
            URL url = new URL(urlString);
92
            URLConnection conn = url.openConnection();
95
            URLConnection conn = url.openConnection();
Line 296... Line 299...
296
        eolSet.addAll(eolWithBadQty);
299
        eolSet.addAll(eolWithBadQty);
297
 
300
 
298
        // Flagship models active as of today (catalog.model_flagship start_date/end_date)
301
        // Flagship models active as of today (catalog.model_flagship start_date/end_date)
299
        Set<Integer> flagshipSet = modelFlagshipRepository.selectActiveFlagshipCatalogIds();
302
        Set<Integer> flagshipSet = modelFlagshipRepository.selectActiveFlagshipCatalogIds();
300
 
303
 
-
 
304
        // Hot deal models active as of today (catalog.model_hot_deal start_date/end_date).
-
 
305
        // This table is the only source of hot_deal_b - tag_listing.hot_deals is not read.
-
 
306
        Set<Integer> hotDealSet = modelHotDealRepository.selectActiveCatalogIds(java.time.LocalDate.now());
-
 
307
 
301
        // Flagship is surfaced as a label (prepended so it shows first, ahead of all other flags)
308
        // Flagship is surfaced as a label (prepended so it shows first, ahead of all other flags)
302
        for (Integer flagshipCatalogId : flagshipSet) {
309
        for (Integer flagshipCatalogId : flagshipSet) {
303
            catalogLabelMap.computeIfAbsent(flagshipCatalogId, k -> new ArrayList<>()).add(0, "flagship");
310
            catalogLabelMap.computeIfAbsent(flagshipCatalogId, k -> new ArrayList<>()).add(0, "flagship");
304
        }
311
        }
305
 
312
 
Line 476... Line 483...
476
                    itemObj.setField("tagId_i", tagListing.getTagId());
483
                    itemObj.setField("tagId_i", tagListing.getTagId());
477
                    itemObj.setField("mrp_f", tagListing.getMrp());
484
                    itemObj.setField("mrp_f", tagListing.getMrp());
478
                    itemObj.setField("mop_f", tagListing.getMop());
485
                    itemObj.setField("mop_f", tagListing.getMop());
479
                    itemObj.setField("sellingPrice_f", tagListing.getSellingPrice());
486
                    itemObj.setField("sellingPrice_f", tagListing.getSellingPrice());
480
                    itemObj.setField("active_b", tagListing.isActive());
487
                    itemObj.setField("active_b", tagListing.isActive());
481
                    itemObj.setField("hot_deal_b", tagListing.isHotDeals());
488
                    itemObj.setField("hot_deal_b", hotDealSet.contains(catalogId));
482
                    mop = tagListing.getMop();
489
                    mop = tagListing.getMop();
483
                    dp = tagListing.getSellingPrice();
490
                    dp = tagListing.getSellingPrice();
484
                }
491
                }
485
                itemObjs.add(itemObj);
492
                itemObjs.add(itemObj);
486
            }
493
            }
Line 562... Line 569...
562
                catalogSolrObj.setField("eol_no_stock_b", true);
569
                catalogSolrObj.setField("eol_no_stock_b", true);
563
            }else {
570
            }else {
564
                catalogSolrObj.setField("eol_no_stock_b", false);
571
                catalogSolrObj.setField("eol_no_stock_b", false);
565
            }
572
            }
566
            catalogSolrObj.setField("flagship_b", flagshipSet.contains(catalogId));
573
            catalogSolrObj.setField("flagship_b", flagshipSet.contains(catalogId));
-
 
574
            catalogSolrObj.setField("hot_deal_b", hotDealSet.contains(catalogId));
567
            catalogSolrObjs.add(catalogSolrObj);
575
            catalogSolrObjs.add(catalogSolrObj);
568
        }
576
        }
569
 
577
 
570
        String solrPath = "http://" + solrUrl + ":8984/solr/demo";
578
        String solrPath = "http://" + solrUrl + ":8984/solr/demo";
571
        SolrClient solr = new HttpSolrClient.Builder(solrPath).build();
579
        SolrClient solr = new HttpSolrClient.Builder(solrPath).build();
Line 592... Line 600...
592
        logger.info("Updating single catalog in Solr: catalogId={}", catalogId);
600
        logger.info("Updating single catalog in Solr: catalogId={}", catalogId);
593
 
601
 
594
        List<status> statuses = Arrays.asList(status.ACTIVE, status.PAUSED_BY_RISK, status.PARTIALLY_ACTIVE);
602
        List<status> statuses = Arrays.asList(status.ACTIVE, status.PAUSED_BY_RISK, status.PARTIALLY_ACTIVE);
595
        boolean flagship = !modelFlagshipRepository
603
        boolean flagship = !modelFlagshipRepository
596
                .selectActiveFlagshipCatalogIds(Collections.singletonList(catalogId)).isEmpty();
604
                .selectActiveFlagshipCatalogIds(Collections.singletonList(catalogId)).isEmpty();
-
 
605
        boolean hotDeal = !modelHotDealRepository
-
 
606
                .selectActiveByCatalogItemIds(Collections.singletonList(catalogId), java.time.LocalDate.now())
-
 
607
                .isEmpty();
597
 
608
 
598
        // Get all TagListings for this catalog
609
        // Get all TagListings for this catalog
599
        List<ItemTagModel> itemTagModels = tagListingRepository.getItemTagByCatalogIdAndStatus(catalogId, statuses);
610
        List<ItemTagModel> itemTagModels = tagListingRepository.getItemTagByCatalogIdAndStatus(catalogId, statuses);
600
 
611
 
601
        if (itemTagModels.isEmpty()) {
612
        if (itemTagModels.isEmpty()) {
Line 658... Line 669...
658
            itemObj.setField("tagId_i", tagListing.getTagId());
669
            itemObj.setField("tagId_i", tagListing.getTagId());
659
            itemObj.setField("mrp_f", tagListing.getMrp());
670
            itemObj.setField("mrp_f", tagListing.getMrp());
660
            itemObj.setField("mop_f", tagListing.getMop());
671
            itemObj.setField("mop_f", tagListing.getMop());
661
            itemObj.setField("sellingPrice_f", tagListing.getSellingPrice());
672
            itemObj.setField("sellingPrice_f", tagListing.getSellingPrice());
662
            itemObj.setField("active_b", tagListing.isActive());
673
            itemObj.setField("active_b", tagListing.isActive());
663
            itemObj.setField("hot_deal_b", tagListing.isHotDeals());
674
            itemObj.setField("hot_deal_b", hotDeal);
664
            mop = tagListing.getMop();
675
            mop = tagListing.getMop();
665
            dp = tagListing.getSellingPrice();
676
            dp = tagListing.getSellingPrice();
666
            itemObjs.add(itemObj);
677
            itemObjs.add(itemObj);
667
 
678
 
668
            // Calculate availability color
679
            // Calculate availability color
Line 793... Line 804...
793
        catalogSolrObj.setField("similarModels_ii", Collections.EMPTY_LIST);
804
        catalogSolrObj.setField("similarModels_ii", Collections.EMPTY_LIST);
794
 
805
 
795
        catalogSolrObj.setField("active_b", active);
806
        catalogSolrObj.setField("active_b", active);
796
        catalogSolrObj.setField("eol_no_stock_b", eolSet.contains(catalogId));
807
        catalogSolrObj.setField("eol_no_stock_b", eolSet.contains(catalogId));
797
        catalogSolrObj.setField("flagship_b", flagship);
808
        catalogSolrObj.setField("flagship_b", flagship);
-
 
809
        catalogSolrObj.setField("hot_deal_b", hotDeal);
798
 
810
 
799
        // Push to Solr
811
        // Push to Solr
800
        String solrPath = "http://" + solrUrl + ":8984/solr/demo";
812
        String solrPath = "http://" + solrUrl + ":8984/solr/demo";
801
        SolrClient solr = new HttpSolrClient.Builder(solrPath).build();
813
        SolrClient solr = new HttpSolrClient.Builder(solrPath).build();
802
 
814