Subversion Repositories SmartDukaan

Rev

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

Rev 36223 Rev 36971
Line 9... Line 9...
9
import com.spice.profitmandi.dao.entity.catalog.TagListing;
9
import com.spice.profitmandi.dao.entity.catalog.TagListing;
10
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
10
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
11
import com.spice.profitmandi.dao.entity.dtr.WebProductListing;
11
import com.spice.profitmandi.dao.entity.dtr.WebProductListing;
12
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
12
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
13
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
13
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
14
import com.spice.profitmandi.dao.repository.catalog.CatalogRepository;
14
import com.spice.profitmandi.dao.repository.catalog.*;
15
import com.spice.profitmandi.dao.repository.catalog.SuperCatalogMappingRepository;
-
 
16
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
-
 
17
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
-
 
18
import com.spice.profitmandi.dao.repository.dtr.Mongo;
15
import com.spice.profitmandi.dao.repository.dtr.Mongo;
19
import com.spice.profitmandi.dao.repository.dtr.WebListingRepository;
16
import com.spice.profitmandi.dao.repository.dtr.WebListingRepository;
20
import com.spice.profitmandi.dao.repository.dtr.WebProductListingRepository;
17
import com.spice.profitmandi.dao.repository.dtr.WebProductListingRepository;
21
import com.spice.profitmandi.dao.repository.similarModel.SimilarModelRepository;
18
import com.spice.profitmandi.dao.repository.similarModel.SimilarModelRepository;
22
import com.spice.profitmandi.service.catalog.SuperCatalogModel;
19
import com.spice.profitmandi.service.catalog.SuperCatalogModel;
Line 83... Line 80...
83
 
80
 
84
    private static final Logger logger = LogManager.getLogger(FofoSolr.class);
81
    private static final Logger logger = LogManager.getLogger(FofoSolr.class);
85
 
82
 
86
    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);
87
 
84
 
-
 
85
    @Autowired
-
 
86
    ModelFlagshipRepository modelFlagshipRepository;
-
 
87
 
88
    private static String getUrlContent(String urlString) {
88
    private static String getUrlContent(String urlString) {
89
        BufferedReader reader = null;
89
        BufferedReader reader = null;
90
        try {
90
        try {
91
            URL url = new URL(urlString);
91
            URL url = new URL(urlString);
92
            URLConnection conn = url.openConnection();
92
            URLConnection conn = url.openConnection();
Line 293... Line 293...
293
        List<Integer> eolWithBadQty = catalogRepository.findAllWithNoGoodStock();
293
        List<Integer> eolWithBadQty = catalogRepository.findAllWithNoGoodStock();
294
 
294
 
295
        Set<Integer> eolSet = new HashSet<>(eolWithOutStock);
295
        Set<Integer> eolSet = new HashSet<>(eolWithOutStock);
296
        eolSet.addAll(eolWithBadQty);
296
        eolSet.addAll(eolWithBadQty);
297
 
297
 
-
 
298
        // Flagship models active as of today (catalog.model_flagship start_date/end_date)
-
 
299
        Set<Integer> flagshipSet = modelFlagshipRepository.selectActiveFlagshipCatalogIds();
-
 
300
 
-
 
301
        // Flagship is surfaced as a label (prepended so it shows first, ahead of all other flags)
-
 
302
        for (Integer flagshipCatalogId : flagshipSet) {
-
 
303
            catalogLabelMap.computeIfAbsent(flagshipCatalogId, k -> new ArrayList<>()).add(0, "flagship");
-
 
304
        }
-
 
305
 
298
 
306
 
299
        logger.info("eolSetIds.size {}" , eolSet.size());
307
        logger.info("eolSetIds.size {}" , eolSet.size());
300
 
308
 
301
        Map<String, Object> projection = new HashMap<>();
309
        Map<String, Object> projection = new HashMap<>();
302
        projection.put("defaultImageUrl", 1);
310
        projection.put("defaultImageUrl", 1);
Line 553... Line 561...
553
            if(eolSet.contains(catalogId)){
561
            if(eolSet.contains(catalogId)){
554
                catalogSolrObj.setField("eol_no_stock_b", true);
562
                catalogSolrObj.setField("eol_no_stock_b", true);
555
            }else {
563
            }else {
556
                catalogSolrObj.setField("eol_no_stock_b", false);
564
                catalogSolrObj.setField("eol_no_stock_b", false);
557
            }
565
            }
-
 
566
            catalogSolrObj.setField("flagship_b", flagshipSet.contains(catalogId));
558
            catalogSolrObjs.add(catalogSolrObj);
567
            catalogSolrObjs.add(catalogSolrObj);
559
        }
568
        }
560
 
569
 
561
        String solrPath = "http://" + solrUrl + ":8984/solr/demo";
570
        String solrPath = "http://" + solrUrl + ":8984/solr/demo";
562
        SolrClient solr = new HttpSolrClient.Builder(solrPath).build();
571
        SolrClient solr = new HttpSolrClient.Builder(solrPath).build();
Line 581... Line 590...
581
     */
590
     */
582
    public void updateSingleCatalog(int catalogId) throws Exception {
591
    public void updateSingleCatalog(int catalogId) throws Exception {
583
        logger.info("Updating single catalog in Solr: catalogId={}", catalogId);
592
        logger.info("Updating single catalog in Solr: catalogId={}", catalogId);
584
 
593
 
585
        List<status> statuses = Arrays.asList(status.ACTIVE, status.PAUSED_BY_RISK, status.PARTIALLY_ACTIVE);
594
        List<status> statuses = Arrays.asList(status.ACTIVE, status.PAUSED_BY_RISK, status.PARTIALLY_ACTIVE);
-
 
595
        boolean flagship = !modelFlagshipRepository
-
 
596
                .selectActiveFlagshipCatalogIds(Collections.singletonList(catalogId)).isEmpty();
586
 
597
 
587
        // Get all TagListings for this catalog
598
        // Get all TagListings for this catalog
588
        List<ItemTagModel> itemTagModels = tagListingRepository.getItemTagByCatalogIdAndStatus(catalogId, statuses);
599
        List<ItemTagModel> itemTagModels = tagListingRepository.getItemTagByCatalogIdAndStatus(catalogId, statuses);
589
 
600
 
590
        if (itemTagModels.isEmpty()) {
601
        if (itemTagModels.isEmpty()) {
Line 609... Line 620...
609
        }
620
        }
610
 
621
 
611
        // Get labels
622
        // Get labels
612
        Map<Integer, List<String>> catalogLabelMap = this.getLabels();
623
        Map<Integer, List<String>> catalogLabelMap = this.getLabels();
613
 
624
 
-
 
625
        // Flagship is surfaced as a label (prepended so it shows first, ahead of all other flags)
-
 
626
        if (flagship) {
-
 
627
            catalogLabelMap.computeIfAbsent(catalogId, k -> new ArrayList<>()).add(0, "flagship");
-
 
628
        }
-
 
629
 
614
        // Get EOL info
630
        // Get EOL info
615
        List<Integer> eolWithOutStock = catalogRepository.findAllWithEOLWithOutStock();
631
        List<Integer> eolWithOutStock = catalogRepository.findAllWithEOLWithOutStock();
616
        List<Integer> eolWithBadQty = catalogRepository.findAllWithNoGoodStock();
632
        List<Integer> eolWithBadQty = catalogRepository.findAllWithNoGoodStock();
617
        Set<Integer> eolSet = new HashSet<>(eolWithOutStock);
633
        Set<Integer> eolSet = new HashSet<>(eolWithOutStock);
618
        eolSet.addAll(eolWithBadQty);
634
        eolSet.addAll(eolWithBadQty);
Line 776... Line 792...
776
        // Similar models - simplified for single update
792
        // Similar models - simplified for single update
777
        catalogSolrObj.setField("similarModels_ii", Collections.EMPTY_LIST);
793
        catalogSolrObj.setField("similarModels_ii", Collections.EMPTY_LIST);
778
 
794
 
779
        catalogSolrObj.setField("active_b", active);
795
        catalogSolrObj.setField("active_b", active);
780
        catalogSolrObj.setField("eol_no_stock_b", eolSet.contains(catalogId));
796
        catalogSolrObj.setField("eol_no_stock_b", eolSet.contains(catalogId));
-
 
797
        catalogSolrObj.setField("flagship_b", flagship);
781
 
798
 
782
        // Push to Solr
799
        // Push to Solr
783
        String solrPath = "http://" + solrUrl + ":8984/solr/demo";
800
        String solrPath = "http://" + solrUrl + ":8984/solr/demo";
784
        SolrClient solr = new HttpSolrClient.Builder(solrPath).build();
801
        SolrClient solr = new HttpSolrClient.Builder(solrPath).build();
785
 
802