Subversion Repositories SmartDukaan

Rev

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

Rev 35285 Rev 35595
Line 21... Line 21...
21
import com.spice.profitmandi.service.catalog.BrandsService;
21
import com.spice.profitmandi.service.catalog.BrandsService;
22
import com.spice.profitmandi.service.inventory.InventoryService;
22
import com.spice.profitmandi.service.inventory.InventoryService;
23
import org.apache.logging.log4j.LogManager;
23
import org.apache.logging.log4j.LogManager;
24
import org.apache.logging.log4j.Logger;
24
import org.apache.logging.log4j.Logger;
25
import org.springframework.beans.factory.annotation.Autowired;
25
import org.springframework.beans.factory.annotation.Autowired;
-
 
26
import org.springframework.cache.annotation.Cacheable;
26
import org.springframework.stereotype.Component;
27
import org.springframework.stereotype.Component;
27
 
28
 
28
import java.time.*;
29
import java.time.*;
29
import java.time.format.DateTimeFormatter;
30
import java.time.format.DateTimeFormatter;
30
import java.util.*;
31
import java.util.*;
Line 106... Line 107...
106
 
107
 
107
        return String.valueOf(value);
108
        return String.valueOf(value);
108
    }
109
    }
109
 
110
 
110
 
111
 
-
 
112
    @Cacheable(value = "brandStockPrices", cacheManager = "redisShortCacheManager")
111
    public List<BrandStockPrice> getBrandStockPrices(int fofoId, boolean allBrands) throws Exception {
113
    public List<BrandStockPrice> getBrandStockPrices(int fofoId, boolean allBrands) throws Exception {
112
        Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(fofoId);
114
        Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(fofoId);
113
        List<BrandStockPrice> brandStockPrices = new ArrayList<>();
115
        List<BrandStockPrice> brandStockPrices = new ArrayList<>();
114
        List<BrandCatalog> mobileBrands = brandsService.getBrandsToDisplay(3);
116
        List<BrandCatalog> mobileBrands = brandsService.getBrandsToDisplay(3);
115
        mobileBrands.stream().forEach(x -> {
117
        mobileBrands.stream().forEach(x -> {
Line 127... Line 129...
127
        }
129
        }
128
 
130
 
129
        return brandStockPrices.stream().filter(x -> x.getTotalQty() > 0).sorted(Comparator.comparingInt(BrandStockPrice::getRank)).collect(Collectors.toList());
131
        return brandStockPrices.stream().filter(x -> x.getTotalQty() > 0).sorted(Comparator.comparingInt(BrandStockPrice::getRank)).collect(Collectors.toList());
130
    }
132
    }
131
 
133
 
-
 
134
    @Cacheable(value = "partnerInvestments", cacheManager = "redisShortCacheManager")
132
    public Map<String, Object> getInvestments(int fofoId) throws Exception {
135
    public Map<String, Object> getInvestments(int fofoId) throws Exception {
133
        Map<String, Object> investments = new LinkedHashMap<>();
136
        Map<String, Object> investments = new LinkedHashMap<>();
134
        PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 0);
137
        PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 0);
135
        LocalDate currentMonthStart = LocalDate.now().withDayOfMonth(1);
138
        LocalDate currentMonthStart = LocalDate.now().withDayOfMonth(1);
136
        LocalDate yesterDate = LocalDate.now().minusDays(1);
139
        LocalDate yesterDate = LocalDate.now().minusDays(1);
Line 321... Line 324...
321
 
324
 
322
        return cm;
325
        return cm;
323
 
326
 
324
    }
327
    }
325
 
328
 
-
 
329
    @Cacheable(value = "partnerSales", cacheManager = "redisShortCacheManager")
326
    public Map<String, Object> getSales(int fofoId) throws ProfitMandiBusinessException {
330
    public Map<String, Object> getSales(int fofoId) throws ProfitMandiBusinessException {
327
 
331
 
328
        Map<String, Object> salesMap = new LinkedHashMap<>();
332
        Map<String, Object> salesMap = new LinkedHashMap<>();
329
        LocalDateTime now = LocalDateTime.now();
333
        LocalDateTime now = LocalDateTime.now();
330
        LocalDateTime startOfToday = LocalDate.now().atStartOfDay();
334
        LocalDateTime startOfToday = LocalDate.now().atStartOfDay();
Line 374... Line 378...
374
        salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
378
        salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
375
        return salesMap;
379
        return salesMap;
376
    }
380
    }
377
 
381
 
378
 
382
 
-
 
383
    @Cacheable(value = "partnerBrandChart", cacheManager = "redisShortCacheManager")
379
    public ChartModel getBrandChart(int fofoId, LocalDate startDate, LocalDate endDate, boolean isQuantity) {
384
    public ChartModel getBrandChart(int fofoId, LocalDate startDate, LocalDate endDate, boolean isQuantity) {
380
 
385
 
381
        LocalDateTime curDate = startDate == null ? LocalDate.now().atStartOfDay().withDayOfMonth(1) : startDate.atStartOfDay();
386
        LocalDateTime curDate = startDate == null ? LocalDate.now().atStartOfDay().withDayOfMonth(1) : startDate.atStartOfDay();
382
        LocalDateTime lastDate = endDate == null ? LocalDate.now().atStartOfDay().with(LocalTime.MAX) : endDate.atStartOfDay();
387
        LocalDateTime lastDate = endDate == null ? LocalDate.now().atStartOfDay().with(LocalTime.MAX) : endDate.atStartOfDay();
383
 
388